OperationPanel.cs 262 KB

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