BEurtle.IssuesForm.loadIssues C# (CSharp) Méthode

loadIssues() private méthode

private loadIssues ( bool refreshData = true ) : void
refreshData bool
Résultat void
        private void loadIssues(bool refreshData=true)
        {
            string focuseditem=null;
            if (IssuesList.SelectedRows.Count > 0)
                focuseditem = IssuesList.SelectedRows[0].Cells[0].ToString();
            bool doredraw = (!refreshData || plugin.loadIssues(this, BERepoLocation.Text));
            try
            {
                Win32.SendMessage(this.Handle, Win32.WM_SETREDRAW, false, 0);
                SuspendLayout();
                IssuesList.Rows.Clear();
                RowToUUID.Clear();
                IssuesList.Columns[IssuesList.Columns.Count - 1].Visible = plugin.parameters.ShowCommentCount != ShowCommentCountType.DontShow;
                ButtonOk.Enabled = false;
                NewIssue.Enabled = false;
                DeleteIssue.Enabled = false;
                VCSInfo.Text = plugin.VCSInfo;

                if(doredraw)
                {
                    var issues_nav = plugin.issues.CreateNavigator();
                    XPathNodeIterator iter = (XPathNodeIterator)issues_nav.Select("/be-xml/bug");
                    foreach (XPathNavigator issue in iter)
                    {
                        //MessageBox.Show(this, issue.OuterXml);
                        Guid uuid = new Guid(issue.Evaluate("string(uuid)").ToString());
                        string shortname=(string) issue.Evaluate("string(short-name)"), status=(string) issue.Evaluate("string(status)"), severity=(string) issue.Evaluate("string(severity)"), created, summary=(string) issue.Evaluate("string(summary)");
                        created=(string) issue.Evaluate("string(created)");
                        if (created == "")
                            created = "unknown";
                        else
                        {
                            try
                            {
                                created = DateTime.Parse(created).ToString("u");
                            }
                            catch (Exception)
                            {
                                created = "BAD";
                            }
                        }
                        if (status_filters.Count > 0)
                        {
                            bool filter = false;
                            foreach (var f in status_filters)
                                if (status.Contains(f)) { filter = true; break; }
                            if (filter) continue;
                        }
                        if (severity_filters.Count > 0)
                        {
                            bool filter = false;
                            foreach (var f in severity_filters)
                                if (severity.Contains(f)) { filter = true; break; }
                            if (filter) continue;
                        }
                        if (status_filters.Count > 0)
                        {
                            bool filter = false;
                            foreach (var f in status_filters)
                                if (status.Contains(f)) { filter = true; break; }
                            if (filter) continue;
                        }
                        if (created_filters.Count > 0)
                        {
                            bool filter = false;
                            foreach (var f in created_filters)
                                if (created.Contains(f)) { filter = true; break; }
                            if (filter) continue;
                        }
                        if (summary_filters.Count > 0)
                        {
                            bool filter = false;
                            foreach (var f in summary_filters)
                                if (summary.Contains(f)) { filter = true; break; }
                            if (filter) continue;
                        }
                        var row = new DataGridViewRow();
                        row.Cells.Add(new DataGridViewTextBoxCell());
                        row.Cells[0].Value = shortname;

                        row.Cells.Add(new DataGridViewTextBoxCell());
                        row.Cells[1].Value = status;
                        if (status == "closed" || status == "fixed" || status == "wontfix")
                            row.Cells[1].Style.BackColor = Color.FromArgb(128, 255, 128);
                        else if (status == "unconfirmed")
                            row.Cells[1].Style.BackColor = Color.FromArgb(255, 255, 128);
                        else if (status == "open" || status == "assigned")
                            row.Cells[1].Style.BackColor = Color.FromArgb(255, 128, 128);

                        row.Cells.Add(new DataGridViewTextBoxCell());
                        row.Cells[2].Value = severity;
                        if (severity == "target")
                            row.Cells[2].Style.BackColor = Color.FromArgb(128, 255, 128);
                        else if (severity == "serious")
                            row.Cells[2].Style.BackColor = Color.FromArgb(255, 255, 128);
                        else if (severity == "critical" || severity == "fatal")
                            row.Cells[2].Style.BackColor = Color.FromArgb(255, 128, 128);

                        row.Cells.Add(new DataGridViewTextBoxCell());
                        row.Cells[3].Value = created;

                        row.Cells.Add(new DataGridViewTextBoxCell());
                        row.Cells[4].Value = summary;

                        row.Cells.Add(new DataGridViewLinkCell());
                        row.Cells[5].Style.Alignment = DataGridViewContentAlignment.MiddleRight;
                        if(plugin.parameters.ShowCommentCount != ShowCommentCountType.DontShow)
                        {
                            int commentcount=int.Parse(issue.Evaluate("count(comment)").ToString());
                            row.Cells[5].Value = commentcount.ToString();
                        }

                        IssuesList.Rows.Add(row);
                        RowToUUID.Add(row, uuid);
                    }
                    NewIssue.Enabled = true;
                    ButtonOk.Enabled = true;
                    if (IssuesList.Rows.Count > 0)
                    {
                        DeleteIssue.Enabled = true;
                        if (focuseditem != null)
                        {
                            foreach (DataGridViewRow item in IssuesList.Rows)
                            {
                                if (item.Cells[0].ToString() == focuseditem)
                                {
                                    IssuesList.Rows[0].Selected = false;
                                    item.Selected = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                Win32.SendMessage(this.Handle, Win32.WM_SETREDRAW, true, 0);
                this.ResumeLayout();
                Refresh();
            }
        }