OperationPanel.cs 281 KB

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