Example #1
0
        private void Alert(AlarmHandleContext context, EGPSCurrentInfo current, EnumAlertState state, ETimingAlertSetting alertSetting, LastTimingAlertStatus lastCachingStatus)
        {
            if (alertSetting.EnableSMS || alertSetting.Enable)
            {
                // 生成报警实例,并将报警存入数据库,最新的报警状态放入缓存中
                ETimingAlertReport alertReport = this.CreateAlertReport(context, current, state, alertSetting);
                GPSServiceFacade.AlertService.Add<ETimingAlertReport>(alertReport);

                lastCachingStatus.LastAlertTime = current.ReportTime;
                AlarmLastStatusService.Singleton.SaveLastTimingAlertStatus(current.VehicleCode.Value, lastCachingStatus);

                if (alertSetting.EnableSMS && this.IsInMobileReceiveTime(alertReport))
                {
                    this.SendSMS(context, alertReport);
                }

                if (alertSetting.Enable && this.IsInUserReceiveTime(alertReport))
                {
                    this.SendWebSiteSMS(context, alertReport);
                }
            }
        }
Example #2
0
        protected void Alert(AlarmHandleContext context, EGPSCurrentInfo current, EnumAlertState state, EOverSpeedAlertSetting setting, LastOverSpeedAlertStatus lastCachingStatus)
        {
            if (setting.EnableSMS || setting.Enable)
            {
                // 生成报警实例,并将报警存入数据库,放入缓存中
                EOverSpeedAlertReport alertReport = this.CreateAlertReport(context, current, state, setting);
                GPSServiceFacade.AlertService.Add<EOverSpeedAlertReport>(alertReport);

                lastCachingStatus.AlertState = state;
                AlarmLastStatusService.Singleton.SaveLastOverSpeedAlertStatus(current.VehicleCode.Value, lastCachingStatus);

                if (setting.EnableSMS && this.IsInMobileReceiveTime(alertReport))
                {
                    this.SendSMS(context, alertReport);
                }

                if (setting.Enable && this.IsInUserReceiveTime(alertReport))
                {
                    this.SendWebSiteSMS(context, alertReport);
                }
            }
        }
Example #3
0
        protected void Alert(AlarmHandleContext context, EGPSCurrentInfo current, EnumAlertState state, EStopCarAlertSetting setting, LastStopCarAlertStatus lastCachingStatus)
        {
            if (setting.EnableSMS || setting.Enable)
            {
                // 生成报警实例,并将报警存入数据库,放入缓存中
                EStopCarAlertReport alertReport = this.CreateAlertReport(context, current, state, setting, lastCachingStatus.LastStopCarTime.Value, Guid.NewGuid());
                GPSServiceFacade.AlertService.Add<EStopCarAlertReport>(alertReport);

                lastCachingStatus.LastAlertRecordId = alertReport.RecordID.ToString();
                lastCachingStatus.LastAlertStartTime = alertReport.GPSReportTime;
                lastCachingStatus.LastAlertEndTime = alertReport.StopEndTime;
                AlarmLastStatusService.Singleton.SaveLastStopCarAlertStatus(current.VehicleCode.Value, lastCachingStatus);

                if (setting.EnableSMS && this.IsInMobileReceiveTime(alertReport))
                {
                    this.SendSMS(context, alertReport);
                }

                if (setting.Enable && this.IsInUserReceiveTime(alertReport))
                {
                    this.SendWebSiteSMS(context, alertReport);
                }
            }
        }
