OperationPanel.cs 240 KB

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