Esempio n. 1
0
 /// <summary>
 /// 清理超时的命令为发送失败状态
 /// </summary>
 private void ClearTimedoutCommands(CommandBLL bll)
 {
     // 更新GSM状态下的命令超时的记录
     bll.Update(f => f.ScheduleTime <= DateTime.Now.AddMinutes(-5) && GsmStatus.Contains(f.Status.Value), act =>
     {
         act.Status = (byte)CommandStatus.Timedout;
     });
     // 更新卫星发送下的超时命令记录,超过80分钟没有回复的,当作超时
     bll.Update(f => IridiumStatus.Skip(2).Contains(f.Status.Value) &&
                f.ScheduleTime <= DateTime.Now.AddMinutes(-IRIDIUM_MT_TIMEOUT), act =>
     {
         act.Status = (byte)CommandStatus.Timedout;
     });
 }
Esempio n. 2
0
        /// <summary>
        /// 处理查询命令的请求
        /// </summary>
        private void HandleCommandRequest()
        {
            using (var bll = new CommandBLL())
            {
                if (string.IsNullOrEmpty(cmd))
                {
                    var ret = "[]";
                    var obj = bll.Find(f => f.ScheduleTime >= DateTime.Now.AddSeconds(-60) &&
                                       f.Status <= (byte)CommandStatus.WaitingForSMS &&
                                       f.TB_Terminal.OnlineStyle == (byte)LinkType.SATELLITE);
                    var command = new Command(obj);
                    ret = JsonConverter.ToJson(command);

                    ResponseJson(ret);
                }
                else
                {
                    // 更新命令发送状态
                    bll.Update(f => f.id == int.Parse(cmd), act =>
                    {
                        act.Status         = (byte)CommandStatus.SentBySAT;
                        act.ActualSendTime = DateTime.Now;
                    });
                }
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 更新铱星方式发送命令的状态
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="status"></param>
 private void UpdateIridiumCommand(TB_Command obj, CommandStatus status, CommandBLL bll)
 {
     bll.Update(f => f.id == obj.id, act =>
     {
         act.Status         = (byte)status;
         act.ActualSendTime = DateTime.Now;
     });
 }
 /// <summary>
 /// 处理铱星终端接收命令的状态
 /// </summary>
 /// <param name="data"></param>
 private void HandleIridiumMTModelReceiveStatus(IridiumData data)
 {
     using (var bll = new CommandBLL())
     {
         bll.Update(f => f.TB_Terminal.TB_Satellite.CardNo.Equals(data.IMEI) && f.IridiumMTMSN == data.MTMSN && f.Status == (byte)CommandStatus.SentBySAT, act =>
         {
             act.Status = (byte)CommandStatus.SentToDestBySAT;
         });
     }
 }
Esempio n. 5
0
 /// <summary>
 /// 更新命令的发送状态
 /// </summary>
 /// <param name="obj"></param>
 private void UpdateGsmCommand(TB_Command obj, CommandStatus status, CommandBLL bll)
 {
     bll.Update(f => f.id == obj.id, act =>
     {
         act.Status = (byte)status;
         if (status == CommandStatus.SentByTCP)
         {
             act.ActualSendTime = DateTime.Now;
         }
     });
 }
Esempio n. 6
0
 /// <summary>
 /// 根据CC00的返回时间更新之前的0xBB0F命令发送状态为成功返回状态
 /// </summary>
 private void Handle0xBB0FStatus()
 {
     using (var bll = new CommandBLL())
     {
         bll.Update(f => f.ScheduleTime >= DateTime.Now.AddMinutes(-10) &&
                    f.Status == (byte)CommandStatus.SentBySMS && f.Command == "0xBB0F", act =>
         {
             act.Status = (byte)CommandStatus.Returned;
         });
     }
 }
 /// <summary>
 /// 处理铱星命令发送状态
 /// </summary>
 /// <param name="data"></param>
 private void HandleIridiumMTServerSendStatus(IridiumData data)
 {
     using (var bll = new CommandBLL())
     {
         bll.Update(f => f.TB_Terminal.TB_Satellite.CardNo.Equals(data.IMEI) && f.Status == (byte)CommandStatus.SatelliteHandled && f.ActualSendTime == null, action =>
         {
             // 更新等待铱星处理的终端的命令为已发送状态
             action.Status         = (byte)CommandStatus.SentBySAT;
             action.IridiumMTMSN   = data.MTMSN;
             action.ActualSendTime = DateTime.Now;
         });
     }
 }
 /// <summary>
 /// 处理1小时内已被卫星模块接收了的命令为正常返回状态
 /// </summary>
 private void HandleIridiumCommandResponseed(IridiumData data)
 {
     // 更新之前发送到网关或终端已读取的命令为发送成功  2015/11/27 12:38
     using (var bll = new CommandBLL())
     {
         bll.Update(f => f.TB_Terminal.TB_Satellite.CardNo.Equals(data.IMEI) &&
                    f.Command == "0x1000" &&
                    (f.Status == (byte)CommandStatus.SentToDestBySAT || f.Status == (byte)CommandStatus.SentBySAT) &&
                    f.ActualSendTime > DateTime.Now.AddMinutes(-60), act =>
         {
             act.Status = (byte)CommandStatus.Returned;
         });
     }
 }
Esempio n. 9
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);
        }
