OperationPanel.cs 329 KB

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