コード例 #1
0
        public StatisticsDto GetStatistics()
        {
            var states =
                Data.GetEnumeration <JobDto>()
                .Where(j => j.StateName != null)
                .GroupBy(j => j.StateName)
                .ToDictionary(j => j.Key, j => j.Count());

            Func <string, int> getCountIfExists = name => states.ContainsKey(name) ? states[name] : 0;

            var succeded = CounterUtilities.GetCombinedCounter("stats:succeeded");
            var deleted  = CounterUtilities.GetCombinedCounter("stats:deleted");

            var recurringJobs = Data.GetEnumeration <SetDto>().Count(c => c.Key == "recurring-jobs");
            var servers       = Data.GetEnumeration <Dto.ServerDto>().Count();

            var stats = new StatisticsDto
            {
                Enqueued   = getCountIfExists(EnqueuedState.StateName),
                Failed     = getCountIfExists(FailedState.StateName),
                Processing = getCountIfExists(ProcessingState.StateName),
                Scheduled  = getCountIfExists(ScheduledState.StateName),
                Servers    = servers,
                Succeeded  = succeded,
                Deleted    = deleted,
                Recurring  = recurringJobs
            };

            return(stats);
        }
コード例 #2
0
        public override long GetCounter(string key)
        {
            Guard.ArgumentNotNull(key, "key");

            return(CounterUtilities.GetCombinedCounter(_data, key));
        }