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)); }
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); } }
private async Task Login(BugzillaArguments arguments) { if (ReadCookies()) { return; } if (arguments.CredentialCallback == null) { throw new BugzillaAuthenticationException(); } var credentials = arguments.CredentialCallback("Bugzilla login"); await SendLoginRequestAsync(credentials.Username, credentials.Password).ConfigureAwait(false); }
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); } }
public async Task PostToBugzillaAsync(BugzillaArguments arguments) { await Task.Delay(3000).ConfigureAwait(false); }
public async Task<BugzillaBug> GetBugInformationAsync(BugzillaArguments arguments, CancellationTokenSource tokenSource) { tokenSource.CancelAfter(TimeSpan.FromSeconds(4)); await Task.Delay(3000, tokenSource.Token).ConfigureAwait(false); return new BugzillaBug("<bug></bug>"); }
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); }