using Estsh.Client.Base; namespace Estsh.Client.StepLibrary { public class RF182CRFIDWrite : StepBase { public override bool Do () { try { //RF182C rf182c=new RF182C (); RFIDApp app = new RFIDApp (httpClient); string el_no = Context [ "serial_number" ] .ToString (); string terminal_id = Context [ "terminal_id" ] .ToString (); // 执行父类的 Do 方法并返回 bool initializeRFIDState =Convert .ToBoolean (Context [ "initializeRFIDState" ] .ToString ()); bool TAGState =Convert .ToBoolean (Context [ "TAGState" ] .ToString ()); if ( initializeRFIDState == true ) { if ( TAGState == false ) { ShowMessage (this , "red|未检测到TAG!"); } else { List RFIDOperationType = app .GetRFIDOperationType (Convert .ToInt32 (terminal_id) , "RFID_IP"); string perationType=""; if ( RFIDOperationType .Count > 0 ) { perationType = RFIDOperationType [ 0 ] [ "operation_type" ] .ToString (); } if ( initializeRFIDState == true && perationType .ToUpper () .ToString () == "WRITE" ) { RF182C.Write(el_no); Thread.Sleep(200); RF182C .read (); if (el_no != RF182C.BarCode) { RF182C.Write(el_no); RF182C .read (); if (el_no != RF182C.BarCode) { ShowMessage (this , "red|RFID写入失败,请重新扫描!"); } Complate(this, new EventArgs()); } Complate(this, new EventArgs()); } } } } catch ( Exception ex ) { // 记录日志 using ( StreamWriter sw = new StreamWriter ("Error_Log_" + DateTime .Now .ToString ("yyyyMM") + ".txt" , true) ) { sw .WriteLine (string .Format ("{0} {1}" , "[" + DateTime .Now .ToString ("yyyy-MM-dd HH:mm:ss") + "] " , ex .ToString ())); sw .Flush (); sw .Close (); ShowMessage(this, "red|RFID写入失败,程序未连接RFID!"); } } return base.Do(); } private void InitializeComponent () { this.SuspendLayout(); // // RF182CRFIDWrite // this.Name = "RF182CRFIDWrite"; this.Size = new System.Drawing.Size(831, 409); this.Load += new System.EventHandler(this.RFIDWrite_Load); this.ResumeLayout(false); } private void RFIDWrite_Load ( object sender , EventArgs e ) { // 工步执行完成后调用此方法 // Complate (this , e); } } }