예제 #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);
                }
            }
        }
예제 #2
0
 public void SaveLastTimingAlertStatus(Guid vehicleCode, LastTimingAlertStatus status)
 {
     string key = CONST_KEY_LAST_TIMING_STATUS + vehicleCode.ToString();
     if (status == null)
     {
         status = new LastTimingAlertStatus();
     }
     this.CachedService.Add(key, status, DateTime.Now.AddDays(1));
 }
예제 #3
0
        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;
        }