OperationPanel.cs 307 KB

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