OperationPanel.cs 246 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403
  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. SNText.Text = "test0205002yi";
  669. #endif
  670. SNTextFocus = new Thread(TextBoxFocus);
  671. SNTextFocus.Start();
  672. SNText.Focus();
  673. }
  674. /// <summary>
  675. /// 强制聚焦扫描框
  676. /// </summary>
  677. public void TextBoxFocus()
  678. {
  679. while (true)
  680. {
  681. if (FocusMark)
  682. {
  683. if (this.CaptionBackColorTop != Color.Yellow || this.CaptionBackColorBottom != Color.Orange)
  684. {
  685. if (this.InvokeRequired)
  686. {
  687. this.BeginInvoke(new Action(() =>
  688. {
  689. this.CaptionBackColorTop = Color.Yellow;
  690. this.CaptionBackColorBottom = Color.Orange;
  691. this.Refresh();
  692. }));
  693. }
  694. }
  695. if (SNText.InvokeRequired)
  696. {
  697. SNText.BeginInvoke(new Action(() =>
  698. {
  699. if (!SNText.Focus())
  700. {
  701. SNText.Focus();
  702. }
  703. }));
  704. }
  705. }
  706. Thread.Sleep(500);
  707. }
  708. }
  709. private void OperationPanel_FormClosing(object sender, FormClosingEventArgs e)
  710. {
  711. if (TVPort.IsOpen)
  712. TVPort.Close();
  713. DeleteIntptr(this.Handle);
  714. GC.Collect();
  715. }
  716. /// <summary>
  717. /// 扫描触发抄写,以回车终结触发
  718. /// </summary>
  719. /// <param name="sender"></param>
  720. /// <param name="e"></param>
  721. private void SNText_KeyDown(object sender, KeyEventArgs e)
  722. {
  723. if (e.KeyCode == Keys.Enter)
  724. {
  725. keyInfo = new KeyInfo();
  726. FocusMark = false;
  727. SNKeyDownEven(this.Handle);
  728. SetInitialStatus();
  729. SN = SNText.Text;
  730. SNText.Enabled = false;
  731. if (FunctionSettingNow.BarcodeLimit)
  732. {
  733. if (SN.Length != FunctionSettingNow.BarcodeLength || !SN.StartsWith(FunctionSettingNow.BarcodeKeyword))
  734. {
  735. MessageBox.Show(string.Format("{0}\r\nSN=<{1}, Len={2}>\r\nKeyword=<{3}>", LResource.WrongBarcode, SN, SN.Length, FunctionSettingNow.BarcodeKeyword));
  736. SNText.Enabled = true;
  737. SNText.Text = "";
  738. return;
  739. }
  740. if (!FunctionSettingNow.BarcodeWrite && (midListNow.keytype != null && midListNow.keytype.ContainsKey("DSN")))
  741. {
  742. // 如果不是全大写字母+数字,返回;
  743. Regex r = new Regex(@"^[A-Z0-9]+$");
  744. if (!r.Match(SN).Success)
  745. {
  746. MessageBox.Show(string.Format("{0}\r\nSN=<{1}, Len={2}>\r\nKeyword=<{3}>", LResource.WrongBarcode, SN, SN.Length, FunctionSettingNow.BarcodeKeyword));
  747. SNText.Enabled = true;
  748. SNText.Text = "";
  749. return;
  750. }
  751. }
  752. }
  753. #region 只有惠州工厂才启用G客户防呆措施;
  754. if (FunctionSettingNow.NTF)
  755. {
  756. StringBuilder strValue = new StringBuilder(256);
  757. // 获取上一次的SN号;
  758. CommonMethod.GetProfileString("MOKAFactoryTools", "LastGSN", "", strValue, 256);
  759. if (strValue.ToString().Equals(SN, StringComparison.OrdinalIgnoreCase))
  760. {
  761. // 连续测试中累计失败的次数;
  762. int lastCount = 0;
  763. CommonMethod.GetProfileString("MOKAFactoryTools", "GFailCount", "0", strValue, 256);
  764. int.TryParse(strValue.ToString(), out lastCount);
  765. // NTF规则:连续测试中累计出现2次Fail,禁止测试.
  766. if (lastCount >= FunctionSettingNow.GFoolProofingCount)
  767. {
  768. Verify dlg = new Verify("累计出现2次Fail,禁止测试!" + "\r\n" + SN);
  769. dlg.ShowDialog();
  770. SNText.Enabled = true;
  771. SNText.Text = "";
  772. return;
  773. }
  774. }
  775. // 根据SN获取订单类型;
  776. string strOrderType;
  777. string strErrorMsg;
  778. if (!GMethod.GetOrderTypeFromSN(SN, orderNow, out strOrderType, out strErrorMsg))
  779. {
  780. Verify dlg = new Verify("根据SN获取订单类型失败,停止测试!" + "\r\nSN:" + SN);
  781. dlg.ShowDialog();
  782. Log.WriteErrorLog(string.Format("SN={0},错误={1}", SN, strErrorMsg));
  783. SNText.Enabled = true;
  784. SNText.Text = "";
  785. return;
  786. }
  787. if (strOrderType.Equals("量产"))
  788. nOrderType = 1;
  789. else if (strOrderType.Equals("试产"))
  790. nOrderType = 0;
  791. else
  792. {
  793. Verify dlg = new Verify("根据SN获取订单类型异常,停止测试!" + "\r\n" + SN);
  794. dlg.ShowDialog();
  795. Log.WriteErrorLog(String.Format("{0}获取订单类型异常={1}", SN, strOrderType));
  796. SNText.Enabled = true;
  797. SNText.Text = "";
  798. return;
  799. }
  800. }
  801. else if ( FunctionSettingNow.SNDoubleTips )
  802. {
  803. StringBuilder strValue = new StringBuilder(256);
  804. // 获取上一次的SN号;
  805. CommonMethod.GetProfileString("MOKAFactoryTools", "LastSN", "", strValue, 256);
  806. if (strValue.ToString().Equals(SN, StringComparison.OrdinalIgnoreCase))
  807. {
  808. if ( MessageBox.Show("该SN已连续使用两次,可能误用到其他机器,请确认是否继续", "提示", MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes)
  809. {
  810. SNText.Enabled = true;
  811. SNText.Text = "";
  812. return;
  813. }
  814. }
  815. CommonMethod.WriteProfileString("MOKAFactoryTools", "LastSN", SN);
  816. }
  817. #endregion
  818. if (CommonMethod.GetLoginAccout().Equals("Sanhua", StringComparison.OrdinalIgnoreCase))
  819. {
  820. string message = string.Empty;
  821. if ( !SanhuaMethod.ProductRouteCheck(SN, out message) )
  822. {
  823. Verify dlg = new Verify(string.Format("{0} ProductRouteCheck faild: {1} ", SN, message));
  824. dlg.ShowDialog();
  825. SNText.Enabled = true;
  826. SNText.Text = "";
  827. return;
  828. }
  829. }
  830. if (preloadNow)
  831. {
  832. bool copydone = false;
  833. string keyjson = SQLiteHelper.Getkeys(localDBNow, SNText.Text.Trim(), out copydone);
  834. if (FunctionSettingNow.NoDoublewrite && copydone)
  835. {
  836. MessageBox.Show(LResource.FindcopiedSN + SN);
  837. SNText.Enabled = true;
  838. SNText.Focus();
  839. }
  840. else if (keyjson.Length > 0)
  841. {
  842. #region 解决Json对象空导致的Bug.
  843. Func<JToken, string> GetJsonValue = (JsonObj) =>
  844. {
  845. if (JsonObj == null )
  846. return "";
  847. return JsonObj.Value<string>();
  848. };
  849. #endregion
  850. JObject jObject = JObject.Parse(keyjson);
  851. keyInfo.DID.data = GetJsonValue(jObject["did"]);
  852. keyInfo.Mac.data = GetJsonValue(jObject["mac"]);
  853. keyInfo.HDCP.data = GetJsonValue(jObject["hdcp"]);
  854. keyInfo.HDCP22.data = GetJsonValue(jObject["hdcp22"]);
  855. //keyInfo.WiDi.data = GetJsonValue(jObject["widi"]);
  856. keyInfo.Widevine.data = GetJsonValue(jObject["widevine"]);
  857. keyInfo.ESN.data = GetJsonValue(jObject["esn"]);
  858. keyInfo.CI_plus.data = GetJsonValue(jObject["cikey"]);
  859. keyInfo.MGK.data = GetJsonValue(jObject["mgk"]);
  860. keyInfo.Attestation.data = GetJsonValue(jObject["attestation"]);
  861. keyInfo.Fairplay.data = GetJsonValue(jObject["fairplay"]);
  862. keyInfo.ECP.data = GetJsonValue(jObject["ecp"]);
  863. keyInfo.WiFi_MAC.data = GetJsonValue(jObject["wifimac"]);
  864. keyInfo.BT_MAC.data = GetJsonValue(jObject["btmac"]);
  865. keyInfo.LEK.data = GetJsonValue(jObject["lek"]);
  866. keyInfo.PEK.data = GetJsonValue(jObject["pek"]);
  867. keyInfo.Playready.data = GetJsonValue(jObject["playready"]);
  868. keyInfo.Hashkey.data = GetJsonValue(jObject["hash"]);
  869. keyInfo.YouTube_KEY.data = GetJsonValue(jObject["youtubekey"]);
  870. keyInfo.ACASKey_Data.data = GetJsonValue(jObject["acaskey_data"]);
  871. //keyInfo.ACASKey_Tool.data = GetJsonValue(jObject["acaskey_tool"]);
  872. keyInfo.DAK.data = GetJsonValue(jObject["dak"]);
  873. keyInfo.FVP.data = GetJsonValue(jObject["FVP"]);
  874. WriteDID.Checked = (keyInfo.DID.Length > 0 && m_writedid.Text != LResource.Skip);
  875. if (WriteDID.Checked)
  876. Log.WriteGetKeyLog("\r\nLocal DB DeviceID=" + keyInfo.DID.data);
  877. WriteMac.Checked = (keyInfo.Mac.Length > 0 && m_writemac.Text != LResource.Skip);
  878. if (WriteMac.Checked)
  879. Log.WriteGetKeyLog("\r\nLocal DB Mac=" + keyInfo.Mac.data);
  880. WriteHDCP.Checked = (keyInfo.HDCP.Length > 0 && m_writehdcp.Text != LResource.Skip);
  881. if (WriteHDCP.Checked)
  882. Log.WriteGetKeyLog("\r\nLocal DB HDCP=" + keyInfo.HDCP.data);
  883. WriteHDCP22.Checked = (keyInfo.HDCP22.Length > 0 && m_writehdcp22.Text != LResource.Skip);
  884. if (WriteHDCP22.Checked)
  885. Log.WriteGetKeyLog("\r\nLocal DB HDCP22=" + keyInfo.HDCP22.data);
  886. WriteWidevine.Checked = (keyInfo.Widevine.Length > 0 && m_writewidevine.Text != LResource.Skip);
  887. if (WriteWidevine.Checked)
  888. Log.WriteGetKeyLog("\r\nLocal DB Widevine=" + keyInfo.Widevine.data);
  889. WriteESN.Checked = (keyInfo.ESN.Length > 0 && m_writeesn.Text != LResource.Skip);
  890. if (WriteESN.Checked)
  891. Log.WriteGetKeyLog("\r\nLocal DB ESN=" + keyInfo.ESN.data);
  892. WriteCiplus.Checked = (keyInfo.CI_plus.Length > 0 && m_writeci.Text != LResource.Skip);
  893. if (WriteCiplus.Checked)
  894. Log.WriteGetKeyLog("\r\nLocal DB Ci=" + keyInfo.CI_plus.data);
  895. WriteMGK.Checked = (keyInfo.MGK.Length > 0 && m_writeMGK.Text != LResource.Skip);
  896. if (WriteMGK.Checked)
  897. Log.WriteGetKeyLog("\r\nLocal DB MGK=" + keyInfo.MGK.data);
  898. WriteAttestation.Checked = (keyInfo.Attestation.Length > 0 && m_writeattestation.Text != LResource.Skip);
  899. if (WriteAttestation.Checked)
  900. Log.WriteGetKeyLog("\r\nLocal DB Attestation=" + keyInfo.Attestation.data);
  901. WriteFairplay.Checked = (keyInfo.Fairplay.Length > 0 && m_writeFairplay.Text != LResource.Skip);
  902. if (WriteFairplay.Checked)
  903. Log.WriteGetKeyLog("\r\nLocal DB Fairplay=" + keyInfo.Fairplay.data);
  904. WriteECP.Checked = (keyInfo.ECP.Length > 0 && m_writeECP.Text != LResource.Skip);
  905. if (WriteECP.Checked)
  906. Log.WriteGetKeyLog("\r\nLocal DB ECP=" + keyInfo.ECP.data);
  907. WriteWifiMac.Checked = (keyInfo.WiFi_MAC.Length > 0 && m_writeWifiMac.Text != LResource.Skip);
  908. if (WriteWifiMac.Checked)
  909. Log.WriteGetKeyLog("\r\nLocal DB WifiMac=" + keyInfo.WiFi_MAC.data);
  910. WriteBTMac.Checked = (keyInfo.BT_MAC.Length > 0 && m_writeBTMac.Text != LResource.Skip);
  911. if (WriteBTMac.Checked)
  912. Log.WriteGetKeyLog("\r\nLocal DB BTMac=" + keyInfo.BT_MAC.data);
  913. WriteLEK.Checked = (keyInfo.LEK.Length > 0 && m_writeLEK.Text != LResource.Skip);
  914. if (WriteLEK.Checked)
  915. Log.WriteGetKeyLog("\r\nLocal DB LEK=" + keyInfo.LEK.data);
  916. WritePEK.Checked = (keyInfo.PEK.Length > 0 && m_writePEK.Text != LResource.Skip);
  917. if (WritePEK.Checked)
  918. Log.WriteGetKeyLog("\r\nLocal DB PEK=" + keyInfo.PEK.data);
  919. WritePlayready.Checked = (keyInfo.Playready.Length > 0 && m_writePlayready.Text != LResource.Skip);
  920. if (WritePlayready.Checked)
  921. Log.WriteGetKeyLog("\r\nLocal DB Playready=" + keyInfo.Playready.data);
  922. WriteHash.Checked = (keyInfo.Hashkey.Length > 0 && m_writeHash.Text != LResource.Skip);
  923. if (WriteHash.Checked)
  924. Log.WriteGetKeyLog("\r\nLocal DB Hashkey=" + keyInfo.Hashkey.data);
  925. WriteYouTube.Checked = (keyInfo.YouTube_KEY.Length > 0 && m_writeYouTube.Text != LResource.Skip);
  926. if (WriteYouTube.Checked)
  927. Log.WriteGetKeyLog("\r\nLocal DB YouTube_KEY=" + keyInfo.YouTube_KEY.data);
  928. WriteACASKey.Checked = (keyInfo.ACASKey_Data.Length > 0 && m_writeACASKey.Text != LResource.Skip);
  929. if (WriteACASKey.Checked)
  930. Log.WriteGetKeyLog("\r\nLocal DB ACAS_KEY=" + keyInfo.ACASKey_Data.data);
  931. WriteDAK.Checked = (keyInfo.DAK.Length > 0 && m_writeDAK.Text != LResource.Skip);
  932. if (WriteDAK.Checked)
  933. Log.WriteGetKeyLog("\r\nLocal DB DAK=" + keyInfo.DAK.data);
  934. WriteFVP.Checked = m_writeFVP.Text != LResource.Skip;
  935. WriteDSN.Checked = (keyInfo.DSN.Length > 0 && m_writeDSN.Text != LResource.Skip);
  936. //WriteDolby.Checked = (keyInfo.Dolby.Length > 0 && m_writeDolby.Text != LResource.Skip);
  937. WritePSN.Checked = FunctionSettingNow.BarcodeWrite;
  938. timer1.Start();
  939. Thread t = new Thread(Writekey);
  940. t.Start();
  941. }
  942. else
  943. {
  944. MessageBox.Show(LResource.FindNullSnInDB + SN);
  945. SNText.Enabled = true;
  946. SNText.Focus();
  947. }
  948. }
  949. else
  950. {
  951. Onlinemode();
  952. }
  953. // 抄写成功后才清空;
  954. //SNText.Text = "";
  955. }
  956. }
  957. /// <summary>
  958. /// 设置成功状态显示
  959. /// </summary>
  960. /// <param name="label"></param>
  961. public void SetsuccessStatus(Label label)
  962. {
  963. if (label.InvokeRequired && label.Text != LResource.Skip)
  964. {
  965. //BeginInvoke(new Action<string>(x => { label.Text = x.ToString(); }), 参数);
  966. label.BeginInvoke(new Action(() => { label.Text = "OK"; label.BackColor = Color.FromArgb(128, 255, 128); }));
  967. }
  968. }
  969. /// <summary>
  970. /// 设置失败状态显示
  971. /// </summary>
  972. /// <param name="label"></param>
  973. public void SetfailStatus(Label label)
  974. {
  975. if (label.InvokeRequired)
  976. {
  977. label.BeginInvoke(new Action(() => { label.Text = "NG"; label.BackColor = Color.Red; }));
  978. }
  979. }
  980. /// <summary>
  981. /// 设置扫描框为输入状态
  982. /// </summary>
  983. /// <param name="textBox"></param>
  984. public void EnableText(TextBox textBox)
  985. {
  986. if (textBox.InvokeRequired)
  987. {
  988. textBox.BeginInvoke(new Action(() => { textBox.Enabled = true; textBox.Text = ""; textBox.Focus(); }));
  989. }
  990. else
  991. {
  992. textBox.Enabled = true;
  993. textBox.Focus();
  994. textBox.Text = "";
  995. }
  996. }
  997. /// <summary>
  998. /// 设置按钮为可点击状态
  999. /// </summary>
  1000. /// <param name="button"></param>
  1001. public void EnableButton(Button button)
  1002. {
  1003. if (button.InvokeRequired)
  1004. {
  1005. button.BeginInvoke(new Action(() => { button.Enabled = true; }));
  1006. }
  1007. else
  1008. button.Enabled = true;
  1009. }
  1010. /// <summary>
  1011. /// 设置特殊的文本和颜色
  1012. /// </summary>
  1013. /// <param name="label">标签控件</param>
  1014. /// <param name="str">需要显示的文本</param>
  1015. /// <param name="color">需要设置的控件背景颜色</param>
  1016. public void SetspecificText(Label label, string str, Color color)
  1017. {
  1018. if (label.InvokeRequired)
  1019. {
  1020. BeginInvoke(new Action<string>(x => { label.Text = x.ToString(); }), str);
  1021. label.BeginInvoke(new Action(() => { label.BackColor = color; }));
  1022. }
  1023. else
  1024. {
  1025. label.Text = str;
  1026. label.BackColor = color;
  1027. }
  1028. }
  1029. /// <summary>
  1030. /// 设置标签控件颜色
  1031. /// </summary>
  1032. /// <param name="label">标签控件对象</param>
  1033. /// <param name="color">需要设置的标签背景颜色</param>
  1034. public void SetcolorStatus(Label label, Color color)
  1035. {
  1036. if (label.InvokeRequired)
  1037. {
  1038. label.BeginInvoke(new Action(() => { label.BackColor = color; }));
  1039. }
  1040. }
  1041. /// <summary>
  1042. /// 跨线程关闭窗口
  1043. /// </summary>
  1044. /// <param name="label"></param>
  1045. /// <param name="color"></param>
  1046. public void Closeform()
  1047. {
  1048. if (this.InvokeRequired)
  1049. {
  1050. this.BeginInvoke(new Action(() => { this.Close(); }));
  1051. }
  1052. }
  1053. /// <summary>
  1054. /// 设置标签控件文本
  1055. /// </summary>
  1056. /// <param name="label">标签控件对象</param>
  1057. /// <param name="color">需要设置的标签文本</param>
  1058. public void SetTextStatus(Label label, string txt)
  1059. {
  1060. if (label.InvokeRequired)
  1061. {
  1062. label.BeginInvoke(new Action(() => { label.Text = txt; }));
  1063. }
  1064. else
  1065. label.Text = txt;
  1066. }
  1067. /// <summary>
  1068. /// 线程内&跨线程设置key数量显示控件
  1069. /// </summary>
  1070. /// <param name="label">数量提示控件</param>
  1071. /// <param name="str">数量值</param>
  1072. /// <param name="status">状态,0为正常,1为获取失败,2为数量不足</param>
  1073. public void SetKeyCountStatus(Label label, string str, int status)
  1074. {
  1075. if (label.InvokeRequired)
  1076. {
  1077. BeginInvoke(new Action<string>(x => { label.Text = x.ToString(); }), str);
  1078. switch (status)
  1079. {
  1080. case 0:
  1081. label.BeginInvoke(new Action(() => { label.ForeColor = Color.Green; }));
  1082. break;
  1083. case 1:
  1084. label.BeginInvoke(new Action(() => { label.BackColor = Color.Red; }));
  1085. break;
  1086. case 2:
  1087. label.BeginInvoke(new Action(() => { label.ForeColor = Color.Red; }));
  1088. break;
  1089. }
  1090. }
  1091. else
  1092. {
  1093. label.Text = str;
  1094. switch (status)
  1095. {
  1096. case 0:
  1097. label.ForeColor = Color.Green; ;
  1098. break;
  1099. case 1:
  1100. label.BackColor = Color.Red;
  1101. break;
  1102. case 2:
  1103. label.ForeColor = Color.Red;
  1104. break;
  1105. }
  1106. }
  1107. }
  1108. /// <summary>
  1109. /// 线程内&跨线程设置checkbox控件的checked值
  1110. /// </summary>
  1111. /// <param name="checkBox">checkbox控件</param>
  1112. /// <param name="status">需要设置的布尔状态</param>
  1113. public void SetCheckboxStatus(CheckBox checkBox, bool status)
  1114. {
  1115. if (checkBox.InvokeRequired)
  1116. {
  1117. BeginInvoke(new Action<bool>(x => { checkBox.Checked = x; }), status);
  1118. }
  1119. else
  1120. {
  1121. checkBox.Checked = status;
  1122. }
  1123. }
  1124. /// <summary>
  1125. /// 重置控件状态,skip除外
  1126. /// </summary>
  1127. public void SetInitialStatus()
  1128. {
  1129. this.CaptionBackColorTop = Color.RoyalBlue;
  1130. this.CaptionBackColorBottom = Color.Cyan;
  1131. this.Refresh();
  1132. /////////////////////////////////////////////////////////////
  1133. #region Set Write;
  1134. if (m_writeci.Text != LResource.Skip)
  1135. {
  1136. m_writeci.Text = "Null";
  1137. m_writeci.BackColor = Color.Transparent;
  1138. }
  1139. if (m_writemac.Text != LResource.Skip)
  1140. {
  1141. m_writemac.Text = "Null";
  1142. m_writemac.BackColor = Color.Transparent;
  1143. }
  1144. if (m_writedid.Text != LResource.Skip)
  1145. {
  1146. m_writedid.Text = "Null";
  1147. m_writedid.BackColor = Color.Transparent;
  1148. }
  1149. if (m_writeesn.Text != LResource.Skip)
  1150. {
  1151. m_writeesn.Text = "Null";
  1152. m_writeesn.BackColor = Color.Transparent;
  1153. }
  1154. if (m_writewidevine.Text != LResource.Skip)
  1155. {
  1156. m_writewidevine.Text = "Null";
  1157. m_writewidevine.BackColor = Color.Transparent;
  1158. }
  1159. if (m_writehdcp.Text != LResource.Skip)
  1160. {
  1161. m_writehdcp.Text = "Null";
  1162. m_writehdcp.BackColor = Color.Transparent;
  1163. }
  1164. if (m_writehdcp22.Text != LResource.Skip)
  1165. {
  1166. m_writehdcp22.Text = "Null";
  1167. m_writehdcp22.BackColor = Color.Transparent;
  1168. }
  1169. if (m_writeattestation.Text != LResource.Skip)
  1170. {
  1171. m_writeattestation.Text = "Null";
  1172. m_writeattestation.BackColor = Color.Transparent;
  1173. }
  1174. if (m_writeMGK.Text != LResource.Skip)
  1175. {
  1176. m_writeMGK.Text = "Null";
  1177. m_writeMGK.BackColor = Color.Transparent;
  1178. }
  1179. if (m_writeFairplay.Text != LResource.Skip)
  1180. {
  1181. m_writeFairplay.Text = "Null";
  1182. m_writeFairplay.BackColor = Color.Transparent;
  1183. }
  1184. if (m_writeECP.Text != LResource.Skip)
  1185. {
  1186. m_writeECP.Text = "Null";
  1187. m_writeECP.BackColor = Color.Transparent;
  1188. }
  1189. if (m_writeLEK.Text != LResource.Skip)
  1190. {
  1191. m_writeLEK.Text = "Null";
  1192. m_writeLEK.BackColor = Color.Transparent;
  1193. }
  1194. if (m_writePEK.Text != LResource.Skip)
  1195. {
  1196. m_writePEK.Text = "Null";
  1197. m_writePEK.BackColor = Color.Transparent;
  1198. }
  1199. if (m_writeHash.Text != LResource.Skip)
  1200. {
  1201. m_writeHash.Text = "Null";
  1202. m_writeHash.BackColor = Color.Transparent;
  1203. }
  1204. if (m_writeDSN.Text != LResource.Skip)
  1205. {
  1206. m_writeDSN.Text = "Null";
  1207. m_writeDSN.BackColor = Color.Transparent;
  1208. }
  1209. if (m_writeWifiMac.Text != LResource.Skip)
  1210. {
  1211. m_writeWifiMac.Text = "Null";
  1212. m_writeWifiMac.BackColor = Color.Transparent;
  1213. }
  1214. if (m_writeBTMac.Text != LResource.Skip)
  1215. {
  1216. m_writeBTMac.Text = "Null";
  1217. m_writeBTMac.BackColor = Color.Transparent;
  1218. }
  1219. if (m_writeDSN.Text != LResource.Skip)
  1220. {
  1221. m_writeDSN.Text = "Null";
  1222. m_writeDSN.BackColor = Color.Transparent;
  1223. }
  1224. if (m_writePlayready.Text != LResource.Skip)
  1225. {
  1226. m_writePlayready.Text = "Null";
  1227. m_writePlayready.BackColor = Color.Transparent;
  1228. }
  1229. if (m_writeYouTube.Text != LResource.Skip)
  1230. {
  1231. m_writeYouTube.Text = "Null";
  1232. m_writeYouTube.BackColor = Color.Transparent;
  1233. }
  1234. if (m_writePSN.Text != LResource.Skip)
  1235. {
  1236. m_writePSN.Text = "Null";
  1237. m_writePSN.BackColor = Color.Transparent;
  1238. }
  1239. if (m_writeACASKey.Text != LResource.Skip)
  1240. {
  1241. m_writeACASKey.Text = "Null";
  1242. m_writeACASKey.BackColor = Color.Transparent;
  1243. }
  1244. if (m_writeEDIDPID.Text != LResource.Skip)
  1245. {
  1246. m_writeEDIDPID.Text = "Null";
  1247. m_writeEDIDPID.BackColor = Color.Transparent;
  1248. }
  1249. if (m_writeEDIDName.Text != LResource.Skip)
  1250. {
  1251. m_writeEDIDName.Text = "Null";
  1252. m_writeEDIDName.BackColor = Color.Transparent;
  1253. }
  1254. #endregion
  1255. /////////////////////////////////////////////////////////////
  1256. #region Write Check;
  1257. if (m_checkci.Text != LResource.Skip)
  1258. {
  1259. m_checkci.Text = "Null";
  1260. m_checkci.BackColor = Color.Transparent;
  1261. }
  1262. if (m_checkmac.Text != LResource.Skip)
  1263. {
  1264. m_checkmac.Text = "Null";
  1265. m_checkmac.BackColor = Color.Transparent;
  1266. }
  1267. if (m_checkdid.Text != LResource.Skip)
  1268. {
  1269. m_checkdid.Text = "Null";
  1270. m_checkdid.BackColor = Color.Transparent;
  1271. }
  1272. if (m_checkesn.Text != LResource.Skip)
  1273. {
  1274. m_checkesn.Text = "Null";
  1275. m_checkesn.BackColor = Color.Transparent;
  1276. }
  1277. if (m_checkwidevine.Text != LResource.Skip)
  1278. {
  1279. m_checkwidevine.Text = "Null";
  1280. m_checkwidevine.BackColor = Color.Transparent;
  1281. }
  1282. if (m_checkhdcp.Text != LResource.Skip)
  1283. {
  1284. m_checkhdcp.Text = "Null";
  1285. m_checkhdcp.BackColor = Color.Transparent;
  1286. }
  1287. if (m_checkhdcp22.Text != LResource.Skip)
  1288. {
  1289. m_checkhdcp22.Text = "Null";
  1290. m_checkhdcp22.BackColor = Color.Transparent;
  1291. }
  1292. if (m_checkattestation.Text != LResource.Skip)
  1293. {
  1294. m_checkattestation.Text = "Null";
  1295. m_checkattestation.BackColor = Color.Transparent;
  1296. }
  1297. if (m_checkMGK.Text != LResource.Skip)
  1298. {
  1299. m_checkMGK.Text = "Null";
  1300. m_checkMGK.BackColor = Color.Transparent;
  1301. }
  1302. if (m_checkFairplay.Text != LResource.Skip)
  1303. {
  1304. m_checkFairplay.Text = "Null";
  1305. m_checkFairplay.BackColor = Color.Transparent;
  1306. }
  1307. if (m_checkECP.Text != LResource.Skip)
  1308. {
  1309. m_checkECP.Text = "Null";
  1310. m_checkECP.BackColor = Color.Transparent;
  1311. }
  1312. if (m_checkLEK.Text != LResource.Skip)
  1313. {
  1314. m_checkLEK.Text = "Null";
  1315. m_checkLEK.BackColor = Color.Transparent;
  1316. }
  1317. if (m_checkPEK.Text != LResource.Skip)
  1318. {
  1319. m_checkPEK.Text = "Null";
  1320. m_checkPEK.BackColor = Color.Transparent;
  1321. }
  1322. if (m_checkHash.Text != LResource.Skip)
  1323. {
  1324. m_checkHash.Text = "Null";
  1325. m_checkHash.BackColor = Color.Transparent;
  1326. }
  1327. if (m_checkDSN.Text != LResource.Skip)
  1328. {
  1329. m_checkDSN.Text = "Null";
  1330. m_checkDSN.BackColor = Color.Transparent;
  1331. }
  1332. if (m_checkWifiMac.Text != LResource.Skip)
  1333. {
  1334. m_checkWifiMac.Text = "Null";
  1335. m_checkWifiMac.BackColor = Color.Transparent;
  1336. }
  1337. if (m_checkBTMac.Text != LResource.Skip)
  1338. {
  1339. m_checkBTMac.Text = "Null";
  1340. m_checkBTMac.BackColor = Color.Transparent;
  1341. }
  1342. if (m_checkDSN.Text != LResource.Skip)
  1343. {
  1344. m_checkDSN.Text = "Null";
  1345. m_checkDSN.BackColor = Color.Transparent;
  1346. }
  1347. if (m_checkPlayready.Text != LResource.Skip)
  1348. {
  1349. m_checkPlayready.Text = "Null";
  1350. m_checkPlayready.BackColor = Color.Transparent;
  1351. }
  1352. if (m_checkYouTube.Text != LResource.Skip)
  1353. {
  1354. m_checkYouTube.Text = "Null";
  1355. m_checkYouTube.BackColor = Color.Transparent;
  1356. }
  1357. if (m_checkACASKey.Text != LResource.Skip)
  1358. {
  1359. m_checkACASKey.Text = "Null";
  1360. m_checkACASKey.BackColor = Color.Transparent;
  1361. }
  1362. #endregion
  1363. /////////////////////////////////////////////////////////////
  1364. #region Read Check;
  1365. if (m_readci.Text != LResource.Skip)
  1366. {
  1367. m_readci.Text = "Null";
  1368. m_readci.BackColor = Color.Transparent;
  1369. }
  1370. if (m_readmac.Text != LResource.Skip)
  1371. {
  1372. m_readmac.Text = "Null";
  1373. m_readmac.BackColor = Color.Transparent;
  1374. }
  1375. if (m_readdid.Text != LResource.Skip)
  1376. {
  1377. m_readdid.Text = "Null";
  1378. m_readdid.BackColor = Color.Transparent;
  1379. }
  1380. if (m_readesn.Text != LResource.Skip)
  1381. {
  1382. m_readesn.Text = "Null";
  1383. m_readesn.BackColor = Color.Transparent;
  1384. }
  1385. if (m_readwidevine.Text != LResource.Skip)
  1386. {
  1387. m_readwidevine.Text = "Null";
  1388. m_readwidevine.BackColor = Color.Transparent;
  1389. }
  1390. if (m_readhdcp.Text != LResource.Skip)
  1391. {
  1392. m_readhdcp.Text = "Null";
  1393. m_readhdcp.BackColor = Color.Transparent;
  1394. }
  1395. if (m_readhdcp22.Text != LResource.Skip)
  1396. {
  1397. m_readhdcp22.Text = "Null";
  1398. m_readhdcp22.BackColor = Color.Transparent;
  1399. }
  1400. if (m_readattestation.Text != LResource.Skip)
  1401. {
  1402. m_readattestation.Text = "Null";
  1403. m_readattestation.BackColor = Color.Transparent;
  1404. }
  1405. if (m_readMGK.Text != LResource.Skip)
  1406. {
  1407. m_readMGK.Text = "Null";
  1408. m_readMGK.BackColor = Color.Transparent;
  1409. }
  1410. if (m_readFairplay.Text != LResource.Skip)
  1411. {
  1412. m_readFairplay.Text = "Null";
  1413. m_readFairplay.BackColor = Color.Transparent;
  1414. }
  1415. if (m_readECP.Text != LResource.Skip)
  1416. {
  1417. m_readECP.Text = "Null";
  1418. m_readECP.BackColor = Color.Transparent;
  1419. }
  1420. if (m_readLEK.Text != LResource.Skip)
  1421. {
  1422. m_readLEK.Text = "Null";
  1423. m_readLEK.BackColor = Color.Transparent;
  1424. }
  1425. if (m_readPEK.Text != LResource.Skip)
  1426. {
  1427. m_readPEK.Text = "Null";
  1428. m_readPEK.BackColor = Color.Transparent;
  1429. }
  1430. if (m_readHash.Text != LResource.Skip)
  1431. {
  1432. m_readHash.Text = "Null";
  1433. m_readHash.BackColor = Color.Transparent;
  1434. }
  1435. if (m_readDSN.Text != LResource.Skip)
  1436. {
  1437. m_readDSN.Text = "Null";
  1438. m_readDSN.BackColor = Color.Transparent;
  1439. }
  1440. if (m_readWifiMac.Text != LResource.Skip)
  1441. {
  1442. m_readWifiMac.Text = "Null";
  1443. m_readWifiMac.BackColor = Color.Transparent;
  1444. }
  1445. if (m_readBTMac.Text != LResource.Skip)
  1446. {
  1447. m_readBTMac.Text = "Null";
  1448. m_readBTMac.BackColor = Color.Transparent;
  1449. }
  1450. if (m_readDSN.Text != LResource.Skip)
  1451. {
  1452. m_readDSN.Text = "Null";
  1453. m_readDSN.BackColor = Color.Transparent;
  1454. }
  1455. if (m_readPlayready.Text != LResource.Skip)
  1456. {
  1457. m_readPlayready.Text = "Null";
  1458. m_readPlayready.BackColor = Color.Transparent;
  1459. }
  1460. if (m_readYouTube.Text != LResource.Skip)
  1461. {
  1462. m_readYouTube.Text = "Null";
  1463. m_readYouTube.BackColor = Color.Transparent;
  1464. }
  1465. if (m_readPSN.Text != LResource.Skip)
  1466. {
  1467. m_readPSN.Text = "Null";
  1468. m_readPSN.BackColor = Color.Transparent;
  1469. }
  1470. if (m_readACASID.Text != LResource.Skip)
  1471. {
  1472. m_readACASID.Text = "Null";
  1473. m_readACASID.BackColor = Color.Transparent;
  1474. }
  1475. if (m_readEDIDPID.Text != LResource.Skip)
  1476. {
  1477. m_readEDIDPID.Text = "Null";
  1478. m_readEDIDPID.BackColor = Color.Transparent;
  1479. }
  1480. if (m_readEDIDName.Text != LResource.Skip)
  1481. {
  1482. m_readEDIDName.Text = "Null";
  1483. m_readEDIDName.BackColor = Color.Transparent;
  1484. }
  1485. if (m_readACASKey.Text != LResource.Skip)
  1486. {
  1487. m_readACASKey.Text = "Null";
  1488. m_readACASKey.BackColor = Color.Transparent;
  1489. }
  1490. #endregion
  1491. ResultStatus.Text = "Wait";
  1492. ResultStatus.BackColor = Color.Transparent;
  1493. SHOPText.BackColor = Color.Transparent;
  1494. OSDText.BackColor = Color.Transparent;
  1495. WBPathText.BackColor = Color.Transparent;
  1496. ProductMsg_Text.BackColor = Color.Transparent;
  1497. }
  1498. /// <summary>
  1499. /// 生成报文;
  1500. /// </summary>
  1501. /// <returns></returns>
  1502. public string GenerateReportInfo()
  1503. {
  1504. #region 移除非IDM抄写的Key;
  1505. if (FunctionSettingNow.MITVEnable && _MiKey != null)
  1506. {
  1507. // 配置要抄写的选项;
  1508. if (_MiKey.EthernetMac != null)
  1509. SetCheckboxStatus(WriteMac, false);
  1510. if (_MiKey.BTMac != null)
  1511. SetCheckboxStatus(WriteBTMac, false);
  1512. if (_MiKey.DSN != null)
  1513. SetCheckboxStatus(WriteDSN, false);
  1514. if (_MiKey.WIFIMAC != null)
  1515. SetCheckboxStatus(WriteWifiMac, false);
  1516. }
  1517. #endregion
  1518. #region 生成IDMKey报文;
  1519. string reportdata = "";
  1520. if (SN.Trim().Length > 0)
  1521. reportdata += "sn=" + SN + "&";
  1522. if (WriteDID.Checked)
  1523. reportdata += "deviceid=" + keyInfo.DID.data + "&";
  1524. if (WriteMac.Checked)
  1525. reportdata += "mac=" + keyInfo.Mac.data + "&";
  1526. if (WriteWifiMac.Checked)
  1527. reportdata += "wifimac=" + keyInfo.WiFi_MAC.data + "&";
  1528. if (WriteBTMac.Checked)
  1529. reportdata += "btmac=" + keyInfo.BT_MAC.data + "&";
  1530. if (WriteHDCP.Checked)
  1531. reportdata += "hdcpkey=" + keyInfo.HDCP.data + "&";
  1532. if (WriteHDCP22.Checked)
  1533. reportdata += "hdcpkey2=" + keyInfo.HDCP22.data + "&";
  1534. if (WriteESN.Checked)
  1535. reportdata += "netfilxesn=" + keyInfo.ESN.data + "&";
  1536. if (WritePEK.Checked)
  1537. reportdata += "pek=" + keyInfo.PEK.data + "&";
  1538. if (WriteYouTube.Checked)
  1539. reportdata += "youtubekey=" + keyInfo.YouTube_KEY.data + "&";
  1540. if (WriteWidevine.Checked)
  1541. reportdata += "widevine=" + keyInfo.Widevine.data + "&";
  1542. if (WriteCiplus.Checked)
  1543. reportdata += "cikey=" + keyInfo.CI_plus.data + "&";
  1544. if (WriteAttestation.Checked)
  1545. reportdata += "attestationmd5=" + keyInfo.Attestation.md5+ "&";
  1546. if (WriteMGK.Checked)
  1547. reportdata += "mgk=" + keyInfo.MGK.data + "&";
  1548. if (WriteFairplay.Checked)
  1549. reportdata += "fairplay=" + keyInfo.Fairplay.data + "&";
  1550. if (WriteECP.Checked)
  1551. reportdata += "ecp=" + keyInfo.ECP.data + "&";
  1552. if (WriteLEK.Checked)
  1553. reportdata += "lek=" + keyInfo.LEK.data + "&";
  1554. if (WritePlayready.Checked)
  1555. reportdata += "playready=" + keyInfo.Playready.data + "&";
  1556. if (WriteHash.Checked)
  1557. reportdata += "hash=" + keyInfo.Hashkey.data + "&";
  1558. if (WriteEDIDPID.Checked)
  1559. reportdata += "EDIDPid=" + keyInfo.EDIDPid.data + "&";
  1560. if (WriteEDIDName.Checked)
  1561. reportdata += "EDIDModeName=" + keyInfo.EDIDModelName.data + "&";
  1562. //if (WriteACASKey.Checked)
  1563. // reportdata += "acas_tool=" + keyInfo.ACASKey_Tool.data + "&";
  1564. if (WriteACASKey.Checked)
  1565. reportdata += "acas_data=" + keyInfo.ACASKey_Data.data + "&";
  1566. if (WriteDAK.Checked)
  1567. reportdata += "DAK=" + keyInfo.DAK.data + "&";
  1568. if (ProjectIDNote.Text != LResource.SkipCovering)
  1569. reportdata += "projectid=" + ProjectIDText.Text + "&";
  1570. if (FunctionSettingNow.WriteWB)
  1571. 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() + "&";
  1572. reportdata += "toolVersion=" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + "&";
  1573. return reportdata;
  1574. #endregion
  1575. }
  1576. public bool ReportMIInfo(out string msg)
  1577. {
  1578. msg = "";
  1579. // 上报MIKey抄写结果;
  1580. ReportMIKey reportMIKey = new ReportMIKey();
  1581. reportMIKey.EthernetMAC = _MiKey.EthernetMac;
  1582. reportMIKey.BTMAC = _MiKey.BTMac;
  1583. reportMIKey.WIFIMAC = _MiKey.WIFIMAC;
  1584. // 读取HDCP长度赋值;
  1585. reportMIKey.HDCP22 = _MiKey._HDCP22.ToString();
  1586. reportMIKey.HDCP14 = _MiKey._HDCP14.ToString();
  1587. // 返回的PSN作为ChipMN和ChipSN;
  1588. reportMIKey.ChipMN = _MiKey._PSN;
  1589. reportMIKey.ChipSN = _MiKey._PSN;
  1590. reportMIKey.DSN = _MiKey.DSN;
  1591. reportMIKey.TVMN = _MiKey.TVMN;
  1592. reportMIKey.TVSN = SN.Replace("/", ""); // 去掉斜杠;
  1593. if (!CommonMethod.ReportMIKey(FunctionSettingNow.MIKeyReportUrl, reportMIKey, out msg))
  1594. {
  1595. msg = string.Format("ReportMIKey error!\r\n{0}", msg);
  1596. Log.WriteErrorLog(msg);
  1597. return false;
  1598. }
  1599. return true;
  1600. }
  1601. /// <summary>
  1602. /// 执行抄key等动作
  1603. /// </summary>
  1604. public void Writekey()
  1605. {
  1606. DateTime startTime = DateTime.Now;
  1607. ArrayList keypath = new ArrayList();
  1608. ArrayList keyStream = new ArrayList();
  1609. ArrayList keyReader = new ArrayList();
  1610. //int SerailDelay = FunctionSettingNow.SerailDelay;
  1611. int SerailDelay = FunctionSettingNow.NextCommandWaitTime;
  1612. Log.WriteInfoLog(SN + " start testing");
  1613. // 0表示抄写失败,特殊:上报IDM失败\获取key失败\抄写失败;
  1614. // 1表示抄写成功,特殊:无;
  1615. // 2表示抄写成功,特殊:但试产NTF要求连续2次PASS才能上传MES,需要再测试一次;
  1616. // 3表示抄写成功,特殊:上报MES失败;
  1617. int TestResult = 0;
  1618. string keycontent = "";
  1619. bool EnterFactoryResult = false;
  1620. byte[] result;
  1621. byte[] data;
  1622. string error = "";
  1623. // 报错信息;
  1624. string ErrMsg = "";
  1625. string psn = "";
  1626. string devicecode = "";
  1627. #if !SIMULATION
  1628. //进工厂
  1629. if (!TVPort.IsOpen)
  1630. {
  1631. try
  1632. {
  1633. TVPort.Open();
  1634. }
  1635. catch (Exception ex)
  1636. {
  1637. MessageBox.Show(ex.Message);
  1638. goto stop;
  1639. }
  1640. }
  1641. for (int i = 0; i <= FunctionSettingNow.EnterFactoryRetry; i++)
  1642. {
  1643. if (i == 0)
  1644. Log.WriteInfoLog("Enter factory...");
  1645. else
  1646. Log.WriteInfoLog("Retry enter factory " + i.ToString() + " ...");
  1647. if (SerialCMD.EnterFactory(TVPort, out result, out data, out error, SerailDelay))
  1648. {
  1649. EnterFactoryResult = true;
  1650. break;
  1651. }
  1652. }
  1653. if (!EnterFactoryResult)
  1654. {
  1655. ErrMsg = string.Format("{0} Enter factory fail, Please check the problem", SN);
  1656. Log.WriteErrorLog(ErrMsg);
  1657. ShowVerifyDelegate(ErrMsg);
  1658. goto stop;
  1659. }
  1660. #endif
  1661. //烧录SN
  1662. if (WritePSN.Checked)
  1663. {
  1664. Log.WriteInfoLog("Write PSN");
  1665. if (SerialCMD.SetFireTVPSN(TVPort, Encoding.ASCII.GetBytes(SN), out result, out data, out error, SerailDelay))
  1666. {
  1667. SetsuccessStatus(m_writePSN);
  1668. Log.WriteInfoLog("Read PSN");
  1669. if (SerialCMD.ReadFireTVPSN(TVPort, out result, out data, out error, SerailDelay))
  1670. {
  1671. if (!Encoding.ASCII.GetString(data).Equals(SN))
  1672. {
  1673. ErrMsg = string.Format("{0} Compare PSN error!\r\n", SN);
  1674. Log.WriteErrorLog(ErrMsg);
  1675. goto end;
  1676. }
  1677. SetsuccessStatus(m_readPSN);
  1678. SetsuccessStatus(ResultStatus);
  1679. goto stop;
  1680. }
  1681. else
  1682. {
  1683. SetfailStatus(m_readPSN);
  1684. ErrMsg = string.Format("{0} Read PSN error!\r\n", SN);
  1685. Log.WriteErrorLog(ErrMsg);
  1686. goto end;
  1687. }
  1688. }
  1689. else
  1690. {
  1691. SetfailStatus(m_writePSN);
  1692. ErrMsg = string.Format("{0} Write PSN error!\r\n", SN);
  1693. Log.WriteErrorLog(ErrMsg);
  1694. goto end;
  1695. }
  1696. }
  1697. string strACASID="";
  1698. // 如果是要导出ACASID+SN,先判断ACASID是否等于20位长度;
  1699. if (FunctionSettingNow.ExportSNACASID)
  1700. {
  1701. if (SerialCMD.ReadJapaneseACASID(TVPort, out result, out data, out error, SerailDelay))
  1702. {
  1703. if (data.Length != 20)
  1704. {
  1705. SetfailStatus(m_readACASID);
  1706. ErrMsg = string.Format("{0} The ACAS ID length doesn't equal 20!\r\n{1}", SN, data.ToString());
  1707. Log.WriteErrorLog(ErrMsg);
  1708. goto end;
  1709. }
  1710. SetsuccessStatus(m_readACASID);
  1711. }
  1712. else
  1713. {
  1714. SetfailStatus(m_readACASID);
  1715. ErrMsg = string.Format("{0} Read ACAS ID error!\r\n", SN);
  1716. Log.WriteErrorLog(ErrMsg);
  1717. goto end;
  1718. }
  1719. //strACASID=data.ToString();
  1720. strACASID = Encoding.ASCII.GetString(data);
  1721. }
  1722. //获取key
  1723. if (midListNow.host == "LocalPC" && !preloadNow)
  1724. {
  1725. string Didpath = "";
  1726. string Macpath = "";
  1727. string Hdcppath = "";
  1728. string Hdcp22path = "";
  1729. string Esnpath = "";
  1730. string MGKpath = "";
  1731. string Widevinepath = "";
  1732. string Cipath = "";
  1733. string Attestationpath = "";
  1734. string Fairplaypath = "";
  1735. string LEKpath = "";
  1736. string PEKpath = "";
  1737. string Playreadypath = "";
  1738. string Hashkeypath = "";
  1739. string AcasKeypath = "";
  1740. if (WriteDID.Checked)
  1741. {
  1742. if (GetLocalKeyCount.GetLocalStringKeys(orderNow, "DeviceID", FunctionSettingNow.LocalDidSize, out FileStream Stream, out StreamReader Reader, out string did, out Didpath, out error, errorDBNow, ref localmidList, SN))
  1743. {
  1744. keyInfo.DID.data = did;
  1745. Log.WriteGetKeyLog("\r\nLocal DeviceID=" + keyInfo.DID);
  1746. if (Stream != null && Reader != null)
  1747. {
  1748. keypath.Add(Didpath);
  1749. keyStream.Add(Stream);
  1750. keyReader.Add(Reader);
  1751. }
  1752. }
  1753. else
  1754. {
  1755. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetDIDError, error);
  1756. Log.WriteErrorLog(ErrMsg);
  1757. goto end;
  1758. }
  1759. }
  1760. if (WriteMac.Checked)
  1761. {
  1762. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "MAC", FunctionSettingNow.LocalMacSize, out FileStream Stream, out BinaryReader Reader, out string mac, out Macpath, out error, errorDBNow, ref localmidList, SN))
  1763. {
  1764. keyInfo.Mac.data = mac;
  1765. Log.WriteGetKeyLog("\r\nLocal Mac=" + keyInfo.Mac);
  1766. if (Stream != null && Reader != null)
  1767. {
  1768. keypath.Add(Macpath);
  1769. keyStream.Add(Stream);
  1770. keyReader.Add(Reader);
  1771. }
  1772. }
  1773. else
  1774. {
  1775. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetMacError, error);
  1776. Log.WriteErrorLog(ErrMsg);
  1777. goto end;
  1778. }
  1779. }
  1780. if (WriteHDCP.Checked)
  1781. {
  1782. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "HDCPKEY", FunctionSettingNow.LocalHdcpSize, out FileStream Stream, out BinaryReader Reader, out string hdcp, out Hdcppath, out error, errorDBNow, ref localmidList, SN))
  1783. {
  1784. keyInfo.HDCP.data = hdcp;
  1785. Log.WriteGetKeyLog("\r\nLocal HDCP=" + keyInfo.HDCP);
  1786. if (Stream != null && Reader != null)
  1787. {
  1788. keypath.Add(Hdcppath);
  1789. keyStream.Add(Stream);
  1790. keyReader.Add(Reader);
  1791. }
  1792. }
  1793. else
  1794. {
  1795. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetHDCPError, error);
  1796. Log.WriteErrorLog(ErrMsg);
  1797. goto end;
  1798. }
  1799. }
  1800. if (WriteHDCP22.Checked)
  1801. {
  1802. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "HDCPKEY22", FunctionSettingNow.LocalHdcp22Size, out FileStream Stream, out BinaryReader Reader, out string hdcp22, out Hdcp22path, out error, errorDBNow, ref localmidList, SN))
  1803. {
  1804. keyInfo.HDCP22.data = hdcp22;
  1805. Log.WriteGetKeyLog("\r\nLocal HDCP22=" + keyInfo.HDCP22);
  1806. if (Stream != null && Reader != null)
  1807. {
  1808. keypath.Add(Hdcp22path);
  1809. keyStream.Add(Stream);
  1810. keyReader.Add(Reader);
  1811. }
  1812. }
  1813. else
  1814. {
  1815. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetHDCP22Error, error);
  1816. Log.WriteErrorLog(ErrMsg);
  1817. goto end;
  1818. }
  1819. }
  1820. if (WriteESN.Checked)
  1821. {
  1822. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "ESN", FunctionSettingNow.LocalEsnSize, out FileStream Stream, out BinaryReader Reader, out string esn, out Esnpath, out error, errorDBNow, ref localmidList, SN))
  1823. {
  1824. keyInfo.ESN.data = esn;
  1825. Log.WriteGetKeyLog("\r\nLocal ESN=" + keyInfo.ESN);
  1826. if (Stream != null && Reader != null)
  1827. {
  1828. keypath.Add(Esnpath);
  1829. keyStream.Add(Stream);
  1830. keyReader.Add(Reader);
  1831. }
  1832. }
  1833. else
  1834. {
  1835. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetESNError, error);
  1836. Log.WriteErrorLog(ErrMsg);
  1837. goto end;
  1838. }
  1839. }
  1840. if (WriteMGK.Checked)
  1841. {
  1842. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "MGK", FunctionSettingNow.LocalMGKSize, out FileStream Stream, out BinaryReader Reader, out string mgk, out MGKpath, out error, errorDBNow, ref localmidList, SN))
  1843. {
  1844. keyInfo.MGK.data = mgk;
  1845. Log.WriteGetKeyLog("\r\nLocal MGK=" + keyInfo.MGK);
  1846. if (Stream != null && Reader != null)
  1847. {
  1848. keypath.Add(MGKpath);
  1849. keyStream.Add(Stream);
  1850. keyReader.Add(Reader);
  1851. }
  1852. }
  1853. else
  1854. {
  1855. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetMGKError, error);
  1856. Log.WriteErrorLog(ErrMsg);
  1857. goto end;
  1858. }
  1859. }
  1860. if (WriteFairplay.Checked)
  1861. {
  1862. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "Fairplay", FunctionSettingNow.LocalFairplaySize, out FileStream Stream, out BinaryReader Reader, out string fairplay, out Fairplaypath, out error, errorDBNow, ref localmidList, SN))
  1863. {
  1864. keyInfo.Fairplay.data = fairplay;
  1865. Log.WriteGetKeyLog("\r\nLocal Fairplay=" + keyInfo.Fairplay);
  1866. if (Stream != null && Reader != null)
  1867. {
  1868. keypath.Add(Fairplaypath);
  1869. keyStream.Add(Stream);
  1870. keyReader.Add(Reader);
  1871. }
  1872. }
  1873. else
  1874. {
  1875. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetFairplayError, error);
  1876. Log.WriteErrorLog(ErrMsg);
  1877. goto end;
  1878. }
  1879. }
  1880. if (WriteWidevine.Checked)
  1881. {
  1882. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "Widevine", FunctionSettingNow.LocalWidevineSize, out FileStream Stream, out BinaryReader Reader, out string widevine, out Widevinepath, out error, errorDBNow, ref localmidList, SN))
  1883. {
  1884. keyInfo.Widevine.data = widevine;
  1885. Log.WriteGetKeyLog("\r\nLocal Widevine=" + keyInfo.Widevine);
  1886. if (Stream != null && Reader != null)
  1887. {
  1888. keypath.Add(Widevinepath);
  1889. keyStream.Add(Stream);
  1890. keyReader.Add(Reader);
  1891. }
  1892. }
  1893. else
  1894. {
  1895. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetWidevineError, error);
  1896. Log.WriteErrorLog(ErrMsg);
  1897. goto end;
  1898. }
  1899. }
  1900. if (WriteCiplus.Checked)
  1901. {
  1902. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "CIKEY", FunctionSettingNow.LocalCiSize, out FileStream Stream, out BinaryReader Reader, out string ci, out Cipath, out error, errorDBNow, ref localmidList, SN))
  1903. {
  1904. keyInfo.CI_plus.data = ci;
  1905. Log.WriteGetKeyLog("\r\nLocal CI_plus=" + keyInfo.CI_plus);
  1906. if (Stream != null && Reader != null)
  1907. {
  1908. keypath.Add(Cipath);
  1909. keyStream.Add(Stream);
  1910. keyReader.Add(Reader);
  1911. }
  1912. }
  1913. else
  1914. {
  1915. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetCiError, error);
  1916. Log.WriteErrorLog(ErrMsg);
  1917. goto end;
  1918. }
  1919. }
  1920. if (WriteAttestation.Checked)
  1921. {
  1922. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "Attestation", FunctionSettingNow.LocalCiSize, out FileStream Stream, out BinaryReader Reader, out string attestation, out Attestationpath, out error, errorDBNow, ref localmidList, SN))
  1923. {
  1924. keyInfo.Attestation.data = attestation;
  1925. Log.WriteGetKeyLog("\r\nLocal attestation=" + keyInfo.Attestation);
  1926. if (Stream != null && Reader != null)
  1927. {
  1928. keypath.Add(Attestationpath);
  1929. keyStream.Add(Stream);
  1930. keyReader.Add(Reader);
  1931. }
  1932. }
  1933. else
  1934. {
  1935. ErrMsg = String.Format("{0}\r\n{1}", LResource.GetAttestationError, error);
  1936. Log.WriteErrorLog(ErrMsg);
  1937. goto end;
  1938. }
  1939. }
  1940. if (fireTVKey.LEK)
  1941. {
  1942. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "LEK", -1, out FileStream Stream, out BinaryReader Reader, out string lek, out LEKpath, out error, errorDBNow, ref localmidList, SN))
  1943. {
  1944. keyInfo.LEK.data = lek;
  1945. Log.WriteGetKeyLog("\r\nLocal LEK=" + keyInfo.LEK);
  1946. if (Stream != null && Reader != null)
  1947. {
  1948. keypath.Add(LEKpath);
  1949. keyStream.Add(Stream);
  1950. keyReader.Add(Reader);
  1951. }
  1952. }
  1953. else
  1954. {
  1955. ErrMsg = String.Format("获取LEK失败 {0}", error);
  1956. Log.WriteErrorLog(ErrMsg);
  1957. goto end;
  1958. }
  1959. }
  1960. if (fireTVKey.PEK)
  1961. {
  1962. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "PEK", -1, out FileStream Stream, out BinaryReader Reader, out string pek, out PEKpath, out error, errorDBNow, ref localmidList, SN))
  1963. {
  1964. keyInfo.PEK.data = pek;
  1965. Log.WriteGetKeyLog("\r\nLocal LEK=" + keyInfo.PEK);
  1966. if (Stream != null && Reader != null)
  1967. {
  1968. keypath.Add(PEKpath);
  1969. keyStream.Add(Stream);
  1970. keyReader.Add(Reader);
  1971. }
  1972. }
  1973. else
  1974. {
  1975. ErrMsg = String.Format("获取PEK失败{0}", error);
  1976. Log.WriteErrorLog(ErrMsg);
  1977. goto end;
  1978. }
  1979. }
  1980. if (fireTVKey.Playready)
  1981. {
  1982. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "Playready", -1, out FileStream Stream, out BinaryReader Reader, out string playready, out Playreadypath, out error, errorDBNow, ref localmidList, SN))
  1983. {
  1984. keyInfo.Playready.data = playready;
  1985. Log.WriteGetKeyLog("\r\nLocal Playready=" + keyInfo.Playready);
  1986. if (Stream != null && Reader != null)
  1987. {
  1988. keypath.Add(Playreadypath);
  1989. keyStream.Add(Stream);
  1990. keyReader.Add(Reader);
  1991. }
  1992. }
  1993. else
  1994. {
  1995. ErrMsg = String.Format("获取Playready失败{0}", error);
  1996. Log.WriteErrorLog(ErrMsg);
  1997. goto end;
  1998. }
  1999. }
  2000. if (fireTVKey.Hashkey)
  2001. {
  2002. if (GetLocalKeyCount.GetLocalHexKeys(orderNow, "Hashkey", -1, out FileStream Stream, out BinaryReader Reader, out string hashkey, out Hashkeypath, out error, errorDBNow, ref localmidList, SN))
  2003. {
  2004. keyInfo.Hashkey.data = hashkey;
  2005. Log.WriteGetKeyLog("\r\nLocal Hashkey=" + keyInfo.Hashkey);
  2006. if (Stream != null && Reader != null)
  2007. {
  2008. keypath.Add(Fairplaypath);
  2009. keyStream.Add(Stream);
  2010. keyReader.Add(Reader);
  2011. }
  2012. }
  2013. else
  2014. {
  2015. ErrMsg = String.Format("获取hashkey失败 {0}", error);
  2016. Log.WriteErrorLog(ErrMsg);
  2017. goto end;
  2018. }
  2019. }
  2020. if (WriteACASKey.Checked)
  2021. {
  2022. 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))
  2023. {
  2024. keyInfo.ACASKey_Data.data = acaskey;
  2025. Log.WriteGetKeyLog("\r\nLocal ACASKey=" + keyInfo.ACASKey_Data);
  2026. if (Stream != null && Reader != null)
  2027. {
  2028. keypath.Add(AcasKeypath);
  2029. keyStream.Add(Stream);
  2030. keyReader.Add(Reader);
  2031. }
  2032. }
  2033. else
  2034. {
  2035. ErrMsg = String.Format("{0} {1}", LResource.GetACASKeyError, error);
  2036. Log.WriteErrorLog(ErrMsg);
  2037. goto end;
  2038. }
  2039. }
  2040. if (WriteEDIDPID.Checked)
  2041. {
  2042. keyInfo.EDIDPid.data = midListNow.keytype["edid_pid"];
  2043. }
  2044. if (WriteEDIDName.Checked)
  2045. {
  2046. keyInfo.EDIDModelName.data = midListNow.keytype["edid_model_name"];
  2047. }
  2048. if (localmidList.host != null)
  2049. {
  2050. if (ClientTypeText.Text.Length == 0)
  2051. {
  2052. SetTextStatus(ClientTypeText, localmidList.clienttype);
  2053. }
  2054. if (SVText.Text.Length == 0)
  2055. {
  2056. SetTextStatus(SVText, localmidList.version);
  2057. }
  2058. if (ProjectIDText.Text.Length == 0)
  2059. {
  2060. SetTextStatus(ProjectIDText, localmidList.projectid);
  2061. }
  2062. }
  2063. }
  2064. else if (!preloadNow)
  2065. {
  2066. // 计算获取全部key耗时;
  2067. Stopwatch watch = new Stopwatch();
  2068. watch.Start();
  2069. // 只用一个接口获取所有Key;
  2070. if ( midListNow.keytype.ContainsKey("DSN") )
  2071. {
  2072. #if !SIMULATION
  2073. // 读取dvicecode
  2074. if (SerialCMD.GetFireTVDevcieCode(TVPort, out result, out data, out error, SerailDelay))
  2075. {
  2076. devicecode = Encoding.ASCII.GetString(data);
  2077. if (devicecode == "N/A")
  2078. {
  2079. ErrMsg = string.Format("Device code format error!\r\n{0}", devicecode);
  2080. Log.WriteErrorLog(ErrMsg);
  2081. goto end;
  2082. }
  2083. }
  2084. else
  2085. {
  2086. ErrMsg = string.Format("{0} Get Device Code Error", SN);
  2087. Log.WriteErrorLog(ErrMsg);
  2088. goto end;
  2089. }
  2090. // 读取psn的值;
  2091. if (SerialCMD.ReadFireTVPSN(TVPort, out result, out data, out error, SerailDelay))
  2092. {
  2093. psn = keyInfo._PSN.data = Encoding.ASCII.GetString(data);
  2094. }
  2095. else
  2096. {
  2097. ErrMsg = string.Format("Failed to read PSN when requesting DSN !\r\n{0}", devicecode);
  2098. Log.WriteErrorLog(ErrMsg);
  2099. goto end;
  2100. }
  2101. #else
  2102. devicecode = "G9V2GV0123260000";
  2103. psn = keyInfo._PSN.data = "B22013921-0B00018";
  2104. #endif
  2105. }
  2106. // 部分订单无key,只有Roku信息;
  2107. if (midListNow.keytype.Count() != 0)
  2108. {
  2109. //if (!CommonMethod.GetIDMKeys(midListNow.host, SN, orderNow, psn, devicecode, key2Write, errorDBNow, ref keyInfo, out error))
  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. EnableText(SNText);
  4745. EnableButton(BtnClickstart);
  4746. SN = "";
  4747. }
  4748. /// <summary>
  4749. /// 显示白平衡配置
  4750. /// </summary>
  4751. /// <param name="sender"></param>
  4752. /// <param name="e"></param>
  4753. private void OnBtnWBView(object sender, EventArgs e)
  4754. {
  4755. SNText.Focus();
  4756. if (FunctionSettingNow.WriteWB)
  4757. {
  4758. 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]);
  4759. }
  4760. else
  4761. {
  4762. MessageBox.Show(LResource.WBNoSet);
  4763. }
  4764. }
  4765. /// <summary>
  4766. /// 更新key的状态
  4767. /// </summary>
  4768. /// <param name="keys">GetMIDInfo的keytype字典</param>
  4769. /// <returns></returns>
  4770. public bool UpdateKeys(Dictionary<string, string> keys, bool autokey)
  4771. {
  4772. if (keys.ContainsKey("DeviceID"))
  4773. {
  4774. if (cfg_writedone.DIDWrite_YesNo)
  4775. SetCheckboxStatus(WriteDID, true);
  4776. UpdateKeyCountOnline("DeviceID", midListNow.clienttype, autokey);
  4777. }
  4778. if (keys.ContainsKey("MAC"))
  4779. {
  4780. if (cfg_writedone.MacWrite_YesNo)
  4781. SetCheckboxStatus(WriteMac, true);
  4782. UpdateKeyCountOnline("MAC", keys["MAC"], autokey);
  4783. }
  4784. if (keys.ContainsKey("HDCP_KEY"))
  4785. {
  4786. if (cfg_writedone.HDCPWrite_YesNo)
  4787. SetCheckboxStatus(WriteHDCP, true);
  4788. UpdateKeyCountOnline("HDCP_KEY", keys["HDCP_KEY"], autokey);
  4789. }
  4790. if (keys.ContainsKey("CI_PLUS_KEY"))
  4791. {
  4792. if (cfg_writedone.CI_plusWrite_YesNo)
  4793. SetCheckboxStatus(WriteCiplus, true);
  4794. UpdateKeyCountOnline("CI_PLUS_KEY", keys["CI_PLUS_KEY"], autokey);
  4795. }
  4796. if (keys.ContainsKey("Widevine_KEY"))
  4797. {
  4798. if (cfg_writedone.WidevineWrite_YesNo)
  4799. SetCheckboxStatus(WriteWidevine, true);
  4800. UpdateKeyCountOnline("Widevine_KEY", keys["Widevine_KEY"], autokey);
  4801. }
  4802. if (keys.ContainsKey("HDCP2.2_KEY"))
  4803. {
  4804. if (cfg_writedone.HDCP22Write_YesNo)
  4805. SetCheckboxStatus(WriteHDCP22, true);
  4806. UpdateKeyCountOnline("HDCP2.2_KEY", keys["HDCP2.2_KEY"], autokey);
  4807. }
  4808. if (keys.ContainsKey("NETFILX_ESN"))
  4809. {
  4810. if (cfg_writedone.ESNWrite_YesNo)
  4811. SetCheckboxStatus(WriteESN, true);
  4812. UpdateKeyCountOnline("NETFILX_ESN", keys["NETFILX_ESN"], autokey);
  4813. }
  4814. if (keys.ContainsKey("Attestation_key"))
  4815. {
  4816. if (cfg_writedone.AttestationWrite_YesNo)
  4817. SetCheckboxStatus(WriteAttestation, true);
  4818. UpdateKeyCountOnline("Attestation_key", keys["Attestation_key"], autokey);
  4819. }
  4820. if (keys.ContainsKey("MGK_KEY"))
  4821. {
  4822. if (cfg_writedone.MGKWrite_YesNo)
  4823. SetCheckboxStatus(WriteMGK, true);
  4824. UpdateKeyCountOnline("MGK_KEY", keys["MGK_KEY"], autokey);
  4825. }
  4826. if (keys.ContainsKey("Fairplay_KEY"))
  4827. {
  4828. if (cfg_writedone.FairplayWrite_YesNo)
  4829. SetCheckboxStatus(WriteFairplay, true);
  4830. UpdateKeyCountOnline("Fairplay_KEY", keys["Fairplay_KEY"], autokey);
  4831. }
  4832. if (keys.ContainsKey("ECP_KEY"))
  4833. {
  4834. if (cfg_writedone.ECPWrite_YesNo)
  4835. SetCheckboxStatus(WriteECP, true);
  4836. UpdateKeyCountOnline("ECP_KEY", keys["ECP_KEY"], autokey);
  4837. }
  4838. if (keys.ContainsKey("WiFi_MAC"))
  4839. {
  4840. if (cfg_writedone.WifiMacWrite_YesNo)
  4841. SetCheckboxStatus(WriteWifiMac, true);
  4842. UpdateKeyCountOnline("WiFi_MAC", keys["WiFi_MAC"], autokey);
  4843. }
  4844. if (keys.ContainsKey("BT_MAC"))
  4845. {
  4846. if (cfg_writedone.BTMacWrite_YesNo)
  4847. SetCheckboxStatus(WriteBTMac, true);
  4848. UpdateKeyCountOnline("BT_MAC", keys["BT_MAC"], autokey);
  4849. }
  4850. if (keys.ContainsKey("LEK"))
  4851. {
  4852. if (cfg_writedone.LEKWrite_YesNo)
  4853. SetCheckboxStatus(WriteLEK, true);
  4854. UpdateKeyCountOnline("LEK", keys["LEK"], false);
  4855. }
  4856. if (keys.ContainsKey("PEK"))
  4857. {
  4858. if (cfg_writedone.PEKWrite_YesNo)
  4859. SetCheckboxStatus(WritePEK, true);
  4860. UpdateKeyCountOnline("PEK", keys["PEK"], false);
  4861. }
  4862. if (keys.ContainsKey("PlayReady_key"))
  4863. {
  4864. if (cfg_writedone.PlayreadyWrite_YesNo)
  4865. SetCheckboxStatus(WritePlayready, true);
  4866. UpdateKeyCountOnline("PlayReady_key", keys["PlayReady_key"], false);
  4867. }
  4868. if (keys.ContainsKey("Hashkey"))
  4869. {
  4870. if (cfg_writedone.HashWrite_YesNo)
  4871. SetCheckboxStatus(WriteHash, true);
  4872. UpdateKeyCountOnline("Hashkey", keys["Hashkey"], false);
  4873. }
  4874. if (keys.ContainsKey("YouTube_KEY"))
  4875. {
  4876. if (cfg_writedone.YouTubeWrite_YesNo)
  4877. SetCheckboxStatus(WriteYouTube, true);
  4878. UpdateKeyCountOnline("YouTube_KEY", keys["YouTube_KEY"], false);
  4879. }
  4880. if (keys.ContainsKey("DSN"))
  4881. {
  4882. if (cfg_writedone.DSNWrite_YesNo)
  4883. SetCheckboxStatus(WriteDSN, true);
  4884. }
  4885. if (keys.ContainsKey("edid_pid"))
  4886. {
  4887. if (cfg_writedone.EDIDPIDWrite_YesNo)
  4888. SetCheckboxStatus(WriteEDIDPID, true);
  4889. }
  4890. if (keys.ContainsKey("edid_model_name"))
  4891. {
  4892. if (cfg_writedone.EDIDModeNameWrite_YesNo)
  4893. SetCheckboxStatus(WriteEDIDName, true);
  4894. }
  4895. if (keys.ContainsKey("ACAS_KEY"))
  4896. {
  4897. if (cfg_writedone.ACASKeyWrite_YesNo)
  4898. SetCheckboxStatus(WriteACASKey, true);
  4899. UpdateKeyCountOnline("ACAS_KEY", keys["ACAS_KEY"], false);
  4900. }
  4901. if (keys.ContainsKey("DAK"))
  4902. {
  4903. if (cfg_writedone.DAKWrite_YesNo)
  4904. SetCheckboxStatus(WriteDAK, true);
  4905. UpdateKeyCountOnline("DAK", keys["DAK"], false);
  4906. }
  4907. if (keys.ContainsKey("FVP"))
  4908. {
  4909. if (cfg_writedone.FVPWrite_YesNo)
  4910. SetCheckboxStatus(WriteFVP, true);
  4911. UpdateKeyCountOnline("FVP", keys["FVP"], false);
  4912. }
  4913. return true;
  4914. }
  4915. /// <summary>
  4916. /// 在线获取key数量,更新Keycount
  4917. /// </summary>
  4918. /// <param name="key">key种类</param>
  4919. /// <param name="keytype">key的具体类型</param>
  4920. /// <returns></returns>
  4921. public bool UpdateKeyCountOnline(string key, string keytype, bool autokey)
  4922. {
  4923. return true;
  4924. }
  4925. /// <summary>
  4926. /// 按键触发在线抄写
  4927. /// 注意:此按键的作用是给不需要输入SN号的工厂使用;
  4928. /// </summary>
  4929. /// <param name="sender"></param>
  4930. /// <param name="e"></param>
  4931. private void OnBtnClickStart(object sender, EventArgs e)
  4932. {
  4933. SN = ""; // SN置为空,用于不需要扫码SN的某些工厂;
  4934. keyInfo = new KeyInfo();
  4935. if (preloadNow)
  4936. {
  4937. MessageBox.Show(LResource.PreloadError, LResource.Error);
  4938. return;
  4939. }
  4940. SetInitialStatus();
  4941. BtnClickstart.Enabled = false;
  4942. SNText.Enabled = false;
  4943. Onlinemode();
  4944. }
  4945. /// <summary>
  4946. /// 在线获取key的方式抄写
  4947. /// </summary>
  4948. public void Onlinemode()
  4949. {
  4950. keyInfo.DID.enable = WriteDID.Checked = (WriteDID.Checked && m_writedid.Text != LResource.Skip);
  4951. keyInfo.Mac.enable = WriteMac.Checked = (WriteMac.Checked && m_writemac.Text != LResource.Skip);
  4952. keyInfo.HDCP.enable = WriteHDCP.Checked = (WriteHDCP.Checked && m_writehdcp.Text != LResource.Skip);
  4953. keyInfo.HDCP22.enable = WriteHDCP22.Checked = (WriteHDCP22.Checked && m_writehdcp22.Text != LResource.Skip);
  4954. keyInfo.Widevine.enable = WriteWidevine.Checked = (WriteWidevine.Checked && m_writewidevine.Text != LResource.Skip);
  4955. keyInfo.ESN.enable = WriteESN.Checked = (WriteESN.Checked && m_writeesn.Text != LResource.Skip);
  4956. keyInfo.CI_plus.enable = WriteCiplus.Checked = (WriteCiplus.Checked && m_writeci.Text != LResource.Skip);
  4957. keyInfo.Attestation.enable = WriteAttestation.Checked = (WriteAttestation.Checked && m_writeattestation.Text != LResource.Skip);
  4958. keyInfo.MGK.enable = WriteMGK.Checked = (WriteMGK.Checked && m_writeMGK.Text != LResource.Skip);
  4959. keyInfo.WiFi_MAC.enable = WriteWifiMac.Checked = (WriteWifiMac.Checked && m_writeWifiMac.Text != LResource.Skip);
  4960. keyInfo.BT_MAC.enable = WriteBTMac.Checked = (WriteBTMac.Checked && m_writeBTMac.Text != LResource.Skip);
  4961. keyInfo.ECP.enable = WriteECP.Checked = (WriteECP.Checked && m_writeECP.Text != LResource.Skip);
  4962. keyInfo.LEK.enable = WriteLEK.Checked = (WriteLEK.Checked && m_writeLEK.Text != LResource.Skip);
  4963. keyInfo.PEK.enable = WritePEK.Checked = (WritePEK.Checked && m_writePEK.Text != LResource.Skip);
  4964. keyInfo.Playready.enable = WritePlayready.Checked = (WritePlayready.Checked && m_writePlayready.Text != LResource.Skip);
  4965. keyInfo.Hashkey.enable = WriteHash.Checked = (WriteHash.Checked && m_writeHash.Text != LResource.Skip);
  4966. keyInfo.YouTube_KEY.enable = WriteYouTube.Checked = (WriteYouTube.Checked && m_writeYouTube.Text != LResource.Skip);
  4967. keyInfo.EDIDPid.enable = WriteEDIDPID.Checked = (WriteEDIDPID.Checked && m_writeEDIDPID.Text != LResource.Skip);
  4968. keyInfo.EDIDModelName.enable = WriteEDIDName.Checked = (WriteEDIDName.Checked && m_writeEDIDName.Text != LResource.Skip);
  4969. keyInfo.ACASKey_Data.enable = WriteACASKey.Checked = (WriteACASKey.Checked && m_writeACASKey.Text != LResource.Skip);
  4970. keyInfo.DAK.enable = WriteDAK.Checked = (WriteDAK.Checked && m_writeDAK.Text != LResource.Skip);
  4971. keyInfo.FVP.enable = WriteFVP.Checked = (WriteFVP.Checked && m_writeFVP.Text != LResource.Skip);
  4972. keyInfo.DSN.enable = WriteDSN.Checked = (WriteDSN.Checked && m_writeDSN.Text != LResource.Skip);
  4973. keyInfo.Fairplay.enable = WriteFairplay.Checked = (WriteFairplay.Checked && m_writeFairplay.Text != LResource.Skip);
  4974. bool preloadresult = false;
  4975. preloadresult = true;
  4976. timer1.Start();
  4977. UpdateKeys(midListNow.keytype, true);
  4978. WritekeyThread = new Thread(Writekey);
  4979. WritekeyThread.Start();
  4980. if (!preloadresult)
  4981. {
  4982. SNText.Enabled = true;
  4983. }
  4984. }
  4985. /// <summary>
  4986. /// 更新订单抄写数量
  4987. /// </summary>
  4988. /// <returns></returns>
  4989. public bool UploadCopyCount()
  4990. {
  4991. return (SQLiteHelper.UpdateProductionNum(errorDBNow, orderNow));
  4992. }
  4993. /// <summary>
  4994. /// 获取定制化抄写信息
  4995. /// </summary>
  4996. /// <param name="sender"></param>
  4997. /// <param name="e"></param>
  4998. private void OnBtnOtherView(object sender, EventArgs e)
  4999. {
  5000. if (midListNow.rokuCustomer != null)
  5001. 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);
  5002. else
  5003. MessageBox.Show("null");
  5004. }
  5005. /// <summary>
  5006. /// 获取本地key数量
  5007. /// </summary>
  5008. public void GetLocalKeysCount()
  5009. {
  5010. int didnum;
  5011. if (GetLocalKeyCount.GetLocalDidCount(orderNow, out didnum, ref localmidList, errorDBNow))
  5012. {
  5013. SetCheckboxStatus(WriteDID, true);
  5014. if (didnum != -1)
  5015. SetKeyCountStatus(DIDCount, didnum.ToString(), 0);
  5016. else
  5017. SetKeyCountStatus(DIDCount, "Read error", 1);
  5018. }
  5019. int macnum;
  5020. if (GetLocalKeyCount.GetLocalMacCount(orderNow, out macnum, ref localmidList, errorDBNow))
  5021. {
  5022. SetCheckboxStatus(WriteMac, true);
  5023. if (macnum != -1)
  5024. SetKeyCountStatus(MacCount, macnum.ToString(), 0);
  5025. else
  5026. SetKeyCountStatus(MacCount, "Read error", 1);
  5027. }
  5028. int hdcpnum;
  5029. if (GetLocalKeyCount.GetLocalHDCPKEYCount(orderNow, out hdcpnum))
  5030. {
  5031. SetCheckboxStatus(WriteHDCP, true);
  5032. if (hdcpnum != -1)
  5033. SetKeyCountStatus(HDCPCount, hdcpnum.ToString(), 0);
  5034. else
  5035. SetKeyCountStatus(HDCPCount, "Read error", 1);
  5036. }
  5037. int hdcp22num;
  5038. if (GetLocalKeyCount.GetLocalHDCPKEY22Count(orderNow, out hdcp22num))
  5039. {
  5040. SetCheckboxStatus(WriteHDCP22, true);
  5041. if (hdcp22num != -1)
  5042. SetKeyCountStatus(HDCP22Count, hdcp22num.ToString(), 0);
  5043. else
  5044. SetKeyCountStatus(HDCP22Count, "Read error", 1);
  5045. }
  5046. int esnnum;
  5047. if (GetLocalKeyCount.GetLocalESNCount(orderNow, out esnnum))
  5048. {
  5049. SetCheckboxStatus(WriteESN, true);
  5050. if (esnnum != -1)
  5051. SetKeyCountStatus(ESNCount, esnnum.ToString(), 0);
  5052. else
  5053. SetKeyCountStatus(ESNCount, "Read error", 1);
  5054. }
  5055. int widevinenum;
  5056. if (GetLocalKeyCount.GetLocalWidevineCount(orderNow, out widevinenum))
  5057. {
  5058. SetCheckboxStatus(WriteWidevine, true);
  5059. if (widevinenum != -1)
  5060. SetKeyCountStatus(WideVineCount, widevinenum.ToString(), 0);
  5061. else
  5062. SetKeyCountStatus(WideVineCount, "Read error", 1);
  5063. }
  5064. int cinum;
  5065. if (GetLocalKeyCount.GetLocalCIKEYCount(orderNow, out cinum))
  5066. {
  5067. SetCheckboxStatus(WriteCiplus, true);
  5068. if (cinum != -1)
  5069. SetKeyCountStatus(CICount, cinum.ToString(), 0);
  5070. else
  5071. SetKeyCountStatus(CICount, "Read error", 1);
  5072. }
  5073. int mgknum;
  5074. if (GetLocalKeyCount.GetLocalMGKCount(orderNow, out mgknum))
  5075. {
  5076. SetCheckboxStatus(WriteMGK, true);
  5077. if (mgknum != -1)
  5078. SetKeyCountStatus(MGKCount, mgknum.ToString(), 0);
  5079. else
  5080. SetKeyCountStatus(MGKCount, "Read error", 1);
  5081. }
  5082. int attestationnum;
  5083. if (GetLocalKeyCount.GetLocalAttestationCount(orderNow, out attestationnum))
  5084. {
  5085. SetCheckboxStatus(WriteAttestation, true);
  5086. if (attestationnum != -1)
  5087. SetKeyCountStatus(AttestationCount, attestationnum.ToString(), 0);
  5088. else
  5089. SetKeyCountStatus(AttestationCount, "Read error", 1);
  5090. }
  5091. int fairplaynum;
  5092. if (GetLocalKeyCount.GetLocalFairplayCount(orderNow, out fairplaynum))
  5093. {
  5094. SetCheckboxStatus(WriteFairplay, true);
  5095. if (fairplaynum != -1)
  5096. SetKeyCountStatus(FairplayCount, fairplaynum.ToString(), 0);
  5097. else
  5098. SetKeyCountStatus(FairplayCount, "Read error", 1);
  5099. }
  5100. int leknum;
  5101. fireTVKey.LEK = GetLocalKeyCount.GetLocalFolderKeyCount(orderNow, "LEK", out leknum);
  5102. int peknum;
  5103. fireTVKey.PEK = GetLocalKeyCount.GetLocalFolderKeyCount(orderNow, "PEK", out peknum);
  5104. int palyreadynum;
  5105. fireTVKey.Playready = GetLocalKeyCount.GetLocalFolderKeyCount(orderNow, "Playready", out palyreadynum);
  5106. int hashkeynum;
  5107. fireTVKey.Hashkey = GetLocalKeyCount.GetLocalFolderKeyCount(orderNow, "Hashkey", out hashkeynum);
  5108. }
  5109. /// <summary>
  5110. /// 抄写用时计数
  5111. /// </summary>
  5112. /// <param name="sender"></param>
  5113. /// <param name="e"></param>
  5114. private void timer1_Tick(object sender, EventArgs e)
  5115. {
  5116. usingTime += 1;
  5117. UsingTime_Text.Text = usingTime.ToString();
  5118. }
  5119. /// <summary>
  5120. /// 取消SN扫描框聚焦
  5121. /// </summary>
  5122. /// <param name="sender"></param>
  5123. /// <param name="e"></param>
  5124. private void SNText_DoubleClick(object sender, EventArgs e)
  5125. {
  5126. FocusMark = false;
  5127. this.CaptionBackColorTop = Color.RoyalBlue;
  5128. this.CaptionBackColorBottom = Color.Cyan;
  5129. this.Refresh();
  5130. }
  5131. /// <summary>
  5132. /// 强制刷新抄写线程
  5133. /// </summary>
  5134. private void OnBtnRefresh(object sender, EventArgs e)
  5135. {
  5136. usingTime = 0;
  5137. EnableText(SNText);
  5138. EnableButton(BtnClickstart);
  5139. SN = "";
  5140. keyInfo = new KeyInfo();
  5141. SetInitialStatus();
  5142. if (WritekeyThread != null)
  5143. {
  5144. if (WritekeyThread.IsAlive)
  5145. {
  5146. WritekeyThread.Abort();
  5147. if (timer1.Enabled)
  5148. {
  5149. timer1.Stop();
  5150. }
  5151. while (WritekeyThread.ThreadState != System.Threading.ThreadState.Aborted)
  5152. {
  5153. Thread.Sleep(100);
  5154. }
  5155. }
  5156. }
  5157. UsingTime_Text.Text = "0";
  5158. GC.Collect();
  5159. MessageBox.Show(LResource.RefreshPanel);
  5160. }
  5161. /// <summary>
  5162. /// 显示订单key可用余量
  5163. /// </summary>
  5164. /// <param name="sender"></param>
  5165. /// <param name="e"></param>
  5166. private void OrderText_MouseEnter(object sender, EventArgs e)
  5167. {
  5168. toolTip1.SetToolTip(OrderText, LResource.AvailableKey + availableCount);
  5169. }
  5170. }
  5171. }