OperationPanel.cs 245 KB

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