OperationPanel.cs 277 KB

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