Example #4
0
        protected void Alert(AlarmHandleContext context, EGPSCurrentInfo current, EnumAlertState state, ETraceAlertSetting alertSetting, LastTracePointAlertStatus lastCachingPointStatus)
        {
            if (alertSetting.EnableSMS || alertSetting.Enable)
            {
                // 生成报警实例,并将报警存入数据库,最新的报警状态放入缓存中
                ETraceAlertReport alertReport = this.CreateAlertReport(context, current, state, alertSetting);

                DateTime dt1 = DateTime.Now;
                GPSServiceFacade.AlertService.Add<ETraceAlertReport>(alertReport);
                Logger.Info(string.Format("Static_AlertReportService.Add<ETraceAlertReport>(alertReport)共花销{0}毫秒", (DateTime.Now - dt1).TotalMilliseconds));

                lastCachingPointStatus.LastAlertTime = current.ReportTime;
                AlarmLastStatusService.Singleton.SaveLastTracePointAlertStatus(current, alertSetting, lastCachingPointStatus);

                LastTraceAlertStatus lastCachingStatus = new LastTraceAlertStatus()
                {
                    LastAlertTracePointId = alertSetting.TracePointID.ToString().ToLower(),
                    LastAlertTime = current.ReportTime
                };
                AlarmLastStatusService.Singleton.SaveLastTraceAlertStatus(current.VehicleCode.Value, lastCachingStatus);

                if (alertSetting.EnableSMS && this.IsInMobileReceiveTime(alertReport))
                {
                    this.SendSMS(context, alertReport);
                }

                if (alertSetting.Enable && this.IsInUserReceiveTime(alertReport))
                {
                    this.SendWebSiteSMS(context, alertReport);
                }
            }
        }
Example #5
0
        protected ETraceAlertReport CreateAlertReport(AlarmHandleContext context, EGPSCurrentInfo current, EnumAlertState state, ETraceAlertSetting alertSetting)
        {
            ETraceAlertReport newReport = new ETraceAlertReport();

            newReport.EnumAlarmGrade = EnumAlarmGrade.Prompt;
            newReport.EnumSMSInfoType = EnumSMSInfoType.Mark;
            newReport.ACCState = current.ACCState;
            newReport.Speed = current.Speed;
            newReport.VStarkMileage = current.StarkMileage;
            newReport.GPSCode = current.GPSCode;
            newReport.ACCState = current.ACCState;
            newReport.Speed = current.Speed;
            newReport.GPSReportTime = current.ReportTime;
            newReport.Latitude = current.Latitude;
            newReport.Longitude = current.Longitude;
            newReport.MobileReceiveBeginTime = alertSetting.MobileReceiveBeginTime;
            newReport.MobileReceiveEndTime = alertSetting.MobileReceiveEndTime;
            newReport.ReceiveMobileList = alertSetting.ReceiveMobileList;
            newReport.ReceiveUserList = alertSetting.ReceiveUserList;
            newReport.TenantCode = alertSetting.TenantCode;
            newReport.UserReceiveBeginTime = alertSetting.UserReceiveBeginTime;
            newReport.UserReceiveEndTime = alertSetting.UserReceiveEndTime;
            newReport.VehicleCode = alertSetting.VehicleCode;
            newReport.VehiclePosition = this.GetPlaceName(context, current.Latitude, current.Longitude);
            newReport.LicensePlate = this.GetLicensePlate(context, current.VehicleCode.Value, alertSetting.TenantCode);
            newReport.EnumAlertState = state;
            newReport.DownSendOrderCode = DownSendCodeHelper.GPS.LogisticVehicle.AddressTracking;
            newReport.TracePoint = alertSetting.TracePoint;

            return newReport;
        }
Example #6
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;
            }
        }
Example #7
0
        private EOverSpeedAlertReport CreateAlertReport(AlarmHandleContext context, EGPSCurrentInfo current, EnumAlertState state, EOverSpeedAlertSetting alertSetting)
        {
            EOverSpeedAlertReport newReport = new EOverSpeedAlertReport();

            newReport.EnumAlarmGrade = EnumAlarmGrade.Prompt;
            newReport.GPSReportTime = current.ReportTime;
            if (state == EnumAlertState.Resume)
            {
                newReport.EnumSMSInfoType = EnumSMSInfoType.NormalSpeed;
                newReport.DownSendOrderCode = DownSendCodeHelper.GPS.LogisticVehicle.SpeedResume;
            }
            else
            {
                newReport.EnumSMSInfoType = EnumSMSInfoType.OverSpeed;
                newReport.DownSendOrderCode = DownSendCodeHelper.GPS.LogisticVehicle.ExceedSpeed;
            }
            newReport.ACCState = current.ACCState;
            newReport.Speed = current.Speed;
            newReport.VStarkMileage = current.StarkMileage;
            newReport.GPSCode = current.GPSCode;
            newReport.Latitude = current.Latitude;
            newReport.Longitude = current.Longitude;
            newReport.MobileReceiveBeginTime = alertSetting.MobileReceiveBeginTime;
            newReport.MobileReceiveEndTime = alertSetting.MobileReceiveEndTime;
            newReport.ReceiveMobileList = alertSetting.ReceiveMobileList;
            newReport.ReceiveUserList = alertSetting.ReceiveUserList;
            newReport.TenantCode = alertSetting.TenantCode;
            newReport.UserReceiveBeginTime = alertSetting.UserReceiveBeginTime;
            newReport.UserReceiveEndTime = alertSetting.UserReceiveEndTime;
            newReport.VehicleCode = alertSetting.VehicleCode;
            newReport.VehiclePosition = this.GetPlaceName(context, current.Latitude, current.Longitude);
            newReport.LicensePlate = this.GetLicensePlate(context, current.VehicleCode.Value, alertSetting.TenantCode);
            newReport.EnumAlertState = state;
            newReport.SpeedLimit = alertSetting.SpeedLimit;
            newReport.VehicleSpeed = Convert.ToInt32(current.Speed);
            newReport.AlertState = (int)state;

            return newReport;
        }
