OperationPanel.cs 314 KB

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