OperationPanel.cs 241 KB

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