コード例 #1
0
ファイル: OverSpeedHandler.cs プロジェクト: hhahh2011/CH.Gps
        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);
                }
            }
        }
コード例 #2
0
 public void SaveLastOverSpeedAlertStatus(Guid vehicleCode, LastOverSpeedAlertStatus status)
 {
     string key = CONST_KEY_LAST_OVERSPEED_STATUS + vehicleCode.ToString();
     if (status == null)
     {
         status = new LastOverSpeedAlertStatus();
     }
     this.CachedService.Add(key, status, DateTime.Now.AddDays(1));
 }
コード例 #3
0
        public LastOverSpeedAlertStatus GetLastOverSpeedAlertStatus(EGPSCurrentInfo current)
        {
            if (!current.VehicleCode.HasValue) return null;

            string key = CONST_KEY_LAST_OVERSPEED_STATUS + current.VehicleCode.Value.ToString();
            var result = this.CachedService.Get(key) as LastOverSpeedAlertStatus;
            if (result == null)
            {
                result = new LastOverSpeedAlertStatus();

                // 找不到则从数据库查找最后一条报表记录
                DateTime dt1 = DateTime.Now;
                var lastReport = GPSServiceFacade.Report.OverSpeed.GetRecentReport(current.VehicleCode.Value);
                Logger.Info("从数据库查找最后一条OverSpeed报表记录", "开销时间(毫秒)", (DateTime.Now - dt1).TotalMilliseconds, "Vehicle Code", current.VehicleCode.Value);

                result = new LastOverSpeedAlertStatus();
                if (lastReport != null)
                {
                    result.AlertState = lastReport.EnumAlertState;  // null;// EnumAlertState.Alerting;
                    result.LastOverSpeedTime = null;
                }
                lastReport = null;

                this.SaveLastOverSpeedAlertStatus(current.VehicleCode.Value, result);
            }

            return result;
        }