OperationPanel.cs 313 KB

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