Exemple #1
0
        /// <summary>
        /// 处理查询命令发送状态的请求
        /// </summary>
        /// <returns></returns>
        private string HandleQueryCommandStatusRequest()
        {
            string ret = "";

            using (var bll = new CommandBLL())
            {
                var cmd = bll.Find(f => f.id == ParseInt(data));
                if (null == cmd)
                {
                    ret = ResponseMessage(-1, "No such command record exists.");
                }
                else
                {
                    byte          status = cmd.Status.Value;
                    CommandStatus state  = (CommandStatus)status;
                    if (state == CommandStatus.Returned)
                    {
                        using (var dbll = new DataBLL())
                        {
                            var list = dbll.FindList <TB_HISTORIES>(f =>
                                                                    f.command_id.Equals(cmd.Command) && f.terminal_id.Equals(cmd.DestinationNo) &&
                                                                    f.receive_time > cmd.ActualSendTime, "receive_time", true);
                            var data = list.FirstOrDefault();
                            var desc = CommandUtility.GetCommandStatus(state);
                            if (null != data)
                            {
                                desc += GetCommandData(data);
                            }
                            ret = ResponseMessage(status, desc);
                        }
                    }
                    else
                    {
                        ret = ResponseMessage(status, CommandUtility.GetCommandStatus(state));
                        if (cmd.Command == "0x4000" && (state == CommandStatus.SentBySMS || state == CommandStatus.SentByTCP))
                        {
                            // 将重置终端连接的命令状态改成不需要回复的状态
                            bll.Update(f => f.id == cmd.id, act =>
                            {
                                act.Status = (byte)CommandStatus.NotNeedReturn;
                            });
                        }
                    }
                }
            }
            return(ret);
        }