Exemplo n.º 1
0
 public void SaveLastStopCarAccOnAlertStatus(Guid vehicleCode, LastStopCarAccOnAlertStatus status)
 {
     string key = CONST_KEY_LAST_STOPCARACCON_STATUS + vehicleCode.ToString();
     if (status == null)
     {
         status = new LastStopCarAccOnAlertStatus();
     }
     this.CachedService.Add(key, status, DateTime.Now.AddDays(1));
 }
Exemplo n.º 2
0
        public LastStopCarAccOnAlertStatus GetLastStopCarAccOnAlertStatus(EGPSCurrentInfo current)
        {
            if (!current.VehicleCode.HasValue) return null;

            string key = CONST_KEY_LAST_STOPCARACCON_STATUS + current.VehicleCode.Value.ToString();
            var result = this.CachedService.Get(key) as LastStopCarAccOnAlertStatus;
            if (result == null)
            {
                // 找不到则从数据库查找最后一条报表记录
                DateTime dt1 = DateTime.Now;
                var lastReport = GPSServiceFacade.Report.StopCarAccOn.GetRecentReport(current.VehicleCode.Value);
                Logger.Info("从数据库查找最后一条StopCarAccOn报表记录", "开销时间(毫秒)", (DateTime.Now - dt1).TotalMilliseconds, "Vehicle Code", current.VehicleCode.Value);

                result = new LastStopCarAccOnAlertStatus();
                if (lastReport != null)
                {
                    result.LastAlertRecordId = lastReport.RecordID.ToString();
                    result.LastAlertStartTime = lastReport.GPSReportTime;
                    result.LastAlertEndTime = lastReport.StopEndTime;
                    result.LastStopCarAccOnTime = null;
                }
                lastReport = null;

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

            return result;
        }