Exemple #1
0
        /// <summary>
        /// 设置仪器状态查询 包括预约
        /// </summary>
        /// <param name="status"></param>
        public void setSCRInstrumentStatusAndFutureStatus(string InstrumentName, SCRInstrumentStatus status, SCRInstrumentFutureStatus futureStatus)
        {
            string[] info = new string[5];
            info[0] = InstrumentName;
            info[1] = status.instrumentStatus;
            string bookingEnd = status.bookingEnd;

            try
            {
                DateTime dt = DateTime.ParseExact(status.bookingEnd, "yyyy-MM-dd HH:mm:ss", null, System.Globalization.DateTimeStyles.AllowWhiteSpaces);
                bookingEnd = dt.ToString("HH:mm:ss");
            }
            catch (Exception ex)
            {
            }
            info[2] = "[" + status.userName + "-" + status.bookingStart + "-" + bookingEnd + "]";
            info[3] = "[" + futureStatus.userName + " " + futureStatus.bookingStart + "" + "" + "]";
            info[4] = futureStatus.phonenumber;

            info           = replaceComma(info);
            this.OtherInfo = info;
        }
Exemple #2
0
        /// <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;
            }
        }