OperationPanel.cs 244 KB

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