OperationPanel.cs 274 KB

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