Exemplo n.º 1
0
        public void UpdateIssue(IssueUpdate update, NetworkCredential credential,
            Action<string> stdout, Action<string> stderr)
        {
            var client = new Gurtle.WebClient();
            System.Collections.Specialized.NameValueCollection data = new System.Collections.Specialized.NameValueCollection(1);
            if (update.Comment.Length > 0)
            {
                data.Add("comment", update.Comment);
            }

            client.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(credential.UserName + ":" + credential.Password)));
            client.UploadValues(CommentIssueUrl(update.Issue.Id), data);
            data.Clear();
            client.UploadValues(CloseIssueUrl(update.Status, update.Issue.Id), data);
        }
Exemplo n.º 2
0
        public Action DownloadIssues(string project, int start, bool includeClosedIssues,
            Func<IEnumerable<Issue>, bool> onData,
            Action<DownloadProgressChangedEventArgs> onProgress,
            Action<bool, Exception> onCompleted)
        {
            Debug.Assert(project != null);
            Debug.Assert(onData != null);

            var client = new Gurtle.WebClient();

            client.DownloadStringAsync(this.IssuesUrl());

            client.DownloadStringCompleted += (sender, args) =>
            {
                if (args.Cancelled || args.Error != null)
                {
                    if (onCompleted != null)
                        onCompleted(args.Cancelled, args.Error);

                    return;
                }
                var issues = IssueTableParser.Parse(args.Result).ToArray();
                onData(issues);

                if (onCompleted != null)
                    onCompleted(false, null);
            };

            if (onProgress != null)
                client.DownloadProgressChanged += (sender, args) => onProgress(args);

            return client.CancelAsync;
        }