/// <summary> /// 直接发送 /// </summary> /// <param name="dmSCRClient"></param> /// <param name="dMSCRProtocol"></param> public void SendReplyToSCRClient(DMClient dmSCRClient, DMSCRProtocol dMSCRProtocol) { if (dmSCRClient != null && dMSCRProtocol != null) { dmSCRClient.Send(dMSCRProtocol.makeMessage()); } }
/// <summary> /// 提交预约数据等 后回复设备 /// </summary> /// <param name="command"></param> /// <param name="dmSCRClient"></param> /// <param name="jsonResult0"></param> /// <param name="jsonResult1"></param> public void SendReplyToSCRClient(COMMAND command, DMClient dmSCRClient, string jsonResult0, string jsonResult1 = null) { DMSCRProtocol dMSCRProtocol; switch (command) { //仪器信息 case COMMAND.REP_SCR_DEV_INFO: //51 dMSCRProtocol = new DMSCRProtocol(HEADER.XXZL.ToString(), VERSION.V0100.ToString(), (int)command, dmSCRClient.DeviceID, (int)dmSCRClient.Stat, (int)dmSCRClient.Powerstat, DateTime.Now.ToString("yyyyMMddHHmmss")); try { SCRInstrumentInformation data = JsonSerializer.Deserialize <SCRInstrumentInformation>(jsonResult0); dMSCRProtocol.setSCRInstrumentInformation(data); dmSCRClient.Send(dMSCRProtocol.makeMessage()); } catch (Exception ex) { writeLog(dmSCRClient, ex.Message, "REP_SCR_DEV_INFO故障"); } break; //回复屏幕首页信息 case COMMAND.REP_SCR_STATE_BOOK: //52 try { dMSCRProtocol = new DMSCRProtocol(HEADER.XXZL.ToString(), VERSION.V0100.ToString(), (int)command, dmSCRClient.DeviceID, (int)STAT.UNCHANGING, (int)POWERSTAT.UNCHANGING, DateTime.Now.ToString("yyyyMMddHHmmss")); SCRInstrumentStatus status = JsonSerializer.Deserialize <SCRInstrumentStatus>(jsonResult0); SCRInstrumentFutureStatus futureStatus = new SCRInstrumentFutureStatus() { bookingStart = "", phonenumber = "", userName = "" }; if (!string.IsNullOrEmpty(jsonResult1)) { futureStatus = JsonSerializer.Deserialize <SCRInstrumentFutureStatus>(jsonResult1); } dMSCRProtocol.setSCRInstrumentStatusAndFutureStatus(dmSCRClient.InstrumentName, status, futureStatus); dmSCRClient.Send(dMSCRProtocol.makeMessage()); } catch (Exception ex) { writeLog(dmSCRClient, ex.Message, "REP_SCR_STATE_BOOK"); } break; case COMMAND.REP_SCR_BOOK_CALENDAR: try { List <SCRBookingPeriod> periodList = JsonSerializer.Deserialize <List <SCRBookingPeriod> >(jsonResult0); dMSCRProtocol = new DMSCRProtocol(HEADER.XXZL.ToString(), VERSION.V0100.ToString(), (int)command, dmSCRClient.DeviceID, (int)dmSCRClient.Stat, (int)dmSCRClient.Powerstat, DateTime.Now.ToString("yyyyMMddHHmmss")); dMSCRProtocol.setSCRCalendar(periodList); dmSCRClient.Send(dMSCRProtocol.makeMessage()); } catch (Exception ex) { writeLog(dmSCRClient, ex.Message, "REP_SCR_BOOK_CALENDAR"); } break; case COMMAND.REP_SCR_BOOK_DATE: //56 try { List <SCRBookingByDayInformation> bookingList = JsonSerializer.Deserialize <List <SCRBookingByDayInformation> >(jsonResult0); dMSCRProtocol = new DMSCRProtocol(HEADER.XXZL.ToString(), VERSION.V0100.ToString(), (int)command, dmSCRClient.DeviceID, (int)dmSCRClient.Stat, (int)dmSCRClient.Powerstat, DateTime.Now.ToString("yyyyMMddHHmmss")); dMSCRProtocol.setSCRBookings(bookingList); dmSCRClient.Send(dMSCRProtocol.makeMessage()); } catch (Exception ex) { writeLog(dmSCRClient, ex.Message, "REP_SCR_BOOK_DATE"); } break; case COMMAND.REP_SCR_BOOKING: dMSCRProtocol = new DMSCRProtocol(HEADER.XXZL.ToString(), VERSION.V0100.ToString(), (int)command, dmSCRClient.DeviceID, (int)dmSCRClient.Stat, (int)dmSCRClient.Powerstat, DateTime.Now.ToString("yyyyMMddHHmmss")); try { SCRBookingREP scrBookingREP = JsonSerializer.Deserialize <SCRBookingREP>(jsonResult0); if (scrBookingREP.code == 500) { if (scrBookingREP.msg.Length > 16) { dMSCRProtocol.setSCRBookingResult(scrBookingREP.msg.Substring(0, 15)); } else { dMSCRProtocol.setSCRBookingResult(scrBookingREP.msg); } } else { dMSCRProtocol.setSCRBookingResult(scrBookingREP.msg); } } catch (Exception ex) { writeLog(dmSCRClient, ex.Message, "REP_SCR_BOOKING"); if (jsonResult0.Length > 16) { dMSCRProtocol.setSCRBookingResult(jsonResult0.Substring(0, 15)); } else { dMSCRProtocol.setSCRBookingResult(jsonResult0); } } dmSCRClient.Send(dMSCRProtocol.makeMessage()); break; } }