예제 #1
0
        private static void MergeStats(IEnumerable <AppResult> appResults, IDictionary <int, ApplicationUsageStatisticsDto> apps, Action <ApplicationUsageStatisticsDto, int> assignMethod)
        {
            foreach (var count in appResults)
            {
                if (count.Count == 0)
                {
                    continue;
                }
                if (!apps.TryGetValue(count.ApplicationId, out var value))
                {
                    value = new ApplicationUsageStatisticsDto
                    {
                        ApplicationId = count.ApplicationId
                    };
                    apps[value.ApplicationId] = value;
                }

                assignMethod(value, count.Count);
            }
        }
예제 #2
0
 private async Task GetApps(Dictionary <int, ApplicationUsageStatisticsDto> apps)
 {
     using (var cmd = _unitOfWork.CreateDbCommand())
     {
         cmd.CommandText = @"select Id, EstimatedNumberOfErrors, NumberOfFtes FROM Applications";
         using (var reader = await cmd.ExecuteReaderAsync())
         {
             while (await reader.ReadAsync())
             {
                 var estimatedNumberOfErrors = reader[1];
                 var numberOfDevelopers      = reader[2];
                 var item = new ApplicationUsageStatisticsDto()
                 {
                     ApplicationId           = reader.GetInt32(0),
                     EstimatedNumberOfErrors =
                         estimatedNumberOfErrors is DBNull ? 0 : (int)estimatedNumberOfErrors,
                     NumberOfDevelopers = numberOfDevelopers is DBNull ? 0 : (decimal)numberOfDevelopers
                 };
                 apps[item.ApplicationId] = item;
             }
         }
     }
 }