コード例 #1
0
ファイル: BugzillaRestClient.cs プロジェクト: nodia/gollum
        public async Task <BugzillaBug> GetBugInformationAsync(BugzillaArguments arguments, CancellationTokenSource tokenSource)
        {
            tokenSource.Token.ThrowIfCancellationRequested();

            await Login(arguments).ConfigureAwait(false);

            tokenSource.Token.ThrowIfCancellationRequested();
            tokenSource.CancelAfter(DefaultTimeout);

            var xml = new XmlRequest
            {
                Method     = "Bug.get",
                Parameters =
                {
                    new XmlParameter {
                        Name = "ids", Value = new[]{ arguments.UpdateToken                }
                    }
                }
            };

            var request = new RestRequest {
                Method = Method.POST, RequestFormat = DataFormat.Xml
            };

            request.AddParameter("text/xml", xml.ToString(), ParameterType.RequestBody);

            var response = await ExecuteAsync(request, tokenSource.Token).ConfigureAwait(false);

            CheckResponse(response);
            return(new BugzillaBug(response.Content));
        }
コード例 #2
0
ファイル: BugzillaRestClient.cs プロジェクト: nodia/gollum
        private async Task SendLoginRequestAsync(string username, string password)
        {
            var xml = new XmlRequest
            {
                Method     = "User.login",
                Parameters =
                {
                    new XmlParameter {
                        Name = "login", Value = username
                    },
                    new XmlParameter {
                        Name = "password", Value = password
                    }
                }
            };

            var request = new RestRequest {
                Method = Method.POST, RequestFormat = DataFormat.Xml
            };

            request.AddParameter("text/xml", xml.ToString(), ParameterType.RequestBody);

            using (var tokenSource = new CancellationTokenSource())
            {
                tokenSource.CancelAfter(DefaultTimeout);
                var response = await ExecuteAsync(request, tokenSource.Token).ConfigureAwait(false);

                CheckResponse(response);
            }
        }
コード例 #3
0
ファイル: BugzillaRestClient.cs プロジェクト: nodia/gollum
        public async Task PostToBugzillaAsync(BugzillaArguments arguments)
        {
            await Login(arguments).ConfigureAwait(false);

            var updateStatus = new XmlRequest
            {
                Method     = "Bug.update",
                Parameters =
                {
                    new XmlParameter {
                        Name = "ids", Value = new[]{ arguments.BugId                }
                    },
                    new XmlParameter {
                        Name = "status", Value = arguments.Status
                    },
                    new XmlParameter {
                        Name = "resolution", Value = arguments.Resolution
                    }
                }
            };

            using (var tokenSource = new CancellationTokenSource())
            {
                var statusRequest = new RestRequest {
                    Method = Method.POST, RequestFormat = DataFormat.Xml
                };
                statusRequest.AddParameter("text/xml", updateStatus.ToString(), ParameterType.RequestBody);

                tokenSource.CancelAfter(DefaultTimeout);
                var statusResponse = await ExecuteAsync(statusRequest, tokenSource.Token).ConfigureAwait(false);

                CheckResponse(statusResponse);

                var addComment = new XmlRequest
                {
                    Method     = "Bug.add_comment",
                    Parameters =
                    {
                        new XmlParameter {
                            Name = "id", Value = arguments.BugId
                        },
                        new XmlParameter {
                            Name = "comment", Value = arguments.Comment
                        }
                    }
                };

                var commentRequest = new RestRequest {
                    Method = Method.POST, RequestFormat = DataFormat.Xml
                };
                commentRequest.AddParameter("text/xml", addComment.ToString(), ParameterType.RequestBody);

                var commentResponse = await ExecuteAsync(commentRequest, tokenSource.Token).ConfigureAwait(false);

                CheckResponse(commentResponse);
            }
        }
コード例 #4
0
ファイル: BugzillaRestClient.cs プロジェクト: space035/gollum
        public async Task PostToBugzillaAsync(BugzillaArguments arguments)
        {
            await Login(arguments).ConfigureAwait(false);

            var updateStatus = new XmlRequest
            {
                Method = "Bug.update",
                Parameters =
                {
                    new XmlParameter {Name = "ids", Value = new[] { arguments.BugId  }},
                    new XmlParameter {Name = "status", Value = arguments.Status},
                    new XmlParameter {Name = "resolution", Value = arguments.Resolution}
                }
            };

            using (var tokenSource = new CancellationTokenSource())
            {
                var statusRequest = new RestRequest { Method = Method.POST, RequestFormat = DataFormat.Xml };
                statusRequest.AddParameter("text/xml", updateStatus.ToString(), ParameterType.RequestBody);

                tokenSource.CancelAfter(DefaultTimeout);
                var statusResponse = await ExecuteAsync(statusRequest, tokenSource.Token).ConfigureAwait(false);
                CheckResponse(statusResponse);

                var addComment = new XmlRequest
                {
                    Method = "Bug.add_comment",
                    Parameters =
                    {
                        new XmlParameter { Name = "id", Value = arguments.BugId },
                        new XmlParameter { Name = "comment", Value = arguments.Comment }
                    }
                };

                var commentRequest = new RestRequest { Method = Method.POST, RequestFormat = DataFormat.Xml };
                commentRequest.AddParameter("text/xml", addComment.ToString(), ParameterType.RequestBody);

                var commentResponse = await ExecuteAsync(commentRequest, tokenSource.Token).ConfigureAwait(false);
                CheckResponse(commentResponse);
            }
        }
コード例 #5
0
ファイル: BugzillaRestClient.cs プロジェクト: space035/gollum
        public async Task<BugzillaBug> GetBugInformationAsync(BugzillaArguments arguments, CancellationTokenSource tokenSource)
        {
            tokenSource.Token.ThrowIfCancellationRequested();

            await Login(arguments).ConfigureAwait(false);
            
            tokenSource.Token.ThrowIfCancellationRequested();
            tokenSource.CancelAfter(DefaultTimeout);

            var xml = new XmlRequest
            {
                Method = "Bug.get",
                Parameters =
                {
                    new XmlParameter {Name = "ids", Value = new[] { arguments.UpdateToken }}
                }
            };

            var request = new RestRequest { Method = Method.POST, RequestFormat = DataFormat.Xml };
            request.AddParameter("text/xml", xml.ToString(), ParameterType.RequestBody);

            var response = await ExecuteAsync(request, tokenSource.Token).ConfigureAwait(false);
            CheckResponse(response);
            return new BugzillaBug(response.Content);
        }
コード例 #6
0
ファイル: BugzillaRestClient.cs プロジェクト: space035/gollum
        private async Task SendLoginRequestAsync(string username, string password)
        {
            var xml = new XmlRequest
            {
                Method = "User.login",
                Parameters =
                {
                    new XmlParameter { Name = "login", Value = username },
                    new XmlParameter { Name = "password", Value = password }
                }
            };

            var request = new RestRequest { Method = Method.POST, RequestFormat = DataFormat.Xml };
            request.AddParameter("text/xml", xml.ToString(), ParameterType.RequestBody);

            using (var tokenSource = new CancellationTokenSource())
            {
                tokenSource.CancelAfter(DefaultTimeout);
                var response = await ExecuteAsync(request, tokenSource.Token).ConfigureAwait(false);
                CheckResponse(response);
            }
        }