OperationPanel.cs 266 KB

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