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); } } }
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; }