OperationPanel.cs 262 KB

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