OperationPanel.cs 310 KB

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