OperationPanel.cs 318 KB

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