OperationPanel.cs 285 KB

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