OperationPanel.cs 318 KB

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