示例#1
0
        private void bg_gitIssuesWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            List<String> list = e.Argument as List<String>;
            GithubRest git = new GithubRest(list[0], list[1]);
            gitComments = new Dictionary<int, List<GitModels.Comments>>();
            openGitMilestones = git.GetMilestones(selectedGitRepositiry);
            if (openGitMilestones != null)
            {
                String textData = "The " + selectedGitRepositiry + " has " + openGitMilestones.Count.ToString() + " open milestones.\n";
                Dispatcher.Invoke(new Action(() => logger.AppendText(textData)));

            }
            closedGitMilestones = git.GetMilestones(selectedGitRepositiry, false);
            if (closedGitMilestones != null)
            {
                String textData = ("The " + selectedGitRepositiry + " has " + closedGitMilestones.Count.ToString() + " closed milestones.\n");
                Dispatcher.Invoke(new Action(() => logger.AppendText(textData)));
            }
            openGitIssues = git.GetIssues(selectedGitRepositiry);
            if (openGitIssues != null)
            {
                String textData = ("The " + selectedGitRepositiry + " has " + openGitIssues.Count.ToString() + " open issues.\n");
                Dispatcher.Invoke(new Action(() => logger.AppendText(textData)));
                // Get individual Comments for each open issue
                foreach (Git2Bit.GitModels.Issue issue in openGitIssues)
                {
                    if (issue.comments > 0)
                    {
                        // has comments:
                        List<Git2Bit.GitModels.Comments> comments = git.GetComments(selectedGitRepositiry, issue.number);
                        String textData1 = ("Issue " + issue.number.ToString() + " has " + comments.Count.ToString() + " comments.\n");
                        Dispatcher.Invoke(new Action(() => logger.AppendText(textData1)));
                        gitComments[issue.number] = comments;
                    }
                }
            }
            closedGitIssues = git.GetIssues(selectedGitRepositiry, false);
            if (closedGitIssues != null)
            {
                logger.AppendText("The " + selectedGitRepositiry + " has " + closedGitIssues.Count.ToString() + " closed issues.\n");
                // Get individual Comments for each open issue
                foreach (Git2Bit.GitModels.Issue issue in closedGitIssues)
                {
                    if (issue.comments > 0)
                    {
                        // has comments:
                        List<Git2Bit.GitModels.Comments> comments = git.GetComments(selectedGitRepositiry, issue.number);
                        String textData1 = ("Issue " + issue.number.ToString() + " has " + comments.Count.ToString() + " comments.\n");
                        Dispatcher.Invoke(new Action(() => logger.AppendText(textData1)));
                        gitComments[issue.number] = comments;
                    }
                }
            }
        }
        private void gitGetIssuesButton_Click(object sender, RoutedEventArgs e)
        {
            GithubRest git = new GithubRest(gitUsername.Text, gitPassword.Password);
            gitComments = new Dictionary<int, List<GitModels.Comments>>();
            openGitMilestones = git.GetMilestones(selectedGitRepositiry);
            logger.AppendText("The " + selectedGitRepositiry + " has " + openGitMilestones.Count.ToString() + " open milestones.\n");
            closedGitMilestones = git.GetMilestones(selectedGitRepositiry, false);
            logger.AppendText("The " + selectedGitRepositiry + " has " + closedGitMilestones.Count.ToString() + " closed milestones.\n");
            openGitIssues = git.GetIssues(selectedGitRepositiry);
            logger.AppendText("The " + selectedGitRepositiry + " has " + openGitIssues.Count.ToString() + " open issues.\n");
            closedGitIssues = git.GetIssues(selectedGitRepositiry, false);
            logger.AppendText("The " + selectedGitRepositiry + " has " + closedGitIssues.Count.ToString() + " closed issues.\n");

            // Get individual Comments for each open issue
            foreach (Git2Bit.GitModels.Issue issue in openGitIssues)
            {
                if (issue.comments > 0)
                {
                    // has comments:
                    List<Git2Bit.GitModels.Comments> comments = git.GetComments(selectedGitRepositiry, issue.number);
                    logger.AppendText("Issue " + issue.number.ToString() + " has " + comments.Count.ToString() + " comments.\n");
                    gitComments[issue.number] = comments;
                }
            }

            // Get individual Comments for each open issue
            foreach (Git2Bit.GitModels.Issue issue in closedGitIssues)
            {
                if (issue.comments > 0)
                {
                    // has comments:
                    List<Git2Bit.GitModels.Comments> comments = git.GetComments(selectedGitRepositiry, issue.number);
                    logger.AppendText("Issue " + issue.number.ToString() + " has " + comments.Count.ToString() + " comments.\n");
                    gitComments[issue.number] = comments;
                }
            }

            gitIssuesButton.IsEnabled = false;
        }