OperationPanel.cs 242 KB

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