OperationPanel.cs 246 KB

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