OperationPanel.cs 246 KB

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