public void Add(EVehicleRunningState entity)
 {
     using (IRepository repository = SessionManager.CreateRepository(typeof(EVehicleRunningState)))
     {
         repository.Save(entity);
     }
 }
示例#2
0
        protected virtual void ModifyRunningState(EVehicleRunningState existRunningState, EnumAlertState alertModifyState, EnumSMSInfoType alarmType)
        {
            if (existRunningState == null) return;

            // 有记录且报警状态不同,修改报警状态
            if (alertModifyState == EnumAlertState.Alerting)
            {
                existRunningState.State = (int)EnumRunningState.Alarming;
                existRunningState.AlarmType = (int)alarmType;
                return;
            }

            // 报警恢复时,删除记录(即重置,重置后AlertHandlerService会将该记录删除)
            if (alertModifyState == EnumAlertState.Resume && existRunningState.AlarmType == (int)alarmType)
            {
                existRunningState.State = (int)EnumRunningState.Running;
                existRunningState.AlarmType = null;
            }
        }
示例#3
0
        /// <summary>
        /// 检查当前车辆的当前状态,
        /// 如果当前状态的报警类型与参数alarmType一致,则还原State为Running,
        /// 否则不进行任何处理
        /// </summary>
        /// <param name="existRunningState"></param>
        /// <param name="alarmType"></param>
        protected virtual void RemoveRunningState(EVehicleRunningState existRunningState, EnumSMSInfoType alarmType)
        {
            if (existRunningState == null) return;

            if (existRunningState.State == (int)EnumRunningState.Alarming && existRunningState.AlarmType == (int)alarmType)
            {
                existRunningState.State = (int)EnumRunningState.Running;
                existRunningState.AlarmType = null;
            }
        }
 private IList<EVehicleRunningState> GetNormalState(IList<Guid> codeList)
 {
     IList<string> newList = codeList.Select(i => i.ToString()).ToList();
     IList<EGPSCurrentInfo> list = GetCurrentInfo(newList);
     IList<EVehicleRunningState> result = new List<EVehicleRunningState>();
     foreach (var item in list)
     {
         EVehicleRunningState state = new EVehicleRunningState() 
         {
             VehicleCode=item.VehicleCode.Value,
             State= (int)GetRunningState(item)
         };
         result.Add(state);
     }
     return result;
 }
        public void Check(IList<EGPSCurrentInfo> list)
        {
            if (list == null || list.Count == 0)
            {
                return;
            }

            IList<EGPSCurrentInfo> ltCurrentInfo = Distinct(list);
            
            IList<EVehicleRunningState> ltState = this.List(list.Select(s => s.VehicleCode.Value).ToList());
            IList<EVehicleRunningState> ltDelete = new List<EVehicleRunningState>();
            IList<EVehicleRunningState> ltAdd = new List<EVehicleRunningState>();
            IList<EVehicleRunningState> ltUpdate = new List<EVehicleRunningState>();
            foreach (var gpsCurrentInfo in ltCurrentInfo)
            {
                EVehicleRunningState vehicleRunningState = ltState.SingleOrDefault(s => s.VehicleCode == gpsCurrentInfo.VehicleCode.Value);
                EnumRunningState state = GetRunningState(gpsCurrentInfo);
                if (vehicleRunningState != null)
                {
                    if (vehicleRunningState.State != (int)EnumRunningState.Alarming)
                    {
                        if (state == EnumRunningState.Running)
                        {
                            ltDelete.Add(vehicleRunningState);
                        }
                        else if (state == EnumRunningState.Stop || state == EnumRunningState.StopAccOn)
                        {
                            if (vehicleRunningState.State != (int)state)
                            {
                                vehicleRunningState.State = (int)state;
                                ltUpdate.Add(vehicleRunningState);
                            }
                        }
                    }
                }
                else
                {
                    if (state != EnumRunningState.Running)
                    {
                        vehicleRunningState = new EVehicleRunningState();
                        vehicleRunningState.State = (int)state;
                        vehicleRunningState.VehicleCode = gpsCurrentInfo.VehicleCode.Value;
                        ltAdd.Add(vehicleRunningState);
                    }
                }
            }
            this.Delete(ltDelete);
            this.Add(ltAdd);
            this.Update(ltUpdate);
        }
        //private string GetMessage(EBaseAlertReport alert)
        //{
        //    string title;
        //    string content;
        //    if (alert.EnumAlertState == EnumAlertState.Alerting)
        //    {
        //        title = alert.GetAlertTitle();
        //        content = alert.GetAlertMessage();
        //    }
        //    else
        //    {
        //        title = alert.GetResumeAlertTitle();
        //        content = alert.GetResumeAlertMessage();
        //    }

        //    return string.Format("[{0}],{1},{2}", title, content, alert.ReceiveUserList);
        //}
 

 
        #endregion

        #region 设置GPS平台报警状态统计


        public virtual void SetRunningState(EnumAlertState alertState, EnumSMSInfoType alarmType, Guid vehicleCode)
        {
            try
            {
                IVehicleRunningStateManager manager = new VehicleRunningStateManager();
                var vehicleRunningState = manager.Get(vehicleCode);
                if (alertState == EnumAlertState.Alerting)
                {
                    if (vehicleRunningState == null)            //没有记录时,保存新记录
                    {
                        vehicleRunningState = new EVehicleRunningState();
                        vehicleRunningState.AlarmType = (int)alarmType;
                        vehicleRunningState.State = (int)EnumRunningState.Alarming;
                        vehicleRunningState.VehicleCode = vehicleCode;
                        manager.Add(vehicleRunningState);
                    }
                    else
                    {
                        if (vehicleRunningState.AlarmType != (int)alarmType)   //有记录且报警状态不同,修改报警状态
                        {
                            vehicleRunningState.State = (int)EnumRunningState.Alarming;
                            vehicleRunningState.AlarmType = (int)alarmType;
                            manager.Update(vehicleRunningState);
                        }
                    }
                }
                else
                {
                    if (vehicleRunningState != null)
                    {
                        if (vehicleRunningState.AlarmType == (int)alarmType)    //报警恢复时,删除记录
                        {
                            manager.Delete(vehicleRunningState);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }