protected bool IsReachCondition(EGPSCurrentInfo current, ETimingAlertSetting alertSetting) { DateTime now = current.ReportTime; DateTime before = now.AddMinutes(-1); DateTime after = now.AddMinutes(1); DateTime tailTime = DateTime.Parse(alertSetting.Time.ToString()); return (tailTime.TimeOfDay >= before.TimeOfDay && tailTime.TimeOfDay <= after.TimeOfDay); }
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); } } }
protected ETimingAlertReport CreateAlertReport(AlarmHandleContext context, EGPSCurrentInfo current, EnumAlertState state, ETimingAlertSetting alertSetting) { ETimingAlertReport newReport = new ETimingAlertReport(); newReport.EnumAlarmGrade = EnumAlarmGrade.Prompt; newReport.EnumSMSInfoType = EnumSMSInfoType.Time; newReport.ACCState = current.ACCState; newReport.Speed = current.Speed; newReport.VStarkMileage = current.StarkMileage; newReport.ACCState = current.ACCState; newReport.Speed = current.Speed; newReport.GPSCode = current.GPSCode; 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.TimeTracking; newReport.Time = alertSetting.Time; return newReport; }
public LastTimingAlertStatus GetLastTimingAlertStatus(EGPSCurrentInfo current, ETimingAlertSetting alertSetting) { if (!current.VehicleCode.HasValue) return null; string key = CONST_KEY_LAST_TIMING_STATUS + current.VehicleCode.Value.ToString(); var result = this.CachedService.Get(key) as LastTimingAlertStatus; if (result == null) { // 找不到则从数据库查找最后一条报表记录 DateTime dt1 = DateTime.Now; var lastReport = GPSServiceFacade.Report.Timing.GetRecentReport(current.GPSCode, alertSetting.Time, current.ReportTime); Logger.Info("从数据库查找最后一条Timing报表记录", "开销时间(毫秒)", (DateTime.Now - dt1).TotalMilliseconds, "Vehicle Code", current.VehicleCode.Value, "Time", alertSetting.Time); result = new LastTimingAlertStatus(); if (lastReport != null) { result.LastAlertTime = lastReport.GPSReportTime; } lastReport = null; this.SaveLastTimingAlertStatus(current.VehicleCode.Value, result); } return result; }