Esempio n. 10
0
        /// <summary>
        /// 处理EE00命令
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="equipment"></param>
        /// <param name="terminal"></param>
        private void Handle0xEE00(TX300 obj, TB_Equipment equipment, TB_Terminal terminal)
        {
            _0xEE00 xee00 = new _0xEE00();

            xee00.Content = obj.MsgContent;
            xee00.Unpackage();
            // 更新终端发送命令的结果
            if (null != equipment && xee00.ErrorCommand.Equals("0x6007"))
            {
                // 更新锁车状态
                using (var bll = new EquipmentBLL())
                {
                    bll.Update(f => f.id == equipment.id, act =>
                    {
                        act.LockStatus = xee00.ErrorParamenter;
                    });
                }
            }
            // 更新命令的发送状态
            using (var bll = new CommandBLL())
            {
                bll.Update(f => f.DestinationNo == obj.TerminalID &&
                           f.Command == xee00.ErrorCommand &&
                           f.ScheduleTime >= DateTime.Now.AddMinutes(-3) &&
                           f.Status >= (byte)CommandStatus.SentByTCP &&
                           f.Status <= (byte)CommandStatus.SentToDest, act =>
                {
                    byte b = 0x10;
                    switch (xee00.Error)
                    {
                    case 0x20:
                        b = (byte)CommandStatus.EposFail;
                        break;

                    case 0x30:
                        b = (byte)CommandStatus.EngNotStart;
                        break;

                    default:
                        b = (byte)CommandStatus.NoFunction;
                        break;
                    }
                    act.Status = b;
                });
            }
        }
Esempio n. 11
0
        /// <summary>
        /// 处理GSM命令回复状态
        /// </summary>
        /// <param name="tx300"></param>
        private void HandleGsmCommandResponsed(TX300 tx300)
        {
            using (var bll = new CommandBLL())
            {
                // 查找定期时间内发送的相同命令记录,直取最后一条命令
                var cmd = bll.FindList <TB_Command>(f => f.DestinationNo.Equals(tx300.TerminalID) &&
                                                    f.Command.Equals("0x" + CustomConvert.IntToDigit(tx300.CommandID, CustomConvert.HEX, 4)) &&
                                                    f.ScheduleTime >= DateTime.Now.AddMinutes(tx300.ProtocolType == Protocol.ProtocolTypes.SATELLITE ? -60 : -3),
                                                    "ScheduleTime", true).FirstOrDefault();

                if (null != cmd)
                {
                    bll.Update(f => f.id == cmd.id, act =>
                    {
                        act.Status = (byte)CommandStatus.Returned;
                    });
                }
                //bll.Update(f => f.DestinationNo == tx300.TerminalID &&
                //    f.Command == "0x" + CustomConvert.IntToDigit(tx300.CommandID, CustomConvert.HEX, 4) &&
                //    f.ScheduleTime >= DateTime.Now.AddMinutes(-3) //&&
                //    //GsmStatus.Skip(2).Contains(f.Status.Value),
                //    , act => { act.Status = (byte)CommandStatus.Returned; });
            }
        }
Esempio n. 12
0
 private void HandleIridiumCommand(TB_Command obj, CommandBLL bll)
 {
     if (null != OnIridiumSend)
     {
         IridiumDataEvent e = new IridiumDataEvent();
         e.Data = new IridiumData()
         {
             Payload = CustomConvert.GetBytes(obj.Content),
             IMEI    = obj.TB_Terminal.TB_Satellite.CardNo,
             MTMSN   = GetIridiumMTMSN()
         };
         e.Data.Payload[2] = ProtocolTypes.SATELLITE;
         OnIridiumSend(this, e);
         // 更新命令发送状态
         bll.Update(f => f.id == obj.id, act =>
         {
             act.Status = (byte)CommandStatus.SatelliteHandled;
         });
         if (obj.TB_Terminal.Satellite != (int?)null)
         {
             HandleIridiumMTFlow(obj.TB_Terminal.Satellite.Value, obj.Content.Length / 2);
         }
     }
 }