OperationPanel.cs 276 KB

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