using Estsh.Client.Base; namespace Estsh.Client.StepLibrary { public class RFIDRead : StepBase { private string inputSN = string.Empty; public string InputSN { get { return inputSN; } } public override bool Do () { try { RFIDApp app = new RFIDApp(httpClient); string el_no = Context["serial_number"].ToString(); string terminal_id = Context["terminal_id"].ToString(); // 执行父类的 Do 方法并返回 bool TAGState = Convert.ToBoolean(Context["TAGState"].ToString()); if (TAGState == false) { ShowMessage(this, "red|托盘未到位!"); } else { string SN = app.ReadyPlc("OPC_ReadSN", Convert.ToInt32(terminal_id)).ToString().ToUpper(); if (!string.IsNullOrEmpty(SN)) { inputSN = SN; } else { ShowMessage(this, "red|读取条码失败!"); return false; } } // 执行父类的 Do 方法并返回 return base .Do (); } 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 (); } return false; } } private void InitializeComponent () { this .SuspendLayout (); // // RFIDRead // this .Name = "RFIDRead"; this .Load += new System .EventHandler (this .RFIDRead_Load); this .ResumeLayout (false); } private void RFIDRead_Load ( object sender , EventArgs e ) { // 工步执行完成后调用此方法 Complate (this , e); } } }