Beispiel #1
0
        /// <summary>
        /// Does issues' search by JQL.
        /// </summary>
        /// <param name="jira">Instance of <c>SimpleJira.Interface.IJira</c>.</param>
        /// <param name="request">Searching request.</param>
        /// <param name="issueType">Type of an issue to return.</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <exception cref="SimpleJira.Interface.JqlCompilationException">Throws exception when JQL is not valid.</exception>
        /// <exception cref="SimpleJira.Interface.JiraAuthorizationException">Throws exception when user is not authorized.</exception>
        /// <exception cref="SimpleJira.Interface.JiraException">Throws exception in other cases.</exception>
        /// <returns>
        ///     Search response which contains issues, issues' count, additional information from request.
        /// </returns>
        public static async Task <JiraIssuesResponse> SelectIssuesAsync(this IJira jira,
                                                                        JiraIssuesRequest request, Type issueType, CancellationToken cancellationToken)
        {
            var response = await jira.SelectIssuesAsync(new JiraIssuesRequest
            {
                Expand        = request.Expand,
                Fields        = request.Fields,
                Jql           = request.Jql,
                MaxResults    = request.MaxResults,
                StartAt       = request.StartAt,
                ValidateQuery = request.ValidateQuery
            }, cancellationToken);

            if (issueType == typeof(JiraIssue))
            {
                return(response);
            }
            return(new JiraIssuesResponse
            {
                Expand = response.Expand,
                Total = response.Total,
                MaxResults = response.MaxResults,
                StartAt = response.StartAt,
                Issues = response.Issues.Select(x => x.Cast(issueType)).ToArray()
            });
        }
Beispiel #2
0
        /// <summary>
        /// Does issues' search by JQL.
        /// </summary>
        /// <param name="jira">Instance of <c>SimpleJira.Interface.IJira</c>.</param>
        /// <param name="request">Searching request.</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <exception cref="SimpleJira.Interface.JqlCompilationException">Throws exception when JQL is not valid.</exception>
        /// <exception cref="SimpleJira.Interface.JiraAuthorizationException">Throws exception when user is not authorized.</exception>
        /// <exception cref="SimpleJira.Interface.JiraException">Throws exception in other cases.</exception>
        /// <returns>
        ///     Typified search response which contains typified issues, issues' count, additional information from request.
        /// </returns>
        public static async Task <JiraIssuesResponse <TIssue> > SelectIssuesAsync <TIssue>(this IJira jira,
                                                                                           JiraIssuesRequest request, CancellationToken cancellationToken) where TIssue : JiraIssue
        {
            var result = await jira.SelectIssuesAsync(request, typeof(TIssue), cancellationToken);

            return(new JiraIssuesResponse <TIssue>
            {
                Expand = result.Expand,
                Issues = result.Issues.Cast <TIssue>().ToArray(),
                Total = result.Total,
                MaxResults = result.MaxResults,
                StartAt = result.StartAt
            });
        }
Beispiel #3
0
        private JiraIssuesResponse SelectIssuesInfo(BuiltQuery builtQuery, Stopwatch stopwatch)
        {
            loggingSettings.Log(LogLevel.Debug,
                                $"Getting the count of issues is starting execution, query [{builtQuery.Query}] ");

            try
            {
                var request = new JiraIssuesRequest
                {
                    Jql        = builtQuery.Query?.ToString() ?? "",
                    StartAt    = 0,
                    MaxResults = 1,
                    Fields     = new[] { "created" }
                };

                var response = jira.SelectIssuesAsync(request, builtQuery.IssueType, CancellationToken.None)
                               .GetAwaiter().GetResult();
                if (stopwatch != null)
                {
                    stopwatch.Stop();
                    loggingSettings.Log(LogLevel.Trace,
                                        $"Getting the count of issues is finished, query [{builtQuery.Query}], took [{stopwatch.Elapsed.TotalMilliseconds}] ms");
                }

                return(response);
            }
            catch (Exception)
            {
                if (stopwatch != null)
                {
                    stopwatch.Stop();
                    loggingSettings.Log(LogLevel.Trace,
                                        $"Getting the count of issues is finished, query [{builtQuery.Query}]. Threw an exception, took [{stopwatch.Elapsed.TotalMilliseconds}] ms");
                }

                throw;
            }
        }
