OperationPanel.cs 252 KB

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