private static void BeginProcessingConversationAggregates(DateTime fromForAggregates, IPlugin loadedPlugin) { Log.Debug($"BeginProcessingConversationAggregates(), {nameof(fromForAggregates)}:{fromForAggregates.ToString("O")}, {nameof(To)}:{To.ToString("O")}"); try { if (fromForAggregates.Equals(DateTime.MinValue)) { throw new ArgumentException("Equals(DateTime.MinValue)", nameof(fromForAggregates)); } // a legacy condition, not sure is it necessary at all // <calculating intervals> if (ToForAggregates.Subtract(fromForAggregates).TotalMinutes < 30) { return; // minimum time frame is 30 minutes (a duration of one grnuality interval) } var intervalList = new List <Interval>(); var tempFrom = fromForAggregates; while (ToForAggregates.Subtract(tempFrom).TotalDays > MaxIntervalDurationDays) { var tempTo = tempFrom.AddDays(MaxIntervalDurationDays).Date; intervalList.Add(new Interval(tempFrom, tempTo)); tempFrom = tempTo.Date; } intervalList.Add(new Interval(tempFrom, ToForAggregates)); // </calculating intervals> // <getting the data> foreach (var interval in intervalList) { var conversationAggregates = PureCloudObj.GetConversationAggregates(interval); if (conversationAggregates?.Results == null || conversationAggregates.Results.Count < 1) { continue; } var conversationAggregatesJson = "{\"queuedata\":" + JsonConvert.SerializeObject(conversationAggregates.Results) + "}"; loadedPlugin.PushData(conversationAggregatesJson); } // </getting the data> } catch (Exception ex) { Log.Error("BeginProcessingConversationAggregates()", ex); } }