private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var resSling = ((sender as FrameworkElement).Tag as ListData).Data as ResSling; this.curSling = resSling; this.tbInfo.Text = ""; this.gridNo = resSling.CabinetGrid; // 发送开锁信号,通知柜门开锁 if (spCabinet.IsOpen) // 已打开,直接发送消息 { var msg = string.Format("8A 01 {0} 11", Convert.ToInt32(resSling.CabinetGrid).ToString("X2")); var flag = spCabinet.Write(string.Format("{0} {1}", msg, BCC.CheckXOR(msg))); if (!flag) { Log.WriteLog(string.Format("ERROR-BOM:开锁消息发送失败,{0}", msg)); } } else // 未打开,先打开端口 { SpConfig spConfig = new SpConfig(); spConfig.PortName = ConfigurationManager.AppSettings["CabinetPort"]; spConfig.BaudRate = 9600; // 波特率 spConfig.Parity = System.IO.Ports.Parity.None; // 偶校验位 spConfig.DataBits = 8; spConfig.StopBits = System.IO.Ports.StopBits.One; // 停止位 try { // 打开 string err = ""; if ((err = spCabinet.Open(spConfig)) != "") { this.ShowMessageInfo(err, this.redBrush); } // 发开锁消息 var msg = string.Format("8A 01 {0} 11", Convert.ToInt32(resSling.CabinetGrid).ToString("X2")); var flag = spCabinet.Write(string.Format("{0} {1}", msg, BCC.CheckXOR(msg))); if (!flag) { Log.WriteLog(string.Format("ERROR-BOM:开锁消息发送失败,{0}", msg)); } } catch (Exception ex) { this.ShowMessageInfo("开锁失败,请重试!", this.redBrush); Log.WriteLog(string.Format("ERROR-BOM:开锁失败,失败信息:{0}", ex.Message)); } } }
private static ResSling CreateSling(List <object> list) { var resSling = new ResSling(); resSling.ResID = list[0].ToString(); resSling.RfID = list[1].ToString(); resSling.ResName = list[2].ToString(); resSling.CreatedTime = list[7].ToString(); resSling.TakeStaffName = list[4].ToString(); resSling.TakeTime = list[5].ToString(); resSling.ReturnPlanTime = list[6].ToString(); resSling.CabinetName = list[10].ToString(); resSling.CabinetLocation = list[11].ToString(); resSling.CabinetGrid = list[8].ToString(); return(resSling); }
private async void TakeSling() { var flag = await Service.TakeSling(this.staffId, this.curSling.RfID); if (flag) { Log.WriteLog(string.Format("INFO-BOW:取出记录入库成功!取出人员:{0}-RFID:{1}", this.staffName, this.curSling.RfID)); // 重新获取列表 this.GetData(); } else { Log.WriteLog(string.Format("ERROR-BOW:取出记录入库失败,请检查日志!取出人员:{0}-RFID:{1}", this.staffName, this.curSling.RfID)); } this.curSling = null; }