Beispiel #1
0
        public async Task <long> GetDuration(String appName, LimitSpan span)
        {
            switch (span)
            {
            case LimitSpan.Day:
                var dayBegin = DateTime.Now.Date;
                return(await SumDuration(appName, l => l.DateCreated >= dayBegin));

            case LimitSpan.Week:
                var tuple     = DateTime.Today.GetWeekBeginAndEnd();
                var weekBegin = tuple.Item1;
                var weekEnd   = tuple.Item2;
                return(await SumDuration(appName, l => l.DateCreated >= weekBegin && l.DateCreated <= weekEnd));

            default:
                throw new ArgumentOutOfRangeException("span");
            }
        }
Beispiel #2
0
 public LimitNotifier(ISyncContext syncContext, LimitSpan limitSpan)
 {
     this.syncContext = syncContext;
     this.LimitSpan   = limitSpan;
     this.timer       = new Timer(OnTimerTick, null, Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan);
 }