OperationPanel.cs 270 KB

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