コード例 #1
0
        private ReductionPeriod LoadPeriod(ReductionSettings settings)
        {
            var      storageKey = GetPositionStorageKey(settings);
            DateTime?startDate;

            try
            {
                startDate = _storage.Get <DateTime?>(storageKey);
                Log.Trace("Loaded start date from storage: " + startDate);
            }
            catch (Exception)
            {
                startDate = settings.StartDate;
            }

            if (startDate == null)
            {
                startDate = DateTime.UtcNow.AddDays(-30);
            }

            var result = new ReductionPeriod();

            result.From      = new DateTime(startDate.Value.Year, startDate.Value.Month, startDate.Value.Day, 0, 0, 0, 0);
            result.To        = result.From.AddDays(1);
            result.IsCurrent = startDate.Value.Date == DateTime.UtcNow.Date;

            return(result);
        }
コード例 #2
0
 private string GetPositionStorageKey(ReductionSettings settings)
 {
     return("poistion_" + GetType().Name + "_" + settings.TimeInterval);
 }
コード例 #3
0
        private void SetNewPeriod(ReductionSettings settings, ReductionPeriod reductionPeriod)
        {
            var storageKey = GetPositionStorageKey(settings);

            _storage.Insert(storageKey, reductionPeriod.To);
        }