OperationPanel.cs 262 KB

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