Beispiel #4
0
 /// <summary>
 /// Does issues' search by JQL.
 /// </summary>
 /// <param name="jira">Instance of <c>SimpleJira.Interface.IJira</c>.</param>
 /// <param name="request">Searching request.</param>
 /// <exception cref="SimpleJira.Interface.JqlCompilationException">Throws exception when JQL is not valid.</exception>
 /// <exception cref="SimpleJira.Interface.JiraAuthorizationException">Throws exception when user is not authorized.</exception>
 /// <exception cref="SimpleJira.Interface.JiraException">Throws exception in other cases.</exception>
 /// <returns>
 ///     Typified search response which contains typified issues, issues' count, additional information from request.
 /// </returns>
 public static Task <JiraIssuesResponse <TIssue> > SelectIssuesAsync <TIssue>(this IJira jira,
                                                                              JiraIssuesRequest request) where TIssue : JiraIssue
 {
     return(jira.SelectIssuesAsync <TIssue>(request, CancellationToken.None));
 }
Beispiel #5
0
 /// <summary>
 /// Does issues' search by JQL.
 /// </summary>
 /// <param name="jira">Instance of <c>SimpleJira.Interface.IJira</c>.</param>
 /// <param name="request">Searching request.</param>
 /// <exception cref="SimpleJira.Interface.JqlCompilationException">Throws exception when JQL is not valid.</exception>
 /// <exception cref="SimpleJira.Interface.JiraAuthorizationException">Throws exception when user is not authorized.</exception>
 /// <exception cref="SimpleJira.Interface.JiraException">Throws exception in other cases.</exception>
 /// <returns>
 ///     Typified search response which contains typified issues, issues' count, additional information from request.
 /// </returns>
 public static JiraIssuesResponse <TIssue> SelectIssues <TIssue>(this IJira jira,
                                                                 JiraIssuesRequest request) where TIssue : JiraIssue
 {
     return(jira.SelectIssuesAsync <TIssue>(request, CancellationToken.None).GetAwaiter().GetResult());
 }
Beispiel #6
0
 /// <summary>
 /// Does issues' search by JQL.
 /// </summary>
 /// <param name="jira">Instance of <c>SimpleJira.Interface.IJira</c>.</param>
 /// <param name="request">Searching request.</param>
 /// <exception cref="SimpleJira.Interface.JqlCompilationException">Throws exception when JQL is not valid.</exception>
 /// <exception cref="SimpleJira.Interface.JiraAuthorizationException">Throws exception when user is not authorized.</exception>
 /// <exception cref="SimpleJira.Interface.JiraException">Throws exception in other cases.</exception>
 /// <returns>
 ///     Search response which contains issues, issues' count, additional information from request.
 /// </returns>
 public static Task <JiraIssuesResponse> SelectIssuesAsync(this IJira jira, JiraIssuesRequest request)
 {
     return(jira.SelectIssuesAsync(request, CancellationToken.None));
 }
Beispiel #7
0
 /// <summary>
 /// Does issues' search by JQL.
 /// </summary>
 /// <param name="jira">Instance of <c>SimpleJira.Interface.IJira</c>.</param>
 /// <param name="request">Searching request.</param>
 /// <param name="issueType">Type of an issue to return.</param>
 /// <exception cref="SimpleJira.Interface.JqlCompilationException">Throws exception when JQL is not valid.</exception>
 /// <exception cref="SimpleJira.Interface.JiraAuthorizationException">Throws exception when user is not authorized.</exception>
 /// <exception cref="SimpleJira.Interface.JiraException">Throws exception in other cases.</exception>
 /// <returns>
 ///     Search response which contains issues, issues' count, additional information from request.
 /// </returns>
 public static JiraIssuesResponse SelectIssues(this IJira jira, JiraIssuesRequest request, Type issueType)
 {
     return(jira.SelectIssuesAsync(request, issueType, CancellationToken.None).GetAwaiter().GetResult());
 }