Example #8
0
        private EPowerDownAlertReport CreateAlertReport(AlarmHandleContext context, EGPSCurrentInfo current, EnumAlertState state, EPowerDownAlertSetting alertSetting, DateTime lastPowerDownTime)
        {
            EPowerDownAlertReport newReport = new EPowerDownAlertReport();

            newReport.EnumAlarmGrade = EnumAlarmGrade.Alarm;
            newReport.ACCState = current.ACCState;
            newReport.Speed = current.Speed;
            newReport.VStarkMileage = current.StarkMileage;
            newReport.EnumSMSInfoType = EnumSMSInfoType.BreakElectricity;
            newReport.GPSCode = current.GPSCode;
            newReport.GPSReportTime = lastPowerDownTime;
            newReport.Latitude = current.Latitude;
            newReport.Longitude = current.Longitude;
            newReport.MobileReceiveBeginTime = alertSetting.MobileReceiveBeginTime;
            newReport.MobileReceiveEndTime = alertSetting.MobileReceiveEndTime;
            newReport.ReceiveMobileList = alertSetting.ReceiveMobileList;
            newReport.ReceiveUserList = alertSetting.ReceiveUserList;
            newReport.TenantCode = alertSetting.TenantCode;
            newReport.UserReceiveBeginTime = alertSetting.UserReceiveBeginTime;
            newReport.UserReceiveEndTime = alertSetting.UserReceiveEndTime;
            newReport.VehicleCode = alertSetting.VehicleCode;
            newReport.VehiclePosition = this.GetPlaceName(context, current.Latitude, current.Longitude);
            newReport.LicensePlate = this.GetLicensePlate(context, current.VehicleCode.Value, alertSetting.TenantCode);
            newReport.EnumAlertState = state;
            newReport.DownSendOrderCode = DownSendCodeHelper.GPS.LogisticVehicle.BreakPower;

            return newReport;
        }
        private EBaseAlertReport CreateAlertReport(EnumAlertState state, EOfflineTimeoutAlertSetting alertSetting)
        {
            EGPSCurrentInfo _gpsCurrentInfo = new GPSTrackManager().GetCurrentInfo(alertSetting.VehicleCode);
            EOfflineTimeoutAlertReport newReport = new EOfflineTimeoutAlertReport();
            newReport.EnumAlarmGrade = EnumAlarmGrade.Prompt;
            newReport.ACCState = _gpsCurrentInfo.ACCState;
            newReport.Speed = _gpsCurrentInfo.Speed;
            newReport.VStarkMileage = _gpsCurrentInfo.StarkMileage;
            newReport.EnumSMSInfoType = EnumSMSInfoType.OfflineTimeout;
            newReport.GPSCode = _gpsCurrentInfo.GPSCode;
            newReport.GPSReportTime = _gpsCurrentInfo.ReportTime;
            newReport.Latitude = _gpsCurrentInfo.Latitude;
            newReport.Longitude = _gpsCurrentInfo.Longitude;
            newReport.MobileReceiveBeginTime = alertSetting.MobileReceiveBeginTime;
            newReport.MobileReceiveEndTime = alertSetting.MobileReceiveEndTime;
            newReport.ReceiveMobileList = alertSetting.ReceiveMobileList;
            newReport.ReceiveUserList = alertSetting.ReceiveUserList;
            newReport.TenantCode = alertSetting.TenantCode;
            newReport.UserReceiveBeginTime = alertSetting.UserReceiveBeginTime;
            newReport.UserReceiveEndTime = alertSetting.UserReceiveEndTime;
            newReport.VehicleCode = alertSetting.VehicleCode;
            newReport.VehiclePosition = this.GetPlaceName(_gpsCurrentInfo.Latitude, _gpsCurrentInfo.Longitude);
            if (_MOVOVehicleDict.ContainsKey(alertSetting.VehicleCode))
            {
                newReport.LicensePlate = _MOVOVehicleDict[alertSetting.VehicleCode];
            }

            newReport.EnumAlertState = state;

            newReport.DownSendOrderCode = DownSendCodeHelper.GPS.LogisticVehicle.FatigueDrive;
            newReport.DurationDrivingTime = alertSetting.DrivingDuration;
            newReport.RestTime = alertSetting.RestTime;
            newReport.AlertState = (int)state;
            return newReport;
        }
        //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);
            }
        }
        private void Alert(EnumAlertState state, EFatigueDrivingAlertSetting setting)
        {
            if (state == EnumAlertState.Alerting)
            {
                if (setting.EnableSMS || setting.Enable)
                {
                    _alertReport = (EFatigueDrivingReport)CreateAlertReport(state, setting);
                    SaveAlertReport();
                    if (setting.EnableSMS && this.IsInReceiveTime(_alertReport.MobileReceiveBeginTime, _alertReport.MobileReceiveEndTime))
                    {
                        SendSMS(_alertReport);
                    }
                    if (setting.Enable && this.IsInReceiveTime(_alertReport.UserReceiveBeginTime, _alertReport.UserReceiveEndTime))
                    {
                        AlarmHandleContext context = new AlarmHandleContext();                        
                        this.SendWebSiteSMS(context, _alertReport);
                    }
                }

            }
            else
            {
                UpdateAlertReport();
            }
        }
