OperationPanel.cs 324 KB

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