Exemplo n.º 1
0
        /// <summary>
        /// 获得仪器数据
        /// </summary>
        /// <param name="deviceId"></param>
        /// <returns></returns>
        public SCRInstrumentInformation getInstrumentInformation(string deviceId)
        {
            //string json = TestData.InstrumentInformation;
            string json = GetURLWebAPI(_LIMSBookURL, "/getInstrumentInformation/" + deviceId);
            SCRInstrumentInformation data = JsonSerializer.Deserialize <SCRInstrumentInformation>(json);

            return(data);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 首页之基础信息
 /// </summary>
 /// <param name="information"></param>
 public void setSCRInstrumentInformation(SCRInstrumentInformation information)
 {
     string[] info = new string[14];
     info[0]        = information.cname;
     info[1]        = information.instrVersion;
     info[2]        = information.contact;
     info[3]        = information.phone;
     info[4]        = information.workTimeOut;
     info[5]        = information.minSpanMin.ToString();
     info[6]        = information.maxSpanMax.ToString();
     info[7]        = information.workeTimeAuthenticate;
     info[8]        = information.weekendAuthenticate.ToString();
     info[9]        = information.powerUpFee.ToString();
     info[10]       = information.weekendAuthenticate.ToString();
     info[11]       = information.hrFee.ToString();
     info[12]       = information.discountIn.ToString();
     info[13]       = information.discountOut.ToString();
     info           = replaceComma(info);
     this.OtherInfo = info;
 }
Exemplo n.º 3
0
        /// <summary>
        /// 处理SCR数据 暂时越过
        /// </summary>
        /// <param name="deviceId"></param>
        /// <param name="command"></param>
        /// <returns></returns>
        public string HandleServerMessage(string deviceId, COMMAND command, DMClient dmSCRClient, DMSCRProtocol dMSCRProtocol)
        {
            string jsonResult0 = "";
            string jsonResult1 = "";

            switch (command)
            {
            case COMMAND.SCR_DEV_INFO:    //11
                //响应获取仪器信息
                jsonResult0 = getInstrumentInformationJSON(deviceId);
                SendReplyToSCRClient(COMMAND.REP_SCR_DEV_INFO, dmSCRClient, jsonResult0);
                break;

            case COMMAND.SCR_STATE_BOOK:    //12
                //响应获取仪器状态和未来的预约情况 test
                //jsonResult0 = TestData.InstrumentStatus;
                //jsonResult1 = TestData.InstrumentFutureStatus;

                try
                {
                    jsonResult0 = GetURLWebAPI(_LIMSBookURL, "/getInstrumentStatus/" + deviceId);
                    jsonResult1 = GetURLWebAPI(_LIMSBookURL, "/getInstrumentFutureStatus/" + deviceId);     //12月没返回数据 webapi要改
                    if (string.IsNullOrEmpty(dmSCRClient.InstrumentName))
                    {
                        SCRInstrumentInformation dataIn = getInstrumentInformation(dmSCRClient.DeviceID);
                        dmSCRClient.InstrumentName    = dataIn.cname;
                        dmSCRClient.InstrumentVersion = dataIn.instrVersion;
                    }
                    SendReplyToSCRClient(COMMAND.REP_SCR_STATE_BOOK, dmSCRClient, jsonResult0, jsonResult1);
                }
                catch (Exception ex)
                {
                    writeLog(dmSCRClient, ex.Message, "SCR_STATE_BOOK");
                }
                break;

            case COMMAND.SCR_BOOK_CALENDAR:    //15
                //响应仪器日历情况
                //jsonResult0 = TestData.InstrumentCalendar;
                jsonResult0 = getCalendarBookingJSON(deviceId, dMSCRProtocol);

                SendReplyToSCRClient(COMMAND.REP_SCR_BOOK_CALENDAR, dmSCRClient, jsonResult0);

                break;

            case COMMAND.SCR_BOOK_DATE:    //16
                //当天预约查询
                //jsonResult0 = TestData.InstrumentDayBooking;
                jsonResult0 = getBookingByDateJSON(deviceId, dMSCRProtocol);
                SendReplyToSCRClient(COMMAND.REP_SCR_BOOK_DATE, dmSCRClient, jsonResult0);
                break;

            case COMMAND.SCR_BOOK_INFO:
                //响应获取预约基础数据
                try
                {
                    DMSCRProtocol rep = getBasicDataRep(deviceId, dMSCRProtocol, dmSCRClient);
                    SendReplyToSCRClient(dmSCRClient, rep);
                }
                catch (Exception ex)
                {
                    writeLog(dmSCRClient, ex.Message, "SCR_BOOK_INFO");
                }
                break;

            case COMMAND.SCR_BOOKING:
                //提交预约
                //string json = GetURLWebAPI(_LIMSBookURL, "agreed/getInstrumentInformation/" + deviceId);
                jsonResult0 = submitBooking(dMSCRProtocol);
                SendReplyToSCRClient(COMMAND.REP_SCR_BOOKING, dmSCRClient, jsonResult0);
                break;

            case COMMAND.SCR_HELP:
                //获取帮助
                try
                {
                    DMSCRProtocol rep = getHelpDataRep(deviceId, dMSCRProtocol, dmSCRClient);
                    SendReplyToSCRClient(dmSCRClient, rep);
                }
                catch (Exception ex) {
                    writeLog(dmSCRClient, ex.Message, "SCR_HELP");
                }
                break;

            case COMMAND.SCR_USERINFO:    //19
                //获取用户数据
                try
                {
                    DMSCRProtocol rep = getUserDataRep(deviceId, dMSCRProtocol, dmSCRClient);
                    SendReplyToSCRClient(dmSCRClient, rep);
                }
                catch (Exception ex)
                {
                    writeLog(dmSCRClient, ex.Message, "SCR_USERINFO");
                }
                break;
            }
            return("");
        }
Exemplo n.º 4
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;
            }
        }