OperationPanel.cs 275 KB

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