Пример #1
0
        private void EditTicket()
        {
            if (ticketsListView.SelectedItems.Count != 1)
            {
                return;
            }

            var tag = (Ticket)ticketsListView.SelectedItems[0].Tag;

            using (var form = new TicketDetailsForm(mContext, FormUtil.GetFontContext(), FormUtil.GetFormatter(), Project, tag)) {
                if (form.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                tag.UpdateAndGenerateHistoryRecord(mContext, TicketChangeFormatter.Default, t => {
                    return(form.RetrieveTicket(t));
                });

                // Flush.
                mContext.Flush();

                // Show tickets.
                ShowTickets();

                UpdateTicket(true);
            }
        }
Пример #2
0
        private void ShowTicket()
        {
            if (ticketsListView.SelectedItems.Count != 1)
            {
                return;
            }

            var tag = (Ticket)ticketsListView.SelectedItems[0].Tag;

            using (var form = new TicketDetailsForm(mContext, FormUtil.GetFontContext(), FormUtil.GetFormatter(), Project, tag)) {
                form.ReadOnly = true;
                form.ShowDialog();
            }
        }
Пример #3
0
        private void ShowTickets()
        {
            if (mResettingTicketFilters)
            {
                return;
            }

            FormUtil.Reselect <Ticket>(ticketsListView, () => {
                string summaryFilter   = ticketSummaryTextBox.Text;
                var reporterFilter     = (string)ticketReportersComboBox.SelectedItem;
                var assignedFilter     = (string)ticketAssignedToComboBox.SelectedItem;
                string milestoneFilter = (string)ticketMilestoneComboBox.SelectedItem;
                var stateFilter        = FormUtil.CastBoxToEnum <MetaTicketState>(ticketStateComboBox);
                var severityFilter     = FormUtil.CastBoxToEnum <TicketSeverity>(ticketSeverityComboBox);
                var priorityFilter     = FormUtil.CastBoxToEnum <TicketPriority>(ticketPriorityComboBox);
                var typeFilter         = FormUtil.CastBoxToEnum <TicketType>(ticketTypeComboBox);

                Ticket[] tickets = Project.GetTickets(mContext);

                tickets = tickets.Where(t => {
                    bool satisfiesSummaryFilter   = FormUtil.SatisfiesFilterContains(t.Summary, summaryFilter);
                    bool satisfiesReporterFilter  = FormUtil.SatisfiesFilterMatch(t.ReportedBy, reporterFilter);
                    bool satisfiesAssignedFilter  = FormUtil.SatisfiesFilterMatch(t.AssignedTo, assignedFilter);
                    bool satisfiesMilestoneFilter = FormUtil.SatisfiesFilterMatch(t.GetMilestone(mContext).Name, milestoneFilter);
                    bool satisfiesStateFilter     = stateFilter == null || stateFilter.Value.AppliesTo(t.State);
                    bool satisfiesSeverityFilter  = FormUtil.SatisfiesFilterEnum(t.Severity, severityFilter);
                    bool satisfiesPriorityFilter  = FormUtil.SatisfiesFilterEnum(t.Priority, priorityFilter);
                    bool satisfiesTypeFilter      = FormUtil.SatisfiesFilterEnum(t.Type, typeFilter);
                    bool satisfiesCreatedFilter   = FormUtil.SatisfiesFilterContains(t.CreateTimestamp, mTicketCreateFilter);
                    bool satisfiesModifiedFilter  = FormUtil.SatisfiesFilterContains(t.ModifyTimestamp, mTicketModifyFilter);

                    return
                    (satisfiesSummaryFilter &&
                     satisfiesReporterFilter &&
                     satisfiesAssignedFilter &&
                     satisfiesMilestoneFilter &&
                     satisfiesStateFilter &&
                     satisfiesSeverityFilter &&
                     satisfiesPriorityFilter &&
                     satisfiesTypeFilter &&
                     satisfiesCreatedFilter &&
                     satisfiesModifiedFilter);
                }).ToArray();

                // Cache milestones.
                var milestoneNames     = new Dictionary <int, string>();
                Milestone[] milestones = Milestone.GetMilestones(mContext);
                foreach (Milestone milestone in milestones)
                {
                    milestoneNames[milestone.ID] = milestone.Name;
                }

                ticketsListView.BeginUpdate();
                ticketsListView.Items.Clear();
                foreach (var ticket in tickets)
                {
                    string ticketPriority = TicketChangeFormatter.Default.TranslateTicketPriority(ticket.Priority);
                    string ticketType     = TicketChangeFormatter.Default.TranslateTicketType(ticket.Type);
                    string ticketSeverity = TicketChangeFormatter.Default.TranslateTicketSeverity(ticket.Severity);
                    string ticketState    = TicketChangeFormatter.Default.TranslateTicketState(ticket.State);

                    var lvi = new ListViewItem();

                    lvi.Text = $"{ticket.TicketNumber}";
                    lvi.SubItems.Add(ticket.Summary);
                    lvi.SubItems.Add(milestoneNames[ticket.MilestoneID]);
                    lvi.SubItems.Add(ticketPriority);
                    lvi.SubItems.Add(ticketType);
                    lvi.SubItems.Add(ticketSeverity);
                    lvi.SubItems.Add(ticketState);
                    lvi.Tag = ticket;

                    ticketsListView.Items.Add(lvi);
                }

                ticketsListView.EndUpdate();
                ticketsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            });

            UpdateButtonsEnabledProperty();
        }
Пример #4
0
        private void AddTicket()
        {
            Milestone[] milestones = Project.GetMilestones(mContext);
            if (milestones.Length == 0)
            {
                MessageBox.Show(
                    Resources.String_PleaseAddAMilestoneBeforeAddingATicket,
                    Resources.String_Error,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error,
                    MessageBoxDefaultButton.Button1,
                    FormUtil.GetMessageBoxOptions(this));
                tabControl.SelectedTab = milestonesTabPage;
                return;
            }

            using (var form = new TicketDetailsForm(mContext, FormUtil.GetFontContext(), FormUtil.GetFormatter(), Project, null)) {
                if (form.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                Ticket ticket = form.RetrieveTicket();

                // Add.
                ticket.Add(mContext);

                // Flush.
                mContext.Flush();

                // Create ticket history entry.
                TicketHistory ticketHistory = ticket.NewHistory(Resources.String_TicketCreated);
                ticketHistory.Add(mContext);

                // Show tickets.
                ShowTickets();

                FormUtil.SelectNew(ticketsListView, ticket);

                UpdateButtonsEnabledProperty();

                ticketsListView.Focus();

                UpdateTicket(true);
            }
        }
Пример #5
0
 public override string ToString()
 {
     return(ToString(FormUtil.GetFormatter()));
 }