OperationPanel.cs 330 KB

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