OperationPanel.cs 308 KB

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