OperationPanel - 压测.cs 284 KB

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