OperationPanel.cs 275 KB

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