示例#1
0
 /// <summary>
 /// Initializes a instance of <seealso cref="TimeRangeItem"/> class.
 /// </summary>
 public TimeRangeItem(
     string caption,
     string timedCountDuration,
     EventGroupTimeRangeEnum timeRange,
     EventTimeRangeEnum eventTimeRange)
 {
     Caption            = caption;
     TimedCountDuration = timedCountDuration;
     EventTimeRange     = eventTimeRange;
     GroupTimeRange     = timeRange;
 }
        /// <summary>
        /// Returns bar chart time line format string based on the <seealso cref="EventGroupTimeRangeEnum"/> value.
        /// </summary>
        public static string TimeLineFormat(this EventGroupTimeRangeEnum timeRange)
        {
            switch (timeRange)
            {
            case EventGroupTimeRangeEnum.PERIOD1WEEK:
            case EventGroupTimeRangeEnum.PERIOD30DAYS:
                return(Resources.ErrorReportingDayTimeLineFormat);

            case EventGroupTimeRangeEnum.PERIOD1DAY:
            case EventGroupTimeRangeEnum.PERIOD1HOUR:
            case EventGroupTimeRangeEnum.PERIOD6HOURS:
                return(Resources.ErrorReportingTimeTimeLineFormat);

            default:
                return(Resources.ErrorReportingDefaultTimeLineFormat);
            }
        }
        /// <summary>
        /// Get a page of <seealso cref="ErrorGroupStats"/> for the given <paramref name="groupId"/>.
        /// The result is divided into pages when the result set is too large.
        /// This call get one page of results.
        /// </summary>
        /// <param name="timeRange">Specifiy the time range of the query.</param>
        /// <param name="timedCountDuration">
        /// The preferred duration for a single returned `TimedCount`.
        /// Optional, If not set, no timed counts are returned.
        /// </param>
        /// <param name="groupId">Optional, The error group id.</param>
        /// <param name="nextPageToken">Optional, A next page token provided by a previous response.</param>
        /// <returns>
        /// A task with <seealso cref="ListGroupStatsResponse"/> as result.
        /// </returns>
        public Task <ListGroupStatsResponse> GetPageOfGroupStatusAsync(
            TimeRangeEnum timeRange,
            string timedCountDuration = null,
            string groupId            = null,
            string nextPageToken      = null)
        {
            var request = Service.Projects.GroupStats.List(ProjectResourceName);

            request.TimeRangePeriod    = timeRange;
            request.TimedCountDuration = timedCountDuration;
            request.GroupId            = groupId;
            request.PageToken          = nextPageToken;
            try
            {
                return(request.ExecuteAsync());
            }
            catch (GoogleApiException ex)
            {
                Debug.WriteLine($"Failed to get GroupStats: {ex.Message}");
                throw new DataSourceException(ex.Message, ex);
            }
        }
        /// <summary>
        /// Returns time count duration to a <seealso cref="EventGroupTimeRangeEnum"/> value.
        /// </summary>
        public static string TimeCountDuration(this EventGroupTimeRangeEnum timeRange)
        {
            switch (timeRange)
            {
            case EventGroupTimeRangeEnum.PERIOD1WEEK:
                return(Resources.ErrorReporting7DayRangeTimeCountDurationLabel);

            case EventGroupTimeRangeEnum.PERIOD30DAYS:
                return(Resources.ErrorReporting30DaysRangeTimeCountDurationLabel);

            case EventGroupTimeRangeEnum.PERIOD1DAY:
                return(Resources.ErrorReporting1DayRangeTimeCountDurationLabel);

            case EventGroupTimeRangeEnum.PERIOD1HOUR:
                return(Resources.ErrorReporting1HourRangeTimeCountDurationLabel);

            case EventGroupTimeRangeEnum.PERIOD6HOURS:
                return(Resources.ErrorReporting6HoursRangeTimeCountDurationLabel);

            default:
                // Not expected. Should not happen. Show an error.
                return(Resources.ErrorReportingUnexpectedEventGroupTimeRangeErrorMessage);
            }
        }