OperationPanel.cs 240 KB

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