OperationPanel.cs 309 KB

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