OperationPanel.cs 310 KB

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