OperationPanel.cs 246 KB

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