OperationPanel.cs 317 KB

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