OperationPanel.cs 323 KB

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