Example #1
0
        private bool IsInRangeBefore(EGPSCurrentInfo current, EAreaAlertSetting areaSet, bool isInRangeNow)
        {
            VTempAreaWarning tempAreaWarning = AlarmLastStatusService.Singleton.GetLastAreaWarning(current, areaSet);
            if (tempAreaWarning == null)
            {
                tempAreaWarning = new VTempAreaWarning();
                tempAreaWarning.AreaCode = areaSet.Area.RecordID;
                tempAreaWarning.GPSCode = current.GPSCode;
                tempAreaWarning.IsInArea = isInRangeNow ? 1 : 0;
                tempAreaWarning.ReportTime = current.ReportTime;
                tempAreaWarning.VehicleCode = current.VehicleCode.Value;

                AlarmLastStatusService.Singleton.SaveLastAreaWarning(current, areaSet, tempAreaWarning);
                return false;
            }

            bool isIn = (tempAreaWarning.IsInArea == (int)EnumAreaAlert.InArea);
            tempAreaWarning.IsInArea = isInRangeNow ? 1 : 0;
            tempAreaWarning.ReportTime = current.ReportTime;
            AlarmLastStatusService.Singleton.SaveLastAreaWarning(current, areaSet, tempAreaWarning);

            return isIn;
        }
        public void SaveLastAreaWarning(EGPSCurrentInfo current, EAreaAlertSetting areaSet, VTempAreaWarning status)
        {
            if (status == null) return;

            string key = CONST_KEY_LAST_AREA_STATUS + areaSet.Area.RecordID.ToString() + "_" + current.VehicleCode.Value.ToString();

            this.CachedService.Add(key, status, DateTime.Now.AddDays(1));
        }