Example #1
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>();
            }
        }
Example #2
0
        public void ChangeToRead(Guid infoID)
        {
            EWebSMSInfo info = GetInfo(infoID);
            if (info == null)
                return;
            //using (IRepository repository = SessionManager.CreateRepository(typeof(EWebSMSAndUser)))
            //{
            //    repository.Register(typeof(EWebSMSAndUser));
            //    HQuery query = new HQuery("Update EWebSMSAndUser Set IsRead = :IsRead , ReadTime = :ReadTime Where SMSInfoID = :SMSInfoID and IsRead=" + (int)EnumIsRead.UnRead);
            //    query.Parameters.Add("IsRead", Convert.ToBoolean(EnumIsRead.Readed));
            //    query.Parameters.Add("ReadTime", DateTime.Now);
            //    query.Parameters.Add("SMSInfoID", infoID);
            //    repository.Execute(query);
            //}

            string sql = string.Format("Update gps_websmsanduser Set IsRead = {0} , ReadTime = '{1}' Where SMSInfoID = '{2}' and IsRead={3}",
              (int)EnumIsRead.Readed, DateTime.Now, infoID, (int)EnumIsRead.UnRead);
            MySqlHelper.ExecuteNonQuery(DefaultConnectionString, sql,120);

            if (info.VehicleCode.HasValue)
            {
                IVehicleRunningStateManager stateManger = new VehicleRunningStateManager();
                stateManger.CheckAndDelete(info.VehicleCode.Value, info.Type);
            }
            using (IRepository repository = SessionManager.CreateRepository(typeof(EWebSMSAndUser_New)))
            {
                repository.Register(typeof(EWebSMSAndUser_New));
                HQuery query = new HQuery("Delete From EWebSMSAndUser_New Where SMSInfoID = :SMSInfoID ");
                query.Parameters.Add("SMSInfoID", infoID);
                repository.Execute(query);
            }
        }
Example #3
0
 private void CheckAndDeleteRunningState(string userCode)
 {
     IList<EWebSMSAndUser_New> ltUser = SearchUnRead(userCode);
     if (ltUser != null && ltUser.Count > 0)
     {
         IList<EWebSMSInfo> ltInfo = GetInfoList(ltUser.Select(s => s.SMSInfoID).ToList());
         Dictionary<Guid, int> dicVehicleCodeAndType = new Dictionary<Guid, int>();
         foreach (var info in ltInfo)
         {
             if (info.VehicleCode.HasValue)
             {
                 if (!dicVehicleCodeAndType.ContainsKey(info.VehicleCode.Value))
                 {
                     dicVehicleCodeAndType.Add(info.VehicleCode.Value, info.Type);
                 }
             }
         }
         if (dicVehicleCodeAndType.Count > 0)
         {
             IVehicleRunningStateManager stateManger = new VehicleRunningStateManager();
             stateManger.CheckAndDelete(dicVehicleCodeAndType);
         }
     }
 }
Example #4
0
 public void ChangeReadState(Guid id)
 {
     using (IRepository repository = SessionManager.CreateRepository(typeof(EWebSMSAndUser)))
     {
         EWebSMSAndUser entity = repository.Get<EWebSMSAndUser>(id);
         if (entity.IsRead)
             return;
         EWebSMSInfo info = GetInfo(entity.SMSInfoID);
         if (info.VehicleCode.HasValue)
         {
             IVehicleRunningStateManager stateManger = new VehicleRunningStateManager();
             stateManger.CheckAndDelete(info.VehicleCode.Value, info.Type);
         }
         
         entity.IsRead = Convert.ToBoolean((int)EnumIsRead.Readed);
         entity.ReadTime = DateTime.Now;
         repository.Update(entity);
     }
     using (IRepository repository = SessionManager.CreateRepository(typeof(EWebSMSAndUser_New)))
     {
         EWebSMSAndUser_New entity = repository.Get<EWebSMSAndUser_New>(id);
         repository.Delete(entity);
     }
 }
 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);
     }
 }
        //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);
            }
        }