OperationPanel.cs 246 KB

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