Example #12
0
        private EStopCarAlertReport CreateAlertReport(AlarmHandleContext context, EGPSCurrentInfo current, EnumAlertState state, EStopCarAlertSetting alertSetting, DateTime lastStopCarTime, Guid newReportId)
        {
            EStopCarAlertReport newReport = new EStopCarAlertReport();

            newReport.RecordID = newReportId;
            newReport.EnumAlarmGrade = EnumAlarmGrade.Prompt;
            newReport.EnumSMSInfoType = EnumSMSInfoType.StopCarOverTime;
            newReport.ACCState = current.ACCState;
            newReport.Speed = current.Speed;
            newReport.StarkMileage = current.StarkMileage;
            newReport.ACCState = current.ACCState;
            newReport.Speed = current.Speed;
            newReport.VStarkMileage = current.StarkMileage;
            newReport.GPSCode = current.GPSCode;
            newReport.GPSReportTime = lastStopCarTime;
            newReport.Latitude = current.Latitude;
            newReport.Longitude = current.Longitude;
            newReport.MobileReceiveBeginTime = alertSetting.MobileReceiveBeginTime;
            newReport.MobileReceiveEndTime = alertSetting.MobileReceiveEndTime;
            newReport.ReceiveMobileList = alertSetting.ReceiveMobileList;
            newReport.ReceiveUserList = alertSetting.ReceiveUserList;
            newReport.TenantCode = alertSetting.TenantCode;
            newReport.UserReceiveBeginTime = alertSetting.UserReceiveBeginTime;
            newReport.UserReceiveEndTime = alertSetting.UserReceiveEndTime;
            newReport.VehicleCode = alertSetting.VehicleCode;
            newReport.VehiclePosition = this.GetPlaceName(context, current.Latitude, current.Longitude);
            newReport.LicensePlate = this.GetLicensePlate(context, current.VehicleCode.Value, alertSetting.TenantCode);
            newReport.EnumAlertState = state;
            newReport.DownSendOrderCode = DownSendCodeHelper.GPS.LogisticVehicle.VehicleStop;
            newReport.StopAlertTimeSpan = (int)((current.ReportTime - lastStopCarTime).TotalMinutes);

            return newReport;
        }