//入口 public void CheckUp() { if (!IsHaveSetted()) { return; } foreach (var setting in _settings) { OfflineTimeoutAlertReportService reportService = new OfflineTimeoutAlertReportService(); GPSTrackManager manager = new GPSTrackManager(); var info = manager.GetCurrentInfo(setting.VehicleCode); if (info.ReportTime.AddMinutes(setting.DrivingDuration) < DateTime.Now) { _alertReport = reportService.GetRecentReport(setting.VehicleCode); if (_alertReport != null && _alertReport.AlertState == (int)EnumAlertState.Alerting) { continue; } _alertReport = (EOfflineTimeoutAlertReport)CreateAlertReport(EnumAlertState.Alerting, setting); SaveAlertReport(); Alert(setting); } else { _alertReport = reportService.GetRecentReport(setting.VehicleCode); if (_alertReport == null) { continue; } if (_alertReport.AlertState == (int)EnumAlertState.Resume) { continue; } UpdateAlertReport(); } } }
private void SendSMS(EOfflineTimeoutAlertReport report) { try { this.SendSMS(report.GetReceiveMobiles(), report.DownSendOrderCode, report.GetSMSParamters(), report.TenantCode, ConsumeType.SMSAlert, report.GetReceiveUsers()); } catch (Exception ex) { Logger.Error(ex.Message); } }
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; }