OperationPanel.cs 314 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631
  1. using CCWin;
  2. using Newtonsoft.Json.Linq;
  3. using SufeiUtil;
  4. using SXLibrary;
  5. using System;
  6. using System.Collections;
  7. using System.Collections.Generic;
  8. using System.Data.SQLite;
  9. using System.Drawing;
  10. using System.IO;
  11. using System.IO.Ports;
  12. using System.Text;
  13. using System.Threading;
  14. using System.Windows.Forms;
  15. using System.Net;
  16. using System.Net.Sockets;
  17. using System.Linq;
  18. using System.Text.RegularExpressions;
  19. using System.Diagnostics;
  20. using MOKA_Factory_Tools.BLL;
  21. using Newtonsoft.Json;
  22. namespace MOKA_Factory_Tools
  23. {
  24. public partial class OperationPanel : Skin_Color
  25. {
  26. //白平衡URL
  27. MidList midListNow = new MidList();
  28. MidList localmidList = new MidList();
  29. MidAddress MidAddressNow = new MidAddress();
  30. FunctionSetting FunctionSettingNow = new FunctionSetting();
  31. WhiteBalanceList WhiteBalanceListNow = new WhiteBalanceList();
  32. Config_WriteCheck cfg_writecheck = new Config_WriteCheck();
  33. Config_ReadCheck cfg_readcheck = new Config_ReadCheck();
  34. Config_WriteDone cfg_writedone = new Config_WriteDone();
  35. SerialPort TVPort = new SerialPort();
  36. SQLiteConnection localDBNow;
  37. SQLiteConnection errorDBNow;
  38. KeyInfo keyInfo = new KeyInfo();
  39. FireTVKey fireTVKey = new FireTVKey();
  40. NTFBLL ntfBLL = null;
  41. bool preloadNow;
  42. string SN;
  43. string orderNow;
  44. Main mainform;
  45. int usingTime = 0;
  46. Thread SNTextFocus;
  47. bool FocusMark = false;
  48. Thread WritekeyThread;
  49. string availableCount = "unknow";
  50. // 只有NTF才用该变量, 0试产, 1=量产;
  51. int nOrderType = -1;
  52. MIKey _MiKey = null;
  53. //删除界面指针委托
  54. public delegate void DisplayUpdateDelegate(IntPtr intPtr);
  55.         //删除界面指针事件
  56.         public event DisplayUpdateDelegate DeleteIntptr;
  57. //扫描回车触发委托
  58. public delegate void SNKeyDown(IntPtr intPtr);
  59.         //扫描回车触发事件
  60.         public event SNKeyDown SNKeyDownEven;
  61. //自动key提取委托
  62. public delegate void AutoKeyRequireDelegate(IntPtr intPtr, string key, string keytype);
  63.         //自动key提取事件
  64.         public event AutoKeyRequireDelegate AutoKeyRequire;
  65. //定义一个委托 调用Verify窗口;
  66. delegate void ShowVerifyCallback(string strMsg);
  67. //委托方法
  68. private void ShowVerifyDailog(string strMsg)
  69. {
  70. //右下角消息框Form
  71. Verify dlg = new Verify(strMsg);
  72. dlg.ShowDialog();
  73. }
  74. //调用委托
  75. private void ShowVerifyDelegate(string strMsg)
  76. {
  77. //创建委托
  78. ShowVerifyCallback wt = new ShowVerifyCallback(ShowVerifyDailog);
  79. //这段代码在主窗体类里面写着,this指主窗体
  80. this.Invoke(wt, new Object[] { strMsg });
  81. }
  82. public OperationPanel(Main form1, SQLiteConnection localDB, SQLiteConnection errorDB, MidAddress midAddress1, FunctionSetting functionSetting, Config_WriteCheck writeCheck1, Config_ReadCheck readCheck1, Config_WriteDone writeDone1, bool preload, MidList midList1, string order)
  83. {
  84. InitializeComponent();
  85. MidAddressNow = midAddress1;
  86. FunctionSettingNow = functionSetting;
  87. cfg_writecheck = writeCheck1;
  88. cfg_readcheck = readCheck1;
  89. cfg_writedone = writeDone1;
  90. localDBNow = localDB;
  91. errorDBNow = errorDB;
  92. preloadNow = preload;
  93. midListNow = midList1;
  94. orderNow = order;
  95. InitPanel();
  96. mainform = form1;
  97. this.mainform.MoveEvent += new MoveHandler(SetFormLocation);
  98. this.mainform.KeyDownEvent += new KeyDownHandler(SetFocus);
  99. if (midListNow.rokuCustomer != null)
  100. ProductMsg_Text.Text = "Roku:";
  101. if (functionSetting.NTF)
  102. ntfBLL = new NTFBLL(functionSetting.Mexican_NTF);
  103. }
  104. /// <summary>
  105. /// 控制界面跟随主界面移动
  106. /// </summary>
  107. /// <param name="XY"></param>
  108. /// <param name="formlocationmsg"></param>
  109. /// <param name="num"></param>
  110. void SetFormLocation(Point XY, ArrayList formlocationmsg, int num)
  111. {
  112. foreach (Dictionary<IntPtr, Point> pairs in formlocationmsg)
  113. {
  114. if (!this.IsDisposed)
  115. {
  116. if (pairs.ContainsKey(this.Handle))
  117. {
  118. if (formlocationmsg.IndexOf(pairs) >= num && num > 0)
  119. {
  120. this.Left = XY.X + this.Size.Width * (formlocationmsg.IndexOf(pairs) - num);
  121. this.Top = XY.Y + this.Size.Height;
  122. }
  123. else
  124. {
  125. this.Left = XY.X + this.Size.Width * formlocationmsg.IndexOf(pairs);
  126. this.Top = XY.Y;
  127. }
  128. break;
  129. }
  130. }
  131. }
  132. }
  133. /// <summary>
  134. /// 按指针设置是否聚焦
  135. /// </summary>
  136. /// <param name="formlocationmsg"></param>
  137. /// <param name="intPtr"></param>
  138. void SetFocus(ArrayList formlocationmsg, IntPtr intPtr)
  139. {
  140. bool mark = false;
  141. bool mark2 = false;
  142. foreach (Dictionary<IntPtr, Point> pairs in formlocationmsg)
  143. {
  144. if (!this.IsDisposed)
  145. {
  146. if (pairs.ContainsKey(this.Handle) && formlocationmsg.IndexOf(pairs) == 0)
  147. {
  148. mark2 = true;
  149. }
  150. if (mark)
  151. {
  152. if (pairs.ContainsKey(this.Handle))
  153. FocusMark = true;
  154. else
  155. mark = false;
  156. }
  157. if (pairs.ContainsKey(intPtr))
  158. {
  159. if (formlocationmsg.IndexOf(pairs) == (formlocationmsg.Count - 1))
  160. {
  161. if (mark2)
  162. FocusMark = true;
  163. }
  164. mark = true;
  165. }
  166. }
  167. }
  168. }
  169. /// <summary>
  170. /// 界面控件初始化
  171. /// </summary>
  172. public void InitPanel()
  173. {
  174. COMText.Text = FunctionSettingNow.TVCOM;
  175. COMText.BackColor = Color.FromArgb(128, 255, 128);
  176. BaudText.Text = FunctionSettingNow.TVBaud;
  177. BaudText.BackColor = Color.FromArgb(128, 255, 128);
  178. WritePSN.Checked = FunctionSettingNow.BarcodeWrite;
  179. #region 串口重试机制;
  180. SerialCMD.EnableRetry = FunctionSettingNow.EnableRetry;
  181. SerialCMD.RetryCount = FunctionSettingNow.RetryCount;
  182. #endregion
  183. #region 设置WriteCheck复选框默认状态;
  184. if (!cfg_writecheck.DIDCheckcheck)
  185. SetspecificText(m_checkdid, LResource.Skip, Color.Yellow);
  186. if (!cfg_writecheck.MacCheckcheck)
  187. SetspecificText(m_checkmac, LResource.Skip, Color.Yellow);
  188. if (!cfg_writecheck.HDCPCheckcheck)
  189. SetspecificText(m_checkhdcp, LResource.Skip, Color.Yellow);
  190. if (!cfg_writecheck.HDCP22Checkcheck)
  191. SetspecificText(m_checkhdcp22, LResource.Skip, Color.Yellow);
  192. if (!cfg_writecheck.WidevineCheckcheck)
  193. SetspecificText(m_checkwidevine, LResource.Skip, Color.Yellow);
  194. if (!cfg_writecheck.ESNCheckcheck)
  195. SetspecificText(m_checkesn, LResource.Skip, Color.Yellow);
  196. if (!cfg_writecheck.CI_plusCheckcheck)
  197. SetspecificText(m_checkci, LResource.Skip, Color.Yellow);
  198. if (!cfg_writecheck.AttestationCheckcheck)
  199. SetspecificText(m_checkattestation, LResource.Skip, Color.Yellow);
  200. if (!cfg_writecheck.MGKCheckcheck)
  201. SetspecificText(m_checkMGK, LResource.Skip, Color.Yellow);
  202. if (!cfg_writecheck.FairplayCheckcheck)
  203. SetspecificText(m_checkFairplay, LResource.Skip, Color.Yellow);
  204. if (!cfg_writecheck.ECPCheckcheck)
  205. SetspecificText(m_checkECP, LResource.Skip, Color.Yellow);
  206. if (!cfg_writecheck.WifiMacCheckcheck)
  207. SetspecificText(m_checkWifiMac, LResource.Skip, Color.Yellow);
  208. if (!cfg_writecheck.BTMacCheckcheck)
  209. SetspecificText(m_checkBTMac, LResource.Skip, Color.Yellow);
  210. if (!cfg_writecheck.LEKCheckcheck)
  211. SetspecificText(m_checkLEK, LResource.Skip, Color.Yellow);
  212. if (!cfg_writecheck.PEKCheckcheck)
  213. SetspecificText(m_checkPEK, LResource.Skip, Color.Yellow);
  214. if (!cfg_writecheck.PlayreadyCheckcheck)
  215. SetspecificText(m_checkPlayready, LResource.Skip, Color.Yellow);
  216. if (!cfg_writecheck.HashCheckcheck)
  217. SetspecificText(m_checkHash, LResource.Skip, Color.Yellow);
  218. if (!cfg_writecheck.DSNCheckcheck)
  219. SetspecificText(m_checkDSN, LResource.Skip, Color.Yellow);
  220. if (!cfg_writecheck.YouTubeCheckcheck)
  221. SetspecificText(m_checkYouTube, LResource.Skip, Color.Yellow);
  222. if (!cfg_writecheck.ACASKeyCheckcheck)
  223. SetspecificText(m_checkACASKey, LResource.Skip, Color.Yellow);
  224. if (!cfg_writecheck.FVPCheckcheck)
  225. SetspecificText(m_checkFVP, LResource.Skip, Color.Yellow);
  226. if (!cfg_writecheck.DAKCheckcheck)
  227. SetspecificText(m_checkDAK, LResource.Skip, Color.Yellow);
  228. if (!cfg_writecheck.KFPCheckcheck)
  229. SetspecificText(m_checkKFP, LResource.Skip, Color.Yellow);
  230. #endregion
  231. #region 设置ReadCheck复选框默认状态
  232. /////////////////////////////////////////////////////////////////
  233. if (!cfg_readcheck.PIDReadcheck)
  234. SetspecificText(ProjectIDNote, LResource.SkipReadCheck, Color.Yellow);
  235. if (!cfg_readcheck.DIDReadcheck)
  236. SetspecificText(m_readdid, LResource.Skip, Color.Yellow);
  237. if (!cfg_readcheck.MacReadcheck)
  238. SetspecificText(m_readmac, LResource.Skip, Color.Yellow);
  239. if (!cfg_readcheck.HDCPReadcheck)
  240. SetspecificText(m_readhdcp, LResource.Skip, Color.Yellow);
  241. if (!cfg_readcheck.HDCP22Readcheck)
  242. SetspecificText(m_readhdcp22, LResource.Skip, Color.Yellow);
  243. if (!cfg_readcheck.WidevineReadcheck)
  244. SetspecificText(m_readwidevine, LResource.Skip, Color.Yellow);
  245. if (!cfg_readcheck.ESNReadcheck)
  246. SetspecificText(m_readesn, LResource.Skip, Color.Yellow);
  247. if (!cfg_readcheck.CI_plusReadcheck)
  248. SetspecificText(m_readci, LResource.Skip, Color.Yellow);
  249. if (!cfg_readcheck.AttestationReadcheck)
  250. SetspecificText(m_readattestation, LResource.Skip, Color.Yellow);
  251. if (!cfg_readcheck.MGKReadcheck)
  252. SetspecificText(m_readMGK, LResource.Skip, Color.Yellow);
  253. if (!cfg_readcheck.FairplayReadcheck)
  254. SetspecificText(m_readFairplay, LResource.Skip, Color.Yellow);
  255. if (!cfg_readcheck.ECPReadcheck)
  256. SetspecificText(m_readECP, LResource.Skip, Color.Yellow);
  257. if (!cfg_readcheck.WifiMacReadcheck)
  258. SetspecificText(m_readWifiMac, LResource.Skip, Color.Yellow);
  259. if (!cfg_readcheck.BTMacReadcheck)
  260. SetspecificText(m_readBTMac, LResource.Skip, Color.Yellow);
  261. if (!cfg_readcheck.LEKReadcheck)
  262. SetspecificText(m_readLEK, LResource.Skip, Color.Yellow);
  263. if (!cfg_readcheck.PEKReadcheck)
  264. SetspecificText(m_readPEK, LResource.Skip, Color.Yellow);
  265. if (!cfg_readcheck.PlayreadyReadcheck)
  266. SetspecificText(m_readPlayready, LResource.Skip, Color.Yellow);
  267. if (!cfg_readcheck.HashReadcheck)
  268. SetspecificText(m_readHash, LResource.Skip, Color.Yellow);
  269. if (!cfg_readcheck.DSNReadcheck)
  270. SetspecificText(m_readDSN, LResource.Skip, Color.Yellow);
  271. if (!cfg_readcheck.SHOPReadcheck)
  272. SetspecificText(SHOPNote, LResource.SkipChecking, Color.Yellow);
  273. if (!cfg_readcheck.OSDReadcheck)
  274. SetspecificText(OSDNote, LResource.SkipChecking, Color.Yellow);
  275. if (!cfg_readcheck.YouTubeReadcheck)
  276. SetspecificText(m_readYouTube, LResource.SkipChecking, Color.Yellow);
  277. if (!cfg_readcheck.EDIDPIDReadcheck)
  278. SetspecificText(m_readEDIDPID, LResource.SkipChecking, Color.Yellow);
  279. if (!cfg_readcheck.EDIDModeNameReadcheck)
  280. SetspecificText(m_readEDIDName, LResource.SkipChecking, Color.Yellow);
  281. if (!cfg_readcheck.ACASKeyReadcheck)
  282. SetspecificText(m_readACASKey, LResource.SkipChecking, Color.Yellow);
  283. if (FunctionSettingNow.ExportSNACASID)
  284. SetspecificText(m_readACASID, LResource.SkipChecking, Color.Yellow);
  285. if (!cfg_readcheck.FVPReadcheck)
  286. SetspecificText(m_readFVP, LResource.SkipChecking, Color.Yellow);
  287. if (!cfg_readcheck.DAKReadcheck)
  288. SetspecificText(m_readDAK, LResource.SkipChecking, Color.Yellow);
  289. if (!cfg_readcheck.KFPReadcheck)
  290. SetspecificText(m_readKFP, LResource.SkipChecking, Color.Yellow);
  291. #endregion
  292. #region 设置WriteDone复选框默认状态
  293. /////////////////////////////////////////////////////////////////
  294. if (!cfg_writedone.PIDWrite_YesNo)
  295. SetspecificText(ProjectIDNote, LResource.SkipCovering, Color.Yellow);
  296. if (!cfg_writedone.ClientTypeCheck_YesNo)
  297. SetspecificText(ClientTypeNote, LResource.SkipChecking, Color.Yellow);
  298. if (!cfg_writedone.SoftwareVersionCheck_YesNo)
  299. SetspecificText(SoftwareVersionNote, LResource.SkipChecking, Color.Yellow);
  300. if (!cfg_writedone.DIDWrite_YesNo)
  301. SetspecificText(m_writedid, LResource.Skip, Color.Yellow);
  302. if (!cfg_writedone.MacWrite_YesNo)
  303. SetspecificText(m_writemac, LResource.Skip, Color.Yellow);
  304. if (!cfg_writedone.HDCPWrite_YesNo)
  305. SetspecificText(m_writehdcp, LResource.Skip, Color.Yellow);
  306. if (!cfg_writedone.HDCP22Write_YesNo)
  307. SetspecificText(m_writehdcp22, LResource.Skip, Color.Yellow);
  308. if (!cfg_writedone.WidevineWrite_YesNo)
  309. SetspecificText(m_writewidevine, LResource.Skip, Color.Yellow);
  310. if (!cfg_writedone.ESNWrite_YesNo)
  311. SetspecificText(m_writeesn, LResource.Skip, Color.Yellow);
  312. if (!cfg_writedone.CI_plusWrite_YesNo)
  313. SetspecificText(m_writeci, LResource.Skip, Color.Yellow);
  314. if (!cfg_writedone.AttestationWrite_YesNo)
  315. SetspecificText(m_writeattestation, LResource.Skip, Color.Yellow);
  316. if (!cfg_writedone.MGKWrite_YesNo)
  317. SetspecificText(m_writeMGK, LResource.Skip, Color.Yellow);
  318. if (!cfg_writedone.FairplayWrite_YesNo)
  319. SetspecificText(m_writeFairplay, LResource.Skip, Color.Yellow);
  320. if (!cfg_writedone.ECPWrite_YesNo)
  321. SetspecificText(m_writeECP, LResource.Skip, Color.Yellow);
  322. if (!cfg_writedone.WifiMacWrite_YesNo)
  323. SetspecificText(m_writeWifiMac, LResource.Skip, Color.Yellow);
  324. if (!cfg_writedone.BTMacWrite_YesNo)
  325. SetspecificText(m_writeBTMac, LResource.Skip, Color.Yellow);
  326. if (!cfg_writedone.LEKWrite_YesNo)
  327. SetspecificText(m_writeLEK, LResource.Skip, Color.Yellow);
  328. if (!cfg_writedone.PEKWrite_YesNo)
  329. SetspecificText(m_writePEK, LResource.Skip, Color.Yellow);
  330. if (!cfg_writedone.PlayreadyWrite_YesNo)
  331. SetspecificText(m_writePlayready, LResource.Skip, Color.Yellow);
  332. if (!cfg_writedone.HashWrite_YesNo)
  333. SetspecificText(m_writeHash, LResource.Skip, Color.Yellow);
  334. if (!cfg_writedone.DSNWrite_YesNo)
  335. SetspecificText(m_writeDSN, LResource.Skip, Color.Yellow);
  336. if (!cfg_writedone.YouTubeWrite_YesNo)
  337. SetspecificText(m_writeYouTube, LResource.Skip, Color.Yellow);
  338. if (!cfg_writedone.EDIDPIDWrite_YesNo)
  339. SetspecificText(m_writeEDIDPID, LResource.Skip, Color.Yellow);
  340. if (!cfg_writedone.EDIDModeNameWrite_YesNo)
  341. SetspecificText(m_writeEDIDName, LResource.Skip, Color.Yellow);
  342. if (!cfg_writedone.ACASKeyWrite_YesNo)
  343. SetspecificText(m_writeACASKey, LResource.Skip, Color.Yellow);
  344. if (!cfg_writedone.FVPWrite_YesNo)
  345. SetspecificText(m_writeFVP, LResource.Skip, Color.Yellow);
  346. if (!cfg_writedone.DAKWrite_YesNo)
  347. SetspecificText(m_writeDAK, LResource.Skip, Color.Yellow);
  348. if (!cfg_writedone.KFPWrite_YesNo)
  349. SetspecificText(m_writeKFP, LResource.Skip, Color.Yellow);
  350. if (FunctionSettingNow.WriteChannel)
  351. ChannelText.Text = FunctionSettingNow.ChannelList;
  352. else
  353. {
  354. ChannelText.Text = LResource.Default;
  355. ChannelText.BackColor = Color.Yellow;
  356. }
  357. if (FunctionSettingNow.WriteOSD)
  358. OSDText.Text = FunctionSettingNow.OSDList;
  359. else
  360. {
  361. OSDText.Text = LResource.Default;
  362. OSDText.BackColor = Color.Yellow;
  363. }
  364. if (FunctionSettingNow.WriteSHOP)
  365. SHOPText.Text = FunctionSettingNow.SHOPList;
  366. else
  367. {
  368. SHOPText.Text = LResource.Default;
  369. SHOPText.BackColor = Color.Yellow;
  370. }
  371. #endregion
  372. if (midListNow.host != "LocalPC")
  373. {
  374. if ((!FunctionSettingNow.WriteWB) && (!cfg_writedone.AutoWhiteBalance))
  375. {
  376. WBPathText.Text = LResource.SkipAutoWB;
  377. WBPathText.BackColor = Color.Yellow;
  378. }
  379. else
  380. {
  381. // 如果是抄写EDID,则不获取白平衡数据;
  382. if (CommonMethod.IsEDIDCopy(midListNow))
  383. midListNow.whiteType = "-1";
  384. Log.WriteInfoLog("whiteType=" + midListNow.whiteType);
  385. switch (midListNow.whiteType)//订单白平衡预置状态
  386. {
  387. case "0"://旧订单,默认值
  388. {
  389. if (CommonMethod.GetWhiteBalanceInfo(TestMode.getWhiteBalanceInfoUrl, orderNow, TestMode.MAC, errorDBNow, out WhiteBalanceListNow))
  390. {
  391. if (WhiteBalanceListNow.whiteBalanceInfo != null)
  392. {
  393. if (WhiteBalanceListNow.whiteBalanceInfo.isExemption == "0")
  394. {
  395. if (FunctionSettingNow.WriteWB)
  396. {
  397. MessageBoxButtons messButton = MessageBoxButtons.YesNo;
  398. DialogResult dr = MessageBox.Show(LResource.HaveWBfromServer, LResource.Error, messButton);
  399. if (dr == DialogResult.Yes)
  400. {
  401. FunctionSettingNow.NormalRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmirgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmiggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmibgain) + 256) };
  402. FunctionSettingNow.CoolRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lbgain) + 256) };
  403. FunctionSettingNow.WarmRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nbgain) + 256) };
  404. WBPathText.Text = LResource.LoadFromServer;
  405. }
  406. else
  407. {
  408. WBPathText.Text = Path.GetFileName(FunctionSettingNow.WBPath);
  409. }
  410. }
  411. else
  412. {
  413. MessageBox.Show(LResource.FindWBfromServer, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  414. FunctionSettingNow.WriteWB = true;
  415. FunctionSettingNow.NormalRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmirgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmiggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmibgain) + 256) };
  416. FunctionSettingNow.CoolRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lbgain) + 256) };
  417. FunctionSettingNow.WarmRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nbgain) + 256) };
  418. WBPathText.Text = LResource.LoadFromServer;
  419. }
  420. }
  421. else if (WhiteBalanceListNow.whiteBalanceInfo.isExemption == "1")
  422. {
  423. WBPathText.Text = LResource.WBExemptOrder;
  424. WBPathText.BackColor = Color.Yellow;
  425. }
  426. }
  427. else
  428. {
  429. if (FunctionSettingNow.WriteWB)
  430. {
  431. MessageBoxButtons messButton = MessageBoxButtons.YesNo;
  432. DialogResult dr = MessageBox.Show(LResource.HaveNoWBfromServer, LResource.Error, messButton);
  433. if (dr == DialogResult.OK)
  434. {
  435. WBPathText.Text = Path.GetFileName(FunctionSettingNow.WBPath);
  436. }
  437. }
  438. else
  439. {
  440. WBPathText.Text = LResource.WBNull;
  441. WBPathText.BackColor = Color.Yellow;
  442. FunctionSettingNow.WriteWB = false;
  443. }
  444. }
  445. }
  446. else
  447. {
  448. MessageBox.Show(LResource.GetWBInfoFail);
  449. if (FunctionSettingNow.WriteWB)
  450. {
  451. WBPathText.Text = Path.GetFileName(FunctionSettingNow.WBPath);
  452. }
  453. else
  454. {
  455. WBPathText.Text = LResource.WBNull;
  456. WBPathText.BackColor = Color.Yellow;
  457. }
  458. }
  459. break;
  460. }
  461. case "1"://未预置或预置LR数据
  462. {
  463. if (CommonMethod.GetWhiteBalanceInfo(TestMode.getWhiteBalanceInfoUrl, orderNow, TestMode.MAC, errorDBNow, out WhiteBalanceListNow))
  464. {
  465. if (WhiteBalanceListNow.whiteBalanceInfo != null)
  466. {
  467. if (WhiteBalanceListNow.whiteBalanceInfo.isExemption == "0")//0是正常白平衡绑定订单,1是白平衡豁免订单
  468. {
  469. if (FunctionSettingNow.WriteWB)
  470. {
  471. MessageBoxButtons messButton = MessageBoxButtons.YesNo;
  472. DialogResult dr = MessageBox.Show(LResource.HaveWBfromServer, LResource.Error, messButton);
  473. if (dr == DialogResult.Yes)
  474. {
  475. FunctionSettingNow.NormalRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmirgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmiggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmibgain) + 256) };
  476. FunctionSettingNow.CoolRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lbgain) + 256) };
  477. FunctionSettingNow.WarmRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nbgain) + 256) };
  478. WBPathText.Text = LResource.LoadFromServer;
  479. }
  480. else
  481. {
  482. WBPathText.Text = Path.GetFileName(FunctionSettingNow.WBPath);
  483. }
  484. }
  485. else
  486. {
  487. MessageBox.Show(LResource.FindWBfromServer, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  488. FunctionSettingNow.WriteWB = true;
  489. FunctionSettingNow.NormalRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmirgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmiggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmibgain) + 256) };
  490. FunctionSettingNow.CoolRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lbgain) + 256) };
  491. FunctionSettingNow.WarmRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nbgain) + 256) };
  492. WBPathText.Text = LResource.LoadFromServer;
  493. }
  494. }
  495. else if (WhiteBalanceListNow.whiteBalanceInfo.isExemption == "1")
  496. {
  497. WBPathText.Text = LResource.WBExemptOrder;
  498. WBPathText.BackColor = Color.Yellow;
  499. }
  500. }
  501. else
  502. {
  503. if (FunctionSettingNow.WriteWB)
  504. {
  505. MessageBoxButtons messButton = MessageBoxButtons.YesNo;
  506. DialogResult dr = MessageBox.Show(LResource.HaveNoWBfromServer, LResource.Error, messButton);
  507. if (dr == DialogResult.OK)
  508. {
  509. WBPathText.Text = Path.GetFileName(FunctionSettingNow.WBPath);
  510. }
  511. }
  512. else
  513. {
  514. WBPathText.Text = LResource.WBNull;
  515. WBPathText.BackColor = Color.Yellow;
  516. FunctionSettingNow.WriteWB = false;
  517. }
  518. }
  519. }
  520. else
  521. {
  522. if (FunctionSettingNow.WriteWB)
  523. {
  524. MessageBox.Show(LResource.GetWBInfoFail);
  525. WBPathText.Text = Path.GetFileName(FunctionSettingNow.WBPath);
  526. }
  527. else
  528. {
  529. MessageBox.Show(LResource.GetWBInfoFail2);
  530. this.Close();
  531. return;
  532. }
  533. }
  534. break;
  535. }
  536. case "2"://已预置PR数据
  537. {
  538. if (CommonMethod.GetWhiteBalanceInfo(TestMode.getWhiteBalanceInfoUrl, orderNow, TestMode.MAC, errorDBNow, out WhiteBalanceListNow))
  539. {
  540. if (WhiteBalanceListNow.whiteBalanceInfo != null)
  541. {
  542. if (WhiteBalanceListNow.whiteBalanceInfo.isExemption == "0")
  543. {
  544. if (FunctionSettingNow.WriteWB)
  545. {
  546. MessageBoxButtons messButton = MessageBoxButtons.YesNo;
  547. DialogResult dr = MessageBox.Show(LResource.HaveWBfromServer, LResource.Error, messButton);
  548. if (dr == DialogResult.Yes)
  549. {
  550. FunctionSettingNow.NormalRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmirgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmiggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmibgain) + 256) };
  551. FunctionSettingNow.CoolRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lbgain) + 256) };
  552. FunctionSettingNow.WarmRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nbgain) + 256) };
  553. WBPathText.Text = LResource.LoadFromServer;
  554. }
  555. else
  556. {
  557. WBPathText.Text = Path.GetFileName(FunctionSettingNow.WBPath);
  558. }
  559. }
  560. else
  561. {
  562. MessageBox.Show(LResource.FindWBfromServer, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  563. FunctionSettingNow.WriteWB = true;
  564. FunctionSettingNow.NormalRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmirgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmiggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.hdmibgain) + 256) };
  565. FunctionSettingNow.CoolRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.lbgain) + 256) };
  566. FunctionSettingNow.WarmRGB = new byte[3] { (byte)Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nrgain), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nggain) + 256), (byte)(Convert.ToDouble(WhiteBalanceListNow.whiteBalanceInfo.nbgain) + 256) };
  567. WBPathText.Text = LResource.LoadFromServer;
  568. }
  569. }
  570. else if (WhiteBalanceListNow.whiteBalanceInfo.isExemption == "1")
  571. {
  572. WBPathText.Text = LResource.WBExemptOrder;
  573. WBPathText.BackColor = Color.Yellow;
  574. }
  575. }
  576. else
  577. {
  578. if (FunctionSettingNow.WriteWB)
  579. {
  580. MessageBoxButtons messButton = MessageBoxButtons.YesNo;
  581. DialogResult dr = MessageBox.Show(LResource.HaveNoWBfromServer, LResource.Error, messButton);
  582. if (dr == DialogResult.OK)
  583. {
  584. WBPathText.Text = Path.GetFileName(FunctionSettingNow.WBPath);
  585. }
  586. }
  587. else
  588. {
  589. WBPathText.Text = LResource.WBNull;
  590. WBPathText.BackColor = Color.Yellow;
  591. FunctionSettingNow.WriteWB = false;
  592. }
  593. }
  594. }
  595. else
  596. {
  597. MessageBox.Show(LResource.GetWBInfoFail);
  598. if (FunctionSettingNow.WriteWB)
  599. {
  600. WBPathText.Text = Path.GetFileName(FunctionSettingNow.WBPath);
  601. }
  602. else
  603. {
  604. WBPathText.Text = LResource.WBNull;
  605. WBPathText.BackColor = Color.Yellow;
  606. }
  607. }
  608. break;
  609. }
  610. case "3"://已预置客户指定数据
  611. {
  612. if (FunctionSettingNow.WriteWB)
  613. {
  614. MessageBox.Show(LResource.PreloadCustomerWB);
  615. this.Close();
  616. return;
  617. }
  618. break;
  619. }
  620. }
  621. }
  622. }
  623. else
  624. {
  625. if (FunctionSettingNow.WriteWB)
  626. {
  627. WBPathText.Text = Path.GetFileName(FunctionSettingNow.WBPath);
  628. }
  629. else
  630. {
  631. WBPathText.Text = LResource.WBNull;
  632. WBPathText.BackColor = Color.Yellow;
  633. }
  634. }
  635. try
  636. {
  637. TVPort.PortName = FunctionSettingNow.TVCOM;
  638. TVPort.BaudRate = Convert.ToInt32(FunctionSettingNow.TVBaud);
  639. TVPort.WriteBufferSize = 20480;
  640. TVPort.ReadBufferSize = 20480;
  641. TVPort.Parity = (Parity)FunctionSettingNow.TVParity;
  642. TVPort.Open();
  643. }
  644. catch (Exception ex)
  645. {
  646. MessageBox.Show(ex.Message);
  647. this.Close();
  648. }
  649. this.Text = FunctionSettingNow.TVCOM;
  650. }
  651. private void OperationPanel_Load(object sender, EventArgs e)
  652. {
  653. #region 研发账号
  654. if (CommonMethod.GetLoginAccout().Equals("RD", StringComparison.OrdinalIgnoreCase))
  655. {
  656. // 修改标题;
  657. //this.Text = "研发抄写专用版";
  658. // 修改底色;
  659. this.CaptionBackColorTop = Color.AntiqueWhite;
  660. this.CaptionBackColorBottom = Color.Beige;
  661. this.BackColor = Color.AliceBlue;
  662. }
  663. #endregion
  664. if (midListNow.host == "LocalPC")
  665. {
  666. OrderText.Text = orderNow;
  667. ClientTypeText.Text = midListNow.clienttype;
  668. SVText.Text = midListNow.version;
  669. ProjectIDText.Text = midListNow.projectid;
  670. GetLocalKeysCount();
  671. }
  672. else if (!preloadNow)
  673. {
  674. OrderText.Text = orderNow;
  675. ClientTypeText.Text = midListNow.clienttype;
  676. SVText.Text = midListNow.version;
  677. ProjectIDText.Text = midListNow.projectid;
  678. UpdateKeys(midListNow.keytype, false);
  679. }
  680. else
  681. {
  682. OrderText.Text = MidAddressNow.order;
  683. ClientTypeText.Text = MidAddressNow.ctype;
  684. SVText.Text = MidAddressNow.version;
  685. ProjectIDText.Text = MidAddressNow.pid;
  686. }
  687. SNText.Text = "";
  688. #if SIMULATION
  689. SN = "40243/C06100001003";
  690. SNText.Text = "40243/C06100001003";
  691. #endif
  692. SNTextFocus = new Thread(TextBoxFocus);
  693. SNTextFocus.Start();
  694. SNText.Focus();
  695. }
  696. /// <summary>
  697. /// 强制聚焦扫描框
  698. /// </summary>
  699. public void TextBoxFocus()
  700. {
  701. while (true)
  702. {
  703. if (FocusMark)
  704. {
  705. if (this.CaptionBackColorTop != Color.Yellow || this.CaptionBackColorBottom != Color.Orange)
  706. {
  707. if (this.InvokeRequired)
  708. {
  709. this.BeginInvoke(new Action(() =>
  710. {
  711. this.CaptionBackColorTop = Color.Yellow;
  712. this.CaptionBackColorBottom = Color.Orange;
  713. this.Refresh();
  714. }));
  715. }
  716. }
  717. if (SNText.InvokeRequired)
  718. {
  719. SNText.BeginInvoke(new Action(() =>
  720. {
  721. if (!SNText.Focus())
  722. {
  723. SNText.Focus();
  724. }
  725. }));
  726. }
  727. }
  728. Thread.Sleep(500);
  729. }
  730. }
  731. private void OperationPanel_FormClosing(object sender, FormClosingEventArgs e)
  732. {
  733. if (TVPort.IsOpen)
  734. TVPort.Close();
  735. DeleteIntptr(this.Handle);
  736. GC.Collect();
  737. }
  738. /// <summary>
  739. /// 扫描触发抄写,以回车终结触发
  740. /// </summary>
  741. /// <param name="sender"></param>
  742. /// <param name="e"></param>
  743. private void SNText_KeyDown(object sender, KeyEventArgs e)
  744. {
  745. if (e.KeyCode == Keys.Enter)
  746. {
  747. keyInfo = new KeyInfo();
  748. FocusMark = false;
  749. SNKeyDownEven(this.Handle);
  750. SetInitialStatus();
  751. SN = SNText.Text;
  752. Log.WriteInfoLog(string.Format("Input SN={0}", SN));
  753. #region 去除SN空格;
  754. SN = SN.Trim();
  755. Log.WriteInfoLog(string.Format("After Trim SN={0}", SN));
  756. #endregion
  757. SNText.Enabled = false;
  758. if (FunctionSettingNow.BarcodeLimit)
  759. {
  760. if (SN.Length != FunctionSettingNow.BarcodeLength || !SN.StartsWith(FunctionSettingNow.BarcodeKeyword))
  761. {
  762. MessageBox.Show(string.Format("{0}\r\nSN=<{1}, Len={2}>\r\nKeyword=<{3}>", LResource.WrongBarcode, SN, SN.Length, FunctionSettingNow.BarcodeKeyword));
  763. SNText.Enabled = true;
  764. SNText.Text = "";
  765. return;
  766. }
  767. if (!FunctionSettingNow.MITVEnable && !FunctionSettingNow.BarcodeWrite && (midListNow.keytype != null && midListNow.keytype.ContainsKey("DSN")))
  768. {
  769. // 如果不是全大写字母+数字,返回;
  770. Regex r = new Regex(@"^[A-Z0-9]+$");
  771. if (!r.Match(SN).Success)
  772. {
  773. MessageBox.Show(string.Format("{0}\r\nSN=<{1}, Len={2}>\r\nKeyword=<{3}>", LResource.WrongBarcode, SN, SN.Length, FunctionSettingNow.BarcodeKeyword));
  774. SNText.Enabled = true;
  775. SNText.Text = "";
  776. return;
  777. }
  778. }
  779. }
  780. #region 只有惠州工厂才启用G客户防呆措施;
  781. if (FunctionSettingNow.NTF)
  782. {
  783. StringBuilder strValue = new StringBuilder(256);
  784. // 获取上一次的SN号;
  785. CommonMethod.GetProfileString("MOKAFactoryTools", "LastGSN", "", strValue, 256);
  786. if (strValue.ToString().Equals(SN, StringComparison.OrdinalIgnoreCase))
  787. {
  788. // 连续测试中累计失败的次数;
  789. int lastCount = 0;
  790. CommonMethod.GetProfileString("MOKAFactoryTools", "GFailCount", "0", strValue, 256);
  791. int.TryParse(strValue.ToString(), out lastCount);
  792. // NTF规则:连续测试中累计出现2次Fail,禁止测试.
  793. if (lastCount >= FunctionSettingNow.GFoolProofingCount)
  794. {
  795. Verify dlg = new Verify("累计出现2次Fail,禁止测试!" + "\r\n" + SN);
  796. dlg.ShowDialog();
  797. SNText.Enabled = true;
  798. SNText.Text = "";
  799. return;
  800. }
  801. }
  802. // 根据SN获取订单类型;
  803. string strOrderType;
  804. string strErrorMsg;
  805. if (!GMethod.GetOrderTypeFromSN(SN, orderNow, out strOrderType, out strErrorMsg))
  806. {
  807. Verify dlg = new Verify("根据SN获取订单类型失败,停止测试!" + "\r\nSN:" + SN);
  808. dlg.ShowDialog();
  809. Log.WriteErrorLog(string.Format("SN={0},错误={1}", SN, strErrorMsg));
  810. SNText.Enabled = true;
  811. SNText.Text = "";
  812. return;
  813. }
  814. if (strOrderType.Equals("量产"))
  815. nOrderType = 1;
  816. else if (strOrderType.Equals("试产"))
  817. nOrderType = 0;
  818. else
  819. {
  820. Verify dlg = new Verify("根据SN获取订单类型异常,停止测试!" + "\r\n" + SN);
  821. dlg.ShowDialog();
  822. Log.WriteErrorLog(String.Format("{0}获取订单类型异常={1}", SN, strOrderType));
  823. SNText.Enabled = true;
  824. SNText.Text = "";
  825. return;
  826. }
  827. }
  828. else if ( FunctionSettingNow.SNDoubleTips )
  829. {
  830. StringBuilder strValue = new StringBuilder(256);
  831. // 获取上一次的SN号;
  832. CommonMethod.GetProfileString("MOKAFactoryTools", "LastSN", "", strValue, 256);
  833. if (strValue.ToString().Equals(SN, StringComparison.OrdinalIgnoreCase))
  834. {
  835. if ( MessageBox.Show("该SN已连续使用两次,可能误用到其他机器,请确认是否继续", "提示", MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes)
  836. {
  837. SNText.Enabled = true;
  838. SNText.Text = "";
  839. return;
  840. }
  841. }
  842. CommonMethod.WriteProfileString("MOKAFactoryTools", "LastSN", SN);
  843. }
  844. #endregion
  845. #if !SIMULATION
  846. if (CommonMethod.GetLoginAccout().Equals("Sanhua", StringComparison.OrdinalIgnoreCase))
  847. {
  848. string message = string.Empty;
  849. if ( !SanhuaMethod.ProductRouteCheck(SN, out message) )
  850. {
  851. Verify dlg = new Verify(string.Format("{0} ProductRouteCheck faild: {1} ", SN, message));
  852. dlg.ShowDialog();
  853. SNText.Enabled = true;
  854. SNText.Text = "";
  855. return;
  856. }
  857. }
  858. #endif
  859. if (preloadNow)
  860. {
  861. bool copydone = false;
  862. string keyjson = SQLiteHelper.Getkeys(localDBNow, SN, out copydone);
  863. if (FunctionSettingNow.NoDoublewrite && copydone)
  864. {
  865. MessageBox.Show(LResource.FindcopiedSN + SN);
  866. SNText.Enabled = true;
  867. SNText.Focus();
  868. }
  869. else if (keyjson.Length > 0)
  870. {
  871. #region 解决Json对象空导致的Bug.
  872. Func<JToken, string> GetJsonValue = (JsonObj) =>
  873. {
  874. if (JsonObj == null )
  875. return "";
  876. return JsonObj.Value<string>();
  877. };
  878. #endregion
  879. JObject jObject = JObject.Parse(keyjson);
  880. keyInfo.DID.data = GetJsonValue(jObject["did"]);
  881. keyInfo.Mac.data = GetJsonValue(jObject["mac"]);
  882. keyInfo.HDCP.data = GetJsonValue(jObject["hdcp"]);
  883. keyInfo.HDCP22.data = GetJsonValue(jObject["hdcp22"]);
  884. //keyInfo.WiDi.data = GetJsonValue(jObject["widi"]);
  885. keyInfo.Widevine.data = GetJsonValue(jObject["widevine"]);
  886. keyInfo.ESN.data = GetJsonValue(jObject["esn"]);
  887. keyInfo.CI_plus.data = GetJsonValue(jObject["cikey"]);
  888. keyInfo.MGK.data = GetJsonValue(jObject["mgk"]);
  889. keyInfo.Attestation.data = GetJsonValue(jObject["attestation"]);
  890. keyInfo.Fairplay.data = GetJsonValue(jObject["fairplay"]);
  891. keyInfo.ECP.data = GetJsonValue(jObject["ecp"]);
  892. keyInfo.WiFi_MAC.data = GetJsonValue(jObject["wifimac"]);
  893. keyInfo.BT_MAC.data = GetJsonValue(jObject["btmac"]);
  894. keyInfo.LEK.data = GetJsonValue(jObject["lek"]);
  895. keyInfo.PEK.data = GetJsonValue(jObject["pek"]);
  896. keyInfo.Playready.data = GetJsonValue(jObject["playready"]);
  897. keyInfo.Hashkey.data = GetJsonValue(jObject["hash"]);
  898. keyInfo.YouTube_KEY.data = GetJsonValue(jObject["youtubekey"]);
  899. keyInfo.ACASKey_Data.data = GetJsonValue(jObject["acaskey_data"]);
  900. //keyInfo.ACASKey_Tool.data = GetJsonValue(jObject["acaskey_tool"]);
  901. keyInfo.DAK.data = GetJsonValue(jObject["dak"]);
  902. keyInfo.FVP.data = GetJsonValue(jObject["FVP"]);
  903. keyInfo.KFP.data = GetJsonValue(jObject["kfp"]);
  904. WriteDID.Checked = (keyInfo.DID.Length > 0 && m_writedid.Text != LResource.Skip);
  905. if (WriteDID.Checked)
  906. Log.WriteGetKeyLog("\r\nLocal DB DeviceID=" + keyInfo.DID.data);
  907. WriteMac.Checked = (keyInfo.Mac.Length > 0 && m_writemac.Text != LResource.Skip);
  908. if (WriteMac.Checked)
  909. Log.WriteGetKeyLog("\r\nLocal DB Mac=" + keyInfo.Mac.data);
  910. WriteHDCP.Checked = (keyInfo.HDCP.Length > 0 && m_writehdcp.Text != LResource.Skip);
  911. if (WriteHDCP.Checked)
  912. Log.WriteGetKeyLog("\r\nLocal DB HDCP=" + keyInfo.HDCP.data);
  913. WriteHDCP22.Checked = (keyInfo.HDCP22.Length > 0 && m_writehdcp22.Text != LResource.Skip);
  914. if (WriteHDCP22.Checked)
  915. Log.WriteGetKeyLog("\r\nLocal DB HDCP22=" + keyInfo.HDCP22.data);
  916. WriteWidevine.Checked = (keyInfo.Widevine.Length > 0 && m_writewidevine.Text != LResource.Skip);
  917. if (WriteWidevine.Checked)
  918. Log.WriteGetKeyLog("\r\nLocal DB Widevine=" + keyInfo.Widevine.data);
  919. WriteESN.Checked = (keyInfo.ESN.Length > 0 && m_writeesn.Text != LResource.Skip);
  920. if (WriteESN.Checked)
  921. Log.WriteGetKeyLog("\r\nLocal DB ESN=" + keyInfo.ESN.data);
  922. WriteCiplus.Checked = (keyInfo.CI_plus.Length > 0 && m_writeci.Text != LResource.Skip);
  923. if (WriteCiplus.Checked)
  924. Log.WriteGetKeyLog("\r\nLocal DB Ci=" + keyInfo.CI_plus.data);
  925. WriteMGK.Checked = (keyInfo.MGK.Length > 0 && m_writeMGK.Text != LResource.Skip);
  926. if (WriteMGK.Checked)
  927. Log.WriteGetKeyLog("\r\nLocal DB MGK=" + keyInfo.MGK.data);
  928. WriteAttestation.Checked = (keyInfo.Attestation.Length > 0 && m_writeattestation.Text != LResource.Skip);
  929. if (WriteAttestation.Checked)
  930. Log.WriteGetKeyLog("\r\nLocal DB Attestation=" + keyInfo.Attestation.data);
  931. WriteFairplay.Checked = (keyInfo.Fairplay.Length > 0 && m_writeFairplay.Text != LResource.Skip);
  932. if (WriteFairplay.Checked)
  933. Log.WriteGetKeyLog("\r\nLocal DB Fairplay=" + keyInfo.Fairplay.data);
  934. WriteECP.Checked = (keyInfo.ECP.Length > 0 && m_writeECP.Text != LResource.Skip);
  935. if (WriteECP.Checked)
  936. Log.WriteGetKeyLog("\r\nLocal DB ECP=" + keyInfo.ECP.data);
  937. WriteWifiMac.Checked = (keyInfo.WiFi_MAC.Length > 0 && m_writeWifiMac.Text != LResource.Skip);
  938. if (WriteWifiMac.Checked)
  939. Log.WriteGetKeyLog("\r\nLocal DB WifiMac=" + keyInfo.WiFi_MAC.data);
  940. WriteBTMac.Checked = (keyInfo.BT_MAC.Length > 0 && m_writeBTMac.Text != LResource.Skip);
  941. if (WriteBTMac.Checked)
  942. Log.WriteGetKeyLog("\r\nLocal DB BTMac=" + keyInfo.BT_MAC.data);
  943. WriteLEK.Checked = (keyInfo.LEK.Length > 0 && m_writeLEK.Text != LResource.Skip);
  944. if (WriteLEK.Checked)
  945. Log.WriteGetKeyLog("\r\nLocal DB LEK=" + keyInfo.LEK.data);
  946. WritePEK.Checked = (keyInfo.PEK.Length > 0 && m_writePEK.Text != LResource.Skip);
  947. if (WritePEK.Checked)
  948. Log.WriteGetKeyLog("\r\nLocal DB PEK=" + keyInfo.PEK.data);
  949. WritePlayready.Checked = (keyInfo.Playready.Length > 0 && m_writePlayready.Text != LResource.Skip);
  950. if (WritePlayready.Checked)
  951. Log.WriteGetKeyLog("\r\nLocal DB Playready=" + keyInfo.Playready.data);
  952. WriteHash.Checked = (keyInfo.Hashkey.Length > 0 && m_writeHash.Text != LResource.Skip);
  953. if (WriteHash.Checked)
  954. Log.WriteGetKeyLog("\r\nLocal DB Hashkey=" + keyInfo.Hashkey.data);
  955. WriteYouTube.Checked = (keyInfo.YouTube_KEY.Length > 0 && m_writeYouTube.Text != LResource.Skip);
  956. if (WriteYouTube.Checked)
  957. Log.WriteGetKeyLog("\r\nLocal DB YouTube_KEY=" + keyInfo.YouTube_KEY.data);
  958. WriteACASKey.Checked = (keyInfo.ACASKey_Data.Length > 0 && m_writeACASKey.Text != LResource.Skip);
  959. if (WriteACASKey.Checked)
  960. Log.WriteGetKeyLog("\r\nLocal DB ACAS_KEY=" + keyInfo.ACASKey_Data.data);
  961. WriteDAK.Checked = (keyInfo.DAK.Length > 0 && m_writeDAK.Text != LResource.Skip);
  962. if (WriteDAK.Checked)
  963. Log.WriteGetKeyLog("\r\nLocal DB DAK=" + keyInfo.DAK.data);
  964. WriteKFP.Checked = (keyInfo.KFP.Length > 0 && m_writeKFP.Text != LResource.Skip);
  965. if ( WriteKFP.Checked)
  966. Log.WriteGetKeyLog("\r\nLocal DB KFP=" + keyInfo.KFP.data);
  967. WriteFVP.Checked = m_writeFVP.Text != LResource.Skip;
  968. WriteDSN.Checked = (keyInfo.DSN.Length > 0 && m_writeDSN.Text != LResource.Skip);
  969. WritePSN.Checked = FunctionSettingNow.BarcodeWrite;
  970. timer1.Start();
  971. Thread t = new Thread(Writekey);
  972. t.Start();
  973. }
  974. else
  975. {
  976. MessageBox.Show(LResource.FindNullSnInDB + SN);
  977. SNText.Enabled = true;
  978. SNText.Focus();
  979. }
  980. }
  981. else
  982. {
  983. Onlinemode();
  984. }
  985. // 抄写成功后才清空;
  986. //SNText.Text = "";
  987. }
  988. }
  989. /// <summary>
  990. /// 设置成功状态显示
  991. /// </summary>
  992. /// <param name="label"></param>
  993. public void SetsuccessStatus(Label label)
  994. {
  995. if (label.InvokeRequired && label.Text != LResource.Skip)
  996. {
  997. //BeginInvoke(new Action<string>(x => { label.Text = x.ToString(); }), 参数);
  998. label.BeginInvoke(new Action(() => { label.Text = "OK"; label.BackColor = Color.FromArgb(128, 255, 128); }));
  999. }
  1000. }
  1001. /// <summary>
  1002. /// 设置失败状态显示
  1003. /// </summary>
  1004. /// <param name="label"></param>
  1005. public void SetfailStatus(Label label)
  1006. {
  1007. if (label.InvokeRequired)
  1008. {
  1009. label.BeginInvoke(new Action(() => { label.Text = "NG"; label.BackColor = Color.Red; }));
  1010. }
  1011. }
  1012. /// <summary>
  1013. /// 设置扫描框为输入状态
  1014. /// </summary>
  1015. /// <param name="textBox"></param>
  1016. public void EnableText(TextBox textBox)
  1017. {
  1018. if (textBox.InvokeRequired)
  1019. {
  1020. textBox.BeginInvoke(new Action(() => { textBox.Enabled = true; textBox.Text = ""; textBox.Focus(); }));
  1021. }
  1022. else
  1023. {
  1024. textBox.Enabled = true;
  1025. textBox.Focus();
  1026. textBox.Text = "";
  1027. }
  1028. }
  1029. /// <summary>
  1030. /// 设置按钮为可点击状态
  1031. /// </summary>
  1032. /// <param name="button"></param>
  1033. public void EnableButton(Button button)
  1034. {
  1035. if (button.InvokeRequired)
  1036. {
  1037. button.BeginInvoke(new Action(() => { button.Enabled = true; }));
  1038. }
  1039. else
  1040. button.Enabled = true;
  1041. }
  1042. /// <summary>
  1043. /// 设置特殊的文本和颜色
  1044. /// </summary>
  1045. /// <param name="label">标签控件</param>
  1046. /// <param name="str">需要显示的文本</param>
  1047. /// <param name="color">需要设置的控件背景颜色</param>
  1048. public void SetspecificText(Label label, string str, Color color)
  1049. {
  1050. if (label.InvokeRequired)
  1051. {
  1052. BeginInvoke(new Action<string>(x => { label.Text = x.ToString(); }), str);
  1053. label.BeginInvoke(new Action(() => { label.BackColor = color; }));
  1054. }
  1055. else
  1056. {
  1057. label.Text = str;
  1058. label.BackColor = color;
  1059. }
  1060. }
  1061. /// <summary>
  1062. /// 设置标签控件颜色
  1063. /// </summary>
  1064. /// <param name="label">标签控件对象</param>
  1065. /// <param name="color">需要设置的标签背景颜色</param>
  1066. public void SetcolorStatus(Label label, Color color)
  1067. {
  1068. if (label.InvokeRequired)
  1069. {
  1070. label.BeginInvoke(new Action(() => { label.BackColor = color; }));
  1071. }
  1072. }
  1073. /// <summary>
  1074. /// 跨线程关闭窗口
  1075. /// </summary>
  1076. /// <param name="label"></param>
  1077. /// <param name="color"></param>
  1078. public void Closeform()
  1079. {
  1080. if (this.InvokeRequired)
  1081. {
  1082. this.BeginInvoke(new Action(() => { this.Close(); }));
  1083. }
  1084. }
  1085. /// <summary>
  1086. /// 设置标签控件文本
  1087. /// </summary>
  1088. /// <param name="label">标签控件对象</param>
  1089. /// <param name="color">需要设置的标签文本</param>
  1090. public void SetTextStatus(Label label, string txt)
  1091. {
  1092. if (label.InvokeRequired)
  1093. {
  1094. label.BeginInvoke(new Action(() => { label.Text = txt; }));
  1095. }
  1096. else
  1097. label.Text = txt;
  1098. }
  1099. /// <summary>
  1100. /// 线程内&跨线程设置key数量显示控件
  1101. /// </summary>
  1102. /// <param name="label">数量提示控件</param>
  1103. /// <param name="str">数量值</param>
  1104. /// <param name="status">状态,0为正常,1为获取失败,2为数量不足</param>
  1105. public void SetKeyCountStatus(Label label, string str, int status)
  1106. {
  1107. if (label.InvokeRequired)
  1108. {
  1109. BeginInvoke(new Action<string>(x => { label.Text = x.ToString(); }), str);
  1110. switch (status)
  1111. {
  1112. case 0:
  1113. label.BeginInvoke(new Action(() => { label.ForeColor = Color.Green; }));
  1114. break;
  1115. case 1:
  1116. label.BeginInvoke(new Action(() => { label.BackColor = Color.Red; }));
  1117. break;
  1118. case 2:
  1119. label.BeginInvoke(new Action(() => { label.ForeColor = Color.Red; }));
  1120. break;
  1121. }
  1122. }
  1123. else
  1124. {
  1125. label.Text = str;
  1126. switch (status)
  1127. {
  1128. case 0:
  1129. label.ForeColor = Color.Green; ;
  1130. break;
  1131. case 1:
  1132. label.BackColor = Color.Red;
  1133. break;
  1134. case 2:
  1135. label.ForeColor = Color.Red;
  1136. break;
  1137. }
  1138. }
  1139. }
  1140. /// <summary>
  1141. /// 线程内&跨线程设置checkbox控件的checked值
  1142. /// </summary>
  1143. /// <param name="checkBox">checkbox控件</param>
  1144. /// <param name="status">需要设置的布尔状态</param>
  1145. public void SetCheckboxStatus(CheckBox checkBox, bool status)
  1146. {
  1147. if (checkBox.InvokeRequired)
  1148. {
  1149. BeginInvoke(new Action<bool>(x => { checkBox.Checked = x; }), status);
  1150. }
  1151. else
  1152. {
  1153. checkBox.Checked = status;
  1154. }
  1155. }
  1156. /// <summary>
  1157. /// 重置控件状态,skip除外
  1158. /// </summary>
  1159. public void SetInitialStatus()
  1160. {
  1161. this.CaptionBackColorTop = Color.RoyalBlue;
  1162. this.CaptionBackColorBottom = Color.Cyan;
  1163. this.Refresh();
  1164. /////////////////////////////////////////////////////////////
  1165. #region Set Write;
  1166. if (m_writeci.Text != LResource.Skip)
  1167. {
  1168. m_writeci.Text = "Null";
  1169. m_writeci.BackColor = Color.Transparent;
  1170. }
  1171. if (m_writemac.Text != LResource.Skip)
  1172. {
  1173. m_writemac.Text = "Null";
  1174. m_writemac.BackColor = Color.Transparent;
  1175. }
  1176. if (m_writedid.Text != LResource.Skip)
  1177. {
  1178. m_writedid.Text = "Null";
  1179. m_writedid.BackColor = Color.Transparent;
  1180. }
  1181. if (m_writeesn.Text != LResource.Skip)
  1182. {
  1183. m_writeesn.Text = "Null";
  1184. m_writeesn.BackColor = Color.Transparent;
  1185. }
  1186. if (m_writewidevine.Text != LResource.Skip)
  1187. {
  1188. m_writewidevine.Text = "Null";
  1189. m_writewidevine.BackColor = Color.Transparent;
  1190. }
  1191. if (m_writehdcp.Text != LResource.Skip)
  1192. {
  1193. m_writehdcp.Text = "Null";
  1194. m_writehdcp.BackColor = Color.Transparent;
  1195. }
  1196. if (m_writehdcp22.Text != LResource.Skip)
  1197. {
  1198. m_writehdcp22.Text = "Null";
  1199. m_writehdcp22.BackColor = Color.Transparent;
  1200. }
  1201. if (m_writeattestation.Text != LResource.Skip)
  1202. {
  1203. m_writeattestation.Text = "Null";
  1204. m_writeattestation.BackColor = Color.Transparent;
  1205. }
  1206. if (m_writeMGK.Text != LResource.Skip)
  1207. {
  1208. m_writeMGK.Text = "Null";
  1209. m_writeMGK.BackColor = Color.Transparent;
  1210. }
  1211. if (m_writeFairplay.Text != LResource.Skip)
  1212. {
  1213. m_writeFairplay.Text = "Null";
  1214. m_writeFairplay.BackColor = Color.Transparent;
  1215. }
  1216. if (m_writeECP.Text != LResource.Skip)
  1217. {
  1218. m_writeECP.Text = "Null";
  1219. m_writeECP.BackColor = Color.Transparent;
  1220. }
  1221. if (m_writeLEK.Text != LResource.Skip)
  1222. {
  1223. m_writeLEK.Text = "Null";
  1224. m_writeLEK.BackColor = Color.Transparent;
  1225. }
  1226. if (m_writePEK.Text != LResource.Skip)
  1227. {
  1228. m_writePEK.Text = "Null";
  1229. m_writePEK.BackColor = Color.Transparent;
  1230. }
  1231. if (m_writeHash.Text != LResource.Skip)
  1232. {
  1233. m_writeHash.Text = "Null";
  1234. m_writeHash.BackColor = Color.Transparent;
  1235. }
  1236. if (m_writeDSN.Text != LResource.Skip)
  1237. {
  1238. m_writeDSN.Text = "Null";
  1239. m_writeDSN.BackColor = Color.Transparent;
  1240. }
  1241. if (m_writeWifiMac.Text != LResource.Skip)
  1242. {
  1243. m_writeWifiMac.Text = "Null";
  1244. m_writeWifiMac.BackColor = Color.Transparent;
  1245. }
  1246. if (m_writeBTMac.Text != LResource.Skip)
  1247. {
  1248. m_writeBTMac.Text = "Null";
  1249. m_writeBTMac.BackColor = Color.Transparent;
  1250. }
  1251. if (m_writeDSN.Text != LResource.Skip)
  1252. {
  1253. m_writeDSN.Text = "Null";
  1254. m_writeDSN.BackColor = Color.Transparent;
  1255. }
  1256. if (m_writePlayready.Text != LResource.Skip)
  1257. {
  1258. m_writePlayready.Text = "Null";
  1259. m_writePlayready.BackColor = Color.Transparent;
  1260. }
  1261. if (m_writeYouTube.Text != LResource.Skip)
  1262. {
  1263. m_writeYouTube.Text = "Null";
  1264. m_writeYouTube.BackColor = Color.Transparent;
  1265. }
  1266. if (m_writePSN.Text != LResource.Skip)
  1267. {
  1268. m_writePSN.Text = "Null";
  1269. m_writePSN.BackColor = Color.Transparent;
  1270. }
  1271. if (m_writeACASKey.Text != LResource.Skip)
  1272. {
  1273. m_writeACASKey.Text = "Null";
  1274. m_writeACASKey.BackColor = Color.Transparent;
  1275. }
  1276. if (m_writeEDIDPID.Text != LResource.Skip)
  1277. {
  1278. m_writeEDIDPID.Text = "Null";
  1279. m_writeEDIDPID.BackColor = Color.Transparent;
  1280. }
  1281. if (m_writeEDIDName.Text != LResource.Skip)
  1282. {
  1283. m_writeEDIDName.Text = "Null";
  1284. m_writeEDIDName.BackColor = Color.Transparent;
  1285. }
  1286. if (m_writeKFP.Text != LResource.Skip)
  1287. {
  1288. m_writeKFP.Text = "Null";
  1289. m_writeKFP.BackColor = Color.Transparent;
  1290. }
  1291. #endregion
  1292. /////////////////////////////////////////////////////////////
  1293. #region Write Check;
  1294. if (m_checkci.Text != LResource.Skip)
  1295. {
  1296. m_checkci.Text = "Null";
  1297. m_checkci.BackColor = Color.Transparent;
  1298. }
  1299. if (m_checkmac.Text != LResource.Skip)
  1300. {
  1301. m_checkmac.Text = "Null";
  1302. m_checkmac.BackColor = Color.Transparent;
  1303. }
  1304. if (m_checkdid.Text != LResource.Skip)
  1305. {
  1306. m_checkdid.Text = "Null";
  1307. m_checkdid.BackColor = Color.Transparent;
  1308. }
  1309. if (m_checkesn.Text != LResource.Skip)
  1310. {
  1311. m_checkesn.Text = "Null";
  1312. m_checkesn.BackColor = Color.Transparent;
  1313. }
  1314. if (m_checkwidevine.Text != LResource.Skip)
  1315. {
  1316. m_checkwidevine.Text = "Null";
  1317. m_checkwidevine.BackColor = Color.Transparent;
  1318. }
  1319. if (m_checkhdcp.Text != LResource.Skip)
  1320. {
  1321. m_checkhdcp.Text = "Null";
  1322. m_checkhdcp.BackColor = Color.Transparent;
  1323. }
  1324. if (m_checkhdcp22.Text != LResource.Skip)
  1325. {
  1326. m_checkhdcp22.Text = "Null";
  1327. m_checkhdcp22.BackColor = Color.Transparent;
  1328. }
  1329. if (m_checkattestation.Text != LResource.Skip)
  1330. {
  1331. m_checkattestation.Text = "Null";
  1332. m_checkattestation.BackColor = Color.Transparent;
  1333. }
  1334. if (m_checkMGK.Text != LResource.Skip)
  1335. {
  1336. m_checkMGK.Text = "Null";
  1337. m_checkMGK.BackColor = Color.Transparent;
  1338. }
  1339. if (m_checkFairplay.Text != LResource.Skip)
  1340. {
  1341. m_checkFairplay.Text = "Null";
  1342. m_checkFairplay.BackColor = Color.Transparent;
  1343. }
  1344. if (m_checkECP.Text != LResource.Skip)
  1345. {
  1346. m_checkECP.Text = "Null";
  1347. m_checkECP.BackColor = Color.Transparent;
  1348. }
  1349. if (m_checkLEK.Text != LResource.Skip)
  1350. {
  1351. m_checkLEK.Text = "Null";
  1352. m_checkLEK.BackColor = Color.Transparent;
  1353. }
  1354. if (m_checkPEK.Text != LResource.Skip)
  1355. {
  1356. m_checkPEK.Text = "Null";
  1357. m_checkPEK.BackColor = Color.Transparent;
  1358. }
  1359. if (m_checkHash.Text != LResource.Skip)
  1360. {
  1361. m_checkHash.Text = "Null";
  1362. m_checkHash.BackColor = Color.Transparent;
  1363. }
  1364. if (m_checkDSN.Text != LResource.Skip)
  1365. {
  1366. m_checkDSN.Text = "Null";
  1367. m_checkDSN.BackColor = Color.Transparent;
  1368. }
  1369. if (m_checkWifiMac.Text != LResource.Skip)
  1370. {
  1371. m_checkWifiMac.Text = "Null";
  1372. m_checkWifiMac.BackColor = Color.Transparent;
  1373. }
  1374. if (m_checkBTMac.Text != LResource.Skip)
  1375. {
  1376. m_checkBTMac.Text = "Null";
  1377. m_checkBTMac.BackColor = Color.Transparent;
  1378. }
  1379. if (m_checkDSN.Text != LResource.Skip)
  1380. {
  1381. m_checkDSN.Text = "Null";
  1382. m_checkDSN.BackColor = Color.Transparent;
  1383. }
  1384. if (m_checkPlayready.Text != LResource.Skip)
  1385. {
  1386. m_checkPlayready.Text = "Null";
  1387. m_checkPlayready.BackColor = Color.Transparent;
  1388. }
  1389. if (m_checkYouTube.Text != LResource.Skip)
  1390. {
  1391. m_checkYouTube.Text = "Null";
  1392. m_checkYouTube.BackColor = Color.Transparent;
  1393. }
  1394. if (m_checkACASKey.Text != LResource.Skip)
  1395. {
  1396. m_checkACASKey.Text = "Null";
  1397. m_checkACASKey.BackColor = Color.Transparent;
  1398. }
  1399. if (m_checkKFP.Text != LResource.Skip)
  1400. {
  1401. m_checkKFP.Text = "Null";
  1402. m_checkKFP.BackColor = Color.Transparent;
  1403. }
  1404. #endregion
  1405. /////////////////////////////////////////////////////////////
  1406. #region Read Check;
  1407. if (m_readci.Text != LResource.Skip)
  1408. {
  1409. m_readci.Text = "Null";
  1410. m_readci.BackColor = Color.Transparent;
  1411. }
  1412. if (m_readmac.Text != LResource.Skip)
  1413. {
  1414. m_readmac.Text = "Null";
  1415. m_readmac.BackColor = Color.Transparent;
  1416. }
  1417. if (m_readdid.Text != LResource.Skip)
  1418. {
  1419. m_readdid.Text = "Null";
  1420. m_readdid.BackColor = Color.Transparent;
  1421. }
  1422. if (m_readesn.Text != LResource.Skip)
  1423. {
  1424. m_readesn.Text = "Null";
  1425. m_readesn.BackColor = Color.Transparent;
  1426. }
  1427. if (m_readwidevine.Text != LResource.Skip)
  1428. {
  1429. m_readwidevine.Text = "Null";
  1430. m_readwidevine.BackColor = Color.Transparent;
  1431. }
  1432. if (m_readhdcp.Text != LResource.Skip)
  1433. {
  1434. m_readhdcp.Text = "Null";
  1435. m_readhdcp.BackColor = Color.Transparent;
  1436. }
  1437. if (m_readhdcp22.Text != LResource.Skip)
  1438. {
  1439. m_readhdcp22.Text = "Null";
  1440. m_readhdcp22.BackColor = Color.Transparent;
  1441. }
  1442. if (m_readattestation.Text != LResource.Skip)
  1443. {
  1444. m_readattestation.Text = "Null";
  1445. m_readattestation.BackColor = Color.Transparent;
  1446. }
  1447. if (m_readMGK.Text != LResource.Skip)
  1448. {
  1449. m_readMGK.Text = "Null";
  1450. m_readMGK.BackColor = Color.Transparent;
  1451. }
  1452. if (m_readFairplay.Text != LResource.Skip)
  1453. {
  1454. m_readFairplay.Text = "Null";
  1455. m_readFairplay.BackColor = Color.Transparent;
  1456. }
  1457. if (m_readECP.Text != LResource.Skip)
  1458. {
  1459. m_readECP.Text = "Null";
  1460. m_readECP.BackColor = Color.Transparent;
  1461. }
  1462. if (m_readLEK.Text != LResource.Skip)
  1463. {
  1464. m_readLEK.Text = "Null";
  1465. m_readLEK.BackColor = Color.Transparent;
  1466. }
  1467. if (m_readPEK.Text != LResource.Skip)
  1468. {
  1469. m_readPEK.Text = "Null";
  1470. m_readPEK.BackColor = Color.Transparent;
  1471. }
  1472. if (m_readHash.Text != LResource.Skip)
  1473. {
  1474. m_readHash.Text = "Null";
  1475. m_readHash.BackColor = Color.Transparent;
  1476. }
  1477. if (m_readDSN.Text != LResource.Skip)
  1478. {
  1479. m_readDSN.Text = "Null";
  1480. m_readDSN.BackColor = Color.Transparent;
  1481. }
  1482. if (m_readWifiMac.Text != LResource.Skip)
  1483. {
  1484. m_readWifiMac.Text = "Null";
  1485. m_readWifiMac.BackColor = Color.Transparent;
  1486. }
  1487. if (m_readBTMac.Text != LResource.Skip)
  1488. {
  1489. m_readBTMac.Text = "Null";
  1490. m_readBTMac.BackColor = Color.Transparent;
  1491. }
  1492. if (m_readDSN.Text != LResource.Skip)
  1493. {
  1494. m_readDSN.Text = "Null";
  1495. m_readDSN.BackColor = Color.Transparent;
  1496. }
  1497. if (m_readPlayready.Text != LResource.Skip)
  1498. {
  1499. m_readPlayready.Text = "Null";
  1500. m_readPlayready.BackColor = Color.Transparent;
  1501. }
  1502. if (m_readYouTube.Text != LResource.Skip)
  1503. {
  1504. m_readYouTube.Text = "Null";
  1505. m_readYouTube.BackColor = Color.Transparent;
  1506. }
  1507. if (m_readPSN.Text != LResource.Skip)
  1508. {
  1509. m_readPSN.Text = "Null";
  1510. m_readPSN.BackColor = Color.Transparent;
  1511. }
  1512. if (m_readACASID.Text != LResource.Skip)
  1513. {
  1514. m_readACASID.Text = "Null";
  1515. m_readACASID.BackColor = Color.Transparent;
  1516. }
  1517. if (m_readEDIDPID.Text != LResource.Skip)
  1518. {
  1519. m_readEDIDPID.Text = "Null";
  1520. m_readEDIDPID.BackColor = Color.Transparent;
  1521. }
  1522. if (m_readEDIDName.Text != LResource.Skip)
  1523. {
  1524. m_readEDIDName.Text = "Null";
  1525. m_readEDIDName.BackColor = Color.Transparent;
  1526. }
  1527. if (m_readACASKey.Text != LResource.Skip)
  1528. {
  1529. m_readACASKey.Text = "Null";
  1530. m_readACASKey.BackColor = Color.Transparent;
  1531. }
  1532. if (m_readKFP.Text != LResource.Skip)
  1533. {
  1534. m_readKFP.Text = "Null";
  1535. m_readKFP.BackColor = Color.Transparent;
  1536. }
  1537. #endregion
  1538. ResultStatus.Text = "Wait";
  1539. ResultStatus.BackColor = Color.Transparent;
  1540. SHOPText.BackColor = Color.Transparent;
  1541. OSDText.BackColor = Color.Transparent;
  1542. WBPathText.BackColor = Color.Transparent;
  1543. ProductMsg_Text.BackColor = Color.Transparent;
  1544. }
  1545. /// <summary>
  1546. /// 生成报文;
  1547. /// </summary>
  1548. /// <returns></returns>
  1549. public string GenerateReportInfo()
  1550. {
  1551. #region 移除非IDM抄写的Key;
  1552. if ((FunctionSettingNow.MITVEnable || FunctionSettingNow.IndiaMITVEnable) && _MiKey != null)
  1553. {
  1554. // 配置要抄写的选项;
  1555. if (_MiKey.EthernetMac != null)
  1556. SetCheckboxStatus(WriteMac, false);
  1557. if (_MiKey.BTMac != null)
  1558. SetCheckboxStatus(WriteBTMac, false);
  1559. if (_MiKey.DSN != null)
  1560. SetCheckboxStatus(WriteDSN, false);
  1561. if (_MiKey.WIFIMAC != null)
  1562. SetCheckboxStatus(WriteWifiMac, false);
  1563. }
  1564. #endregion
  1565. #region 生成IDMKey报文;
  1566. string reportdata = "";
  1567. if (SN.Trim().Length > 0)
  1568. reportdata += "sn=" + SN + "&";
  1569. if (WriteDID.Checked)
  1570. reportdata += "deviceid=" + keyInfo.DID.data + "&";
  1571. if (WriteMac.Checked)
  1572. reportdata += "mac=" + keyInfo.Mac.data + "&";
  1573. if (WriteWifiMac.Checked)
  1574. reportdata += "wifimac=" + keyInfo.WiFi_MAC.data + "&";
  1575. if (WriteBTMac.Checked)
  1576. reportdata += "btmac=" + keyInfo.BT_MAC.data + "&";
  1577. if (WriteHDCP.Checked)
  1578. reportdata += "hdcpkey=" + keyInfo.HDCP.data + "&";
  1579. if (WriteHDCP22.Checked)
  1580. reportdata += "hdcpkey2=" + keyInfo.HDCP22.data + "&";
  1581. if (WriteESN.Checked)
  1582. reportdata += "netfilxesn=" + keyInfo.ESN.data + "&";
  1583. if (WritePEK.Checked)
  1584. reportdata += "pek=" + keyInfo.PEK.data + "&";
  1585. if (WriteYouTube.Checked)
  1586. reportdata += "youtubekey=" + keyInfo.YouTube_KEY.data + "&";
  1587. if (WriteWidevine.Checked)
  1588. reportdata += "widevine=" + keyInfo.Widevine.data + "&";
  1589. if (WriteCiplus.Checked)
  1590. reportdata += "cikey=" + keyInfo.CI_plus.data + "&";
  1591. if (WriteAttestation.Checked)
  1592. reportdata += "attestationmd5=" + keyInfo.AttestationMD5.data + "&";
  1593. if (WriteMGK.Checked)
  1594. reportdata += "mgk=" + keyInfo.MGK.data + "&";
  1595. if (WriteFairplay.Checked)
  1596. reportdata += "fairplay=" + keyInfo.Fairplay.data + "&";
  1597. if (WriteECP.Checked)
  1598. reportdata += "ecp=" + keyInfo.ECP.data + "&";
  1599. if (WriteLEK.Checked)
  1600. reportdata += "lek=" + keyInfo.LEK.data + "&";
  1601. if (WritePlayready.Checked)
  1602. reportdata += "playready=" + keyInfo.Playready.data + "&";
  1603. if (WriteHash.Checked)
  1604. reportdata += "hash=" + keyInfo.Hashkey.data + "&";
  1605. if (WriteEDIDPID.Checked)
  1606. reportdata += "EDIDPid=" + keyInfo.EDIDPid.data + "&";
  1607. if (WriteEDIDName.Checked)
  1608. reportdata += "EDIDModeName=" + keyInfo.EDIDModelName.data + "&";
  1609. if (WriteKFP.Checked)
  1610. reportdata += "KFP_KEY=" + keyInfo.KFP.data + "&";
  1611. if (WriteACASKey.Checked)
  1612. reportdata += "acas_data=" + keyInfo.ACASKey_Data.data + "&";
  1613. if (WriteDAK.Checked)
  1614. reportdata += "DAK=" + keyInfo.DAK.data + "&";
  1615. if (ProjectIDNote.Text != LResource.SkipCovering)
  1616. reportdata += "projectid=" + ProjectIDText.Text + "&";
  1617. if (FunctionSettingNow.WriteWB)
  1618. reportdata += "wbNormal=" + FunctionSettingNow.NormalRGB[0].ToString() + ":" + FunctionSettingNow.NormalRGB[1].ToString() + ":" + FunctionSettingNow.NormalRGB[2].ToString() + "&" + "wbCool=" + FunctionSettingNow.CoolRGB[0].ToString() + ":" + FunctionSettingNow.CoolRGB[1].ToString() + ":" + FunctionSettingNow.CoolRGB[2].ToString() + "&" + "wbWarm=" + FunctionSettingNow.WarmRGB[0].ToString() + ":" + FunctionSettingNow.WarmRGB[1].ToString() + ":" + FunctionSettingNow.WarmRGB[2].ToString() + "&";
  1619. reportdata += "toolVersion=" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + "&";
  1620. return reportdata;
  1621. #endregion
  1622. }
  1623. public bool ReportMIInfo(out string msg)
  1624. {
  1625. msg = "";
  1626. // 上报MIKey抄写结果;
  1627. ReportMIKey reportMIKey = new ReportMIKey();
  1628. reportMIKey.EthernetMAC = _MiKey.EthernetMac;
  1629. reportMIKey.BTMAC = _MiKey.BTMac;
  1630. reportMIKey.WIFIMAC = _MiKey.WIFIMAC;
  1631. // 读取HDCP长度赋值;
  1632. reportMIKey.HDCP22 = _MiKey._HDCP22.ToString();
  1633. reportMIKey.HDCP14 = _MiKey._HDCP14.ToString();
  1634. // 返回的PSN作为ChipMN和ChipSN;
  1635. reportMIKey.ChipMN = _MiKey._PSN;
  1636. reportMIKey.ChipSN = _MiKey._PSN;
  1637. reportMIKey.DSN = _MiKey.DSN;
  1638. reportMIKey.TVMN = _MiKey.TVMN;
  1639. reportMIKey.TVSN = SN.Replace("/", ""); // 去掉斜杠;
  1640. if (!CommonMethod.ReportMIKey(FunctionSettingNow.MIKeyReportUrl, reportMIKey, out msg))
  1641. {
  1642. msg = string.Format("ReportMIKey error!\r\n{0}", msg);
  1643. Log.WriteErrorLog(msg);
  1644. return false;
  1645. }
  1646. return true;
  1647. }
  1648. /// <summary>
  1649. /// 执行抄key等动作
  1650. /// </summary>
  1651. public void Writekey()
  1652. {
  1653. DateTime startTime = DateTime.Now;
  1654. ArrayList keypath = new ArrayList();
  1655. ArrayList keyStream = new ArrayList();
  1656. ArrayList keyReader = new ArrayList();
  1657. //int SerailDelay = FunctionSettingNow.SerailDelay;
  1658. int SerailDelay = FunctionSettingNow.NextCommandWaitTime;
  1659. Log.WriteInfoLog(SN + " start testing");
  1660. // 0表示抄写失败,特殊:上报IDM失败\获取key失败\抄写失败;
  1661. // 1表示抄写成功,特殊:无;
  1662. // 2表示抄写成功,特殊:但试产NTF要求连续2次PASS才能上传MES,需要再测试一次;
  1663. // 3表示抄写成功,特殊:上报MES失败;
  1664. int TestResult = 0;
  1665. string keycontent = "";
  1666. bool EnterFactoryResult = false;
  1667. byte[] result;
  1668. byte[] data;
  1669. string error = "";
  1670. // 报错信息;
  1671. string ErrMsg = "";
  1672. string psn = "";
  1673. string devicecode = "";
  1674. #if !SIMULATION
  1675. //进工厂
  1676. if (!TVPort.IsOpen)
  1677. {
  1678. try
  1679. {
  1680. TVPort.Open();
  1681. }
  1682. catch (Exception ex)
  1683. {
  1684. MessageBox.Show(ex.Message);
  1685. goto stop;
  1686. }
  1687. }
  1688. for (int i = 0; i <= FunctionSettingNow.EnterFactoryRetry; i++)
  1689. {
  1690. if (i == 0)
  1691. Log.WriteInfoLog("Enter factory...");
  1692. else
  1693. Log.WriteInfoLog("Retry enter factory " + i.ToString() + " ...");
  1694. if (SerialCMD.EnterFactory(TVPort, out result, out data, out error, SerailDelay))
  1695. {
  1696. EnterFactoryResult = true;
  1697. break;
  1698. }
  1699. }
  1700. if (!EnterFactoryResult)
  1701. {
  1702. ErrMsg = string.Format("{0} Enter factory fail, Please check the problem", SN);
  1703. Log.WriteErrorLog(ErrMsg);
  1704. ShowVerifyDelegate(ErrMsg);
  1705. goto stop;
  1706. }
  1707. #endif
  1708. //烧录SN
  1709. if (WritePSN.Checked)
  1710. {
  1711. Log.WriteInfoLog("Write PSN");
  1712. if (SerialCMD.SetFireTVPSN(TVPort, Encoding.ASCII.GetBytes(SN), out result, out data, out error, SerailDelay))
  1713. {
  1714. SetsuccessStatus(m_writePSN);
  1715. Log.WriteInfoLog("Read PSN");
  1716. if (SerialCMD.ReadFireTVPSN(TVPort, out result, out data, out error, SerailDelay))
  1717. {
  1718. if (!Encoding.ASCII.GetString(data).Equals(SN))
  1719. {
  1720. ErrMsg = string.Format("{0} Compare PSN error!\r\n", SN);
  1721. Log.WriteErrorLog(ErrMsg);
  1722. goto end;
  1723. }
  1724. SetsuccessStatus(m_readPSN);
  1725. SetsuccessStatus(ResultStatus);
  1726. // 设置成功;
  1727. TestResult = 1;
  1728. // 抄写完PSN后,需要切PID,不能直接goto stop;
  1729. // goto stop;
  1730. }
  1731. else
  1732. {
  1733. SetfailStatus(m_readPSN);
  1734. ErrMsg = string.Format("{0} Read PSN error!\r\n", SN);
  1735. Log.WriteErrorLog(ErrMsg);
  1736. goto end;
  1737. }
  1738. }
  1739. else
  1740. {
  1741. SetfailStatus(m_writePSN);
  1742. ErrMsg = string.Format("{0} Write PSN error!\r\n", SN);
  1743. Log.WriteErrorLog(ErrMsg);
  1744. goto end;
  1745. }
  1746. }
  1747. string strACASID="";
  1748. // 如果是要导出ACASID+SN,先判断ACASID是否等于20位长度;
  1749. if (FunctionSettingNow.ExportSNACASID)
  1750. {
  1751. if (SerialCMD.ReadJapaneseACASID(TVPort, out result, out data, out error, SerailDelay))
  1752. {
  1753. if (data.Length != 20)
  1754. {
  1755. SetfailStatus(m_readACASID);
  1756. ErrMsg = string.Format("{0} The ACAS ID length doesn't equal 20!\r\n{1}", SN, data.ToString());
  1757. Log.WriteErrorLog(ErrMsg);
  1758. goto end;
  1759. }
  1760. SetsuccessStatus(m_readACASID);
  1761. }
  1762. else
  1763. {
  1764. SetfailStatus(m_readACASID);
  1765. ErrMsg = string.Format("{0} Read ACAS ID error!\r\n", SN);
  1766. Log.WriteErrorLog(ErrMsg);
  1767. goto end;
  1768. }
  1769. //strACASID=data.ToString();
  1770. strACASID = Encoding.ASCII.GetString(data);
  1771. }
  1772. //获取key
  1773. if (midListNow.host == "LocalPC" && !preloadNow)
  1774. {
  1775. string Didpath = "";
  1776. string Macpath = "";
  1777. string Hdcppath = "";
  1778. string Hdcp22path = "";
  1779. string Esnpath = "";
  1780. string MGKpath = "";
  1781. string Widevinepath = "";
  1782. string Cipath = "";
  1783. string Attestationpath = "";
  1784. string Fairplaypath = "";
  1785. string LEKpath = "";
  1786. string PEKpath = "";
  1787. string Playreadypath = "";
  1788. string Hashkeypath = "";
  1789. string AcasKeypath = "";
  1790. if (WriteDID.Checked)
  1791. {
  1792. if (GetLocalKeyCount.GetLocalStringKeys(orderNow, "DeviceID", FunctionSettingNow.LocalDidSize, out FileStream Stream, out StreamReader Reader, out string did, out Didpath, out error, errorDBNow, ref localmidList, SN))
  1793. {
  1794. keyInfo.DID.data = did;
  1795. Log.WriteGetKeyLog("\r\nLocal DeviceID=" + keyInfo.DID);
  1796. if (Stream != null && Reader != null)
  1797. {
  1798. keypath.Add(Didpath);
  1799. keyStream.Add(Stream);
  1800. keyReader.Add(Reader);
  1801. }
  1802. }
  1803. else
  1804. {
  1805. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetDIDError, error);
  1806. Log.WriteErrorLog(ErrMsg);
  1807. goto end;
  1808. }
  1809. }
  1810. if (WriteMac.Checked)
  1811. {
  1812. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "MAC", FunctionSettingNow.LocalMacSize, out FileStream Stream, out BinaryReader Reader, out string mac, out Macpath, out error, errorDBNow, ref localmidList, SN))
  1813. {
  1814. keyInfo.Mac.data = mac;
  1815. Log.WriteGetKeyLog("\r\nLocal Mac=" + keyInfo.Mac);
  1816. if (Stream != null && Reader != null)
  1817. {
  1818. keypath.Add(Macpath);
  1819. keyStream.Add(Stream);
  1820. keyReader.Add(Reader);
  1821. }
  1822. }
  1823. else
  1824. {
  1825. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetMacError, error);
  1826. Log.WriteErrorLog(ErrMsg);
  1827. goto end;
  1828. }
  1829. }
  1830. if (WriteHDCP.Checked)
  1831. {
  1832. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "HDCPKEY", FunctionSettingNow.LocalHdcpSize, out FileStream Stream, out BinaryReader Reader, out string hdcp, out Hdcppath, out error, errorDBNow, ref localmidList, SN))
  1833. {
  1834. keyInfo.HDCP.data = hdcp;
  1835. Log.WriteGetKeyLog("\r\nLocal HDCP=" + keyInfo.HDCP);
  1836. if (Stream != null && Reader != null)
  1837. {
  1838. keypath.Add(Hdcppath);
  1839. keyStream.Add(Stream);
  1840. keyReader.Add(Reader);
  1841. }
  1842. }
  1843. else
  1844. {
  1845. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetHDCPError, error);
  1846. Log.WriteErrorLog(ErrMsg);
  1847. goto end;
  1848. }
  1849. }
  1850. if (WriteHDCP22.Checked)
  1851. {
  1852. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "HDCPKEY22", FunctionSettingNow.LocalHdcp22Size, out FileStream Stream, out BinaryReader Reader, out string hdcp22, out Hdcp22path, out error, errorDBNow, ref localmidList, SN))
  1853. {
  1854. keyInfo.HDCP22.data = hdcp22;
  1855. Log.WriteGetKeyLog("\r\nLocal HDCP22=" + keyInfo.HDCP22);
  1856. if (Stream != null && Reader != null)
  1857. {
  1858. keypath.Add(Hdcp22path);
  1859. keyStream.Add(Stream);
  1860. keyReader.Add(Reader);
  1861. }
  1862. }
  1863. else
  1864. {
  1865. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetHDCP22Error, error);
  1866. Log.WriteErrorLog(ErrMsg);
  1867. goto end;
  1868. }
  1869. }
  1870. if (WriteESN.Checked)
  1871. {
  1872. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "ESN", FunctionSettingNow.LocalEsnSize, out FileStream Stream, out BinaryReader Reader, out string esn, out Esnpath, out error, errorDBNow, ref localmidList, SN))
  1873. {
  1874. keyInfo.ESN.data = esn;
  1875. Log.WriteGetKeyLog("\r\nLocal ESN=" + keyInfo.ESN);
  1876. if (Stream != null && Reader != null)
  1877. {
  1878. keypath.Add(Esnpath);
  1879. keyStream.Add(Stream);
  1880. keyReader.Add(Reader);
  1881. }
  1882. }
  1883. else
  1884. {
  1885. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetESNError, error);
  1886. Log.WriteErrorLog(ErrMsg);
  1887. goto end;
  1888. }
  1889. }
  1890. if (WriteMGK.Checked)
  1891. {
  1892. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "MGK", FunctionSettingNow.LocalMGKSize, out FileStream Stream, out BinaryReader Reader, out string mgk, out MGKpath, out error, errorDBNow, ref localmidList, SN))
  1893. {
  1894. keyInfo.MGK.data = mgk;
  1895. Log.WriteGetKeyLog("\r\nLocal MGK=" + keyInfo.MGK);
  1896. if (Stream != null && Reader != null)
  1897. {
  1898. keypath.Add(MGKpath);
  1899. keyStream.Add(Stream);
  1900. keyReader.Add(Reader);
  1901. }
  1902. }
  1903. else
  1904. {
  1905. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetMGKError, error);
  1906. Log.WriteErrorLog(ErrMsg);
  1907. goto end;
  1908. }
  1909. }
  1910. if (WriteFairplay.Checked)
  1911. {
  1912. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "Fairplay", FunctionSettingNow.LocalFairplaySize, out FileStream Stream, out BinaryReader Reader, out string fairplay, out Fairplaypath, out error, errorDBNow, ref localmidList, SN))
  1913. {
  1914. keyInfo.Fairplay.data = fairplay;
  1915. Log.WriteGetKeyLog("\r\nLocal Fairplay=" + keyInfo.Fairplay);
  1916. if (Stream != null && Reader != null)
  1917. {
  1918. keypath.Add(Fairplaypath);
  1919. keyStream.Add(Stream);
  1920. keyReader.Add(Reader);
  1921. }
  1922. }
  1923. else
  1924. {
  1925. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetFairplayError, error);
  1926. Log.WriteErrorLog(ErrMsg);
  1927. goto end;
  1928. }
  1929. }
  1930. if (WriteWidevine.Checked)
  1931. {
  1932. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "Widevine", FunctionSettingNow.LocalWidevineSize, out FileStream Stream, out BinaryReader Reader, out string widevine, out Widevinepath, out error, errorDBNow, ref localmidList, SN))
  1933. {
  1934. keyInfo.Widevine.data = widevine;
  1935. Log.WriteGetKeyLog("\r\nLocal Widevine=" + keyInfo.Widevine);
  1936. if (Stream != null && Reader != null)
  1937. {
  1938. keypath.Add(Widevinepath);
  1939. keyStream.Add(Stream);
  1940. keyReader.Add(Reader);
  1941. }
  1942. }
  1943. else
  1944. {
  1945. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetWidevineError, error);
  1946. Log.WriteErrorLog(ErrMsg);
  1947. goto end;
  1948. }
  1949. }
  1950. if (WriteCiplus.Checked)
  1951. {
  1952. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "CIKEY", FunctionSettingNow.LocalCiSize, out FileStream Stream, out BinaryReader Reader, out string ci, out Cipath, out error, errorDBNow, ref localmidList, SN))
  1953. {
  1954. keyInfo.CI_plus.data = ci;
  1955. Log.WriteGetKeyLog("\r\nLocal CI_plus=" + keyInfo.CI_plus);
  1956. if (Stream != null && Reader != null)
  1957. {
  1958. keypath.Add(Cipath);
  1959. keyStream.Add(Stream);
  1960. keyReader.Add(Reader);
  1961. }
  1962. }
  1963. else
  1964. {
  1965. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetCiError, error);
  1966. Log.WriteErrorLog(ErrMsg);
  1967. goto end;
  1968. }
  1969. }
  1970. if (WriteAttestation.Checked)
  1971. {
  1972. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "Attestation", FunctionSettingNow.LocalCiSize, out FileStream Stream, out BinaryReader Reader, out string attestation, out Attestationpath, out error, errorDBNow, ref localmidList, SN))
  1973. {
  1974. keyInfo.Attestation.data = attestation;
  1975. Log.WriteGetKeyLog("\r\nLocal attestation=" + keyInfo.Attestation);
  1976. if (Stream != null && Reader != null)
  1977. {
  1978. keypath.Add(Attestationpath);
  1979. keyStream.Add(Stream);
  1980. keyReader.Add(Reader);
  1981. }
  1982. }
  1983. else
  1984. {
  1985. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetAttestationError, error);
  1986. Log.WriteErrorLog(ErrMsg);
  1987. goto end;
  1988. }
  1989. }
  1990. if (fireTVKey.LEK)
  1991. {
  1992. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "LEK", -1, out FileStream Stream, out BinaryReader Reader, out string lek, out LEKpath, out error, errorDBNow, ref localmidList, SN))
  1993. {
  1994. keyInfo.LEK.data = lek;
  1995. Log.WriteGetKeyLog("\r\nLocal LEK=" + keyInfo.LEK);
  1996. if (Stream != null && Reader != null)
  1997. {
  1998. keypath.Add(LEKpath);
  1999. keyStream.Add(Stream);
  2000. keyReader.Add(Reader);
  2001. }
  2002. }
  2003. else
  2004. {
  2005. ErrMsg = String.Format("获取LEK失败 {0}", error);
  2006. Log.WriteErrorLog(ErrMsg);
  2007. goto end;
  2008. }
  2009. }
  2010. if (fireTVKey.PEK)
  2011. {
  2012. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "PEK", -1, out FileStream Stream, out BinaryReader Reader, out string pek, out PEKpath, out error, errorDBNow, ref localmidList, SN))
  2013. {
  2014. keyInfo.PEK.data = pek;
  2015. Log.WriteGetKeyLog("\r\nLocal LEK=" + keyInfo.PEK);
  2016. if (Stream != null && Reader != null)
  2017. {
  2018. keypath.Add(PEKpath);
  2019. keyStream.Add(Stream);
  2020. keyReader.Add(Reader);
  2021. }
  2022. }
  2023. else
  2024. {
  2025. ErrMsg = String.Format("获取PEK失败{0}", error);
  2026. Log.WriteErrorLog(ErrMsg);
  2027. goto end;
  2028. }
  2029. }
  2030. if (fireTVKey.Playready)
  2031. {
  2032. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "Playready", -1, out FileStream Stream, out BinaryReader Reader, out string playready, out Playreadypath, out error, errorDBNow, ref localmidList, SN))
  2033. {
  2034. keyInfo.Playready.data = playready;
  2035. Log.WriteGetKeyLog("\r\nLocal Playready=" + keyInfo.Playready);
  2036. if (Stream != null && Reader != null)
  2037. {
  2038. keypath.Add(Playreadypath);
  2039. keyStream.Add(Stream);
  2040. keyReader.Add(Reader);
  2041. }
  2042. }
  2043. else
  2044. {
  2045. ErrMsg = String.Format("获取Playready失败{0}", error);
  2046. Log.WriteErrorLog(ErrMsg);
  2047. goto end;
  2048. }
  2049. }
  2050. if (fireTVKey.Hashkey)
  2051. {
  2052. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "Hashkey", -1, out FileStream Stream, out BinaryReader Reader, out string hashkey, out Hashkeypath, out error, errorDBNow, ref localmidList, SN))
  2053. {
  2054. keyInfo.Hashkey.data = hashkey;
  2055. Log.WriteGetKeyLog("\r\nLocal Hashkey=" + keyInfo.Hashkey);
  2056. if (Stream != null && Reader != null)
  2057. {
  2058. keypath.Add(Fairplaypath);
  2059. keyStream.Add(Stream);
  2060. keyReader.Add(Reader);
  2061. }
  2062. }
  2063. else
  2064. {
  2065. ErrMsg = String.Format("获取hashkey失败 {0}", error);
  2066. Log.WriteErrorLog(ErrMsg);
  2067. goto end;
  2068. }
  2069. }
  2070. if (WriteACASKey.Checked)
  2071. {
  2072. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "ACAS_KEY", FunctionSettingNow.localACASKeySize, out FileStream Stream, out BinaryReader Reader, out string acaskey, out AcasKeypath, out error, errorDBNow, ref localmidList, SN))
  2073. {
  2074. keyInfo.ACASKey_Data.data = acaskey;
  2075. Log.WriteGetKeyLog("\r\nLocal ACASKey=" + keyInfo.ACASKey_Data);
  2076. if (Stream != null && Reader != null)
  2077. {
  2078. keypath.Add(AcasKeypath);
  2079. keyStream.Add(Stream);
  2080. keyReader.Add(Reader);
  2081. }
  2082. }
  2083. else
  2084. {
  2085. ErrMsg = String.Format("{0} {1}", LResource.GetACASKeyError, error);
  2086. Log.WriteErrorLog(ErrMsg);
  2087. goto end;
  2088. }
  2089. }
  2090. if (WriteEDIDPID.Checked)
  2091. {
  2092. keyInfo.EDIDPid.data = midListNow.keytype["edid_pid"];
  2093. }
  2094. if (WriteEDIDName.Checked)
  2095. {
  2096. keyInfo.EDIDModelName.data = midListNow.keytype["edid_model_name"];
  2097. }
  2098. if (localmidList.host != null)
  2099. {
  2100. if (ClientTypeText.Text.Length == 0)
  2101. {
  2102. SetTextStatus(ClientTypeText, localmidList.clienttype);
  2103. }
  2104. if (SVText.Text.Length == 0)
  2105. {
  2106. SetTextStatus(SVText, localmidList.version);
  2107. }
  2108. if (ProjectIDText.Text.Length == 0)
  2109. {
  2110. SetTextStatus(ProjectIDText, localmidList.projectid);
  2111. }
  2112. }
  2113. }
  2114. else if (!preloadNow)
  2115. {
  2116. // 计算获取全部key耗时;
  2117. Stopwatch watch = new Stopwatch();
  2118. watch.Start();
  2119. // 只用一个接口获取所有Key;
  2120. if (!WritePSN.Checked && midListNow.keytype.ContainsKey("DSN") )
  2121. {
  2122. #if !SIMULATION
  2123. // 读取dvicecode
  2124. if (SerialCMD.GetFireTVDevcieCode(TVPort, out result, out data, out error, SerailDelay))
  2125. {
  2126. keyInfo.DID.data = did;
  2127. Log.WriteGetKeyLog("\r\nDeviceID=" + keyInfo.DID);
  2128. }
  2129. else
  2130. {
  2131. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetDIDError, error);
  2132. Log.WriteErrorLog(ErrMsg);
  2133. goto end;
  2134. }
  2135. }
  2136. if (WriteMac.Checked && midListNow.keytype.ContainsKey("MAC"))
  2137. {
  2138. if (CommonMethod.GetKeys(midListNow.host, "MAC", SN, midListNow.keytype["MAC"], errorDBNow, out string mac, out error, orderNow, out string md5))
  2139. {
  2140. keyInfo.Mac.data = mac;
  2141. Log.WriteGetKeyLog("\r\nMac=" + keyInfo.Mac);
  2142. }
  2143. else
  2144. {
  2145. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetMacError, error);
  2146. Log.WriteErrorLog(ErrMsg);
  2147. goto end;
  2148. }
  2149. }
  2150. if (WriteHDCP.Checked && midListNow.keytype.ContainsKey("HDCP_KEY"))
  2151. {
  2152. if (CommonMethod.GetKeys(midListNow.host, "HDCP_KEY", SN, midListNow.keytype["HDCP_KEY"], errorDBNow, out string hdcp, out error, orderNow, out string md5))
  2153. {
  2154. keyInfo.HDCP.data = hdcp;
  2155. Log.WriteGetKeyLog("\r\nHDCP=" + keyInfo.HDCP);
  2156. }
  2157. else
  2158. {
  2159. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetHDCPError, error);
  2160. Log.WriteErrorLog(ErrMsg);
  2161. goto end;
  2162. }
  2163. }
  2164. if (WriteHDCP22.Checked && midListNow.keytype.ContainsKey("HDCP2.2_KEY"))
  2165. {
  2166. if (CommonMethod.GetKeys(midListNow.host, "HDCP2.2_KEY", SN, midListNow.keytype["HDCP2.2_KEY"], errorDBNow, out string hdcp22, out error, orderNow, out string md5))
  2167. {
  2168. keyInfo.HDCP22.data = hdcp22;
  2169. Log.WriteGetKeyLog("\r\nHDCP22=" + keyInfo.HDCP22);
  2170. }
  2171. else
  2172. {
  2173. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetHDCP22Error, error);
  2174. Log.WriteErrorLog(ErrMsg);
  2175. goto end;
  2176. }
  2177. }
  2178. if (WriteESN.Checked && midListNow.keytype.ContainsKey("NETFILX_ESN"))
  2179. {
  2180. if (CommonMethod.GetKeys(midListNow.host, "NETFILX_ESN", SN, midListNow.keytype["NETFILX_ESN"], errorDBNow, out string esn, out error, orderNow, out string md5))
  2181. {
  2182. keyInfo.ESN.data = esn;
  2183. Log.WriteGetKeyLog("\r\nESN=" + keyInfo.ESN);
  2184. }
  2185. else
  2186. {
  2187. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetESNError, error);
  2188. Log.WriteErrorLog(ErrMsg);
  2189. goto end;
  2190. }
  2191. }
  2192. if (WriteWiDi.Checked && midListNow.keytype.ContainsKey("WiDi"))
  2193. {
  2194. if (CommonMethod.GetKeys(midListNow.host, "WiDi", SN, midListNow.keytype["WiDi"], errorDBNow, out string widi, out error, orderNow, out string md5))
  2195. {
  2196. keyInfo.WiDi.data = widi;
  2197. Log.WriteGetKeyLog("\r\nWiDi=" + keyInfo.WiDi);
  2198. }
  2199. else
  2200. {
  2201. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetWiDiError, error);
  2202. Log.WriteErrorLog(ErrMsg);
  2203. goto end;
  2204. }
  2205. }
  2206. if (WriteCiplus.Checked && midListNow.keytype.ContainsKey("CI_PLUS_KEY"))
  2207. {
  2208. if (CommonMethod.GetKeys(midListNow.host, "CI_PLUS_KEY", SN, midListNow.keytype["CI_PLUS_KEY"], errorDBNow, out string ci, out error, orderNow, out string md5))
  2209. {
  2210. keyInfo.CI_plus.data = ci;
  2211. Log.WriteGetKeyLog("\r\nCI_plus=" + keyInfo.CI_plus);
  2212. }
  2213. else
  2214. {
  2215. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetCiError, error);
  2216. Log.WriteErrorLog(ErrMsg);
  2217. goto end;
  2218. }
  2219. }
  2220. if (WriteWidevine.Checked && midListNow.keytype.ContainsKey("Widevine_KEY"))
  2221. {
  2222. if (CommonMethod.GetWidevineAnAttestationKey(
  2223. midListNow.host,
  2224. SN,
  2225. midListNow.keytype["Widevine_KEY"],
  2226. errorDBNow,
  2227. out bool isAndroidTV,
  2228. out string widevine,
  2229. out string attestation,
  2230. out error,
  2231. orderNow,
  2232. out string md5))
  2233. {
  2234. keyInfo.Widevine.data = widevine;
  2235. Log.WriteGetKeyLog("\r\nWidevine=" + keyInfo.Widevine);
  2236. if (isAndroidTV)
  2237. {
  2238. keyInfo.Attestation.data = attestation;
  2239. keyInfo.AttestationMD5.data = md5;
  2240. Log.WriteGetKeyLog("\r\nAttestationMD5=" + keyInfo.AttestationMD5);
  2241. }
  2242. }
  2243. else
  2244. {
  2245. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetWidevineError, error);
  2246. Log.WriteErrorLog(ErrMsg);
  2247. goto end;
  2248. }
  2249. #else
  2250. devicecode = "2C5";
  2251. psn = keyInfo._PSN.data = "FZ7BBCP2A11XXNXM00008";
  2252. #endif
  2253. }
  2254. if (!CommonMethod.IsEDIDCopy(midListNow))
  2255. {
  2256. // 部分订单无key,只有Roku信息;
  2257. if (midListNow.keytype.Count() != 0 )
  2258. {
  2259. if (!V2Method.GetMidKey(midListNow.host, SN, orderNow, psn, devicecode, key2Write, errorDBNow, ref keyInfo, out error))
  2260. {
  2261. ErrMsg = string.Format("{0} GetIDMKeys Failed!\r\n{1}", SN, error);
  2262. Log.WriteErrorLog(ErrMsg);
  2263. goto end;
  2264. }
  2265. #if OD_VER
  2266. if (keyInfo != null)
  2267. {
  2268. // 单个key保存;
  2269. Action<KeyData, string, string> SaveKey = (keydata, order, sn) =>
  2270. {
  2271. if ( keydata.Length > 0 )
  2272. {
  2273. if (keydata.name.Equals("mac") || keydata.name.Equals("wifiMac") || keydata.name.Equals("btMac"))
  2274. { // mac地址需要去除多余的符号;
  2275. keydata.data = keydata.data.Replace("-", "");
  2276. if (FunctionSettingNow.MITVEnable == true)
  2277. keydata.data = keydata.data.Replace(":", "");
  2278. }
  2279. byte[] data = null;
  2280. if (keydata.name.Equals("deviceid") || keydata.name.Equals("dsn"))
  2281. { // 字符串原样保存;
  2282. data = Encoding.ASCII.GetBytes(keydata.data);
  2283. }
  2284. else
  2285. {
  2286. data = SerialInit.HexToByte(keydata.data);
  2287. }
  2288. // 保存文件;
  2289. string SaveDir = string.Format("{0}{1}\\{2}\\", AppDomain.CurrentDomain.BaseDirectory, order, sn);
  2290. if (!Directory.Exists(SaveDir))
  2291. {
  2292. Directory.CreateDirectory(SaveDir);
  2293. }
  2294. for(int i = 0; i < 10000; i++ ) {
  2295. string file = string.Format("{0}{1}_{2}.bin", SaveDir, keydata.name, i);
  2296. if ( !File.Exists(file) ) {
  2297. var fs = new FileStream(file, FileMode.Create);
  2298. fs.Write(data, 0, data.Length);
  2299. fs.Close();
  2300. break;
  2301. }
  2302. }
  2303. }
  2304. };
  2305. SaveKey(keyInfo.ACASKey_Data, OrderText.Text, SN);
  2306. SaveKey(keyInfo.Attestation, OrderText.Text, SN);
  2307. SaveKey(keyInfo.BT_MAC, OrderText.Text, SN);
  2308. SaveKey(keyInfo.CI_plus, OrderText.Text, SN);
  2309. SaveKey(keyInfo.DAK, OrderText.Text, SN);
  2310. SaveKey(keyInfo.DID, OrderText.Text, SN);
  2311. SaveKey(keyInfo.DSN, OrderText.Text, SN);
  2312. SaveKey(keyInfo.ECP, OrderText.Text, SN);
  2313. SaveKey(keyInfo.ESN, OrderText.Text, SN);
  2314. SaveKey(keyInfo.Fairplay, OrderText.Text, SN);
  2315. SaveKey(keyInfo.Hashkey, OrderText.Text, SN);
  2316. SaveKey(keyInfo.HDCP, OrderText.Text, SN);
  2317. SaveKey(keyInfo.HDCP22, OrderText.Text, SN);
  2318. SaveKey(keyInfo.KFP, OrderText.Text, SN);
  2319. SaveKey(keyInfo.LEK, OrderText.Text, SN);
  2320. SaveKey(keyInfo.Mac, OrderText.Text, SN);
  2321. SaveKey(keyInfo.MGK, OrderText.Text, SN);
  2322. SaveKey(keyInfo.PEK, OrderText.Text, SN);
  2323. SaveKey(keyInfo.Playready, OrderText.Text, SN);
  2324. SaveKey(keyInfo.Widevine, OrderText.Text, SN);
  2325. SaveKey(keyInfo.WiFi_MAC, OrderText.Text, SN);
  2326. SaveKey(keyInfo.YouTube_KEY, OrderText.Text, SN);
  2327. MessageBox.Show("下载完成");
  2328. goto stop;
  2329. }
  2330. #endif
  2331. }
  2332. else
  2333. {
  2334. Log.WriteInfoLog("mid type is null, don't query idm keys");
  2335. }
  2336. }
  2337. if (midListNow.keytype.ContainsKey("DSN"))
  2338. {
  2339. // 预防切了pid后,deviceCode变化了;
  2340. if ( keyInfo.DSN.data != null && keyInfo.DSN.data.IndexOf(devicecode) == -1)
  2341. {
  2342. keyInfo.Fairplay.data = fairplay;
  2343. Log.WriteGetKeyLog("\r\nFairplay=" + keyInfo.Fairplay);
  2344. }
  2345. else
  2346. {
  2347. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetFairplayError, error);
  2348. Log.WriteErrorLog(ErrMsg);
  2349. goto end;
  2350. }
  2351. }
  2352. #region EDID屏抄写是从MID中获取值;
  2353. if (WriteEDIDPID.Checked)
  2354. {
  2355. keyInfo.EDIDPid.data = midListNow.keytype["edid_pid"];
  2356. }
  2357. if (WriteEDIDName.Checked && midListNow.keytype.ContainsKey("edid_model_name"))
  2358. {
  2359. keyInfo.EDIDModelName.data = midListNow.keytype["edid_model_name"];
  2360. }
  2361. #endregion
  2362. watch.Stop();
  2363. Log.WriteInfoLog(string.Format("Get All Keys Elapsed={0}", watch.Elapsed.TotalMilliseconds));
  2364. }
  2365. #region 小米FireTV功能启用;
  2366. if (FunctionSettingNow.MITVEnable || FunctionSettingNow.IndiaMITVEnable)
  2367. {
  2368. // 获取Key;
  2369. if (!CommonMethod.GetMIKey(FunctionSettingNow.MIKeyUrl, SN, out _MiKey, out error))
  2370. {
  2371. ErrMsg = string.Format("GetMIKey error!\r\n{0}", error);
  2372. Log.WriteErrorLog(ErrMsg);
  2373. goto end;
  2374. }
  2375. // 配置要抄写的选项;
  2376. if (_MiKey.EthernetMac != null)
  2377. {
  2378. SetCheckboxStatus(WriteMac, true);
  2379. keyInfo.Mac.data = _MiKey.EthernetMac;
  2380. keyInfo.Mac.enable = true;
  2381. }
  2382. else if ( !midListNow.keytype.ContainsKey("MAC") )
  2383. {
  2384. SetCheckboxStatus(WriteMac, false);
  2385. }
  2386. if (_MiKey.BTMac != null)
  2387. {
  2388. SetCheckboxStatus(WriteBTMac, true);
  2389. keyInfo.BT_MAC.data = _MiKey.BTMac;
  2390. keyInfo.BT_MAC.enable = true;
  2391. }
  2392. else if (!midListNow.keytype.ContainsKey("BT_MAC"))
  2393. {
  2394. SetCheckboxStatus(WriteBTMac, false);
  2395. }
  2396. if (_MiKey.DSN != null)
  2397. {
  2398. SetCheckboxStatus(WriteDSN, true);
  2399. keyInfo.DSN.data = _MiKey.DSN;
  2400. keyInfo.DSN.enable = true;
  2401. // 预防切了pid后,deviceCode变化了;
  2402. if (keyInfo.DSN.data != null && keyInfo.DSN.data.IndexOf(devicecode) == -1)
  2403. {
  2404. ErrMsg = string.Format("The device code [{0}] is not included in the DSN [{1}]!\r\n", devicecode, keyInfo.DSN.data);
  2405. Log.WriteErrorLog(ErrMsg);
  2406. goto end;
  2407. }
  2408. }
  2409. else if (!midListNow.keytype.ContainsKey("DSN"))
  2410. {
  2411. SetCheckboxStatus(WriteDSN, false);
  2412. }
  2413. if (_MiKey.WIFIMAC != null)
  2414. {
  2415. SetCheckboxStatus(WriteWifiMac, true);
  2416. keyInfo.WiFi_MAC.data = _MiKey.WIFIMAC;
  2417. keyInfo.WiFi_MAC.enable = true;
  2418. }
  2419. else if (!midListNow.keytype.ContainsKey("WiFi_MAC"))
  2420. {
  2421. SetCheckboxStatus(WriteWifiMac, false);
  2422. }
  2423. }
  2424. #endregion
  2425. #if !SIMULATION
  2426. #region 开始抄写;
  2427. // 如果是抄写EDID,则不获取白平衡数据;
  2428. if (CommonMethod.IsEDIDCopy(midListNow))
  2429. {
  2430. SetspecificText(SoftwareVersionNote, LResource.SkipChecking, Color.Yellow);
  2431. SetspecificText(ClientTypeNote, LResource.SkipChecking, Color.Yellow);
  2432. if (midListNow.projectid.Equals("0"))
  2433. SetspecificText(ProjectIDNote, LResource.SkipCovering, Color.Yellow);
  2434. }
  2435. //检查Software version
  2436. if (SoftwareVersionNote.Text != LResource.SkipChecking)
  2437. {
  2438. Log.WriteInfoLog("Check software version...\r\n");
  2439. if (SerialCMD.GetSoftVersion(TVPort, out result, out data, out error, SerailDelay))
  2440. {
  2441. string sfv = Encoding.ASCII.GetString(data);
  2442. if (sfv != SVText.Text)
  2443. {
  2444. MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
  2445. DialogResult dr = MessageBox.Show(LResource.MainboardFV + sfv + LResource.differentfromserver + SVText.Text + "\r\n" + LResource.SkipFVChecking, LResource.Error, messButton);
  2446. if (dr == DialogResult.OK)
  2447. {
  2448. SetspecificText(SoftwareVersionNote, LResource.SkipChecking, Color.Yellow);
  2449. SetcolorStatus(SVText, Color.Yellow);
  2450. }
  2451. else
  2452. {
  2453. SetspecificText(SoftwareVersionNote, sfv, Color.Red);
  2454. SetcolorStatus(SVText, Color.Red);
  2455. goto end;
  2456. }
  2457. }
  2458. else
  2459. {
  2460. SetcolorStatus(SVText, Color.FromArgb(128, 255, 128));
  2461. }
  2462. }
  2463. else
  2464. {
  2465. ErrMsg = string.Format("{0} Read software version fail!", SN);
  2466. Log.WriteErrorLog(ErrMsg);
  2467. goto end;
  2468. }
  2469. }
  2470. //DID抄写
  2471. if (WriteDID.Checked)
  2472. {
  2473. if (!CommonMethod.IsNumberAndWord(keyInfo.DID.data))
  2474. {
  2475. ErrMsg = string.Format("DID format error!\r\n{0}", keyInfo.DID.data);
  2476. Log.WriteErrorLog(ErrMsg);
  2477. goto end;
  2478. }
  2479. byte[] DIDData = Encoding.ASCII.GetBytes(keyInfo.DID.data);
  2480. Log.WriteInfoLog("Write DID...");
  2481. if (SerialCMD.SetDeviceID(TVPort, DIDData, out result, out data, out error, SerailDelay))
  2482. {
  2483. SetsuccessStatus(m_writedid);
  2484. Log.WriteInfoLog("Check DID...");
  2485. if (cfg_writecheck.DIDCheckcheck ? SerialCMD.CheckDeviceId(TVPort, out result, out data, out error, SerailDelay) : true)
  2486. {
  2487. SetsuccessStatus(m_checkdid);
  2488. Log.WriteInfoLog("Read DID...");
  2489. if (cfg_readcheck.DIDReadcheck ? SerialCMD.GetDeviceId(TVPort, out result, out data, out error, SerailDelay) : true)
  2490. {
  2491. if (cfg_readcheck.DIDReadcheck)
  2492. {
  2493. if (SerialInit.BytesCompare_Base64(data, DIDData))
  2494. {
  2495. SetsuccessStatus(m_readdid);
  2496. }
  2497. else
  2498. {
  2499. SetfailStatus(m_readdid);
  2500. ErrMsg = string.Format("{0} contrast DID fail!", SN);
  2501. Log.WriteErrorLog(ErrMsg);
  2502. goto end; ;
  2503. }
  2504. }
  2505. }
  2506. else
  2507. {
  2508. SetfailStatus(m_readdid);
  2509. ErrMsg = string.Format("{0} read DID fail!", SN);
  2510. Log.WriteErrorLog(ErrMsg);
  2511. goto end;
  2512. }
  2513. }
  2514. else
  2515. {
  2516. SetfailStatus(m_checkdid);
  2517. ErrMsg = string.Format("{0} check DID fail!", SN);
  2518. Log.WriteErrorLog(ErrMsg);
  2519. goto end;
  2520. }
  2521. }
  2522. else
  2523. {
  2524. SetfailStatus(m_writedid);
  2525. ErrMsg = string.Format("{0} Write DID fail!", SN);
  2526. Log.WriteErrorLog(ErrMsg);
  2527. goto end;
  2528. }
  2529. keyInfo.DID.result = true;
  2530. }
  2531. //Eth_Mac抄写
  2532. if (WriteMac.Checked)
  2533. {
  2534. string mac = keyInfo.Mac.data.Replace("-", "");
  2535. if (FunctionSettingNow.MITVEnable || FunctionSettingNow.IndiaMITVEnable)
  2536. mac = keyInfo.Mac.data.Replace(":", "");
  2537. if (!CommonMethod.IsNumberAndWord(mac))
  2538. {
  2539. ErrMsg = string.Format("Mac format error!\r\n{0}", mac);
  2540. Log.WriteErrorLog(ErrMsg);
  2541. goto end;
  2542. }
  2543. byte[] MacData = SerialInit.HexToByte(mac);
  2544. Log.WriteInfoLog("Write Mac...");
  2545. if (SerialCMD.SetMAC(TVPort, MacData, out result, out data, out error, SerailDelay))
  2546. {
  2547. SetsuccessStatus(m_writemac);
  2548. Log.WriteInfoLog("Check Mac...");
  2549. if (cfg_writecheck.MacCheckcheck ? SerialCMD.CheckMAC(TVPort, out result, out data, out error, SerailDelay) : true)
  2550. {
  2551. SetsuccessStatus(m_checkmac);
  2552. Log.WriteInfoLog("Read Mac...");
  2553. if (cfg_readcheck.MacReadcheck ? SerialCMD.GetMAC(TVPort, out result, out data, out error, SerailDelay) : true)
  2554. {
  2555. if (cfg_readcheck.MacReadcheck)
  2556. {
  2557. if (SerialInit.BytesCompare_Base64(data, MacData))
  2558. {
  2559. SetsuccessStatus(m_readmac);
  2560. }
  2561. else
  2562. {
  2563. SetfailStatus(m_readmac);
  2564. ErrMsg = string.Format("{0} contrast Mac fail!", SN);
  2565. Log.WriteErrorLog(ErrMsg);
  2566. goto end;
  2567. }
  2568. }
  2569. }
  2570. else
  2571. {
  2572. SetfailStatus(m_readmac);
  2573. ErrMsg = string.Format("{0} read Mac fail!", SN);
  2574. Log.WriteErrorLog(ErrMsg);
  2575. goto end;
  2576. }
  2577. }
  2578. else
  2579. {
  2580. SetfailStatus(m_checkmac);
  2581. ErrMsg = string.Format("{0} check Mac fail!", SN);
  2582. Log.WriteErrorLog(ErrMsg);
  2583. goto end;
  2584. }
  2585. }
  2586. else
  2587. {
  2588. SetfailStatus(m_writemac);
  2589. ErrMsg = string.Format("{0} Write Mac fail!", SN);
  2590. Log.WriteErrorLog(ErrMsg);
  2591. goto end;
  2592. }
  2593. keyInfo.Mac.result = true;
  2594. }
  2595. //WiFi_MAC抄写
  2596. if (WriteWifiMac.Checked)
  2597. {
  2598. string wifimac = keyInfo.WiFi_MAC.data.Replace("-", "");
  2599. if (FunctionSettingNow.MITVEnable || FunctionSettingNow.IndiaMITVEnable)
  2600. wifimac = wifimac.Replace(":", "");
  2601. if (!CommonMethod.IsNumberAndWord(wifimac))
  2602. {
  2603. ErrMsg = string.Format("Wifi Mac format error!\r\n{0}", wifimac);
  2604. Log.WriteErrorLog(ErrMsg);
  2605. goto end;
  2606. }
  2607. byte[] WifiMacData = Encoding.ASCII.GetBytes(wifimac);
  2608. Log.WriteInfoLog("Write WifiMac...");
  2609. if (SerialCMD.SetFireTVWifiMac(TVPort, WifiMacData, out result, out data, out error, SerailDelay))
  2610. {
  2611. SetsuccessStatus(m_writeWifiMac);
  2612. Log.WriteInfoLog("Check WifiMac...");
  2613. if (cfg_writecheck.WifiMacCheckcheck ? SerialCMD.CheckFireTVWifiMac(TVPort, out result, out data, out error, SerailDelay) : true)
  2614. {
  2615. SetsuccessStatus(m_checkWifiMac);
  2616. Log.WriteInfoLog("Read WifiMac...");
  2617. if (cfg_readcheck.WifiMacReadcheck ? SerialCMD.GetFireTVWiFi_Mac(TVPort, out result, out data, out error, SerailDelay) : true)
  2618. {
  2619. if (cfg_readcheck.WifiMacReadcheck)
  2620. {
  2621. if (SerialInit.BytesCompare_Base64(data, WifiMacData))
  2622. {
  2623. SetsuccessStatus(m_readWifiMac);
  2624. }
  2625. else
  2626. {
  2627. SetfailStatus(m_readWifiMac);
  2628. ErrMsg = string.Format("{0} contrast Wifi Mac fail!", SN);
  2629. Log.WriteErrorLog(ErrMsg);
  2630. goto end;
  2631. }
  2632. }
  2633. }
  2634. else
  2635. {
  2636. SetfailStatus(m_readWifiMac);
  2637. ErrMsg = string.Format("{0} read Wifi Mac fail!", SN);
  2638. Log.WriteErrorLog(ErrMsg);
  2639. goto end;
  2640. }
  2641. }
  2642. else
  2643. {
  2644. SetfailStatus(m_checkWifiMac);
  2645. ErrMsg = string.Format("{0} check Wifi Mac fail!", SN);
  2646. Log.WriteErrorLog(ErrMsg);
  2647. goto end;
  2648. }
  2649. }
  2650. else
  2651. {
  2652. SetfailStatus(m_writeWifiMac);
  2653. ErrMsg = string.Format("{0} Write Wifi Mac fail!", SN);
  2654. Log.WriteErrorLog(ErrMsg);
  2655. goto end;
  2656. }
  2657. keyInfo.WiFi_MAC.result = true;
  2658. }
  2659. //BT_MAC抄写
  2660. if (WriteBTMac.Checked)
  2661. {
  2662. string btmac = keyInfo.BT_MAC.data.Replace("-", "");
  2663. if (FunctionSettingNow.MITVEnable || FunctionSettingNow.IndiaMITVEnable)
  2664. btmac = btmac.Replace(":", "");
  2665. if (!CommonMethod.IsNumberAndWord(btmac))
  2666. {
  2667. ErrMsg = string.Format("BTMac format error!\r\n{0}", btmac);
  2668. Log.WriteErrorLog(ErrMsg);
  2669. goto end;
  2670. }
  2671. byte[] BTMacData = Encoding.ASCII.GetBytes(btmac);
  2672. Log.WriteInfoLog("Write BTMac...");
  2673. if (SerialCMD.SetFireTVBTMac(TVPort, BTMacData, out result, out data, out error, SerailDelay))
  2674. {
  2675. SetsuccessStatus(m_writeBTMac);
  2676. Log.WriteInfoLog("Check BTMac...");
  2677. if (cfg_writecheck.BTMacCheckcheck ? SerialCMD.CheckFireTVBTMac(TVPort, out result, out data, out error, SerailDelay) : true)
  2678. {
  2679. SetsuccessStatus(m_checkBTMac);
  2680. Log.WriteInfoLog("Read BTMac...");
  2681. if (cfg_readcheck.BTMacReadcheck ? SerialCMD.GetFireTVBT_Mac(TVPort, out result, out data, out error, SerailDelay) : true)
  2682. {
  2683. if (cfg_readcheck.BTMacReadcheck)
  2684. {
  2685. if (SerialInit.BytesCompare_Base64(data, BTMacData))
  2686. {
  2687. SetsuccessStatus(m_readBTMac);
  2688. }
  2689. else
  2690. {
  2691. SetfailStatus(m_readBTMac);
  2692. ErrMsg = string.Format("{0} contrast BT Mac fail!", SN);
  2693. Log.WriteErrorLog(ErrMsg);
  2694. goto end;
  2695. }
  2696. }
  2697. }
  2698. else
  2699. {
  2700. SetfailStatus(m_readBTMac);
  2701. ErrMsg = string.Format("{0} read BT Mac fail!", SN);
  2702. Log.WriteErrorLog(ErrMsg);
  2703. goto end;
  2704. }
  2705. }
  2706. else
  2707. {
  2708. SetfailStatus(m_checkBTMac);
  2709. ErrMsg = string.Format("{0} check BT Mac fail!", SN);
  2710. Log.WriteErrorLog(ErrMsg);
  2711. goto end;
  2712. }
  2713. }
  2714. else
  2715. {
  2716. SetfailStatus(m_writeBTMac);
  2717. ErrMsg = string.Format("{0} Write BT Mac fail!", SN);
  2718. Log.WriteErrorLog(ErrMsg);
  2719. goto end;
  2720. }
  2721. keyInfo.BT_MAC.result = true;
  2722. }
  2723. //PEK抄写
  2724. if (WritePEK.Checked)
  2725. {
  2726. if (!CommonMethod.IsNumberAndWord(keyInfo.PEK.data))
  2727. {
  2728. ErrMsg = string.Format("PEK format error!\r\n{0}", keyInfo.PEK.data);
  2729. Log.WriteErrorLog(ErrMsg);
  2730. goto end;
  2731. }
  2732. byte[] PEKData = SerialInit.HexToByte(keyInfo.PEK.data);
  2733. Log.WriteInfoLog("Write PEK...");
  2734. if (SerialCMD.SetFireTVPEK(TVPort, PEKData, out result, out data, out error, SerailDelay))
  2735. {
  2736. SetsuccessStatus(m_writePEK);
  2737. Log.WriteInfoLog("Check PEK...");
  2738. if (cfg_writecheck.PEKCheckcheck ? SerialCMD.CheckFireTVPEK(TVPort, out result, out data, out error, SerailDelay) : true)
  2739. {
  2740. SetsuccessStatus(m_checkPEK);
  2741. Log.WriteInfoLog("Read PEK...");
  2742. if (cfg_readcheck.PEKReadcheck ? SerialCMD.ReadFireTVPEK(TVPort, out result, out data, out error, SerailDelay) : true)
  2743. {
  2744. if (cfg_readcheck.PEKReadcheck)
  2745. {
  2746. if (SerialInit.BytesCompare_Base64(data, PEKData))
  2747. {
  2748. SetsuccessStatus(m_readPEK);
  2749. }
  2750. else
  2751. {
  2752. SetfailStatus(m_readPEK);
  2753. ErrMsg = string.Format("{0} contrast PEK fail!", SN);
  2754. Log.WriteErrorLog(ErrMsg);
  2755. goto end;
  2756. }
  2757. }
  2758. }
  2759. else
  2760. {
  2761. SetfailStatus(m_readPEK);
  2762. ErrMsg = string.Format("{0} read PEK fail!", SN);
  2763. Log.WriteErrorLog(ErrMsg);
  2764. goto end;
  2765. }
  2766. }
  2767. else
  2768. {
  2769. SetfailStatus(m_checkPEK);
  2770. ErrMsg = string.Format("{0} check PEK fail!", SN);
  2771. Log.WriteErrorLog(ErrMsg);
  2772. goto end;
  2773. }
  2774. }
  2775. else
  2776. {
  2777. SetfailStatus(m_writePEK);
  2778. ErrMsg = string.Format("{0} Write PEK fail!", SN);
  2779. Log.WriteErrorLog(ErrMsg);
  2780. goto end;
  2781. }
  2782. keyInfo.PEK.result = true;
  2783. }
  2784. // DAK 抄写;
  2785. if (WriteDAK.Checked)
  2786. {
  2787. if (!CommonMethod.IsNumberAndWord(keyInfo.DAK.data))
  2788. {
  2789. ErrMsg = string.Format("DAK format error!\r\n{0}", keyInfo.DAK.data);
  2790. Log.WriteErrorLog(ErrMsg);
  2791. goto end;
  2792. }
  2793. byte[] DAKData = SerialInit.HexToByte(keyInfo.DAK.data);
  2794. Log.WriteInfoLog("Write DAK...");
  2795. if (SerialCMD.SetFireTVDAK(TVPort, DAKData, out result, out data, out error, SerailDelay))
  2796. {
  2797. SetsuccessStatus(m_writeDAK);
  2798. Log.WriteInfoLog("Check DAK...");
  2799. if (cfg_writecheck.DAKCheckcheck ? SerialCMD.CheckFireTVDAK(TVPort, out result, out data, out error, SerailDelay) : true)
  2800. {
  2801. SetsuccessStatus(m_checkDAK);
  2802. }
  2803. else
  2804. {
  2805. SetfailStatus(m_checkDAK);
  2806. ErrMsg = string.Format("{0} check DAK fail!", SN);
  2807. Log.WriteErrorLog(ErrMsg);
  2808. goto end;
  2809. }
  2810. }
  2811. else
  2812. {
  2813. SetfailStatus(m_writeDAK);
  2814. ErrMsg = string.Format("{0} Write DAK fail!", SN);
  2815. Log.WriteErrorLog(ErrMsg);
  2816. goto end;
  2817. }
  2818. keyInfo.DAK.result = true;
  2819. }
  2820. //LEK抄写
  2821. if (WriteLEK.Checked)
  2822. {
  2823. if (!CommonMethod.IsNumberAndWord(keyInfo.LEK.data))
  2824. {
  2825. ErrMsg = string.Format("LEK format error!\r\n{0}", keyInfo.LEK.data);
  2826. Log.WriteErrorLog(ErrMsg);
  2827. goto end;
  2828. }
  2829. byte[] LEKData = SerialInit.HexToByte(keyInfo.LEK.data);
  2830. Log.WriteInfoLog("Write LEK...");
  2831. if (SerialCMD.SetFireTVLEK(TVPort, LEKData, out result, out data, out error, SerailDelay))
  2832. {
  2833. SetsuccessStatus(m_writeLEK);
  2834. Log.WriteInfoLog("Check LEK...");
  2835. if (cfg_writecheck.LEKCheckcheck ? SerialCMD.CheckFireTVLEK(TVPort, out result, out data, out error, SerailDelay) : true)
  2836. {
  2837. SetsuccessStatus(m_checkLEK);
  2838. Log.WriteInfoLog("Read LEK...");
  2839. if (cfg_readcheck.LEKReadcheck ? SerialCMD.ReadFireTVLEK(TVPort, out result, out data, out error, SerailDelay) : true)
  2840. {
  2841. if (cfg_readcheck.LEKReadcheck)
  2842. {
  2843. if (SerialInit.BytesCompare_Base64(data, LEKData))
  2844. {
  2845. SetsuccessStatus(m_readLEK);
  2846. }
  2847. else
  2848. {
  2849. SetfailStatus(m_readLEK);
  2850. ErrMsg = string.Format("{0} contrast LEK fail!", SN);
  2851. Log.WriteErrorLog(ErrMsg);
  2852. goto end;
  2853. }
  2854. }
  2855. }
  2856. else
  2857. {
  2858. SetfailStatus(m_readLEK);
  2859. ErrMsg = string.Format("{0} read LEK fail!", SN);
  2860. Log.WriteErrorLog(ErrMsg);
  2861. goto end;
  2862. }
  2863. }
  2864. else
  2865. {
  2866. SetfailStatus(m_checkLEK);
  2867. ErrMsg = string.Format("{0} check LEK fail!", SN);
  2868. Log.WriteErrorLog(ErrMsg);
  2869. goto end;
  2870. }
  2871. }
  2872. else
  2873. {
  2874. SetfailStatus(m_writeLEK);
  2875. ErrMsg = string.Format("{0} Write LEK fail!", SN);
  2876. Log.WriteErrorLog(ErrMsg);
  2877. goto end;
  2878. }
  2879. keyInfo.LEK.result = true;
  2880. }
  2881. //HDCP KEY抄写
  2882. if (WriteHDCP.Checked)
  2883. {
  2884. if (!CommonMethod.IsNumberAndWord(keyInfo.HDCP.data))
  2885. {
  2886. ErrMsg = string.Format("HDCP format error!\r\n{0}", keyInfo.HDCP.data);
  2887. Log.WriteErrorLog(ErrMsg);
  2888. goto end;
  2889. }
  2890. byte[] HDCPData = SerialInit.HexToByte(keyInfo.HDCP.data);
  2891. Log.WriteInfoLog("Write HDCP...");
  2892. if (SerialCMD.SetHDCPKey(TVPort, HDCPData, out result, out data, out error, SerailDelay))
  2893. {
  2894. SetsuccessStatus(m_writehdcp);
  2895. Log.WriteInfoLog("Check HDCP...");
  2896. if (cfg_writecheck.HDCPCheckcheck ? SerialCMD.CheckHDCP(TVPort, out result, out data, out error, SerailDelay) : true)
  2897. {
  2898. SetsuccessStatus(m_checkhdcp);
  2899. Log.WriteInfoLog("Read HDCP...");
  2900. if (cfg_readcheck.HDCPReadcheck ? SerialCMD.GetHDCPKey(TVPort, out result, out data, out error, SerailDelay) : true)
  2901. {
  2902. if (cfg_readcheck.HDCPReadcheck)
  2903. {
  2904. if (SerialInit.BytesCompare_Base64(data, HDCPData))
  2905. {
  2906. SetsuccessStatus(m_readhdcp);
  2907. }
  2908. else
  2909. {
  2910. SetfailStatus(m_readhdcp);
  2911. ErrMsg = string.Format("{0} contrast HDCP fail!", SN);
  2912. Log.WriteErrorLog(ErrMsg);
  2913. goto end;
  2914. }
  2915. }
  2916. }
  2917. else
  2918. {
  2919. SetfailStatus(m_readhdcp);
  2920. ErrMsg = string.Format("{0} read HDCP fail!", SN);
  2921. Log.WriteErrorLog(ErrMsg);
  2922. goto end;
  2923. }
  2924. }
  2925. else
  2926. {
  2927. SetfailStatus(m_checkhdcp);
  2928. ErrMsg = string.Format("{0} check HDCP fail!", SN);
  2929. Log.WriteErrorLog(ErrMsg);
  2930. goto end;
  2931. }
  2932. }
  2933. else
  2934. {
  2935. SetfailStatus(m_writehdcp);
  2936. ErrMsg = string.Format("{0} Write HDCP fail!", SN);
  2937. Log.WriteErrorLog(ErrMsg);
  2938. goto end;
  2939. }
  2940. keyInfo.HDCP.result = true;
  2941. }
  2942. //HDCP22 KEY抄写
  2943. if (WriteHDCP22.Checked)
  2944. {
  2945. if (!CommonMethod.IsNumberAndWord(keyInfo.HDCP22.data))
  2946. {
  2947. ErrMsg = string.Format("HDCP22 format error!\r\n{0}", keyInfo.HDCP22.data);
  2948. Log.WriteErrorLog(ErrMsg);
  2949. goto end;
  2950. }
  2951. byte[] HDCP22Data = SerialInit.HexToByte(keyInfo.HDCP22.data);
  2952. Log.WriteInfoLog("Write HDCP22...");
  2953. if (SerialCMD.SetHDCPKey22(TVPort, HDCP22Data, out result, out data, out error, SerailDelay))
  2954. {
  2955. SetsuccessStatus(m_writehdcp22);
  2956. Log.WriteInfoLog("Check HDCP22...");
  2957. if (cfg_writecheck.HDCP22Checkcheck ? SerialCMD.CheckHDCP22(TVPort, out result, out data, out error, SerailDelay) : true)
  2958. {
  2959. SetsuccessStatus(m_checkhdcp22);
  2960. Log.WriteInfoLog("Read HDCP22...");
  2961. if (cfg_readcheck.HDCP22Readcheck ? SerialCMD.GetHDCPKey22(TVPort, out result, out data, out error, SerailDelay) : true)
  2962. {
  2963. if (cfg_readcheck.HDCP22Readcheck)
  2964. {
  2965. if (SerialInit.BytesCompare_Base64(data, HDCP22Data))
  2966. {
  2967. SetsuccessStatus(m_readhdcp22);
  2968. }
  2969. else
  2970. {
  2971. SetfailStatus(m_readhdcp22);
  2972. ErrMsg = string.Format("{0} contrast HDCP22 fail!", SN);
  2973. Log.WriteErrorLog(ErrMsg);
  2974. goto end;
  2975. }
  2976. }
  2977. }
  2978. else
  2979. {
  2980. SetfailStatus(m_readhdcp22);
  2981. ErrMsg = string.Format("{0} read HDCP22 fail!", SN);
  2982. Log.WriteErrorLog(ErrMsg);
  2983. goto end;
  2984. }
  2985. }
  2986. else
  2987. {
  2988. SetfailStatus(m_checkhdcp22);
  2989. ErrMsg = string.Format("{0} check HDCP22 fail!", SN);
  2990. Log.WriteErrorLog(ErrMsg);
  2991. goto end;
  2992. }
  2993. }
  2994. else
  2995. {
  2996. SetfailStatus(m_writehdcp22);
  2997. ErrMsg = string.Format("{0} Write HDCP22 fail!", SN);
  2998. Log.WriteErrorLog(ErrMsg);
  2999. goto end;
  3000. }
  3001. keyInfo.HDCP22.result = true;
  3002. }
  3003. //ESN KEY抄写
  3004. if (WriteESN.Checked)
  3005. {
  3006. if (!CommonMethod.IsNumberAndWord(keyInfo.ESN.data))
  3007. {
  3008. ErrMsg = string.Format("ESN format error!\r\n{0}", keyInfo.ESN.data);
  3009. Log.WriteErrorLog(ErrMsg);
  3010. goto end;
  3011. }
  3012. byte[] ESNData = SerialInit.HexToByte(keyInfo.ESN.data);
  3013. Log.WriteInfoLog("Write ESN...");
  3014. if (SerialCMD.SetNetflixESN(TVPort, ESNData, out result, out data, out error, SerailDelay))
  3015. {
  3016. SetsuccessStatus(m_writeesn);
  3017. Log.WriteInfoLog("Check ESN...");
  3018. if (cfg_writecheck.ESNCheckcheck ? SerialCMD.CheckNetflixESN(TVPort, out result, out data, out error, SerailDelay) : true)
  3019. {
  3020. SetsuccessStatus(m_checkesn);
  3021. Log.WriteInfoLog("Read ESN...");
  3022. if (cfg_readcheck.ESNReadcheck ? SerialCMD.GetNetflixESN(TVPort, out result, out data, out error, SerailDelay) : true)
  3023. {
  3024. if (cfg_readcheck.ESNReadcheck)
  3025. {
  3026. if (SerialInit.BytesCompare_Base64(data, ESNData))
  3027. {
  3028. SetsuccessStatus(m_readesn);
  3029. }
  3030. else
  3031. {
  3032. SetfailStatus(m_readesn);
  3033. ErrMsg = string.Format("{0} contrast ESN fail!", SN);
  3034. Log.WriteErrorLog(ErrMsg);
  3035. goto end;
  3036. }
  3037. }
  3038. }
  3039. else
  3040. {
  3041. SetfailStatus(m_readesn);
  3042. ErrMsg = string.Format("{0} read ESN fail!", SN);
  3043. Log.WriteErrorLog(ErrMsg);
  3044. goto end;
  3045. }
  3046. }
  3047. else
  3048. {
  3049. SetfailStatus(m_checkesn);
  3050. ErrMsg = string.Format("{0} check ESN fail!", SN);
  3051. Log.WriteErrorLog(ErrMsg);
  3052. goto end;
  3053. }
  3054. }
  3055. else
  3056. {
  3057. SetfailStatus(m_writeesn);
  3058. ErrMsg = string.Format("{0} Write ESN fail!", SN);
  3059. Log.WriteErrorLog(ErrMsg);
  3060. goto end;
  3061. }
  3062. }
  3063. //Youtube key抄写
  3064. if (WriteYouTube.Checked)
  3065. {
  3066. if (!CommonMethod.IsNumberAndWord(keyInfo.YouTube_KEY.data))
  3067. {
  3068. ErrMsg = string.Format("YouTube format error!\r\n{0}", keyInfo.YouTube_KEY.data);
  3069. Log.WriteErrorLog(ErrMsg);
  3070. goto end;
  3071. }
  3072. byte[] YouTubeData = SerialInit.HexToByte(keyInfo.YouTube_KEY.data);
  3073. Log.WriteInfoLog("Write YouTube key...");
  3074. if (SerialCMD.SetFireTVYoutube(TVPort, YouTubeData, out result, out data, out error, SerailDelay))
  3075. {
  3076. SetsuccessStatus(m_writeYouTube);
  3077. Log.WriteInfoLog("Check YouTube_KEY...");
  3078. if (cfg_writecheck.YouTubeCheckcheck ? SerialCMD.CheckFireTVYoutube(TVPort, out result, out data, out error, SerailDelay) : true)
  3079. {
  3080. SetsuccessStatus(m_checkYouTube);
  3081. Log.WriteInfoLog("Read YouTube_KEY...");
  3082. if (cfg_readcheck.YouTubeReadcheck ? SerialCMD.ReadFireTVYoutube(TVPort, out result, out data, out error, SerailDelay) : true)
  3083. {
  3084. if (cfg_readcheck.YouTubeReadcheck)
  3085. {
  3086. if (SerialInit.BytesCompare_Base64(data, YouTubeData))
  3087. {
  3088. SetsuccessStatus(m_readYouTube);
  3089. }
  3090. else
  3091. {
  3092. SetfailStatus(m_readYouTube);
  3093. ErrMsg = string.Format("{0} contrast YouTube_KEY fail!", SN);
  3094. Log.WriteErrorLog(ErrMsg);
  3095. goto end;
  3096. }
  3097. }
  3098. }
  3099. else
  3100. {
  3101. SetfailStatus(m_readYouTube);
  3102. ErrMsg = string.Format("{0} read YouTube_KEY fail!", SN);
  3103. Log.WriteErrorLog(ErrMsg);
  3104. goto end;
  3105. }
  3106. }
  3107. else
  3108. {
  3109. SetfailStatus(m_checkYouTube);
  3110. ErrMsg = string.Format("{0} check YouTube_KEY fail!", SN);
  3111. Log.WriteErrorLog(ErrMsg);
  3112. goto end;
  3113. }
  3114. }
  3115. else
  3116. {
  3117. SetfailStatus(m_writeYouTube);
  3118. ErrMsg = string.Format("{0} Write YouTube_KEY fail!", SN);
  3119. Log.WriteErrorLog(ErrMsg);
  3120. goto end;
  3121. }
  3122. keyInfo.YouTube_KEY.result = true;
  3123. }
  3124. //Widevine KEY抄写
  3125. if (WriteWidevine.Checked)
  3126. {
  3127. if (!CommonMethod.IsNumberAndWord(keyInfo.Widevine.data))
  3128. {
  3129. ErrMsg = string.Format("Widevine format error!\r\n{0}", keyInfo.Widevine.data);
  3130. Log.WriteErrorLog(ErrMsg);
  3131. //MessageBox.Show(LResource.WidevineFormatError + "\r\n" + keyInfo.Widevine);
  3132. goto end;
  3133. }
  3134. byte[] WidevineData = SerialInit.HexToByte(keyInfo.Widevine.data);
  3135. Log.WriteInfoLog("Write Widevine...");
  3136. if (SerialCMD.SetWidevine(TVPort, WidevineData, out result, out data, out error, SerailDelay))
  3137. {
  3138. SetsuccessStatus(m_writewidevine);
  3139. Log.WriteInfoLog("Check Widevine...");
  3140. if (cfg_writecheck.WidevineCheckcheck ? SerialCMD.CheckWidevine(TVPort, out result, out data, out error, SerailDelay) : true)
  3141. {
  3142. SetsuccessStatus(m_checkwidevine);
  3143. Log.WriteInfoLog("Read Widevine...");
  3144. if (cfg_readcheck.WidevineReadcheck ? SerialCMD.GetWidevine(TVPort, out result, out data, out error, SerailDelay) : true)
  3145. {
  3146. if (cfg_readcheck.WidevineReadcheck)
  3147. {
  3148. if (CommonMethod.CompareMD5(WidevineData, data))
  3149. {
  3150. SetsuccessStatus(m_readwidevine);
  3151. }
  3152. else
  3153. {
  3154. if (SerialInit.BytesCompare_Base64(data, WidevineData))
  3155. {
  3156. SetsuccessStatus(m_readwidevine);
  3157. }
  3158. else
  3159. {
  3160. SetfailStatus(m_readwidevine);
  3161. ErrMsg = string.Format("{0} contrast Widevine fail!", SN);
  3162. Log.WriteErrorLog(ErrMsg);
  3163. goto end;
  3164. }
  3165. }
  3166. }
  3167. }
  3168. else
  3169. {
  3170. SetfailStatus(m_readwidevine);
  3171. ErrMsg = string.Format("{0} read Widevine fail!", SN);
  3172. Log.WriteErrorLog(ErrMsg);
  3173. goto end;
  3174. }
  3175. }
  3176. else
  3177. {
  3178. SetfailStatus(m_checkwidevine);
  3179. ErrMsg = string.Format("{0} check Widevine fail!", SN);
  3180. Log.WriteErrorLog(ErrMsg);
  3181. goto end;
  3182. }
  3183. }
  3184. else
  3185. {
  3186. SetfailStatus(m_writewidevine);
  3187. ErrMsg = string.Format("{0} Write Widevine fail!", SN);
  3188. Log.WriteErrorLog(ErrMsg);
  3189. goto end;
  3190. }
  3191. keyInfo.Widevine.result = true;
  3192. }
  3193. //CI plus KEY抄写
  3194. if (WriteCiplus.Checked)
  3195. {
  3196. if (!CommonMethod.IsNumberAndWord(keyInfo.CI_plus.data))
  3197. {
  3198. ErrMsg = string.Format("CI_plus format error!\r\n{0}", keyInfo.CI_plus.data);
  3199. Log.WriteErrorLog(ErrMsg);
  3200. goto end;
  3201. }
  3202. byte[] CiplusData = SerialInit.HexToByte(keyInfo.CI_plus.data);
  3203. Log.WriteInfoLog("Write CI plus...");
  3204. if (SerialCMD.SetCiKey(TVPort, CiplusData, out result, out data, out error, SerailDelay))
  3205. {
  3206. SetsuccessStatus(m_writeci);
  3207. Log.WriteInfoLog("Check CI plus...");
  3208. if (cfg_writecheck.CI_plusCheckcheck ? SerialCMD.CheckCikey(TVPort, out result, out data, out error, SerailDelay) : true)
  3209. {
  3210. SetsuccessStatus(m_checkci);
  3211. Log.WriteInfoLog("Read CI plus...");
  3212. if (cfg_readcheck.CI_plusReadcheck ? SerialCMD.GetCiKey(TVPort, out result, out data, out error, SerailDelay) : true)
  3213. {
  3214. if (cfg_readcheck.CI_plusReadcheck)
  3215. {
  3216. if (CommonMethod.CompareMD5(CiplusData, data))
  3217. {
  3218. SetsuccessStatus(m_readci);
  3219. }
  3220. else
  3221. {
  3222. if (SerialInit.BytesCompare_Base64(data, CiplusData))
  3223. {
  3224. SetsuccessStatus(m_readci);
  3225. }
  3226. else
  3227. {
  3228. SetfailStatus(m_readci);
  3229. ErrMsg = string.Format("{0} contrast CI plus fail!", SN);
  3230. Log.WriteErrorLog(ErrMsg);
  3231. goto end;
  3232. }
  3233. }
  3234. }
  3235. }
  3236. else
  3237. {
  3238. SetfailStatus(m_readci);
  3239. ErrMsg = string.Format("{0} read CI plus fail!", SN);
  3240. Log.WriteErrorLog(ErrMsg);
  3241. goto end;
  3242. }
  3243. }
  3244. else
  3245. {
  3246. SetfailStatus(m_checkci);
  3247. ErrMsg = string.Format("{0} check CI plus fail!", SN);
  3248. Log.WriteErrorLog(ErrMsg);
  3249. goto end;
  3250. }
  3251. }
  3252. else
  3253. {
  3254. SetfailStatus(m_writeci);
  3255. ErrMsg = string.Format("{0} Write CI plus fail!", SN);
  3256. Log.WriteErrorLog(ErrMsg);
  3257. goto end;
  3258. }
  3259. keyInfo.CI_plus.result = true;
  3260. }
  3261. //Attestation KEY抄写
  3262. if (WriteAttestation.Checked)
  3263. {
  3264. if (!CommonMethod.IsNumberAndWord(keyInfo.Attestation.data))
  3265. {
  3266. ErrMsg = string.Format("Attestation key format error!\r\n{0}", keyInfo.Attestation.data);
  3267. Log.WriteErrorLog(ErrMsg);
  3268. goto end;
  3269. }
  3270. byte[] AttestationData = SerialInit.HexToByte(keyInfo.Attestation.data);
  3271. Log.WriteInfoLog("Write Attestation key...");
  3272. if (SerialCMD.SetAttestationKey(TVPort, AttestationData, out result, out data, out error, SerailDelay))
  3273. {
  3274. SetsuccessStatus(m_writeattestation);
  3275. Log.WriteInfoLog("Check Attestation key...");
  3276. if (cfg_writecheck.AttestationCheckcheck ? SerialCMD.CheckAttestationKey(TVPort, out result, out data, out error, SerailDelay) : true)
  3277. {
  3278. SetsuccessStatus(m_checkattestation);
  3279. Log.WriteInfoLog("Read Attestation key...");
  3280. if (cfg_readcheck.AttestationReadcheck ? SerialCMD.GetAttestationKey(TVPort, out result, out data, out error, SerailDelay) : true)
  3281. {
  3282. if (cfg_readcheck.AttestationReadcheck)
  3283. {
  3284. if (CommonMethod.CompareMD5(AttestationData, data))
  3285. {
  3286. SetsuccessStatus(m_readattestation);
  3287. }
  3288. else
  3289. {
  3290. if (SerialInit.BytesCompare_Base64(data, AttestationData))
  3291. {
  3292. SetsuccessStatus(m_readattestation);
  3293. }
  3294. else
  3295. {
  3296. SetfailStatus(m_readattestation);
  3297. ErrMsg = string.Format("{0} contrast Attestation key fail!", SN);
  3298. Log.WriteErrorLog(ErrMsg);
  3299. goto end;
  3300. }
  3301. }
  3302. }
  3303. }
  3304. else
  3305. {
  3306. SetfailStatus(m_readattestation);
  3307. ErrMsg = string.Format("{0} read Attestation key fail!", SN);
  3308. Log.WriteErrorLog(ErrMsg);
  3309. goto end;
  3310. }
  3311. }
  3312. else
  3313. {
  3314. SetfailStatus(m_checkattestation);
  3315. ErrMsg = string.Format("{0} check Attestation key fail!", SN);
  3316. Log.WriteErrorLog(ErrMsg);
  3317. goto end;
  3318. }
  3319. }
  3320. else
  3321. {
  3322. SetfailStatus(m_writeattestation);
  3323. ErrMsg = string.Format("{0} Write Attestation key fail!", SN);
  3324. Log.WriteErrorLog(ErrMsg);
  3325. goto end;
  3326. }
  3327. keyInfo.Attestation.result = true;
  3328. }
  3329. //MGK KEY抄写
  3330. if (WriteMGK.Checked)
  3331. {
  3332. if (!CommonMethod.IsNumberAndWord(keyInfo.MGK.data))
  3333. {
  3334. ErrMsg = string.Format("MGK format error!\r\n{0}", keyInfo.MGK.data);
  3335. Log.WriteErrorLog(ErrMsg);
  3336. goto end;
  3337. }
  3338. byte[] MGKData = SerialInit.HexToByte(keyInfo.MGK.data);
  3339. Log.WriteInfoLog("Write MGK...");
  3340. if (SerialCMD.SetMGKKey(TVPort, MGKData, out result, out data, out error, SerailDelay))
  3341. {
  3342. SetsuccessStatus(m_writeMGK);
  3343. Log.WriteInfoLog("Check MGK...");
  3344. if (cfg_writecheck.MGKCheckcheck ? SerialCMD.CheckMGKkey(TVPort, out result, out data, out error, SerailDelay) : true)
  3345. {
  3346. SetsuccessStatus(m_checkMGK);
  3347. Log.WriteInfoLog("Read MGK...");
  3348. if (cfg_readcheck.MGKReadcheck ? SerialCMD.GetMGKKey(TVPort, out result, out data, out error, SerailDelay) : true)
  3349. {
  3350. if (cfg_readcheck.MGKReadcheck)
  3351. {
  3352. if (CommonMethod.CompareMD5(MGKData, data))
  3353. {
  3354. SetsuccessStatus(m_readMGK);
  3355. }
  3356. else
  3357. {
  3358. if (SerialInit.BytesCompare_Base64(data, MGKData))
  3359. {
  3360. SetsuccessStatus(m_readMGK);
  3361. }
  3362. else
  3363. {
  3364. SetfailStatus(m_readMGK);
  3365. ErrMsg = string.Format("{0} contrast MGK fail!", SN);
  3366. Log.WriteErrorLog(ErrMsg);
  3367. goto end;
  3368. }
  3369. }
  3370. }
  3371. }
  3372. else
  3373. {
  3374. SetfailStatus(m_readMGK);
  3375. ErrMsg = string.Format("{0} read MGK fail!", SN);
  3376. Log.WriteErrorLog(ErrMsg);
  3377. goto end;
  3378. }
  3379. }
  3380. else
  3381. {
  3382. SetfailStatus(m_checkMGK);
  3383. ErrMsg = string.Format("{0} check MGK fail!", SN);
  3384. Log.WriteErrorLog(ErrMsg);
  3385. goto end;
  3386. }
  3387. }
  3388. else
  3389. {
  3390. SetfailStatus(m_writeMGK);
  3391. ErrMsg = string.Format("{0} Write MGK fail!", SN);
  3392. Log.WriteErrorLog(ErrMsg);
  3393. goto end;
  3394. }
  3395. keyInfo.MGK.result = true;
  3396. }
  3397. //Fairplay KEY抄写
  3398. if (WriteFairplay.Checked)
  3399. {
  3400. if (!CommonMethod.IsNumberAndWord(keyInfo.Fairplay.data))
  3401. {
  3402. ErrMsg = string.Format("Fairplay format error!\r\n{0}", keyInfo.Fairplay.data);
  3403. Log.WriteErrorLog(ErrMsg);
  3404. goto end;
  3405. }
  3406. byte[] FairplayData = SerialInit.HexToByte(keyInfo.Fairplay.data);
  3407. Log.WriteInfoLog("Write Fairplay...");
  3408. if (SerialCMD.SetFireTVFairplay(TVPort, FairplayData, out result, out data, out error, SerailDelay))
  3409. {
  3410. SetsuccessStatus(m_writeFairplay);
  3411. Log.WriteInfoLog("Check Fairplay...");
  3412. if (cfg_writecheck.FairplayCheckcheck ? SerialCMD.CheckFireTVFairplay(TVPort, out result, out data, out error, SerailDelay) : true)
  3413. {
  3414. SetsuccessStatus(m_checkFairplay);
  3415. Log.WriteInfoLog("Read Fairplay...");
  3416. if (cfg_readcheck.FairplayReadcheck ? SerialCMD.ReadFireTVFairplay(TVPort, out result, out data, out error, SerailDelay) : true)
  3417. {
  3418. if (cfg_readcheck.FairplayReadcheck)
  3419. {
  3420. if (SerialInit.BytesCompare_Base64(data, FairplayData))
  3421. {
  3422. SetsuccessStatus(m_readFairplay);
  3423. }
  3424. else
  3425. {
  3426. SetfailStatus(m_readFairplay);
  3427. ErrMsg = string.Format("{0} contrast Fairplay fail!", SN);
  3428. Log.WriteErrorLog(ErrMsg);
  3429. goto end;
  3430. }
  3431. }
  3432. }
  3433. else
  3434. {
  3435. SetfailStatus(m_readFairplay);
  3436. ErrMsg = string.Format("{0} read Fairplay fail!", SN);
  3437. Log.WriteErrorLog(ErrMsg);
  3438. goto end;
  3439. }
  3440. }
  3441. else
  3442. {
  3443. SetfailStatus(m_checkFairplay);
  3444. ErrMsg = string.Format("{0} check Fairplay fail!", SN);
  3445. Log.WriteErrorLog(ErrMsg);
  3446. goto end;
  3447. }
  3448. }
  3449. else
  3450. {
  3451. SetfailStatus(m_writeFairplay);
  3452. ErrMsg = string.Format("{0} Write Fairplay fail!", SN);
  3453. Log.WriteErrorLog(ErrMsg);
  3454. goto end;
  3455. }
  3456. keyInfo.Fairplay.result = true;
  3457. }
  3458. //ECP KEY抄写
  3459. if (WriteECP.Checked)
  3460. {
  3461. if (!CommonMethod.IsNumberAndWord(keyInfo.ECP.data))
  3462. {
  3463. ErrMsg = string.Format("ECP format error!\r\n{0}", keyInfo.ECP.data);
  3464. Log.WriteErrorLog(ErrMsg);
  3465. goto end;
  3466. }
  3467. byte[] ECPData = SerialInit.HexToByte(keyInfo.ECP.data);
  3468. Log.WriteInfoLog("Write ECP...");
  3469. if (SerialCMD.SetECP(TVPort, ECPData, out result, out data, out error, SerailDelay))
  3470. {
  3471. SetsuccessStatus(m_writeECP);
  3472. Log.WriteInfoLog("Check ECP...");
  3473. if (cfg_writecheck.ECPCheckcheck ? SerialCMD.CheckECP(TVPort, out result, out data, out error, SerailDelay) : true)
  3474. {
  3475. SetsuccessStatus(m_checkECP);
  3476. Log.WriteInfoLog("Read ECP...");
  3477. if (cfg_readcheck.ECPReadcheck ? SerialCMD.GetECP(TVPort, out result, out data, out error, SerailDelay) : true)
  3478. {
  3479. if (cfg_readcheck.ECPReadcheck)
  3480. {
  3481. if (SerialInit.BytesCompare_Base64(data, ECPData))
  3482. {
  3483. SetsuccessStatus(m_readECP);
  3484. }
  3485. else
  3486. {
  3487. SetfailStatus(m_readECP);
  3488. ErrMsg = string.Format("{0} contrast ECP fail!", SN);
  3489. Log.WriteErrorLog(ErrMsg);
  3490. goto end;
  3491. }
  3492. }
  3493. }
  3494. else
  3495. {
  3496. SetfailStatus(m_readECP);
  3497. ErrMsg = string.Format("{0} read ECP fail!", SN);
  3498. Log.WriteErrorLog(ErrMsg);
  3499. goto end;
  3500. }
  3501. }
  3502. else
  3503. {
  3504. SetfailStatus(m_checkECP);
  3505. ErrMsg = string.Format("{0} check ECP fail!", SN);
  3506. Log.WriteErrorLog(ErrMsg);
  3507. goto end;
  3508. }
  3509. }
  3510. else
  3511. {
  3512. SetfailStatus(m_writeECP);
  3513. ErrMsg = string.Format("{0} Write ECP fail!", SN);
  3514. Log.WriteErrorLog(ErrMsg);
  3515. goto end;
  3516. }
  3517. keyInfo.ECP.result = true;
  3518. }
  3519. //Playready抄写
  3520. if (WritePlayready.Checked)
  3521. {
  3522. if (!CommonMethod.IsNumberAndWord(keyInfo.Playready.data))
  3523. {
  3524. ErrMsg = string.Format("Playready format error!\r\n{0}", keyInfo.Playready.data);
  3525. Log.WriteErrorLog(ErrMsg);
  3526. goto end;
  3527. }
  3528. byte[] PlayreadyData = SerialInit.HexToByte(keyInfo.Playready.data);
  3529. Log.WriteInfoLog("Write Playready...");
  3530. if (SerialCMD.SetFireTVPlayready(TVPort, PlayreadyData, out result, out data, out error, SerailDelay))
  3531. {
  3532. SetsuccessStatus(m_writePlayready);
  3533. Log.WriteInfoLog("Check Playready...");
  3534. if (cfg_writecheck.PlayreadyCheckcheck ? SerialCMD.CheckFireTVPlayready(TVPort, out result, out data, out error, SerailDelay) : true)
  3535. {
  3536. SetsuccessStatus(m_checkPlayready);
  3537. Log.WriteInfoLog("Read Playready...");
  3538. if (cfg_readcheck.PlayreadyReadcheck ? SerialCMD.ReadFireTVPlayready(TVPort, out result, out data, out error, SerailDelay) : true)
  3539. {
  3540. if (cfg_readcheck.PlayreadyReadcheck)
  3541. {
  3542. if (CommonMethod.CompareMD5(PlayreadyData, data))
  3543. {
  3544. SetsuccessStatus(m_readPlayready);
  3545. }
  3546. else
  3547. {
  3548. if (SerialInit.BytesCompare_Base64(data, PlayreadyData))
  3549. {
  3550. SetsuccessStatus(m_readPlayready);
  3551. }
  3552. else
  3553. {
  3554. SetfailStatus(m_readPlayready);
  3555. ErrMsg = string.Format("{0} contrast Playready fail!", SN);
  3556. Log.WriteErrorLog(ErrMsg);
  3557. goto end;
  3558. }
  3559. }
  3560. }
  3561. }
  3562. else
  3563. {
  3564. SetfailStatus(m_readPlayready);
  3565. ErrMsg = string.Format("{0} read Playready fail!", SN);
  3566. Log.WriteErrorLog(ErrMsg);
  3567. goto end;
  3568. }
  3569. }
  3570. else
  3571. {
  3572. SetfailStatus(m_checkPlayready);
  3573. ErrMsg = string.Format("{0} check Playready fail!", SN);
  3574. Log.WriteErrorLog(ErrMsg);
  3575. goto end;
  3576. }
  3577. }
  3578. else
  3579. {
  3580. SetfailStatus(m_writePlayready);
  3581. ErrMsg = string.Format("{0} Write Playready fail!", SN);
  3582. Log.WriteErrorLog(ErrMsg);
  3583. goto end;
  3584. }
  3585. keyInfo.Playready.result = true;
  3586. }
  3587. // KFP抄写;
  3588. if (WriteKFP.Checked)
  3589. {
  3590. if (!CommonMethod.IsNumberAndWord(keyInfo.KFP.data))
  3591. {
  3592. ErrMsg = string.Format("KFP format error!\r\n{0}", keyInfo.KFP.data);
  3593. Log.WriteErrorLog(ErrMsg);
  3594. goto end;
  3595. }
  3596. byte[] KFPData = SerialInit.HexToByte(keyInfo.KFP.data);
  3597. Log.WriteInfoLog("Write KFP...");
  3598. if (SerialCMD.SetKFPKey(TVPort, KFPData, out result, out data, out error, SerailDelay))
  3599. {
  3600. SetsuccessStatus(m_writeKFP);
  3601. Log.WriteInfoLog("Check KFP...");
  3602. if (cfg_writecheck.KFPCheckcheck ? SerialCMD.CheckKFPKey(TVPort, out result, out data, out error, SerailDelay) : true)
  3603. {
  3604. SetsuccessStatus(m_checkKFP);
  3605. Log.WriteInfoLog("Read KFP...");
  3606. if (cfg_readcheck.KFPReadcheck ? SerialCMD.ReadKFPKey(TVPort, out result, out data, out error, SerailDelay) : true)
  3607. {
  3608. if (cfg_readcheck.KFPReadcheck)
  3609. {
  3610. if (CommonMethod.CompareMD5(KFPData, data))
  3611. {
  3612. SetsuccessStatus(m_readKFP);
  3613. }
  3614. else
  3615. {
  3616. if (SerialInit.BytesCompare_Base64(data, KFPData))
  3617. {
  3618. SetsuccessStatus(m_readKFP);
  3619. }
  3620. else
  3621. {
  3622. SetfailStatus(m_readKFP);
  3623. ErrMsg = string.Format("{0} contrast KFP fail!", SN);
  3624. Log.WriteErrorLog(ErrMsg);
  3625. goto end;
  3626. }
  3627. }
  3628. }
  3629. }
  3630. else
  3631. {
  3632. SetfailStatus(m_readKFP);
  3633. ErrMsg = string.Format("{0} read KFP fail!", SN);
  3634. Log.WriteErrorLog(ErrMsg);
  3635. goto end;
  3636. }
  3637. }
  3638. else
  3639. {
  3640. SetfailStatus(m_checkKFP);
  3641. ErrMsg = string.Format("{0} check KFP fail!", SN);
  3642. Log.WriteErrorLog(ErrMsg);
  3643. goto end;
  3644. }
  3645. }
  3646. else
  3647. {
  3648. SetfailStatus(m_writeKFP);
  3649. ErrMsg = string.Format("{0} Write KFP fail!", SN);
  3650. Log.WriteErrorLog(ErrMsg);
  3651. goto end;
  3652. }
  3653. keyInfo.KFP.result = true;
  3654. }
  3655. #region FVP激活-放在Hash key抄写之后,应用于所有FireTV项目-已通过郁沛确认;
  3656. if (WriteFVP.Checked)
  3657. {
  3658. keyInfo.FVP.data = "FAIL"; //默认失败;
  3659. Log.WriteInfoLog("Activate FVP...");
  3660. byte[] FVPData = new byte[] { };
  3661. if (SerialCMD.ActiveMiFireTVFVP(TVPort, FVPData, out result, out data, out error, SerailDelay))
  3662. {
  3663. SetsuccessStatus(m_writeFVP);
  3664. keyInfo.FVP.data = "PASS"; // 激活成功;
  3665. Log.WriteInfoLog("Check FVP...");
  3666. if (cfg_writecheck.FVPCheckcheck ? SerialCMD.CheckMiFireTVFVP(TVPort, out result, out data, out error, SerailDelay) : true)
  3667. {
  3668. SetsuccessStatus(m_checkFVP);
  3669. // result只作为check结果;
  3670. keyInfo.FVP.result = true;
  3671. }
  3672. else
  3673. {
  3674. SetfailStatus(m_checkFVP);
  3675. ErrMsg = string.Format("{0} check FVP fail!", SN);
  3676. Log.WriteErrorLog(ErrMsg);
  3677. keyInfo.FVP.result = false;
  3678. goto end;
  3679. }
  3680. }
  3681. else
  3682. {
  3683. SetfailStatus(m_writeFVP);
  3684. ErrMsg = string.Format("Activate FVP Failed {0}", error);
  3685. Log.WriteErrorLog(ErrMsg);
  3686. keyInfo.FVP.data = "FAIL";
  3687. keyInfo.FVP.result = false;
  3688. goto end;
  3689. }
  3690. }
  3691. #endregion
  3692. // Dolby Key抄写;
  3693. if ( cfg_writecheck.DolbyCheckcheck )
  3694. {
  3695. Log.WriteInfoLog("Check Dolby Key...");
  3696. if ( !SerialCMD.CheckDolbyKey(TVPort, out result, out data, out error, SerailDelay) )
  3697. {
  3698. ErrMsg = string.Format("{0} check Dolby fail!", SN);
  3699. Log.WriteErrorLog(ErrMsg);
  3700. goto end;
  3701. }
  3702. }
  3703. //Hash抄写
  3704. if (WriteHash.Checked)
  3705. {
  3706. if (!CommonMethod.IsNumberAndWord(keyInfo.Hashkey.data))
  3707. {
  3708. ErrMsg = string.Format("Hash format error!\r\n{0}", keyInfo.Hashkey.data);
  3709. Log.WriteErrorLog(ErrMsg);
  3710. goto end;
  3711. }
  3712. byte[] HashData = SerialInit.HexToByte(keyInfo.Hashkey.data);
  3713. Log.WriteInfoLog("Write Hash...");
  3714. if (SerialCMD.SetFireTVHashkey(TVPort, HashData, out result, out data, out error, SerailDelay))
  3715. {
  3716. SetsuccessStatus(m_writeHash);
  3717. Log.WriteInfoLog("Check Hash...");
  3718. if (cfg_writecheck.HashCheckcheck ? SerialCMD.CheckFireTVHashkey(TVPort, out result, out data, out error, SerailDelay) : true)
  3719. {
  3720. SetsuccessStatus(m_checkHash);
  3721. Log.WriteInfoLog("Read Hash...");
  3722. if (cfg_readcheck.HashReadcheck ? SerialCMD.ReadFireTVHashkey(TVPort, out result, out data, out error, SerailDelay) : true)
  3723. {
  3724. if (cfg_readcheck.HashReadcheck)
  3725. {
  3726. if (SerialInit.BytesCompare_Base64(data, HashData))
  3727. {
  3728. SetsuccessStatus(m_readHash);
  3729. }
  3730. else
  3731. {
  3732. SetfailStatus(m_readHash);
  3733. ErrMsg = string.Format("{0} contrast Hash fail!", SN);
  3734. Log.WriteErrorLog(ErrMsg);
  3735. goto end;
  3736. }
  3737. }
  3738. }
  3739. else
  3740. {
  3741. SetfailStatus(m_readHash);
  3742. ErrMsg = string.Format("{0} read Hash fail!", SN);
  3743. Log.WriteErrorLog(ErrMsg);
  3744. goto end;
  3745. }
  3746. }
  3747. else
  3748. {
  3749. SetfailStatus(m_checkHash);
  3750. ErrMsg = string.Format("{0} check Hash fail!", SN);
  3751. Log.WriteErrorLog(ErrMsg);
  3752. goto end;
  3753. }
  3754. }
  3755. else
  3756. {
  3757. SetfailStatus(m_writeHash);
  3758. ErrMsg = string.Format("{0} Write Hash fail!", SN);
  3759. Log.WriteErrorLog(ErrMsg);
  3760. goto end;
  3761. }
  3762. keyInfo.Hashkey.result = true;
  3763. }
  3764. //频道预置
  3765. if (FunctionSettingNow.WriteChannel)
  3766. {
  3767. Log.WriteInfoLog("setting channel...");
  3768. if (SerialCMD.SetChannel(TVPort, FunctionSettingNow.ChannelCode, out result, out data, out error, SerailDelay))
  3769. {
  3770. /*
  3771. Log.WriteInfoLog("getting channel...");
  3772. if (SerialCMD.GetChannel(TVPort, out result, out data, out error))
  3773. {
  3774. if(SerialInit.BytesCompare_Base64(data, FunctionSettingNow.ChannelCode))
  3775. {
  3776. }
  3777. else
  3778. {
  3779. Log.WriteErrorLog(SN + " get different channel");
  3780. goto end;
  3781. }
  3782. }
  3783. else
  3784. {
  3785. Log.WriteErrorLog(SN + " fail to get channel");
  3786. goto end;
  3787. }*/
  3788. Log.WriteInfoLog(SN + " set channel success");
  3789. SetcolorStatus(ChannelText, Color.FromArgb(128, 255, 128));
  3790. }
  3791. else
  3792. {
  3793. ErrMsg = string.Format("{0} fail to set channel!", SN);
  3794. Log.WriteErrorLog(ErrMsg);
  3795. goto end;
  3796. }
  3797. }
  3798. //OSD语言设置
  3799. if (FunctionSettingNow.WriteOSD)
  3800. {
  3801. Log.WriteInfoLog("setting OSD language...");
  3802. if (SerialCMD.SetOSDLanguage(TVPort, FunctionSettingNow.OSDLCode, out result, out data, out error, SerailDelay))
  3803. {
  3804. if (cfg_readcheck.OSDReadcheck)
  3805. {
  3806. Log.WriteInfoLog("getting OSD language...");
  3807. if (SerialCMD.GetOSDLanguage(TVPort, out result, out data, out error, SerailDelay))
  3808. {
  3809. if (SerialInit.BytesCompare_Base64(data, FunctionSettingNow.OSDLCode))
  3810. {
  3811. SetcolorStatus(OSDText, Color.FromArgb(128, 255, 128));
  3812. }
  3813. else
  3814. {
  3815. ErrMsg = string.Format("{0} get different OSD language!", SN);
  3816. Log.WriteErrorLog(ErrMsg);
  3817. goto end;
  3818. }
  3819. }
  3820. else
  3821. {
  3822. ErrMsg = string.Format("{0} fail to get OSD language!", SN);
  3823. Log.WriteErrorLog(ErrMsg);
  3824. goto end;
  3825. }
  3826. }
  3827. else
  3828. Log.WriteInfoLog("skip read OSD language...");
  3829. }
  3830. else
  3831. {
  3832. ErrMsg = string.Format("{0} fail to set OSD language!", SN);
  3833. Log.WriteErrorLog(ErrMsg);
  3834. goto end;
  3835. }
  3836. }
  3837. //Shop语言设置
  3838. if (FunctionSettingNow.WriteSHOP)
  3839. {
  3840. Log.WriteInfoLog("setting SHOP language...");
  3841. if (SerialCMD.SetShopLanguage(TVPort, FunctionSettingNow.ShopLCode, out result, out data, out error, SerailDelay))
  3842. {
  3843. if (cfg_readcheck.SHOPReadcheck)
  3844. {
  3845. Log.WriteInfoLog("getting SHOP language...");
  3846. if (SerialCMD.GetShopLanguage(TVPort, out result, out data, out error, SerailDelay))
  3847. {
  3848. if (SerialInit.BytesCompare_Base64(data, FunctionSettingNow.ShopLCode))
  3849. {
  3850. SetcolorStatus(SHOPText, Color.FromArgb(128, 255, 128));
  3851. }
  3852. else
  3853. {
  3854. ErrMsg = string.Format("{0} get different SHOP language!", SN);
  3855. Log.WriteErrorLog(ErrMsg);
  3856. goto end;
  3857. }
  3858. }
  3859. else
  3860. {
  3861. ErrMsg = string.Format("{0} fail to get SHOP language!", SN);
  3862. Log.WriteErrorLog(ErrMsg);
  3863. goto end;
  3864. }
  3865. }
  3866. else
  3867. Log.WriteInfoLog("skip read SHOP language...");
  3868. }
  3869. else
  3870. {
  3871. ErrMsg = string.Format("{0} fail to set SHOP language!", SN);
  3872. Log.WriteErrorLog(ErrMsg);
  3873. goto end;
  3874. }
  3875. }
  3876. // EDID Pid抄写;
  3877. if (WriteEDIDPID.Checked)
  3878. {
  3879. // 4字节转成整数:0~65535,0x0000~0xffff;
  3880. if (Regex.IsMatch(keyInfo.EDIDPid.data, "^[A-Fa-f0-9]{4}$"))
  3881. {
  3882. byte[] EDIDPidData = SerialInit.strToToHexByte(keyInfo.EDIDPid.data);
  3883. Log.WriteInfoLog("Write EDID Pid...");
  3884. if (SerialCMD.SetEDIDPid(TVPort, EDIDPidData, out result, out data, out error, SerailDelay))
  3885. {
  3886. SetsuccessStatus(m_writeEDIDPID);
  3887. Log.WriteInfoLog("Read EDID Pid...");
  3888. if (cfg_readcheck.EDIDPIDReadcheck ? SerialCMD.ReadEDIDPid(TVPort, out result, out data, out error, SerailDelay) : true)
  3889. {
  3890. if (cfg_readcheck.EDIDPIDReadcheck)
  3891. {
  3892. if (SerialInit.BytesCompare_Base64(data, EDIDPidData))
  3893. {
  3894. SetsuccessStatus(m_readEDIDPID);
  3895. }
  3896. else
  3897. {
  3898. SetfailStatus(m_readEDIDPID);
  3899. ErrMsg = string.Format("{0} contrast EDID PID fail!", SN);
  3900. Log.WriteErrorLog(ErrMsg);
  3901. goto end;
  3902. }
  3903. }
  3904. }
  3905. else
  3906. {
  3907. SetfailStatus(m_readEDIDPID);
  3908. ErrMsg = string.Format("{0} read EDID PID fail!", SN);
  3909. Log.WriteErrorLog(ErrMsg);
  3910. goto end;
  3911. }
  3912. }
  3913. else
  3914. {
  3915. SetfailStatus(m_writeEDIDPID);
  3916. ErrMsg = string.Format("{0} Write EDID PID fail!", SN);
  3917. Log.WriteErrorLog(ErrMsg);
  3918. goto end;
  3919. }
  3920. }
  3921. else
  3922. {
  3923. SetfailStatus(m_writeEDIDPID);
  3924. ErrMsg = string.Format("{0} The EDID PID Format Error!", SN);
  3925. Log.WriteErrorLog(ErrMsg);
  3926. goto end;
  3927. }
  3928. keyInfo.EDIDPid.result = true;
  3929. }
  3930. // EDID Mode Name抄写;
  3931. if (WriteEDIDName.Checked)
  3932. {
  3933. // 首字符:只能数字和字母;
  3934. if (Regex.IsMatch(keyInfo.EDIDModelName.data, "^[A-Za-z0-9]{1}[A-Za-z0-9_ \\.\\-]{2,12}[A-Za-z0-9]{1}$"))
  3935. {
  3936. // 长度为13字节;
  3937. byte[] EDIDNameData = Encoding.ASCII.GetBytes(keyInfo.EDIDModelName.data);
  3938. Log.WriteInfoLog("Write EDID Mode Name...");
  3939. if (SerialCMD.SetEDIDModelName(TVPort, EDIDNameData, out result, out data, out error, SerailDelay))
  3940. {
  3941. SetsuccessStatus(m_writeEDIDName);
  3942. Log.WriteInfoLog("Read EDID Mode Name...");
  3943. if (cfg_readcheck.EDIDModeNameReadcheck ? SerialCMD.ReadEDIDModelName(TVPort, out result, out data, out error, SerailDelay) : true)
  3944. {
  3945. if (cfg_readcheck.EDIDModeNameReadcheck)
  3946. {
  3947. if (SerialInit.BytesCompare_Base64(data, EDIDNameData))
  3948. {
  3949. SetsuccessStatus(m_readEDIDName);
  3950. }
  3951. else
  3952. {
  3953. SetfailStatus(m_readEDIDName);
  3954. ErrMsg = string.Format("{0} contrast EDID Mode Name fail!", SN);
  3955. Log.WriteErrorLog(ErrMsg);
  3956. goto end;
  3957. }
  3958. }
  3959. }
  3960. else
  3961. {
  3962. SetfailStatus(m_readEDIDName);
  3963. ErrMsg = string.Format("{0} read EDID Mode Name fail!", SN);
  3964. Log.WriteErrorLog(ErrMsg);
  3965. goto end;
  3966. }
  3967. }
  3968. else
  3969. {
  3970. SetfailStatus(m_writeEDIDName);
  3971. ErrMsg = string.Format("{0} Write EDID Mode Name fail!", SN);
  3972. Log.WriteErrorLog(ErrMsg);
  3973. goto end;
  3974. }
  3975. }
  3976. else
  3977. {
  3978. SetfailStatus(m_writeEDIDName);
  3979. ErrMsg = string.Format("{0} The EDID Model Name Format Error!", SN);
  3980. Log.WriteErrorLog(ErrMsg);
  3981. goto end;
  3982. }
  3983. keyInfo.EDIDModelName.result = true;
  3984. }
  3985. // ACAS Key抄写;
  3986. if (WriteACASKey.Checked)
  3987. {
  3988. // 1.acas key抄写前,必须先抄写playreadkey;
  3989. // 2.将tool先抄写再抄写data;
  3990. Log.WriteInfoLog("Write ACAC Key...");
  3991. byte[] ACASKeyData = SerialInit.HexToByte(keyInfo.ACASKey_Data.data);
  3992. if (SerialCMD.SetACASKeyData(TVPort, ACASKeyData, out result, out data, out error, SerailDelay))
  3993. {
  3994. SetsuccessStatus(m_writeACASKey);
  3995. Log.WriteInfoLog("Check ACAS Key Data...");
  3996. if (cfg_writecheck.ACASKeyCheckcheck ? SerialCMD.CheckACASKeyData(TVPort, out result, out data, out error, SerailDelay) : true)
  3997. {
  3998. SetsuccessStatus(m_checkACASKey);
  3999. Log.WriteInfoLog("Read ACAS Key Data...");
  4000. if (cfg_readcheck.ACASKeyReadcheck ? SerialCMD.ReadACASKeyData(TVPort, out result, out data, out error, SerailDelay) : true)
  4001. {
  4002. if (cfg_readcheck.ACASKeyReadcheck)
  4003. {
  4004. if (CommonMethod.CompareMD5(ACASKeyData, data))
  4005. {
  4006. SetsuccessStatus(m_readACASKey);
  4007. }
  4008. else
  4009. {
  4010. SetfailStatus(m_readACASKey);
  4011. ErrMsg = string.Format("{0} contrast ACAS Key Data fail!", SN);
  4012. Log.WriteErrorLog(ErrMsg);
  4013. goto end;
  4014. }
  4015. }
  4016. }
  4017. else
  4018. {
  4019. SetfailStatus(m_readACASKey);
  4020. ErrMsg = string.Format("{0} read ACAS Key Data fail!", SN);
  4021. Log.WriteErrorLog(ErrMsg);
  4022. goto end;
  4023. }
  4024. }
  4025. else
  4026. {
  4027. SetfailStatus(m_checkACASKey);
  4028. ErrMsg = string.Format("{0} Check ACAS Key Data fail!", SN);
  4029. Log.WriteErrorLog(ErrMsg);
  4030. goto end;
  4031. }
  4032. }
  4033. else
  4034. {
  4035. SetfailStatus(m_writeACASKey);
  4036. ErrMsg = string.Format("{0} Write ACAS Key Data fail!", SN);
  4037. Log.WriteErrorLog(ErrMsg);
  4038. goto end;
  4039. }
  4040. keyInfo.ACASKey_Data.result = true;
  4041. }
  4042. //Project ID 抄写检查
  4043. if (ProjectIDNote.Text != LResource.SkipCovering)
  4044. {
  4045. Log.WriteInfoLog("Write projectID...");
  4046. if (ProjectIDNote.Text == LResource.Covering || ProjectIDNote.Text == LResource.SkipReadCheck)
  4047. {
  4048. SetspecificText(ProjectIDNote, ProjectIDNote.Text, Color.FromArgb(128, 255, 128));
  4049. byte[] param = CommonMethod.InttoBytelist(Convert.ToInt32(ProjectIDText.Text));
  4050. Log.WriteInfoLog("Set projectID...");
  4051. if (SerialCMD.SetProjectId(TVPort, param, out result, out data, out error, SerailDelay))
  4052. {
  4053. if (ProjectIDNote.Text != LResource.SkipReadCheck)
  4054. {
  4055. Log.WriteInfoLog("Check projectID...");
  4056. if (cfg_writedone.PIDWriteDelay > 0)
  4057. {
  4058. Thread.Sleep(cfg_writedone.PIDWriteDelay);//MS6586切完PID需要强制等待3s
  4059. }
  4060. if (SerialCMD.GetProjectID(TVPort, out result, out data, out error, SerailDelay, CommonMethod.IsEDIDCopy(midListNow)))
  4061. {
  4062. int readpid2 = CommonMethod.BytelisttoInt(data);
  4063. if (readpid2.ToString() != ProjectIDText.Text)
  4064. {
  4065. SetcolorStatus(ProjectIDText, Color.Red);
  4066. ErrMsg = SN + " read project id:" + readpid2.ToString() + "different from written: " + ProjectIDText.Text + " error";
  4067. Log.WriteErrorLog(ErrMsg);
  4068. goto end;
  4069. }
  4070. else
  4071. {
  4072. SetcolorStatus(ProjectIDText, Color.Green);
  4073. }
  4074. }
  4075. else
  4076. {
  4077. SetcolorStatus(ProjectIDText, Color.Red);
  4078. ErrMsg = string.Format("{0} get project id error!", SN);
  4079. Log.WriteErrorLog(ErrMsg);
  4080. goto end;
  4081. }
  4082. }
  4083. else
  4084. {
  4085. Log.WriteInfoLog("Skip check projectID...");
  4086. }
  4087. }
  4088. else
  4089. {
  4090. SetcolorStatus(ProjectIDText, Color.Red);
  4091. ErrMsg = string.Format("{0} set project id error!", SN);
  4092. Log.WriteErrorLog(ErrMsg);
  4093. goto end;
  4094. }
  4095. }
  4096. else
  4097. {
  4098. if (SerialCMD.GetProjectID(TVPort, out result, out data, out error, SerailDelay, CommonMethod.IsEDIDCopy(midListNow)))
  4099. {
  4100. int readpid = CommonMethod.BytelisttoInt(data);
  4101. if (readpid.ToString() != ProjectIDText.Text)
  4102. {
  4103. MessageBoxButtons messButton = MessageBoxButtons.YesNoCancel;
  4104. DialogResult dr = MessageBox.Show(LResource.MainboardPID + readpid.ToString() + LResource.DifferentFromSetting + "\r\n" + LResource.CoveringPID, LResource.Error, messButton);
  4105. if (dr == DialogResult.Yes)
  4106. {
  4107. SetspecificText(ProjectIDNote, LResource.Covering, Color.FromArgb(128, 255, 128));
  4108. byte[] param = CommonMethod.InttoBytelist(Convert.ToInt32(ProjectIDText.Text));
  4109. if (SerialCMD.SetProjectId(TVPort, param, out result, out data, out error, SerailDelay))
  4110. {
  4111. if (cfg_writedone.PIDWriteDelay > 0)
  4112. {
  4113. Thread.Sleep(cfg_writedone.PIDWriteDelay);//MS6586切完PID需要强制等待3s
  4114. }
  4115. Log.WriteInfoLog("Check projectID...");
  4116. if (SerialCMD.GetProjectID(TVPort, out result, out data, out error, SerailDelay, CommonMethod.IsEDIDCopy(midListNow)))
  4117. {
  4118. int readpid2 = CommonMethod.BytelisttoInt(data);
  4119. if (readpid2.ToString() != ProjectIDText.Text)
  4120. {
  4121. SetcolorStatus(ProjectIDText, Color.Red);
  4122. ErrMsg = SN + " read project id:" + readpid2.ToString() + "different from written: " + ProjectIDText.Text + " error";
  4123. Log.WriteErrorLog(ErrMsg);
  4124. goto end;
  4125. }
  4126. else
  4127. {
  4128. SetcolorStatus(ProjectIDText, Color.Green);
  4129. }
  4130. }
  4131. else
  4132. {
  4133. SetcolorStatus(ProjectIDText, Color.Red);
  4134. ErrMsg = string.Format("{0} get project id error!", SN);
  4135. Log.WriteErrorLog(ErrMsg);
  4136. goto end;
  4137. }
  4138. }
  4139. else
  4140. {
  4141. SetcolorStatus(ProjectIDText, Color.Red);
  4142. ErrMsg = string.Format("{0} set project id error!", SN);
  4143. Log.WriteErrorLog(ErrMsg);
  4144. goto end;
  4145. }
  4146. }
  4147. else if (dr == DialogResult.No)
  4148. {
  4149. SetspecificText(ProjectIDNote, LResource.SkipCovering, Color.Yellow);
  4150. SetcolorStatus(ProjectIDText, Color.Yellow);
  4151. }
  4152. else
  4153. {
  4154. SetspecificText(ProjectIDNote, readpid.ToString(), Color.Red);
  4155. SetcolorStatus(ProjectIDText, Color.Red);
  4156. goto end;
  4157. }
  4158. }
  4159. else
  4160. {
  4161. SetcolorStatus(ProjectIDText, Color.FromArgb(128, 255, 128));
  4162. }
  4163. }
  4164. else
  4165. {
  4166. ErrMsg = string.Format("{0} Read ProjectID fail!", SN);
  4167. Log.WriteErrorLog(ErrMsg);
  4168. goto end;
  4169. }
  4170. }
  4171. }
  4172. //检查ClientType
  4173. if (ClientTypeNote.Text != LResource.SkipChecking)
  4174. {
  4175. Log.WriteInfoLog("Read ClientType...");
  4176. if (SerialCMD.GetClientType(TVPort, out result, out data, out error, SerailDelay))
  4177. {
  4178. string ctype = Encoding.ASCII.GetString(data);
  4179. if (ctype != ClientTypeText.Text)
  4180. {
  4181. MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
  4182. DialogResult dr = MessageBox.Show(LResource.MainboardCType + ctype + LResource.differentfromserver + ClientTypeText.Text + "\r\n" + LResource.SkipCTypeChecking, LResource.Error, messButton);
  4183. if (dr == DialogResult.OK)
  4184. {
  4185. SetspecificText(ClientTypeNote, LResource.SkipChecking, Color.Yellow);
  4186. SetcolorStatus(ClientTypeText, Color.Yellow);
  4187. }
  4188. else
  4189. {
  4190. SetspecificText(ClientTypeNote, ctype, Color.Red);
  4191. SetcolorStatus(ClientTypeText, Color.Red);
  4192. goto end;
  4193. }
  4194. }
  4195. else
  4196. {
  4197. SetcolorStatus(ClientTypeText, Color.FromArgb(128, 255, 128));
  4198. }
  4199. }
  4200. else
  4201. {
  4202. ErrMsg = string.Format("{0} Read ClientType fail!", SN);
  4203. Log.WriteErrorLog(ErrMsg);
  4204. goto end;
  4205. }
  4206. }
  4207. //白平衡初始化
  4208. if (FunctionSettingNow.WBInit)
  4209. {
  4210. Log.WriteInfoLog("WhiteBalance init...");
  4211. if (SerialCMD.WBInit(TVPort, out result, out data, out error, SerailDelay))
  4212. {
  4213. }
  4214. else
  4215. {
  4216. ErrMsg = string.Format("{0} WhiteBalance ini fail!", SN);
  4217. Log.WriteErrorLog(ErrMsg);
  4218. goto end;
  4219. }
  4220. }
  4221. //白平衡赋值
  4222. if (FunctionSettingNow.WriteWB)
  4223. {
  4224. Log.WriteInfoLog("Set normal RGB...");
  4225. if (SerialCMD.SetWBNormal(TVPort, FunctionSettingNow.NormalRGB, out result, out data, out error, SerailDelay))
  4226. {
  4227. Log.WriteInfoLog("Set cool RGB...");
  4228. if (SerialCMD.SetWBCool(TVPort, FunctionSettingNow.CoolRGB, out result, out data, out error, SerailDelay))
  4229. {
  4230. Log.WriteInfoLog("Set warm RGB...");
  4231. if (SerialCMD.SetWBWarm(TVPort, FunctionSettingNow.WarmRGB, out result, out data, out error, SerailDelay))
  4232. {
  4233. SetcolorStatus(WBPathText, Color.FromArgb(128, 255, 128));
  4234. }
  4235. else
  4236. {
  4237. ErrMsg = string.Format("{0} Set warm RGB fail!", SN);
  4238. Log.WriteErrorLog(ErrMsg);
  4239. goto end;
  4240. }
  4241. }
  4242. else
  4243. {
  4244. ErrMsg = string.Format("{0} Set cool RGB fail!", SN);
  4245. Log.WriteErrorLog(ErrMsg);
  4246. goto end;
  4247. }
  4248. }
  4249. else
  4250. {
  4251. ErrMsg = string.Format("{0} Set normal RGB fail!", SN);
  4252. Log.WriteErrorLog(ErrMsg);
  4253. goto end;
  4254. }
  4255. }
  4256. // 如果存在文件roku.info,优先使用文件内容;
  4257. if (File.Exists(LocalPath.localpath + "roku.info"))
  4258. midListNow.rokuCustomer = V2Method.GetRokuFileInfo();
  4259. //Roku客户服务信息抄写
  4260. if (midListNow.rokuCustomer != null )
  4261. {
  4262. string brand = midListNow.rokuCustomer.brand;
  4263. Log.WriteInfoLog("Write Roku brand...");
  4264. if (SerialCMD.SetROKUBrand(TVPort, Encoding.ASCII.GetBytes(brand), out result, out data, out error, SerailDelay))
  4265. {
  4266. Log.WriteInfoLog("Check Roku brand...");
  4267. if (SerialCMD.CheckROKUBrand(TVPort, out result, out data, out error, SerailDelay))
  4268. {
  4269. Log.WriteInfoLog("Read Roku brand...");
  4270. if (SerialCMD.GetROKUBrand(TVPort, out result, out data, out error, SerailDelay))
  4271. {
  4272. if (SerialInit.BytesCompare_Base64(data, Encoding.ASCII.GetBytes(brand)))
  4273. {
  4274. Log.WriteInfoLog("ROKU brand 写入成功:" + Encoding.ASCII.GetString(data));
  4275. }
  4276. else
  4277. {
  4278. ErrMsg = string.Format("{0} Contrast ROKU brand fail!", SN);
  4279. Log.WriteErrorLog(ErrMsg);
  4280. goto end;
  4281. }
  4282. }
  4283. else
  4284. {
  4285. ErrMsg = string.Format("{0} Read ROKU brand fail!", SN);
  4286. Log.WriteErrorLog(ErrMsg);
  4287. goto end;
  4288. }
  4289. }
  4290. else
  4291. {
  4292. ErrMsg = string.Format("{0} Check ROKU brand fail!", SN);
  4293. Log.WriteErrorLog(ErrMsg);
  4294. goto end;
  4295. }
  4296. }
  4297. else
  4298. {
  4299. ErrMsg = string.Format("{0} Write ROKU brand fail!", SN);
  4300. Log.WriteErrorLog(ErrMsg);
  4301. goto end;
  4302. }
  4303. string model = midListNow.rokuCustomer.oemmodel;
  4304. Log.WriteInfoLog("Write Roku model...");
  4305. if (SerialCMD.SetModelName(TVPort, Encoding.ASCII.GetBytes(model), out result, out data, out error, SerailDelay))
  4306. {
  4307. Log.WriteInfoLog("Check Roku model...");
  4308. if (SerialCMD.CheckModelName(TVPort, out result, out data, out error, SerailDelay))
  4309. {
  4310. Log.WriteInfoLog("Read Roku model...");
  4311. if (SerialCMD.GetModelName(TVPort, out result, out data, out error, SerailDelay))
  4312. {
  4313. if (SerialInit.BytesCompare_Base64(data, Encoding.ASCII.GetBytes(model)))
  4314. {
  4315. Log.WriteInfoLog("ROKU model 写入成功:" + Encoding.ASCII.GetString(data));
  4316. }
  4317. else
  4318. {
  4319. ErrMsg = string.Format("{0} Contrast ROKU model fail!", SN);
  4320. Log.WriteErrorLog(ErrMsg);
  4321. goto end;
  4322. }
  4323. }
  4324. else
  4325. {
  4326. ErrMsg = string.Format("{0} Read ROKU model fail!", SN);
  4327. Log.WriteErrorLog(ErrMsg);
  4328. goto end;
  4329. }
  4330. }
  4331. else
  4332. {
  4333. ErrMsg = string.Format("{0} Check ROKU model fail!", SN);
  4334. Log.WriteErrorLog(ErrMsg);
  4335. goto end;
  4336. }
  4337. }
  4338. else
  4339. {
  4340. ErrMsg = string.Format("{0} Write ROKU model fail!", SN);
  4341. Log.WriteErrorLog(ErrMsg);
  4342. goto end;
  4343. }
  4344. string[] dateInit = midListNow.rokuCustomer.productiondate.Split('-');
  4345. byte[] productdate = new byte[3] { Convert.ToByte(dateInit[0]), Convert.ToByte(dateInit[1]), Convert.ToByte(dateInit[2]) };
  4346. Log.WriteInfoLog("Write Roku production date...");
  4347. if (SerialCMD.SetROKUProductionDate(TVPort, productdate, out result, out data, out error, SerailDelay))
  4348. {
  4349. Log.WriteInfoLog("Check Roku production date...");
  4350. if (SerialCMD.CheckROKUProductionDate(TVPort, out result, out data, out error, SerailDelay))
  4351. {
  4352. Log.WriteInfoLog("Read Roku production date...");
  4353. if (SerialCMD.GetROKUProductionDate(TVPort, out result, out data, out error, SerailDelay))
  4354. {
  4355. string date = "20" + productdate[0].ToString() + "." + productdate[1].ToString() + ".WW" + productdate[2].ToString();
  4356. if (Encoding.ASCII.GetString(data) == date)
  4357. {
  4358. Log.WriteInfoLog("ROKU production date 写入成功:" + Encoding.ASCII.GetString(data));
  4359. }
  4360. else
  4361. {
  4362. ErrMsg = string.Format("{0} Contrast ROKU production fail!", SN);
  4363. Log.WriteErrorLog(ErrMsg);
  4364. goto end;
  4365. }
  4366. }
  4367. else
  4368. {
  4369. ErrMsg = string.Format("{0} Read ROKU production fail!", SN);
  4370. Log.WriteErrorLog(ErrMsg);
  4371. goto end;
  4372. }
  4373. }
  4374. else
  4375. {
  4376. ErrMsg = string.Format("{0} Check ROKU production fail!", SN);
  4377. Log.WriteErrorLog(ErrMsg);
  4378. goto end;
  4379. }
  4380. }
  4381. else
  4382. {
  4383. ErrMsg = string.Format("{0} Write ROKU production fail!", SN);
  4384. Log.WriteErrorLog(ErrMsg);
  4385. goto end;
  4386. }
  4387. if ( midListNow.rokuCustomer.data != null && midListNow.rokuCustomer.data.Count != 0 )
  4388. {
  4389. foreach (var item in midListNow.rokuCustomer.data)
  4390. {
  4391. Log.WriteInfoLog(string.Format("{0} to be write", item.region));
  4392. string region = item.region;
  4393. Log.WriteInfoLog("Write Roku region...");
  4394. if (SerialCMD.SetROKURegion(TVPort, Encoding.ASCII.GetBytes(region), out result, out data, out error, SerailDelay))
  4395. {
  4396. Log.WriteInfoLog("Check Roku region...");
  4397. if (SerialCMD.CheckROKURegion(TVPort, out result, out data, out error, SerailDelay))
  4398. {
  4399. Log.WriteInfoLog("Read Roku region...");
  4400. if (SerialCMD.GetROKURegion(TVPort, out result, out data, out error, SerailDelay))
  4401. {
  4402. if (SerialInit.BytesCompare_Base64(data, Encoding.ASCII.GetBytes(region)))
  4403. {
  4404. Log.WriteInfoLog("ROKU region 写入成功:" + Encoding.ASCII.GetString(data));
  4405. }
  4406. else
  4407. {
  4408. ErrMsg = string.Format("{0} Contrast ROKU region fail!", SN);
  4409. Log.WriteErrorLog(ErrMsg);
  4410. goto end;
  4411. }
  4412. }
  4413. else
  4414. {
  4415. ErrMsg = string.Format("{0} Read ROKU region fail!", SN);
  4416. Log.WriteErrorLog(ErrMsg);
  4417. goto end;
  4418. }
  4419. }
  4420. else
  4421. {
  4422. ErrMsg = string.Format("{0} Check ROKU region fail!", SN);
  4423. Log.WriteErrorLog(ErrMsg);
  4424. goto end;
  4425. }
  4426. }
  4427. else
  4428. {
  4429. ErrMsg = string.Format("{0} Write ROKU region fail!", SN);
  4430. Log.WriteErrorLog(ErrMsg);
  4431. goto end;
  4432. }
  4433. string phone = item.supportphone;
  4434. Log.WriteInfoLog("Write Roku phone...");
  4435. if (SerialCMD.SetROKUSupportPhone(TVPort, Encoding.ASCII.GetBytes(phone), out result, out data, out error, SerailDelay))
  4436. {
  4437. Log.WriteInfoLog("Check Roku phone...");
  4438. if (SerialCMD.CheckROKUSupportPhone(TVPort, out result, out data, out error, SerailDelay))
  4439. {
  4440. Log.WriteInfoLog("Read Roku phone...");
  4441. if (SerialCMD.GetROKUSupportPhone(TVPort, out result, out data, out error, SerailDelay))
  4442. {
  4443. if (SerialInit.BytesCompare_Base64(data, Encoding.ASCII.GetBytes(phone)))
  4444. {
  4445. Log.WriteInfoLog("ROKU phone 写入成功:" + Encoding.ASCII.GetString(data));
  4446. }
  4447. else
  4448. {
  4449. ErrMsg = string.Format("{0} Contrast ROKU phone fail!", SN);
  4450. Log.WriteErrorLog(ErrMsg);
  4451. goto end;
  4452. }
  4453. }
  4454. else
  4455. {
  4456. ErrMsg = string.Format("{0} Read ROKU phone fail!", SN);
  4457. Log.WriteErrorLog(ErrMsg);
  4458. goto end;
  4459. }
  4460. }
  4461. else
  4462. {
  4463. ErrMsg = string.Format("{0} Check ROKU phone fail!", SN);
  4464. Log.WriteErrorLog(ErrMsg);
  4465. goto end;
  4466. }
  4467. }
  4468. else
  4469. {
  4470. ErrMsg = string.Format("{0} Write ROKU phone fail!", SN);
  4471. Log.WriteErrorLog(ErrMsg);
  4472. goto end;
  4473. }
  4474. string url = item.supporturl;
  4475. Log.WriteInfoLog("Write Roku url...");
  4476. if (SerialCMD.SetROKUSupportURL(TVPort, Encoding.ASCII.GetBytes(url), out result, out data, out error, SerailDelay))
  4477. {
  4478. Log.WriteInfoLog("Check Roku url...");
  4479. if (SerialCMD.CheckROKUSupportURL(TVPort, out result, out data, out error, SerailDelay))
  4480. {
  4481. Log.WriteInfoLog("Read Roku url...");
  4482. if (SerialCMD.GetROKUSupportURL(TVPort, out result, out data, out error, SerailDelay))
  4483. {
  4484. if (SerialInit.BytesCompare_Base64(data, Encoding.ASCII.GetBytes(url)))
  4485. {
  4486. Log.WriteInfoLog("ROKU url 写入成功:" + Encoding.ASCII.GetString(data));
  4487. }
  4488. else
  4489. {
  4490. ErrMsg = string.Format("{0} Contrast ROKU url fail!", SN);
  4491. Log.WriteErrorLog(ErrMsg);
  4492. goto end;
  4493. }
  4494. }
  4495. else
  4496. {
  4497. ErrMsg = string.Format("{0} Read ROKU url fail!", SN);
  4498. Log.WriteErrorLog(ErrMsg);
  4499. goto end;
  4500. }
  4501. }
  4502. else
  4503. {
  4504. ErrMsg = string.Format("{0} Check ROKU url fail!", SN);
  4505. Log.WriteErrorLog(ErrMsg);
  4506. goto end;
  4507. }
  4508. }
  4509. else
  4510. {
  4511. ErrMsg = string.Format("{0} Write ROKU url fail!", SN);
  4512. Log.WriteErrorLog(ErrMsg);
  4513. goto end;
  4514. }
  4515. }
  4516. }
  4517. if (midListNow.rokuCustomer.remotetype.Length > 0 && midListNow.rokuCustomer.remotetype != "null")
  4518. {
  4519. byte[] remotetype = new byte[1] { Convert.ToByte(midListNow.rokuCustomer.remotetype) };
  4520. Log.WriteInfoLog("Write Roku remotetype...");
  4521. if (SerialCMD.SetROKURemoteType(TVPort, remotetype, out result, out data, out error, SerailDelay))
  4522. {
  4523. Log.WriteInfoLog("Check Roku remotetype...");
  4524. if (SerialCMD.CheckROKURemoteType(TVPort, out result, out data, out error, SerailDelay))
  4525. {
  4526. Log.WriteInfoLog("Read Roku remotetype...");
  4527. if (SerialCMD.GetROKURemoteType(TVPort, out result, out data, out error, SerailDelay))
  4528. {
  4529. if (SerialInit.BytesCompare_Base64(data, remotetype))
  4530. {
  4531. Log.WriteInfoLog("ROKU remotetype 写入成功:" + Encoding.ASCII.GetString(data));
  4532. }
  4533. else
  4534. {
  4535. ErrMsg = string.Format("{0} Contrast ROKU remotetype fail!", SN);
  4536. Log.WriteErrorLog(ErrMsg);
  4537. goto end;
  4538. }
  4539. }
  4540. else
  4541. {
  4542. ErrMsg = string.Format("{0} Read ROKU remotetype fail!", SN);
  4543. Log.WriteErrorLog(ErrMsg);
  4544. goto end;
  4545. }
  4546. }
  4547. else
  4548. {
  4549. ErrMsg = string.Format("{0} Check ROKU remotetype fail!", SN);
  4550. Log.WriteErrorLog(ErrMsg);
  4551. goto end;
  4552. }
  4553. }
  4554. else
  4555. {
  4556. ErrMsg = string.Format("{0} Write ROKU remotetype fail!", SN);
  4557. Log.WriteErrorLog(ErrMsg);
  4558. goto end;
  4559. }
  4560. }
  4561. SetcolorStatus(ProductMsg_Text, Color.FromArgb(128, 255, 128));
  4562. }
  4563. // DSN抄写;
  4564. if (WriteDSN.Checked)
  4565. {
  4566. if (FunctionSettingNow.MITVEnable || FunctionSettingNow.IndiaMITVEnable)
  4567. {// 小米的DSN抄写不用这么多处理;
  4568. if (!CommonMethod.IsNumberAndWord(keyInfo.DSN.data))
  4569. {
  4570. ErrMsg = string.Format("DSN format error!\r\n{0}", keyInfo.DSN.data);
  4571. Log.WriteErrorLog(ErrMsg);
  4572. goto end;
  4573. }
  4574. byte[] DSNData = System.Text.Encoding.ASCII.GetBytes(keyInfo.DSN.data);
  4575. Log.WriteInfoLog("Write DSN...");
  4576. if (SerialCMD.SetFireTVDSN(TVPort, DSNData, out result, out data, out error, SerailDelay))
  4577. {
  4578. SetsuccessStatus(m_writeDSN);
  4579. Log.WriteInfoLog("Check DSN...");
  4580. if (cfg_writecheck.DSNCheckcheck ? SerialCMD.CheckFireTVDSN(TVPort, out result, out data, out error, SerailDelay) : true)
  4581. {
  4582. SetsuccessStatus(m_checkDSN);
  4583. Log.WriteInfoLog("Read DSN...");
  4584. if (cfg_readcheck.DSNReadcheck ? SerialCMD.GetFireTVDSN(TVPort, out result, out data, out error, SerailDelay) : true)
  4585. {
  4586. if (SerialInit.BytesCompare_Base64(data, DSNData))
  4587. {
  4588. SetsuccessStatus(m_readDSN);
  4589. //DSN读取别对成功
  4590. }
  4591. else
  4592. {
  4593. SetfailStatus(m_readDSN);
  4594. ErrMsg = string.Format("{0} contrast DSN fail!", SN);
  4595. Log.WriteErrorLog(ErrMsg);
  4596. goto end;
  4597. }
  4598. }
  4599. else
  4600. {
  4601. SetfailStatus(m_readDSN);
  4602. ErrMsg = string.Format("{0} read DSN fail!", SN);
  4603. Log.WriteErrorLog(ErrMsg);
  4604. goto end;
  4605. }
  4606. }
  4607. else
  4608. {
  4609. SetfailStatus(m_checkDSN);
  4610. ErrMsg = string.Format("{0} check DSN fail!", SN);
  4611. Log.WriteErrorLog(ErrMsg);
  4612. goto end;
  4613. }
  4614. }
  4615. else
  4616. {
  4617. SetfailStatus(m_writeDSN);
  4618. ErrMsg = string.Format("{0} Write DSN fail!", SN);
  4619. Log.WriteErrorLog(ErrMsg);
  4620. goto end;
  4621. }
  4622. }
  4623. else
  4624. {// 如果是G客户,要在抄写其他key前时行fsn+psn查重处理;
  4625. // 计算函数耗时;
  4626. Stopwatch watch = new Stopwatch();
  4627. watch.Start();
  4628. if (SN == null)
  4629. {
  4630. MessageBox.Show("Please scan to trigger testing");
  4631. goto end;
  4632. }
  4633. if (SN.Trim().Length == 0)
  4634. {
  4635. SetsuccessStatus(m_writeDSN);
  4636. Log.WriteInfoLog("Check DSN...");
  4637. if (cfg_writecheck.DSNCheckcheck ? SerialCMD.CheckFireTVDSN(TVPort, out result, out data, out error, SerailDelay) : true)
  4638. {
  4639. SetsuccessStatus(m_checkDSN);
  4640. Log.WriteInfoLog("Read DSN...");
  4641. if (cfg_readcheck.DSNReadcheck ? SerialCMD.GetFireTVDSN(TVPort, out result, out data, out error, SerailDelay) : true)
  4642. {
  4643. if (SerialInit.BytesCompare_Base64(data, DSNData))
  4644. {
  4645. SetsuccessStatus(m_readDSN);
  4646. //DSN读取别对成功
  4647. }
  4648. else
  4649. {
  4650. SetfailStatus(m_readDSN);
  4651. ErrMsg = string.Format("{0} contrast DSN fail!", SN);
  4652. Log.WriteErrorLog(ErrMsg);
  4653. goto end;
  4654. }
  4655. }
  4656. else
  4657. {
  4658. SetfailStatus(m_readDSN);
  4659. ErrMsg = string.Format("{0} read DSN fail!", SN);
  4660. Log.WriteErrorLog(ErrMsg);
  4661. goto end;
  4662. }
  4663. }
  4664. else
  4665. {
  4666. SetfailStatus(m_checkDSN);
  4667. ErrMsg = string.Format("{0} check DSN fail!", SN);
  4668. Log.WriteErrorLog(ErrMsg);
  4669. goto end;
  4670. }
  4671. }
  4672. else
  4673. {
  4674. ErrMsg = string.Format("{0} Get Device Code Error", SN);
  4675. Log.WriteErrorLog(ErrMsg);
  4676. goto end;
  4677. }
  4678. watch.Stop();
  4679. Log.WriteInfoLog(string.Format("Write DSN Elapsed={0}", watch.Elapsed.TotalMilliseconds));
  4680. }
  4681. keyInfo.DSN.result = true;
  4682. }
  4683. #region 小米FireTV功能;
  4684. if (FunctionSettingNow.MITVEnable || FunctionSettingNow.IndiaMITVEnable)
  4685. {
  4686. #if true
  4687. // 读取PSN;
  4688. byte[] result_psn;
  4689. byte[] data_psn;
  4690. if (SerialCMD.ReadFireTVPSN(TVPort, out result_psn, out data_psn, out error, SerailDelay))
  4691. {
  4692. _MiKey._PSN = Encoding.ASCII.GetString(data_psn);
  4693. }
  4694. else
  4695. {
  4696. ErrMsg = string.Format("读取PSN失败 {0}", error);
  4697. Log.WriteErrorLog(ErrMsg);
  4698. goto end;
  4699. }
  4700. #else
  4701. //小米 2717版不可读 PSN的24K需要生产,更新一版不读取PSN功能的抄写软件
  4702. _MiKey._PSN = DateTime.Now.ToString("yyyy-MM-dd-HH-mm:ss");
  4703. #endif
  4704. // CVT抄写: Hashkey、HDCP_KEY1.4、HDCP2.2_KEY、CI_PLUS_KEY、ECP_KEY、FVP
  4705. if (cfg_writecheck.HashCheckcheck ? !SerialCMD.CheckFireTVHashkey(TVPort, out result, out data, out error, SerailDelay) : false)
  4706. {
  4707. ErrMsg = string.Format("Check Hashkey失败 {0}", error);
  4708. Log.WriteErrorLog(ErrMsg);
  4709. goto end;
  4710. }
  4711. if (cfg_writecheck.CI_plusCheckcheck ? !SerialCMD.CheckCikey(TVPort, out result, out data, out error, SerailDelay) : false)
  4712. {
  4713. ErrMsg = string.Format("Check Cikey失败 {0}", error);
  4714. Log.WriteErrorLog(ErrMsg);
  4715. goto end;
  4716. }
  4717. if (cfg_writecheck.ECPCheckcheck ? !SerialCMD.CheckECP(TVPort, out result, out data, out error, SerailDelay) : false)
  4718. {
  4719. ErrMsg = string.Format("Check Cikey失败 {0}", error);
  4720. Log.WriteErrorLog(ErrMsg);
  4721. goto end;
  4722. }
  4723. if (cfg_writecheck.HDCPCheckcheck ? !SerialCMD.CheckHDCP(TVPort, out result, out data, out error, SerailDelay) : false)
  4724. {
  4725. ErrMsg = string.Format("Check HDCP 失败 {0}", error);
  4726. Log.WriteErrorLog(ErrMsg);
  4727. goto end;
  4728. }
  4729. if (cfg_writecheck.HDCP22Checkcheck ? !SerialCMD.CheckHDCP22(TVPort, out result, out data, out error, SerailDelay) : false)
  4730. {
  4731. ErrMsg = string.Format("Check HDCP22 失败 {0}", error);
  4732. Log.WriteErrorLog(ErrMsg);
  4733. goto end;
  4734. }
  4735. // 读取HDCP;
  4736. if (cfg_readcheck.HDCPReadcheck)
  4737. {
  4738. if (!SerialCMD.GetHDCPKey(TVPort, out result, out data, out error, SerailDelay))
  4739. {
  4740. ErrMsg = string.Format("读取HDCP失败 {0}", error);
  4741. Log.WriteErrorLog(ErrMsg);
  4742. _MiKey._HDCP14 = 0;
  4743. goto end;
  4744. }
  4745. else
  4746. {
  4747. _MiKey._HDCP14 = data.Length;
  4748. }
  4749. }
  4750. // 读取HDCP;
  4751. if (cfg_readcheck.HDCP22Readcheck)
  4752. {
  4753. if (!SerialCMD.GetHDCPKey22(TVPort, out result, out data, out error, SerailDelay))
  4754. {
  4755. ErrMsg = string.Format("读取HDCP22失败 {0}", error);
  4756. Log.WriteErrorLog(ErrMsg);
  4757. _MiKey._HDCP22 = 0;
  4758. goto end;
  4759. }
  4760. else
  4761. {
  4762. _MiKey._HDCP22 = data.Length;
  4763. }
  4764. }
  4765. }
  4766. #endregion
  4767. // 生成IDM报文;
  4768. keycontent = GenerateReportInfo();
  4769. //自定义指令发送
  4770. if (FunctionSettingNow.CustomCMD != null)
  4771. {
  4772. if (FunctionSettingNow.CustomCMD.Count > 0)
  4773. {
  4774. foreach (string cmd in FunctionSettingNow.CustomCMD.Values)
  4775. {
  4776. byte[] Cmddata = SerialInit.HexToByte(cmd);
  4777. TVPort.Write(Cmddata, 0, Cmddata.Count());
  4778. Thread.Sleep(500);
  4779. }
  4780. }
  4781. }
  4782. #region 波兰工厂DHA功能-抄写所有Key后执行Trigger和Check指令;
  4783. if (FunctionSettingNow.DHA == true)
  4784. {
  4785. Log.WriteInfoLog("Start to Trigger DHA...");
  4786. if (SerialCMD.TriggerDHA(TVPort, out result, out data, out error, SerailDelay))
  4787. {
  4788. Thread.Sleep(FunctionSettingNow.CheckDHAWaitTime);
  4789. Log.WriteInfoLog("Start to Check DHA...");
  4790. if (!SerialCMD.CheckDHA(TVPort, out result, out data, out error, SerailDelay))
  4791. {
  4792. ErrMsg = string.Format("{0} Check DHA Fail", SN);
  4793. Log.WriteErrorLog(ErrMsg);
  4794. goto end;
  4795. }
  4796. }
  4797. else
  4798. {
  4799. ErrMsg = string.Format("{0} Trigger DHA Fail", SN);
  4800. Log.WriteErrorLog(ErrMsg);
  4801. goto end;
  4802. }
  4803. }
  4804. #endregion
  4805. #endregion
  4806. #endif
  4807. //数据上传
  4808. if (midListNow.host == "LocalPC" && !preloadNow)
  4809. {// 离线抄写
  4810. if (GetLocalKeyCount.DeleteLocalKeys(keypath, keyStream, keyReader))
  4811. {
  4812. TestResult = 1;
  4813. UploadCopyCount();
  4814. LocalTxtRecord.LocalRecord(keycontent + "sversionid=" + localmidList.version + "&clienttype=" + localmidList.clienttype + "&ordernum=" + orderNow + "\r\n", orderNow);
  4815. }
  4816. else
  4817. {
  4818. ErrMsg = "Fail to delete local keys";
  4819. Log.WriteErrorLog(ErrMsg);
  4820. goto end;
  4821. }
  4822. }
  4823. else if (preloadNow)
  4824. {// 预绑定抄写;
  4825. //更新DB抄写状态
  4826. if (SQLiteHelper.UpdateCopyStatus(localDBNow, SN, out string copydate))
  4827. {
  4828. UploadCopyCount();
  4829. TestResult = 1;
  4830. }
  4831. else
  4832. {
  4833. ErrMsg = string.Format("{0} update copy record fail!", SN);
  4834. Log.WriteErrorLog(ErrMsg);
  4835. goto end;
  4836. }
  4837. //上传抄写状态
  4838. if (midListNow.host != "LocalPC")
  4839. //CommonMethod.UploadPreloadCopyResult(MidAddressNow.host, copydate, SN, localDBNow, errorDBNow, false, "", FunctionSettingNow.ReportTimeOut);
  4840. V2Method.ReportOfflineData(MidAddressNow.host, copydate, SN, localDBNow, errorDBNow, false, "");
  4841. }
  4842. else if (!CommonMethod.HTTPChecker(midListNow.host))
  4843. {
  4844. Log.WriteGetKeyLog("Order:" + orderNow + " host is null,scanning sn:" + SN);
  4845. TestResult = 1;
  4846. UploadCopyCount();
  4847. UpdateKeys(midListNow.keytype, false);
  4848. }
  4849. else
  4850. {// 在线抄写;
  4851. if (WriteDID.Checked)
  4852. {
  4853. string postjson = V2Method.GetReportJson(orderNow, SN, isNodid: false, midListNow.clienttype, midListNow.version, ProjectIDText.Text, ref keyInfo, FunctionSettingNow.MITVEnable || FunctionSettingNow.IndiaMITVEnable, ref _MiKey);
  4854. if (V2Method.ReportOnlineData(midListNow.host, orderNow, postjson, errorDBNow, false, "", FunctionSettingNow.ReportTimeOut))
  4855. {
  4856. TestResult = 1;
  4857. }
  4858. else
  4859. {
  4860. TestResult = 0;
  4861. UploadCopyCount();
  4862. ErrMsg = "上报结果到MID系统失败";
  4863. Log.WriteErrorLog(ErrMsg);
  4864. UpdateKeys(midListNow.keytype, false);
  4865. goto end;
  4866. }
  4867. }
  4868. else
  4869. {
  4870. // 烧录PSN的不用上传;
  4871. if (!WritePSN.Checked)
  4872. {
  4873. if (SN.Trim().Length > 0)
  4874. {
  4875. keycontent += "nodid=true&";
  4876. string postjson = V2Method.GetReportJson(orderNow, SN, isNodid: true, midListNow.clienttype, midListNow.version, ProjectIDText.Text, ref keyInfo, FunctionSettingNow.MITVEnable || FunctionSettingNow.IndiaMITVEnable, ref _MiKey);
  4877. if (V2Method.ReportOnlineData(midListNow.host, orderNow, postjson, errorDBNow, false, "", FunctionSettingNow.ReportTimeOut))
  4878. {
  4879. TestResult = 1;
  4880. }
  4881. else
  4882. {
  4883. TestResult = 0;
  4884. UploadCopyCount();
  4885. ErrMsg = "上报结果到MID系统失败";
  4886. Log.WriteErrorLog(ErrMsg);
  4887. UpdateKeys(midListNow.keytype, false);
  4888. goto end;
  4889. }
  4890. }
  4891. else
  4892. {
  4893. LocalTxtRecord.LocalRecord(midListNow.host + "/v1/report.do?\r\n" + keycontent + "sversionid=" + midListNow.version + "&clienttype=" + midListNow.clienttype + "&ordernum=" + orderNow + "\r\n\r\n", orderNow);
  4894. if (FunctionSettingNow.AllowNoScanning)
  4895. {
  4896. TestResult = 1;
  4897. }
  4898. else
  4899. {
  4900. ErrMsg = "未扫码启动数据抄写";
  4901. Log.WriteErrorLog(ErrMsg);
  4902. MessageBox.Show("You must scan to start the burning!");
  4903. TestResult = 0;
  4904. }
  4905. }
  4906. }
  4907. }
  4908. // 上报完成后,更新本地数据库Key的数量;
  4909. UploadCopyCount();
  4910. // 同时,在线更新Key数量;
  4911. UpdateKeys(midListNow.keytype, false);
  4912. }
  4913. if (FunctionSettingNow.ExportSNACASID)
  4914. {// 只有抄写成功,才输出ACASID;
  4915. CommonMethod.ExportSNACASID(orderNow, SN, strACASID);
  4916. if (!SanhuaMethod.UploadIdcData(SN, strACASID, out error))
  4917. {
  4918. TestResult = 0;
  4919. ErrMsg = string.Format("{0} UploadIdcData fail! {1}", SN, error);
  4920. Log.WriteErrorLog(ErrMsg);
  4921. goto end;
  4922. }
  4923. }
  4924. if (CommonMethod.GetLoginAccout().Equals("Sanhua", StringComparison.OrdinalIgnoreCase))
  4925. {
  4926. SerialCMD.ReadJapaneseACASID(TVPort, out result, out data, out error, SerailDelay);
  4927. CommonMethod.ExportSNACASID(orderNow, SN, Encoding.ASCII.GetString(data));
  4928. }
  4929. #region 小米FireTV功能;
  4930. if (FunctionSettingNow.MITVEnable || FunctionSettingNow.IndiaMITVEnable)
  4931. {
  4932. if (!ReportMIInfo(out error))
  4933. {
  4934. TestResult = 0;
  4935. ErrMsg = string.Format("{0} ReportMIInfo ini fail! {1}", SN, error);
  4936. Log.WriteErrorLog(ErrMsg);
  4937. goto end;
  4938. }
  4939. }
  4940. #endregion
  4941. Thread.Sleep(FunctionSettingNow.Wait_after_completion);
  4942. SetsuccessStatus(ResultStatus);
  4943. end:
  4944. // 退出工厂模式;
  4945. if (FunctionSettingNow.LeaveFactory ? !SerialCMD.LeaveFactory(TVPort, out result, out data, out error, SerailDelay) : false )
  4946. {
  4947. ErrMsg = string.Format("LeaveFactory Fail\r\n {0}", SN);
  4948. Log.WriteErrorLog(ErrMsg);
  4949. }
  4950. #region 只有惠州工厂才启用G客户防呆措施;
  4951. if (FunctionSettingNow.NTF)
  4952. {
  4953. string strLastResult = "";
  4954. string strLastSN = CommonMethod.ReadProfileString("MOKAFactoryTools", "LastGSN", "");
  4955. if (strLastSN.Equals(SN, StringComparison.OrdinalIgnoreCase))
  4956. {
  4957. if (TestResult == 0)
  4958. {
  4959. int lastCount = 0;
  4960. // 更新连续测试中累计失败的次数
  4961. string strFailCount = CommonMethod.ReadProfileString("MOKAFactoryTools", "GFailCount", "0");
  4962. int.TryParse(strFailCount, out lastCount);
  4963. CommonMethod.WriteProfileString("MOKAFactoryTools", "GFailCount", (++lastCount).ToString());
  4964. if (lastCount >= 2)
  4965. {// 累计2次Fail;
  4966. ShowVerifyDelegate("累计2次测试失败,禁止再测试,请做好坏机标记");
  4967. }
  4968. }
  4969. // 获取上一次抄写状态;
  4970. strLastResult = CommonMethod.ReadProfileString("MOKAFactoryTools", "LastGResult", "");
  4971. // 更新抄写结果;
  4972. CommonMethod.WriteProfileString("MOKAFactoryTools", "LastGResult", TestResult != 0 ? "1" : "0");
  4973. }
  4974. else
  4975. {
  4976. CommonMethod.WriteProfileString("MOKAFactoryTools", "LastGSN", SN);
  4977. // 重置连续测试中累计失败的次数为0;
  4978. CommonMethod.WriteProfileString("MOKAFactoryTools", "GFailCount", TestResult == 0 ? "1" : "0");
  4979. // 更新抄写状态;
  4980. CommonMethod.WriteProfileString("MOKAFactoryTools", "LastGResult", TestResult != 0 ? "1" : "0");
  4981. // 如果是试产NTF,且第一次测试就Fail,提示再测试多一次;
  4982. if (TestResult == 0 && nOrderType == 0)
  4983. {
  4984. Log.WriteErrorLog("试产订单:请再测试一次\r\n第一次测试为FAIL,请再测试确认结果!");
  4985. ShowVerifyDelegate("试产订单:请再测试一次\r\n第一次测试为FAIL,请再测试确认结果!");
  4986. }
  4987. }
  4988. if (strLastResult.ToString().Equals("0") && (TestResult == 1) && (nOrderType == 0))
  4989. {
  4990. // 上次抄写是失败,这次是成功的,试产NTF要再次要求抄写一次才能上报AMTest.
  4991. ErrMsg = "试产订单:请再测试一次\r\n上一次测试为FAIL,需要连续2次PASS,请再测试确认结果!";
  4992. Log.WriteErrorLog(ErrMsg);
  4993. ShowVerifyDelegate(ErrMsg);
  4994. // 仍设置为失败;
  4995. TestResult = 2;
  4996. }
  4997. if (!ntfBLL.SetDataBuringResult(FunctionSettingNow.Line, FunctionSettingNow.Station, SN, orderNow, keyInfo.DSN, TestResult == 0 ? false : true, strLastSN, nOrderType, TestResult == 0 ? ErrMsg : ""))
  4998. {
  4999. //ntf失败,也需要提示;
  5000. ErrMsg = string.Format("统计NTF失败:{0}", SN);
  5001. Log.WriteErrorLog(ErrMsg);
  5002. TestResult = 0;
  5003. }
  5004. else
  5005. {
  5006. if ((TestResult == 1) && ntfBLL.ResultType.Equals("NTF", StringComparison.OrdinalIgnoreCase))
  5007. {
  5008. // TestResut == 0 && TestResut == 2时,也不提示NTF;
  5009. ErrMsg = string.Format("结果类型为NTF,请将产品做好NTF标记:{0}", SN);
  5010. ShowVerifyDelegate(ErrMsg);
  5011. }
  5012. }
  5013. if (TestResult != 2)
  5014. { // 上报抄写结果到MES系统中;
  5015. string strOutMsg;
  5016. string returnObject;
  5017. if (!GMethod.ReportDataBurningResultToMES(SN, keyInfo.DSN, (TestResult != 0) ? "Pass" : "Fail", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), errorDBNow, out strOutMsg, out returnObject))
  5018. {
  5019. ErrMsg = string.Format("上报抄写结果到MES失败,请紧急处理:{0}", strOutMsg);
  5020. Log.WriteErrorLog(ErrMsg);
  5021. // 上报MES失败,重置为False
  5022. TestResult = 0;
  5023. }
  5024. // 将测试结果保存到Kayla要求的csv文件中;
  5025. GMethod.GeneratKaylaData(FunctionSettingNow.Line, FunctionSettingNow.Station, OrderText.Text, SN, startTime, DateTime.Now, returnObject, keyInfo, TestResult != 0 ? true : false);
  5026. }
  5027. }
  5028. #endregion
  5029. if (TestResult == 0)
  5030. {
  5031. if (ErrMsg == "")
  5032. ErrMsg = error;
  5033. SetfailStatus(ResultStatus);
  5034. if (midListNow.host == "LocalPC" && !preloadNow)
  5035. {
  5036. GetLocalKeyCount.UnlockLocalKeys(keypath, keyStream, keyReader);
  5037. }
  5038. // 启动NG弹框功能;
  5039. ShowVerifyDelegate(ErrMsg);
  5040. Thread.Sleep(300);
  5041. }
  5042. if (midListNow.host == "LocalPC" && !preloadNow)
  5043. {
  5044. GetLocalKeysCount();
  5045. }
  5046. stop:
  5047. timer1.Stop();
  5048. usingTime = 0;
  5049. #if !SIMULATION
  5050. SN = "";
  5051. EnableText(SNText);
  5052. #endif
  5053. EnableButton(BtnClickstart);
  5054. }
  5055. /// <summary>
  5056. /// 显示白平衡配置
  5057. /// </summary>
  5058. /// <param name="sender"></param>
  5059. /// <param name="e"></param>
  5060. private void OnBtnWBView(object sender, EventArgs e)
  5061. {
  5062. SNText.Focus();
  5063. if (FunctionSettingNow.WriteWB)
  5064. {
  5065. MessageBox.Show("NormalR:" + FunctionSettingNow.NormalRGB[0] + "\r\nNormalG:" + FunctionSettingNow.NormalRGB[1] + "\r\nNormalB:" + FunctionSettingNow.NormalRGB[2] + "\r\nCoolR:" + FunctionSettingNow.CoolRGB[0] + "\r\nCoolG:" + FunctionSettingNow.CoolRGB[1] + "\r\nCoolB:" + FunctionSettingNow.CoolRGB[2] + "\r\nWarmR:" + FunctionSettingNow.WarmRGB[0] + "\r\nWarmG:" + FunctionSettingNow.WarmRGB[1] + "\r\nWarmB:" + FunctionSettingNow.WarmRGB[2]);
  5066. }
  5067. else
  5068. {
  5069. MessageBox.Show(LResource.WBNoSet);
  5070. }
  5071. }
  5072. /// <summary>
  5073. /// 更新key的状态
  5074. /// </summary>
  5075. /// <param name="keys">GetMIDInfo的keytype字典</param>
  5076. /// <returns></returns>
  5077. public bool UpdateKeys(Dictionary<string, string> keys, bool autokey)
  5078. {
  5079. GetOrderRemainKeyCount(orderNow);
  5080. if (keys.ContainsKey("DeviceID"))
  5081. {
  5082. if (cfg_writedone.DIDWrite_YesNo)
  5083. SetCheckboxStatus(WriteDID, true);
  5084. UpdateKeyCount("DeviceID", midListNow.clienttype, autokey);
  5085. }
  5086. if (keys.ContainsKey("MAC"))
  5087. {
  5088. if (cfg_writedone.MacWrite_YesNo)
  5089. SetCheckboxStatus(WriteMac, true);
  5090. UpdateKeyCount("MAC", keys["MAC"], autokey);
  5091. }
  5092. if (keys.ContainsKey("HDCP_KEY"))
  5093. {
  5094. if (cfg_writedone.HDCPWrite_YesNo)
  5095. SetCheckboxStatus(WriteHDCP, true);
  5096. UpdateKeyCount("HDCP_KEY", keys["HDCP_KEY"], autokey);
  5097. }
  5098. if (keys.ContainsKey("CI_PLUS_KEY"))
  5099. {
  5100. if (cfg_writedone.CI_plusWrite_YesNo)
  5101. SetCheckboxStatus(WriteCiplus, true);
  5102. UpdateKeyCount("CI_PLUS_KEY", keys["CI_PLUS_KEY"], autokey);
  5103. }
  5104. if (keys.ContainsKey("Widevine_KEY"))
  5105. {
  5106. if (cfg_writedone.WidevineWrite_YesNo)
  5107. SetCheckboxStatus(WriteWidevine, true);
  5108. UpdateKeyCount("Widevine_KEY", keys["Widevine_KEY"], autokey);
  5109. }
  5110. if (keys.ContainsKey("HDCP2.2_KEY"))
  5111. {
  5112. if (cfg_writedone.HDCP22Write_YesNo)
  5113. SetCheckboxStatus(WriteHDCP22, true);
  5114. UpdateKeyCount("HDCP2.2_KEY", keys["HDCP2.2_KEY"], autokey);
  5115. }
  5116. if (keys.ContainsKey("NETFILX_ESN"))
  5117. {
  5118. if (cfg_writedone.ESNWrite_YesNo)
  5119. SetCheckboxStatus(WriteESN, true);
  5120. UpdateKeyCount("NETFILX_ESN", keys["NETFILX_ESN"], autokey);
  5121. }
  5122. if (keys.ContainsKey("Attestation_key"))
  5123. {
  5124. if (cfg_writedone.AttestationWrite_YesNo)
  5125. SetCheckboxStatus(WriteAttestation, true);
  5126. UpdateKeyCount("Attestation_key", keys["Attestation_key"], autokey);
  5127. }
  5128. if (keys.ContainsKey("MGK_KEY"))
  5129. {
  5130. if (cfg_writedone.MGKWrite_YesNo)
  5131. SetCheckboxStatus(WriteMGK, true);
  5132. UpdateKeyCount("MGK_KEY", keys["MGK_KEY"], autokey);
  5133. }
  5134. if (keys.ContainsKey("Fairplay_KEY"))
  5135. {
  5136. if (cfg_writedone.FairplayWrite_YesNo)
  5137. SetCheckboxStatus(WriteFairplay, true);
  5138. UpdateKeyCount("Fairplay_KEY", keys["Fairplay_KEY"], autokey);
  5139. }
  5140. if (keys.ContainsKey("ECP_KEY"))
  5141. {
  5142. if (cfg_writedone.ECPWrite_YesNo)
  5143. SetCheckboxStatus(WriteECP, true);
  5144. UpdateKeyCount("ECP_KEY", keys["ECP_KEY"], autokey);
  5145. }
  5146. if (keys.ContainsKey("WiFi_MAC"))
  5147. {
  5148. if (cfg_writedone.WifiMacWrite_YesNo)
  5149. SetCheckboxStatus(WriteWifiMac, true);
  5150. UpdateKeyCount("WiFi_MAC", keys["WiFi_MAC"], autokey);
  5151. }
  5152. if (keys.ContainsKey("BT_MAC"))
  5153. {
  5154. if (cfg_writedone.BTMacWrite_YesNo)
  5155. SetCheckboxStatus(WriteBTMac, true);
  5156. UpdateKeyCount("BT_MAC", keys["BT_MAC"], autokey);
  5157. }
  5158. if (keys.ContainsKey("LEK"))
  5159. {
  5160. if (cfg_writedone.LEKWrite_YesNo)
  5161. SetCheckboxStatus(WriteLEK, true);
  5162. UpdateKeyCount("LEK", keys["LEK"], false);
  5163. }
  5164. if (keys.ContainsKey("PEK"))
  5165. {
  5166. if (cfg_writedone.PEKWrite_YesNo)
  5167. SetCheckboxStatus(WritePEK, true);
  5168. UpdateKeyCount("PEK", keys["PEK"], false);
  5169. }
  5170. if (keys.ContainsKey("PlayReady_key"))
  5171. {
  5172. if (cfg_writedone.PlayreadyWrite_YesNo)
  5173. SetCheckboxStatus(WritePlayready, true);
  5174. UpdateKeyCount("PlayReady_key", keys["PlayReady_key"], false);
  5175. }
  5176. if (keys.ContainsKey("Hashkey"))
  5177. {
  5178. if (cfg_writedone.HashWrite_YesNo)
  5179. SetCheckboxStatus(WriteHash, true);
  5180. UpdateKeyCount("Hashkey", keys["Hashkey"], false);
  5181. }
  5182. if (keys.ContainsKey("YouTube_KEY"))
  5183. {
  5184. if (cfg_writedone.YouTubeWrite_YesNo)
  5185. SetCheckboxStatus(WriteYouTube, true);
  5186. UpdateKeyCount("YouTube_KEY", keys["YouTube_KEY"], false);
  5187. }
  5188. if (keys.ContainsKey("DSN"))
  5189. {
  5190. if (cfg_writedone.DSNWrite_YesNo)
  5191. SetCheckboxStatus(WriteDSN, true);
  5192. }
  5193. if (keys.ContainsKey("edid_pid"))
  5194. {
  5195. if (cfg_writedone.EDIDPIDWrite_YesNo)
  5196. SetCheckboxStatus(WriteEDIDPID, true);
  5197. }
  5198. if (keys.ContainsKey("edid_model_name"))
  5199. {
  5200. if (cfg_writedone.EDIDModeNameWrite_YesNo)
  5201. SetCheckboxStatus(WriteEDIDName, true);
  5202. }
  5203. if (keys.ContainsKey("ACAS_KEY"))
  5204. {
  5205. if (cfg_writedone.ACASKeyWrite_YesNo)
  5206. SetCheckboxStatus(WriteACASKey, true);
  5207. UpdateKeyCount("ACAS_KEY", keys["ACAS_KEY"], false);
  5208. }
  5209. if (keys.ContainsKey("DAK"))
  5210. {
  5211. if (cfg_writedone.DAKWrite_YesNo)
  5212. SetCheckboxStatus(WriteDAK, true);
  5213. UpdateKeyCount("DAK", keys["DAK"], false);
  5214. }
  5215. if (keys.ContainsKey("FVP"))
  5216. {
  5217. if (cfg_writedone.FVPWrite_YesNo)
  5218. SetCheckboxStatus(WriteFVP, true);
  5219. }
  5220. return true;
  5221. }
  5222. public bool UpdateKeyCountEx(string key, ref Dictionary<string, string> keys, bool autokey)
  5223. {
  5224. if (keys.ContainsKey(key))
  5225. return UpdateKeyCount(key, keys[key], autokey);
  5226. return false;
  5227. }
  5228. /// <summary>
  5229. /// 获取key数量,更新Keycount
  5230. /// </summary>
  5231. /// <param name="key">key种类</param>
  5232. /// <param name="keytype">key的具体类型</param>
  5233. /// <returns></returns>
  5234. public bool UpdateKeyCount(string key, string keytype, bool autokey)
  5235. {
  5236. string url = midListNow.host;
  5237. string url1;
  5238. string count;
  5239. string code;
  5240. string desc;
  5241. HttpHelper http = new HttpHelper();
  5242. HttpItem item = new HttpItem()
  5243. {
  5244. Encoding = Encoding.Default,
  5245. Method = "post",
  5246. ContentType = "application/x-www-form-urlencoded"
  5247. };
  5248. switch (key)
  5249. {
  5250. case "DeviceID":
  5251. {
  5252. url1 = url + "/statdeviceid.do?";
  5253. item.URL = url1;
  5254. item.Postdata = "devicetype=tcl_unknown_model";
  5255. HttpResult result = http.GetHtml(item);
  5256. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  5257. {
  5258. Log.WriteGetKeyLog("\r\nGetDeviceID count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  5259. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  5260. {
  5261. if (count == "0")
  5262. SetKeyCountStatus(DIDCount, count, 2);
  5263. else
  5264. SetKeyCountStatus(DIDCount, count, 0);
  5265. if (autokey && WriteDID.Checked)
  5266. {
  5267. int keycount = Convert.ToInt32(count.Replace(",", ""));
  5268. if (availableCount != "unknow")
  5269. {
  5270. if (Convert.ToInt32(availableCount) > keycount)
  5271. AutoKeyRequire(this.Handle, key, "tcl_unknown_model");
  5272. else if (keycount < 500)
  5273. AutoKeyRequire(this.Handle, key, keytype);
  5274. }
  5275. else if (keycount < 500)
  5276. AutoKeyRequire(this.Handle, key, "tcl_unknown_model");
  5277. }
  5278. }
  5279. else
  5280. {
  5281. CommonMethod.ReportErrormsg("Fail to parse DID count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5282. SetKeyCountStatus(DIDCount, code + "Error", 1);
  5283. }
  5284. }
  5285. else
  5286. {
  5287. CommonMethod.ReportErrormsg("Fail to get DID count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5288. SetKeyCountStatus(DIDCount, result.StatusDescription, 1);
  5289. return false;
  5290. }
  5291. break;
  5292. }
  5293. case "MAC":
  5294. {
  5295. url1 = url + "/statmac.do?";
  5296. item.URL = url1;
  5297. item.Postdata = "typeString=" + keytype;
  5298. HttpResult result = http.GetHtml(item);
  5299. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  5300. {
  5301. Log.WriteGetKeyLog("\r\nGetMac count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  5302. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  5303. {
  5304. if (count == "0")
  5305. SetKeyCountStatus(MacCount, count, 2);
  5306. else
  5307. SetKeyCountStatus(MacCount, count, 0);
  5308. if (autokey && WriteMac.Checked)
  5309. {
  5310. int keycount = Convert.ToInt32(count.Replace(",", ""));
  5311. if (availableCount != "unknow")
  5312. {
  5313. if (Convert.ToInt32(availableCount) > keycount)
  5314. AutoKeyRequire(this.Handle, key, keytype);
  5315. else if (keycount < 500)
  5316. AutoKeyRequire(this.Handle, key, keytype);
  5317. }
  5318. else if (keycount < 500)
  5319. AutoKeyRequire(this.Handle, key, keytype);
  5320. }
  5321. }
  5322. else
  5323. {
  5324. CommonMethod.ReportErrormsg("Fail to parse Mac count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5325. SetKeyCountStatus(MacCount, code + "Error", 1);
  5326. }
  5327. }
  5328. else
  5329. {
  5330. CommonMethod.ReportErrormsg("Fail to get Mac count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5331. SetKeyCountStatus(MacCount, result.StatusDescription, 1);
  5332. return false;
  5333. }
  5334. break;
  5335. }
  5336. case "HDCP_KEY":
  5337. {
  5338. url1 = url + "/stathdcpkey.do?";
  5339. item.URL = url1;
  5340. item.Postdata = "type=" + keytype;
  5341. HttpResult result = http.GetHtml(item);
  5342. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  5343. {
  5344. Log.WriteGetKeyLog("\r\nGetHDCP_KEY count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  5345. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  5346. {
  5347. if (count == "0")
  5348. SetKeyCountStatus(HDCPCount, count, 2);
  5349. else
  5350. SetKeyCountStatus(HDCPCount, count, 0);
  5351. if (autokey && WriteHDCP.Checked)
  5352. {
  5353. int keycount = Convert.ToInt32(count.Replace(",", ""));
  5354. if (availableCount != "unknow")
  5355. {
  5356. if (Convert.ToInt32(availableCount) > keycount)
  5357. AutoKeyRequire(this.Handle, key, keytype);
  5358. else if (keycount < 500)
  5359. AutoKeyRequire(this.Handle, key, keytype);
  5360. }
  5361. else if (keycount < 500)
  5362. AutoKeyRequire(this.Handle, key, keytype);
  5363. }
  5364. }
  5365. else
  5366. {
  5367. CommonMethod.ReportErrormsg("Fail to parse hdcp count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5368. SetKeyCountStatus(HDCPCount, code + "Error", 1);
  5369. }
  5370. }
  5371. else
  5372. {
  5373. CommonMethod.ReportErrormsg("Fail to get hdcp count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5374. SetKeyCountStatus(HDCPCount, result.StatusDescription, 1);
  5375. return false;
  5376. }
  5377. break;
  5378. }
  5379. case "CI_PLUS_KEY":
  5380. {
  5381. url1 = url + "/statcikey.do?";
  5382. item.URL = url1;
  5383. item.Postdata = "type=" + keytype;
  5384. HttpResult result = http.GetHtml(item);
  5385. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  5386. {
  5387. Log.WriteGetKeyLog("\r\nGetCI_PLUS_KEY count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  5388. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  5389. {
  5390. if (count == "0")
  5391. SetKeyCountStatus(CICount, count, 2);
  5392. else
  5393. SetKeyCountStatus(CICount, count, 0);
  5394. if (autokey && WriteCiplus.Checked)
  5395. {
  5396. int keycount = Convert.ToInt32(count.Replace(",", ""));
  5397. if (availableCount != "unknow")
  5398. {
  5399. if (Convert.ToInt32(availableCount) > keycount)
  5400. AutoKeyRequire(this.Handle, key, keytype);
  5401. else if (keycount < 500)
  5402. AutoKeyRequire(this.Handle, key, keytype);
  5403. }
  5404. else if (keycount < 500)
  5405. AutoKeyRequire(this.Handle, key, keytype);
  5406. }
  5407. }
  5408. else
  5409. {
  5410. CommonMethod.ReportErrormsg("Fail to parses ciplus count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5411. SetKeyCountStatus(CICount, code + "Error", 1);
  5412. }
  5413. }
  5414. else
  5415. {
  5416. CommonMethod.ReportErrormsg("Fail to get ciplus count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5417. SetKeyCountStatus(CICount, result.StatusDescription, 1);
  5418. return false;
  5419. }
  5420. break;
  5421. }
  5422. case "WiDi":
  5423. {
  5424. url1 = url + "/statwidi.do?";
  5425. item.URL = url1;
  5426. item.Postdata = "type=" + keytype;
  5427. HttpResult result = http.GetHtml(item);
  5428. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  5429. {
  5430. Log.WriteGetKeyLog("\r\nGetWiDi count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  5431. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  5432. {
  5433. if (count == "0")
  5434. SetKeyCountStatus(WidiCount, count, 2);
  5435. else
  5436. SetKeyCountStatus(WidiCount, count, 0);
  5437. if (autokey && WriteWiDi.Checked)
  5438. {
  5439. int keycount = Convert.ToInt32(count.Replace(",", ""));
  5440. if (availableCount != "unknow")
  5441. {
  5442. if (Convert.ToInt32(availableCount) > keycount)
  5443. AutoKeyRequire(this.Handle, key, keytype);
  5444. else if (keycount < 500)
  5445. AutoKeyRequire(this.Handle, key, keytype);
  5446. }
  5447. else if (keycount < 500)
  5448. AutoKeyRequire(this.Handle, key, keytype);
  5449. }
  5450. }
  5451. else
  5452. {
  5453. CommonMethod.ReportErrormsg("Fail to parse widi count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5454. SetKeyCountStatus(WidiCount, code + "Error", 1);
  5455. }
  5456. }
  5457. else
  5458. {
  5459. CommonMethod.ReportErrormsg("Fail to get widi count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5460. SetKeyCountStatus(WidiCount, result.StatusDescription, 1);
  5461. return false;
  5462. }
  5463. break;
  5464. }
  5465. case "Widevine_KEY":
  5466. {
  5467. url1 = url + "/statWidevineAndAttestation.do?";
  5468. item.URL = url1;
  5469. item.Postdata = "type=" + keytype;
  5470. HttpResult result = http.GetHtml(item);
  5471. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  5472. {
  5473. Log.WriteGetKeyLog("\r\nGetWidevine_KEY count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  5474. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  5475. {
  5476. if (count == "0")
  5477. SetKeyCountStatus(WideVineCount, count, 2);
  5478. else
  5479. SetKeyCountStatus(WideVineCount, count, 0);
  5480. if (autokey && WriteWidevine.Checked)
  5481. {
  5482. int keycount = Convert.ToInt32(count.Replace(",", ""));
  5483. if (availableCount != "unknow")
  5484. {
  5485. if (Convert.ToInt32(availableCount) > keycount)
  5486. AutoKeyRequire(this.Handle, key, keytype);
  5487. else if (keycount < 500)
  5488. AutoKeyRequire(this.Handle, key, keytype);
  5489. }
  5490. else if (keycount < 500)
  5491. AutoKeyRequire(this.Handle, key, keytype);
  5492. }
  5493. }
  5494. else
  5495. {
  5496. CommonMethod.ReportErrormsg("Fail to parse widevine count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5497. SetKeyCountStatus(WideVineCount, code + "Error", 1);
  5498. }
  5499. }
  5500. else
  5501. {
  5502. CommonMethod.ReportErrormsg("Fail to get widevine count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5503. SetKeyCountStatus(WideVineCount, result.StatusDescription, 1);
  5504. return false;
  5505. }
  5506. break;
  5507. }
  5508. case "HDCP2.2_KEY":
  5509. {
  5510. url1 = url + "/stathdcpkey2.do?";
  5511. item.URL = url1;
  5512. item.Postdata = "type=" + keytype;
  5513. HttpResult result = http.GetHtml(item);
  5514. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  5515. {
  5516. Log.WriteGetKeyLog("\r\nGetHDCP2.2_KEY count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  5517. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  5518. {
  5519. if (count == "0")
  5520. SetKeyCountStatus(HDCP22Count, count, 2);
  5521. else
  5522. SetKeyCountStatus(HDCP22Count, count, 0);
  5523. if (autokey && WriteHDCP22.Checked)
  5524. {
  5525. int keycount = Convert.ToInt32(count.Replace(",", ""));
  5526. if (availableCount != "unknow")
  5527. {
  5528. if (Convert.ToInt32(availableCount) > keycount)
  5529. AutoKeyRequire(this.Handle, key, keytype);
  5530. else if (keycount < 500)
  5531. AutoKeyRequire(this.Handle, key, keytype);
  5532. }
  5533. else if (keycount < 500)
  5534. AutoKeyRequire(this.Handle, key, keytype);
  5535. }
  5536. }
  5537. else
  5538. {
  5539. CommonMethod.ReportErrormsg("Fail to parse hdcp22 count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5540. SetKeyCountStatus(HDCP22Count, code + "Error", 1);
  5541. }
  5542. }
  5543. else
  5544. {
  5545. CommonMethod.ReportErrormsg("Fail to get hdcp22 count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5546. SetKeyCountStatus(HDCP22Count, result.StatusDescription, 1);
  5547. return false;
  5548. }
  5549. break;
  5550. }
  5551. case "NETFILX_ESN":
  5552. {
  5553. url1 = url + "/statnetfilxesn.do?";
  5554. item.URL = url1;
  5555. item.Postdata = "type=" + keytype;
  5556. HttpResult result = http.GetHtml(item);
  5557. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  5558. {
  5559. Log.WriteGetKeyLog("\r\nGetNETFILX_ESN count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  5560. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  5561. {
  5562. if (count == "0")
  5563. SetKeyCountStatus(ESNCount, count, 2);
  5564. else
  5565. SetKeyCountStatus(ESNCount, count, 0);
  5566. if (autokey && WriteESN.Checked)
  5567. {
  5568. int keycount = Convert.ToInt32(count.Replace(",", ""));
  5569. if (availableCount != "unknow")
  5570. {
  5571. if (Convert.ToInt32(availableCount) > keycount)
  5572. AutoKeyRequire(this.Handle, key, keytype);
  5573. else if (keycount < 500)
  5574. AutoKeyRequire(this.Handle, key, keytype);
  5575. }
  5576. else if (keycount < 500)
  5577. AutoKeyRequire(this.Handle, key, keytype);
  5578. }
  5579. }
  5580. else
  5581. {
  5582. CommonMethod.ReportErrormsg("Fail to parse esn count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5583. SetKeyCountStatus(ESNCount, code + "Error", 1);
  5584. }
  5585. }
  5586. else
  5587. {
  5588. CommonMethod.ReportErrormsg("Fail to get esn count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5589. SetKeyCountStatus(ESNCount, result.StatusDescription, 1);
  5590. return false;
  5591. }
  5592. break;
  5593. }
  5594. case "Attestation_key":
  5595. {
  5596. url1 = url + "/statWidevineAndAttestation.do?";
  5597. item.URL = url1;
  5598. item.Postdata = "type=" + keytype;
  5599. HttpResult result = http.GetHtml(item);
  5600. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  5601. {
  5602. Log.WriteGetKeyLog("\r\nGetAttestation_key count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  5603. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  5604. {
  5605. if (count == "0")
  5606. SetKeyCountStatus(AttestationCount, count, 2);
  5607. else
  5608. SetKeyCountStatus(AttestationCount, count, 0);
  5609. if (autokey && WriteAttestation.Checked)
  5610. {
  5611. int keycount = Convert.ToInt32(count.Replace(",", ""));
  5612. if (availableCount != "unknow")
  5613. {
  5614. if (Convert.ToInt32(availableCount) > keycount)
  5615. AutoKeyRequire(this.Handle, key, keytype);
  5616. else if (keycount < 500)
  5617. AutoKeyRequire(this.Handle, key, keytype);
  5618. }
  5619. else if (keycount < 500)
  5620. AutoKeyRequire(this.Handle, key, keytype);
  5621. }
  5622. }
  5623. else
  5624. {
  5625. CommonMethod.ReportErrormsg("Fail to parses attestation count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5626. SetKeyCountStatus(AttestationCount, code + "Error", 1);
  5627. }
  5628. }
  5629. else
  5630. {
  5631. CommonMethod.ReportErrormsg("Fail to get ciplus count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5632. SetKeyCountStatus(AttestationCount, result.StatusDescription, 1);
  5633. return false;
  5634. }
  5635. break;
  5636. }
  5637. case "MGK_KEY":
  5638. {
  5639. url1 = url + "/statmgk.do?";
  5640. item.URL = url1;
  5641. item.Postdata = "type=" + keytype;
  5642. HttpResult result = http.GetHtml(item);
  5643. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  5644. {
  5645. Log.WriteGetKeyLog("\r\nGetMGK count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  5646. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  5647. {
  5648. if (count == "0")
  5649. SetKeyCountStatus(MGKCount, count, 2);
  5650. else
  5651. SetKeyCountStatus(MGKCount, count, 0);
  5652. if (autokey && WriteMGK.Checked)
  5653. {
  5654. int keycount = Convert.ToInt32(count.Replace(",", ""));
  5655. if (availableCount != "unknow")
  5656. {
  5657. if (Convert.ToInt32(availableCount) > keycount)
  5658. AutoKeyRequire(this.Handle, key, keytype);
  5659. else if (keycount < 500)
  5660. AutoKeyRequire(this.Handle, key, keytype);
  5661. }
  5662. else if (keycount < 500)
  5663. AutoKeyRequire(this.Handle, key, keytype);
  5664. }
  5665. }
  5666. else
  5667. {
  5668. CommonMethod.ReportErrormsg("Fail to parse MGK count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5669. SetKeyCountStatus(MGKCount, code + "Error", 1);
  5670. }
  5671. }
  5672. else
  5673. {
  5674. CommonMethod.ReportErrormsg("Fail to get MGK count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5675. SetKeyCountStatus(MGKCount, result.StatusDescription, 1);
  5676. return false;
  5677. }
  5678. break;
  5679. }
  5680. case "Fairplay_KEY":
  5681. {
  5682. url1 = url + "/statfairplay.do?";
  5683. item.URL = url1;
  5684. item.Postdata = "type=" + keytype;
  5685. HttpResult result = http.GetHtml(item);
  5686. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  5687. {
  5688. Log.WriteGetKeyLog("\r\nGetFairplay_KEY count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  5689. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  5690. {
  5691. if (count == "0")
  5692. SetKeyCountStatus(FairplayCount, count, 2);
  5693. else
  5694. SetKeyCountStatus(FairplayCount, count, 0);
  5695. if (autokey && WriteFairplay.Checked)
  5696. {
  5697. int keycount = Convert.ToInt32(count.Replace(",", ""));
  5698. if (availableCount != "unknow")
  5699. {
  5700. if (Convert.ToInt32(availableCount) > keycount)
  5701. AutoKeyRequire(this.Handle, key, keytype);
  5702. else if (keycount < 500)
  5703. AutoKeyRequire(this.Handle, key, keytype);
  5704. }
  5705. else if (keycount < 500)
  5706. AutoKeyRequire(this.Handle, key, keytype);
  5707. }
  5708. }
  5709. else
  5710. {
  5711. CommonMethod.ReportErrormsg("Fail to parse Fairplay count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5712. SetKeyCountStatus(FairplayCount, code + "Error", 1);
  5713. }
  5714. }
  5715. else
  5716. {
  5717. CommonMethod.ReportErrormsg("Fail to get Fairplay count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5718. SetKeyCountStatus(FairplayCount, result.StatusDescription, 1);
  5719. return false;
  5720. }
  5721. break;
  5722. }
  5723. case "ECP_KEY":
  5724. {
  5725. url1 = url + "/statecp.do?";
  5726. item.URL = url1;
  5727. item.Postdata = "type=" + keytype;
  5728. HttpResult result = http.GetHtml(item);
  5729. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  5730. {
  5731. Log.WriteGetKeyLog("\r\nGetECP_KEY count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  5732. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  5733. {
  5734. if (count == "0")
  5735. SetKeyCountStatus(ECPCount, count, 2);
  5736. else
  5737. SetKeyCountStatus(ECPCount, count, 0);
  5738. if (autokey && WriteECP.Checked)
  5739. {
  5740. int keycount = Convert.ToInt32(count.Replace(",", ""));
  5741. if (availableCount != "unknow")
  5742. {
  5743. if (Convert.ToInt32(availableCount) > keycount)
  5744. AutoKeyRequire(this.Handle, key, keytype);
  5745. else if (keycount < 500)
  5746. AutoKeyRequire(this.Handle, key, keytype);
  5747. }
  5748. else if (keycount < 500)
  5749. AutoKeyRequire(this.Handle, key, keytype);
  5750. }
  5751. }
  5752. else
  5753. {
  5754. CommonMethod.ReportErrormsg("Fail to parse ECP count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5755. SetKeyCountStatus(ECPCount, code + "Error", 1);
  5756. }
  5757. }
  5758. else
  5759. {
  5760. CommonMethod.ReportErrormsg("Fail to get ECP count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5761. SetKeyCountStatus(ECPCount, result.StatusDescription, 1);
  5762. return false;
  5763. }
  5764. break;
  5765. }
  5766. case "WiFi_MAC":
  5767. {
  5768. url1 = url + "/statmac.do?";
  5769. item.URL = url1;
  5770. item.Postdata = "typeString=" + keytype;
  5771. HttpResult result = http.GetHtml(item);
  5772. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  5773. {
  5774. Log.WriteGetKeyLog("\r\nGetWifiMac count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  5775. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  5776. {
  5777. if (count == "0")
  5778. SetKeyCountStatus(WifiMacCount, count, 2);
  5779. else
  5780. SetKeyCountStatus(WifiMacCount, count, 0);
  5781. if (autokey && WriteWifiMac.Checked)
  5782. {
  5783. int keycount = Convert.ToInt32(count.Replace(",", ""));
  5784. if (availableCount != "unknow")
  5785. {
  5786. if (Convert.ToInt32(availableCount) > keycount)
  5787. AutoKeyRequire(this.Handle, key, keytype);
  5788. else if (keycount < 500)
  5789. AutoKeyRequire(this.Handle, key, keytype);
  5790. }
  5791. else if (keycount < 500)
  5792. AutoKeyRequire(this.Handle, key, keytype);
  5793. }
  5794. }
  5795. else
  5796. {
  5797. CommonMethod.ReportErrormsg("Fail to parse WifiMac count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5798. SetKeyCountStatus(WifiMacCount, code + "Error", 1);
  5799. }
  5800. }
  5801. else
  5802. {
  5803. CommonMethod.ReportErrormsg("Fail to get WifiMac count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5804. SetKeyCountStatus(WifiMacCount, result.StatusDescription, 1);
  5805. return false;
  5806. }
  5807. break;
  5808. }
  5809. case "BT_MAC":
  5810. {
  5811. url1 = url + "/statmac.do?";
  5812. item.URL = url1;
  5813. item.Postdata = "typeString=" + keytype;
  5814. HttpResult result = http.GetHtml(item);
  5815. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  5816. {
  5817. Log.WriteGetKeyLog("\r\nGetBTMac count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  5818. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  5819. {
  5820. if (count == "0")
  5821. SetKeyCountStatus(BTMacCount, count, 2);
  5822. else
  5823. SetKeyCountStatus(BTMacCount, count, 0);
  5824. if (autokey && WriteBTMac.Checked)
  5825. {
  5826. int keycount = Convert.ToInt32(count.Replace(",", ""));
  5827. if (availableCount != "unknow")
  5828. {
  5829. if (Convert.ToInt32(availableCount) > keycount)
  5830. AutoKeyRequire(this.Handle, key, keytype);
  5831. else if (keycount < 500)
  5832. AutoKeyRequire(this.Handle, key, keytype);
  5833. }
  5834. else if (keycount < 500)
  5835. AutoKeyRequire(this.Handle, key, keytype);
  5836. }
  5837. }
  5838. else
  5839. {
  5840. CommonMethod.ReportErrormsg("Fail to parse BTMac count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5841. SetKeyCountStatus(BTMacCount, code + "Error", 1);
  5842. }
  5843. }
  5844. else
  5845. {
  5846. CommonMethod.ReportErrormsg("Fail to get BTMac count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5847. SetKeyCountStatus(BTMacCount, result.StatusDescription, 1);
  5848. return false;
  5849. }
  5850. break;
  5851. }
  5852. case "LEK":
  5853. {
  5854. url1 = url + "/statlek.do?";
  5855. item.URL = url1;
  5856. item.Postdata = "type=" + keytype;
  5857. HttpResult result = http.GetHtml(item);
  5858. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  5859. {
  5860. Log.WriteGetKeyLog("\r\nGetLEK count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  5861. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  5862. {
  5863. if (count == "0")
  5864. SetKeyCountStatus(LEKCount, count, 2);
  5865. else
  5866. SetKeyCountStatus(LEKCount, count, 0);
  5867. }
  5868. else
  5869. {
  5870. CommonMethod.ReportErrormsg("Fail to parse LEK count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5871. SetKeyCountStatus(LEKCount, code + "Error", 1);
  5872. }
  5873. }
  5874. else
  5875. {
  5876. CommonMethod.ReportErrormsg("Fail to get LEK count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5877. SetKeyCountStatus(LEKCount, result.StatusDescription, 1);
  5878. return false;
  5879. }
  5880. break;
  5881. }
  5882. case "PEK":
  5883. {
  5884. url1 = url + "/statpek.do?";
  5885. item.URL = url1;
  5886. item.Postdata = "type=" + keytype;
  5887. HttpResult result = http.GetHtml(item);
  5888. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  5889. {
  5890. Log.WriteGetKeyLog("\r\nGetPEK count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  5891. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  5892. {
  5893. if (count == "0")
  5894. SetKeyCountStatus(PEKCount, count, 2);
  5895. else
  5896. SetKeyCountStatus(PEKCount, count, 0);
  5897. }
  5898. else
  5899. {
  5900. CommonMethod.ReportErrormsg("Fail to parse PEK count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5901. SetKeyCountStatus(PEKCount, code + "Error", 1);
  5902. }
  5903. }
  5904. else
  5905. {
  5906. CommonMethod.ReportErrormsg("Fail to get PEK count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5907. SetKeyCountStatus(PEKCount, result.StatusDescription, 1);
  5908. return false;
  5909. }
  5910. break;
  5911. }
  5912. case "PlayReady_key":
  5913. {
  5914. url1 = url + "/statplayready.do?";
  5915. item.URL = url1;
  5916. item.Postdata = "type=" + keytype;
  5917. HttpResult result = http.GetHtml(item);
  5918. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  5919. {
  5920. Log.WriteGetKeyLog("\r\nGetPlayReady_key count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  5921. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  5922. {
  5923. if (count == "0")
  5924. SetKeyCountStatus(PlayreadyCount, count, 2);
  5925. else
  5926. SetKeyCountStatus(PlayreadyCount, count, 0);
  5927. }
  5928. else
  5929. {
  5930. CommonMethod.ReportErrormsg("Fail to parse PlayReady_key count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5931. SetKeyCountStatus(PlayreadyCount, code + "Error", 1);
  5932. }
  5933. }
  5934. else
  5935. {
  5936. CommonMethod.ReportErrormsg("Fail to get PlayReady_key count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5937. SetKeyCountStatus(PlayreadyCount, result.StatusDescription, 1);
  5938. return false;
  5939. }
  5940. break;
  5941. }
  5942. case "Hashkey":
  5943. {
  5944. url1 = url + "/stathash.do?";
  5945. item.URL = url1;
  5946. item.Postdata = "type=" + keytype;
  5947. HttpResult result = http.GetHtml(item);
  5948. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  5949. {
  5950. Log.WriteGetKeyLog("\r\nGetHashkey count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  5951. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  5952. {
  5953. if (count == "0")
  5954. SetKeyCountStatus(HashCount, count, 2);
  5955. else
  5956. SetKeyCountStatus(HashCount, count, 0);
  5957. }
  5958. else
  5959. {
  5960. CommonMethod.ReportErrormsg("Fail to parse Hashkey count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5961. SetKeyCountStatus(HashCount, code + "Error", 1);
  5962. }
  5963. }
  5964. else
  5965. {
  5966. CommonMethod.ReportErrormsg("Fail to get Hashkey count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5967. SetKeyCountStatus(HashCount, result.StatusDescription, 1);
  5968. return false;
  5969. }
  5970. break;
  5971. }
  5972. case "YouTube_KEY":
  5973. {
  5974. url1 = url + "/statYoutubeKey.do?";
  5975. item.URL = url1;
  5976. item.Postdata = "type=" + keytype;
  5977. HttpResult result = http.GetHtml(item);
  5978. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  5979. {
  5980. Log.WriteGetKeyLog("\r\nGetYoutubehkey count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  5981. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  5982. {
  5983. if (count == "0")
  5984. SetKeyCountStatus(YouTubeCount, count, 2);
  5985. else
  5986. SetKeyCountStatus(YouTubeCount, count, 0);
  5987. }
  5988. else
  5989. {
  5990. CommonMethod.ReportErrormsg("Fail to parse Youtube key count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5991. SetKeyCountStatus(YouTubeCount, code + "Error", 1);
  5992. }
  5993. }
  5994. else
  5995. {
  5996. CommonMethod.ReportErrormsg("Fail to get Youtube key count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  5997. SetKeyCountStatus(YouTubeCount, result.StatusDescription, 1);
  5998. return false;
  5999. }
  6000. break;
  6001. }
  6002. case "ACAS_KEY": // 获取ACAS KEY数量;
  6003. {
  6004. url1 = url + "/statAcasKey.do?";
  6005. item.URL = url1;
  6006. item.Postdata = "type=" + keytype;
  6007. HttpResult result = http.GetHtml(item);
  6008. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  6009. {
  6010. Log.WriteGetKeyLog("\r\nGetACASkey count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  6011. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  6012. {
  6013. if (count == "0")
  6014. SetKeyCountStatus(ACASKeyCount, count, 2);
  6015. else
  6016. SetKeyCountStatus(ACASKeyCount, count, 0);
  6017. }
  6018. else
  6019. {
  6020. CommonMethod.ReportErrormsg("Fail to parse ACAS key count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  6021. SetKeyCountStatus(ACASKeyCount, code + "Error", 1);
  6022. }
  6023. }
  6024. else
  6025. {
  6026. CommonMethod.ReportErrormsg("Fail to get ACAS key count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  6027. SetKeyCountStatus(ACASKeyCount, result.StatusDescription, 1);
  6028. return false;
  6029. }
  6030. break;
  6031. }
  6032. case "DAK":
  6033. {
  6034. url1 = url + "/statdak.do?";
  6035. item.URL = url1;
  6036. item.Postdata = "type=" + keytype;
  6037. HttpResult result = http.GetHtml(item);
  6038. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  6039. {
  6040. Log.WriteGetKeyLog("\r\nGetDAK count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  6041. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  6042. {
  6043. if (count == "0")
  6044. SetKeyCountStatus(DAKCount, count, 2);
  6045. else
  6046. SetKeyCountStatus(DAKCount, count, 0);
  6047. }
  6048. else
  6049. {
  6050. CommonMethod.ReportErrormsg("Fail to parse DAK count", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  6051. SetKeyCountStatus(DAKCount, code + "Error", 1);
  6052. }
  6053. }
  6054. else
  6055. {
  6056. CommonMethod.ReportErrormsg("Fail to get DAK count", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  6057. SetKeyCountStatus(DAKCount, result.StatusDescription, 1);
  6058. return false;
  6059. }
  6060. break;
  6061. }
  6062. default:
  6063. {
  6064. break;
  6065. }
  6066. }
  6067. return true;
  6068. }
  6069. /// <summary>
  6070. /// 获取订单可用key余量
  6071. /// </summary>
  6072. /// <param name="order">订单号</param>
  6073. /// <returns></returns>
  6074. public bool GetOrderRemainKeyCount(string order)
  6075. {
  6076. string url = midListNow.host;
  6077. string url1;
  6078. string count;
  6079. string code;
  6080. string desc;
  6081. if (!CommonMethod.HTTPChecker(url))
  6082. return false;
  6083. HttpHelper http = new HttpHelper();
  6084. HttpItem item = new HttpItem()
  6085. {
  6086. Encoding = Encoding.Default,
  6087. Method = "post",
  6088. ContentType = "application/x-www-form-urlencoded",
  6089. Timeout = 3000
  6090. };
  6091. url1 = url + "/getAvailableKeyCount.do?";
  6092. item.URL = url1;
  6093. item.Postdata = "ordernum=" + order;
  6094. HttpResult result = http.GetHtml(item);
  6095. if (result.StatusCode == System.Net.HttpStatusCode.OK)
  6096. {
  6097. Log.WriteGetKeyLog("\r\nGetOrderRemainKeyCount count:\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
  6098. if (Xmlconfig.KeyCountXml(result.Html, "response", "count", out code, out desc, out count))
  6099. {
  6100. availableCount = count.Replace(",", "");
  6101. }
  6102. else
  6103. {
  6104. availableCount = "unknow";
  6105. CommonMethod.ReportErrormsg("Fail to parse GetOrderRemainKeyCount", desc + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  6106. }
  6107. }
  6108. else
  6109. {
  6110. availableCount = "unknow";
  6111. CommonMethod.ReportErrormsg("Fail to get GetOrderRemainKeyCount", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
  6112. return false;
  6113. }
  6114. return true;
  6115. }
  6116. /// <summary>
  6117. /// 按键触发在线抄写
  6118. /// 注意:此按键的作用是给不需要输入SN号的工厂使用;
  6119. /// </summary>
  6120. /// <param name="sender"></param>
  6121. /// <param name="e"></param>
  6122. private void OnBtnClickStart(object sender, EventArgs e)
  6123. {
  6124. SN = SNText.Text; // SN置为空,用于不需要扫码SN的某些工厂;
  6125. keyInfo = new KeyInfo();
  6126. if (preloadNow)
  6127. {
  6128. MessageBox.Show(LResource.PreloadError, LResource.Error);
  6129. return;
  6130. }
  6131. SetInitialStatus();
  6132. BtnClickstart.Enabled = false;
  6133. SNText.Enabled = false;
  6134. Onlinemode();
  6135. }
  6136. /// <summary>
  6137. /// 在线获取key的方式抄写
  6138. /// </summary>
  6139. public void Onlinemode()
  6140. {
  6141. keyInfo.DID.enable = WriteDID.Checked = (WriteDID.Checked && m_writedid.Text != LResource.Skip);
  6142. keyInfo.Mac.enable = WriteMac.Checked = (WriteMac.Checked && m_writemac.Text != LResource.Skip);
  6143. keyInfo.HDCP.enable = WriteHDCP.Checked = (WriteHDCP.Checked && m_writehdcp.Text != LResource.Skip);
  6144. keyInfo.HDCP22.enable = WriteHDCP22.Checked = (WriteHDCP22.Checked && m_writehdcp22.Text != LResource.Skip);
  6145. keyInfo.Widevine.enable = WriteWidevine.Checked = (WriteWidevine.Checked && m_writewidevine.Text != LResource.Skip);
  6146. keyInfo.ESN.enable = WriteESN.Checked = (WriteESN.Checked && m_writeesn.Text != LResource.Skip);
  6147. keyInfo.CI_plus.enable = WriteCiplus.Checked = (WriteCiplus.Checked && m_writeci.Text != LResource.Skip);
  6148. keyInfo.Attestation.enable = WriteAttestation.Checked = (WriteAttestation.Checked && m_writeattestation.Text != LResource.Skip);
  6149. keyInfo.MGK.enable = WriteMGK.Checked = (WriteMGK.Checked && m_writeMGK.Text != LResource.Skip);
  6150. keyInfo.WiFi_MAC.enable = WriteWifiMac.Checked = (WriteWifiMac.Checked && m_writeWifiMac.Text != LResource.Skip);
  6151. keyInfo.BT_MAC.enable = WriteBTMac.Checked = (WriteBTMac.Checked && m_writeBTMac.Text != LResource.Skip);
  6152. keyInfo.ECP.enable = WriteECP.Checked = (WriteECP.Checked && m_writeECP.Text != LResource.Skip);
  6153. keyInfo.LEK.enable = WriteLEK.Checked = (WriteLEK.Checked && m_writeLEK.Text != LResource.Skip);
  6154. keyInfo.PEK.enable = WritePEK.Checked = (WritePEK.Checked && m_writePEK.Text != LResource.Skip);
  6155. keyInfo.Playready.enable = WritePlayready.Checked = (WritePlayready.Checked && m_writePlayready.Text != LResource.Skip);
  6156. keyInfo.Hashkey.enable = WriteHash.Checked = (WriteHash.Checked && m_writeHash.Text != LResource.Skip);
  6157. keyInfo.YouTube_KEY.enable = WriteYouTube.Checked = (WriteYouTube.Checked && m_writeYouTube.Text != LResource.Skip);
  6158. keyInfo.EDIDPid.enable = WriteEDIDPID.Checked = (WriteEDIDPID.Checked && m_writeEDIDPID.Text != LResource.Skip);
  6159. keyInfo.EDIDModelName.enable = WriteEDIDName.Checked = (WriteEDIDName.Checked && m_writeEDIDName.Text != LResource.Skip);
  6160. keyInfo.ACASKey_Data.enable = WriteACASKey.Checked = (WriteACASKey.Checked && m_writeACASKey.Text != LResource.Skip);
  6161. keyInfo.DAK.enable = WriteDAK.Checked = (WriteDAK.Checked && m_writeDAK.Text != LResource.Skip);
  6162. keyInfo.FVP.enable = WriteFVP.Checked = (WriteFVP.Checked && m_writeFVP.Text != LResource.Skip);
  6163. keyInfo.DSN.enable = WriteDSN.Checked = (WriteDSN.Checked && m_writeDSN.Text != LResource.Skip);
  6164. keyInfo.Fairplay.enable = WriteFairplay.Checked = (WriteFairplay.Checked && m_writeFairplay.Text != LResource.Skip);
  6165. bool preloadresult = false;
  6166. preloadresult = true;
  6167. timer1.Start();
  6168. UpdateKeys(midListNow.keytype, true);
  6169. WritekeyThread = new Thread(Writekey);
  6170. WritekeyThread.Start();
  6171. if (!preloadresult)
  6172. {
  6173. SNText.Enabled = true;
  6174. }
  6175. }
  6176. /// <summary>
  6177. /// 更新订单抄写数量
  6178. /// </summary>
  6179. /// <returns></returns>
  6180. public bool UploadCopyCount()
  6181. {
  6182. return (SQLiteHelper.UpdateProductionNum(errorDBNow, orderNow));
  6183. }
  6184. /// <summary>
  6185. /// 获取定制化抄写信息
  6186. /// </summary>
  6187. /// <param name="sender"></param>
  6188. /// <param name="e"></param>
  6189. private void OnBtnOtherView(object sender, EventArgs e)
  6190. {
  6191. if (midListNow.rokuCustomer != null)
  6192. MessageBox.Show("Roku TV\r\n" + "Brand:" +
  6193. midListNow.rokuCustomer.brand + "\r\nOEM Model:" +
  6194. midListNow.rokuCustomer.oemmodel + "\r\nDate:" +
  6195. midListNow.rokuCustomer.productiondate + "\r\nRegion:" +
  6196. JsonConvert.SerializeObject(midListNow.rokuCustomer.data).ToString() + "\r\nData:" +
  6197. midListNow.rokuCustomer.remotetype, LResource.ProductMsg);
  6198. else
  6199. MessageBox.Show("null");
  6200. }
  6201. /// <summary>
  6202. /// 获取本地key数量
  6203. /// </summary>
  6204. public void GetLocalKeysCount()
  6205. {
  6206. int didnum;
  6207. if (GetLocalKeyCount.GetLocalDidCount(orderNow, out didnum, ref localmidList, errorDBNow))
  6208. {
  6209. SetCheckboxStatus(WriteDID, true);
  6210. if (didnum != -1)
  6211. SetKeyCountStatus(DIDCount, didnum.ToString(), 0);
  6212. else
  6213. SetKeyCountStatus(DIDCount, "Read error", 1);
  6214. }
  6215. int macnum;
  6216. if (GetLocalKeyCount.GetLocalMacCount(orderNow, out macnum, ref localmidList, errorDBNow))
  6217. {
  6218. SetCheckboxStatus(WriteMac, true);
  6219. if (macnum != -1)
  6220. SetKeyCountStatus(MacCount, macnum.ToString(), 0);
  6221. else
  6222. SetKeyCountStatus(MacCount, "Read error", 1);
  6223. }
  6224. int hdcpnum;
  6225. if (GetLocalKeyCount.GetLocalHDCPKEYCount(orderNow, out hdcpnum))
  6226. {
  6227. SetCheckboxStatus(WriteHDCP, true);
  6228. if (hdcpnum != -1)
  6229. SetKeyCountStatus(HDCPCount, hdcpnum.ToString(), 0);
  6230. else
  6231. SetKeyCountStatus(HDCPCount, "Read error", 1);
  6232. }
  6233. int hdcp22num;
  6234. if (GetLocalKeyCount.GetLocalHDCPKEY22Count(orderNow, out hdcp22num))
  6235. {
  6236. SetCheckboxStatus(WriteHDCP22, true);
  6237. if (hdcp22num != -1)
  6238. SetKeyCountStatus(HDCP22Count, hdcp22num.ToString(), 0);
  6239. else
  6240. SetKeyCountStatus(HDCP22Count, "Read error", 1);
  6241. }
  6242. int esnnum;
  6243. if (GetLocalKeyCount.GetLocalESNCount(orderNow, out esnnum))
  6244. {
  6245. SetCheckboxStatus(WriteESN, true);
  6246. if (esnnum != -1)
  6247. SetKeyCountStatus(ESNCount, esnnum.ToString(), 0);
  6248. else
  6249. SetKeyCountStatus(ESNCount, "Read error", 1);
  6250. }
  6251. int widevinenum;
  6252. if (GetLocalKeyCount.GetLocalWidevineCount(orderNow, out widevinenum))
  6253. {
  6254. SetCheckboxStatus(WriteWidevine, true);
  6255. if (widevinenum != -1)
  6256. SetKeyCountStatus(WideVineCount, widevinenum.ToString(), 0);
  6257. else
  6258. SetKeyCountStatus(WideVineCount, "Read error", 1);
  6259. }
  6260. int cinum;
  6261. if (GetLocalKeyCount.GetLocalCIKEYCount(orderNow, out cinum))
  6262. {
  6263. SetCheckboxStatus(WriteCiplus, true);
  6264. if (cinum != -1)
  6265. SetKeyCountStatus(CICount, cinum.ToString(), 0);
  6266. else
  6267. SetKeyCountStatus(CICount, "Read error", 1);
  6268. }
  6269. int mgknum;
  6270. if (GetLocalKeyCount.GetLocalMGKCount(orderNow, out mgknum))
  6271. {
  6272. SetCheckboxStatus(WriteMGK, true);
  6273. if (mgknum != -1)
  6274. SetKeyCountStatus(MGKCount, mgknum.ToString(), 0);
  6275. else
  6276. SetKeyCountStatus(MGKCount, "Read error", 1);
  6277. }
  6278. int attestationnum;
  6279. if (GetLocalKeyCount.GetLocalAttestationCount(orderNow, out attestationnum))
  6280. {
  6281. SetCheckboxStatus(WriteAttestation, true);
  6282. if (attestationnum != -1)
  6283. SetKeyCountStatus(AttestationCount, attestationnum.ToString(), 0);
  6284. else
  6285. SetKeyCountStatus(AttestationCount, "Read error", 1);
  6286. }
  6287. int fairplaynum;
  6288. if (GetLocalKeyCount.GetLocalFairplayCount(orderNow, out fairplaynum))
  6289. {
  6290. SetCheckboxStatus(WriteFairplay, true);
  6291. if (fairplaynum != -1)
  6292. SetKeyCountStatus(FairplayCount, fairplaynum.ToString(), 0);
  6293. else
  6294. SetKeyCountStatus(FairplayCount, "Read error", 1);
  6295. }
  6296. int leknum;
  6297. fireTVKey.LEK = GetLocalKeyCount.GetLocalFolderKeyCount(orderNow, "LEK", out leknum);
  6298. int peknum;
  6299. fireTVKey.PEK = GetLocalKeyCount.GetLocalFolderKeyCount(orderNow, "PEK", out peknum);
  6300. int palyreadynum;
  6301. fireTVKey.Playready = GetLocalKeyCount.GetLocalFolderKeyCount(orderNow, "Playready", out palyreadynum);
  6302. int hashkeynum;
  6303. fireTVKey.Hashkey = GetLocalKeyCount.GetLocalFolderKeyCount(orderNow, "Hashkey", out hashkeynum);
  6304. }
  6305. /// <summary>
  6306. /// 抄写用时计数
  6307. /// </summary>
  6308. /// <param name="sender"></param>
  6309. /// <param name="e"></param>
  6310. private void timer1_Tick(object sender, EventArgs e)
  6311. {
  6312. usingTime += 1;
  6313. UsingTime_Text.Text = usingTime.ToString();
  6314. }
  6315. /// <summary>
  6316. /// 取消SN扫描框聚焦
  6317. /// </summary>
  6318. /// <param name="sender"></param>
  6319. /// <param name="e"></param>
  6320. private void SNText_DoubleClick(object sender, EventArgs e)
  6321. {
  6322. FocusMark = false;
  6323. this.CaptionBackColorTop = Color.RoyalBlue;
  6324. this.CaptionBackColorBottom = Color.Cyan;
  6325. this.Refresh();
  6326. }
  6327. /// <summary>
  6328. /// 强制刷新抄写线程
  6329. /// </summary>
  6330. private void OnBtnRefresh(object sender, EventArgs e)
  6331. {
  6332. usingTime = 0;
  6333. EnableText(SNText);
  6334. EnableButton(BtnClickstart);
  6335. SN = "";
  6336. keyInfo = new KeyInfo();
  6337. SetInitialStatus();
  6338. if (WritekeyThread != null)
  6339. {
  6340. if (WritekeyThread.IsAlive)
  6341. {
  6342. WritekeyThread.Abort();
  6343. if (timer1.Enabled)
  6344. {
  6345. timer1.Stop();
  6346. }
  6347. while (WritekeyThread.ThreadState != System.Threading.ThreadState.Aborted)
  6348. {
  6349. Thread.Sleep(100);
  6350. }
  6351. }
  6352. }
  6353. UsingTime_Text.Text = "0";
  6354. GC.Collect();
  6355. MessageBox.Show(LResource.RefreshPanel);
  6356. }
  6357. /// <summary>
  6358. /// 显示订单key可用余量
  6359. /// </summary>
  6360. /// <param name="sender"></param>
  6361. /// <param name="e"></param>
  6362. private void OrderText_MouseEnter(object sender, EventArgs e)
  6363. {
  6364. toolTip1.SetToolTip(OrderText, LResource.AvailableKey + availableCount);
  6365. }
  6366. }
  6367. }