Ejemplo n.º 1
0
        private async void TxtRepository_Enter(object sender, EventArgs e)
        {
            String owner = TxtOwner.Text;

            if (owner.Length == 0)
            {
                return;
            }

            try
            {
                var tracker = IssueTrackerFactory.CreateIssueTracker(Params);
                if (tracker != null)
                {
                    var repos = await tracker.GetAllRepositories();

                    var repo_list = new AutoCompleteStringCollection();
                    repo_list.AddRange(repos.ToArray());

                    TxtRepository.AutoCompleteCustomSource = repo_list;
                }
            }
            catch
            {
                // Let this silently fail, the user just won't have an autocomplete list
                // This could be due to no network connection, invalid username, etc
            }
        }
Ejemplo n.º 2
0
        public IssueBrowserDialog(Parameters parameters)
        {
            Logger.LogMessageWithData("IssueBrowserDialog()");

            InitializeComponent();

            // Set the icons here instead of them being stored in the resource file multiple times
            this.Icon             = Properties.Resources.TurtleHub;
            updateNotifyIcon.Icon = Properties.Resources.TurtleHub;

            this.parameters = parameters;

            checkBoxShowPrs.Checked = parameters.ShowPrsByDefault;

            Text = string.Format(Text, parameters.Repository);

            // Wrap the objectlistview and set the aspects appropriately
            issuelistview = new TypedObjectListView <TurtleIssue>(this.objectListView1);
            issuelistview.GetColumn(0).AspectGetter = delegate(TurtleIssue x) { return(x.Number); };
            issuelistview.GetColumn(1).AspectGetter = delegate(TurtleIssue x) { return(x.Title); };
            issuelistview.GetColumn(2).AspectGetter = delegate(TurtleIssue x) { return(x.Creator); };
            issuelistview.GetColumn(3).AspectGetter = delegate(TurtleIssue x) { return(x.Assignee); };

            // Start the tracker magic
            tracker = IssueTrackerFactory.CreateIssueTracker(parameters);
        }
Ejemplo n.º 3
0
        public bool ValidateParameters(IntPtr hParentWnd, string parameters)
        {
            Logger.LogMessageWithData("ValidateParameters: " + parameters);
            Parameters        parms;
            RepositoryMetrics metrics = null;

            try
            {
                parms = new Parameters(parameters);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "TurtleHub", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (parms.Owner.Length == 0 || parms.Repository.Length == 0)
            {
                MessageBox.Show("Invalid parameters.", "TurtleHub", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }

            try
            {
                var tracker = IssueTrackerFactory.CreateIssueTracker(parms);
                var task    = tracker.GetRepositoryMetrics();
                if (task != null)
                {
                    task.Wait();
                    metrics = task.Result;
                }
            }
            catch (AggregateException aex)
            {
                // NOTE: since we are waiting on the task, an AggregateException is thrown instead of just an ApiExcpetion
                foreach (Exception ex in aex.InnerExceptions)
                {
                    if (ex is Octokit.NotFoundException)
                    {
                        if (((Octokit.NotFoundException)ex).HttpResponse.StatusCode == HttpStatusCode.NotFound)
                        {
                            var res = MessageBox.Show("This repository cannot be found on the server. Continue anyways?", "TurtleHub", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                            return(res == DialogResult.Yes);
                        }
                    }
                }

                // Some other exception happend. Silently fail, not a big deal
                return(true);
            }

            if (metrics != null)
            {
                // Do a bit more to validate it
                if (!metrics.HasIssues)
                {
                    var res = MessageBox.Show("This repository doesn't allow issues to be created. Continue anyways?", "TurtleHub", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (res == DialogResult.No)
                    {
                        return(false);
                    }
                }
                else if (metrics.OpenIssues == 0)
                {
                    var res = MessageBox.Show("This repository doesn't have any open issues. Continue anyways?", "TurtleHub", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (res == DialogResult.No)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }