OperationPanel.cs 314 KB

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