protected virtual void DeleteAlarmRunningState(EnumSMSInfoType alarmType, Guid vehicleCode)
 {
     try
     {
         IVehicleRunningStateManager manager = new VehicleRunningStateManager();
         var vehicleRunningState = manager.Get(vehicleCode);
         if (vehicleRunningState != null && vehicleRunningState.State == (int)EnumRunningState.Alarming
             && vehicleRunningState.AlarmType == (int)alarmType)
         {
             manager.Delete(vehicleRunningState);
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
 }
Exemplo n.º 2
0
        private IList<EVehicleRunningState> GetRunningStates(EGPSInstallationInfo[] arrEGPSInstallationInfo)
        {
            try
            {
                IList<Guid> ltVehicleCode = new List<Guid>();
                foreach (var item in arrEGPSInstallationInfo)
                {
                    Guid code = item.VehicleInfo.Code;
                    if (!ltVehicleCode.Contains(code))
                    {
                        ltVehicleCode.Add(code);
                    }
                }

                IVehicleRunningStateManager mgr = new VehicleRunningStateManager();
                return mgr.Get(ltVehicleCode);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return new List<EVehicleRunningState>();
            }
        }
        //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);
            }
        }