OperationPanel.cs 310 KB

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