OperationPanel.cs 281 KB

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