public object Get(GetHourlyReport request) { DateTime end_date; if (string.IsNullOrEmpty(request.end_date)) { end_date = DateTime.Now; } else { _logger.Info("End_Date: " + request.end_date); end_date = DateTime.ParseExact(request.end_date, "yyyy-MM-dd", CultureInfo.InvariantCulture); } SortedDictionary <string, int> report = Repository.GetHourlyUsageReport(request.days, end_date); for (int day = 0; day < 7; day++) { for (int hour = 0; hour < 24; hour++) { string key = day + "-" + hour.ToString("D2"); if (report.ContainsKey(key) == false) { report.Add(key, 0); } } } return(report); }
public object Get(GetHourlyReport request) { AuthorizationInfo user_info = _ac.GetAuthorizationInfo(Request); UserPolicy policy = _userManager.GetUserPolicy(user_info.User); if (!policy.IsAdministrator) { return(new SortedDictionary <string, int>()); } string[] filter_tokens = new string[0]; if (request.filter != null) { filter_tokens = request.filter.Split(','); } DateTime end_date; if (string.IsNullOrEmpty(request.end_date)) { end_date = DateTime.Now; } else { _logger.Info("End_Date: " + request.end_date); end_date = DateTime.ParseExact(request.end_date, "yyyy-MM-dd", CultureInfo.InvariantCulture); } SortedDictionary <string, int> report = repository.GetHourlyUsageReport(request.user_id, request.days, end_date, filter_tokens); for (int day = 0; day < 7; day++) { for (int hour = 0; hour < 24; hour++) { string key = day + "-" + hour.ToString("D2"); if (report.ContainsKey(key) == false) { report.Add(key, 0); } } } return(report); }