public void RetrieveTicketHistory(TicketHistory ticketHistory) { if (ticketHistory == null) { throw new ArgumentNullException("ticketHistory"); } // Nothing. return; }
public TicketHistory[] GetHistory(IDatabaseProvider db) { if (db == null) { throw new ArgumentNullException(nameof(db)); } if (ID == InvalidID) { string message = Resources.String_CurrentObjectDoesNotExistInTheDatabase; throw new InvalidOperationException(message); } return(TicketHistory.GetTicketHistoryByTicketID(db, ID)); }
public void ShowTicketHistory(TicketHistory ticketHistory) { if (ticketHistory == null) { throw new ArgumentNullException("ticketHistory"); } if (DateTimeFormatter != null) { timestampTextBox.Text = DateTimeFormatter.Format(ticketHistory.Timestamp); } else { timestampTextBox.Text = string.Format("{0}", ticketHistory.Timestamp); } changesTextBox.Text = ticketHistory.Changes; commentTextBox.Text = ticketHistory.Comment; return; }
public bool UpdateAndGenerateHistoryRecord(IDatabaseProvider db, ITicketChangeFormatter formatter, Func <Ticket, Ticket> assignNewProperties) { if (db == null) { throw new ArgumentNullException(nameof(db)); } if (formatter == null) { throw new ArgumentNullException(nameof(formatter)); } if (assignNewProperties == null) { throw new ArgumentNullException(nameof(assignNewProperties)); } var @new = assignNewProperties(Copy()); if (@new.ID != ID) { throw new InvalidOperationException("Cannot modify ticket ID"); } if (@new.TicketNumber != TicketNumber) { throw new InvalidOperationException("Cannot modify ticket number"); } // Changes. var changesStringBuilder = new StringBuilder(); // Milestone. if (MilestoneID != @new.MilestoneID) { changesStringBuilder.AppendFormat(formatter.Milestone(db, MilestoneID, @new.MilestoneID)); changesStringBuilder.AppendLine(); MilestoneID = @new.MilestoneID; } // Summary. if (Summary != @new.Summary) { changesStringBuilder.AppendFormat(formatter.Summary(Summary, @new.Summary)); changesStringBuilder.AppendLine(); Summary = @new.Summary; } // Reported by. if (ReportedBy != @new.ReportedBy) { changesStringBuilder.AppendFormat(formatter.ReportedBy(ReportedBy, @new.ReportedBy)); changesStringBuilder.AppendLine(); ReportedBy = @new.ReportedBy; } // Type. if (Type != @new.Type) { changesStringBuilder.AppendFormat(formatter.Type(Type, @new.Type)); changesStringBuilder.AppendLine(); Type = @new.Type; } // Severity. if (Severity != @new.Severity) { changesStringBuilder.AppendFormat(formatter.Severity(Severity, @new.Severity)); changesStringBuilder.AppendLine(); Severity = @new.Severity; } // State. if (State != @new.State) { changesStringBuilder.AppendFormat(formatter.State(State, @new.State)); changesStringBuilder.AppendLine(); State = @new.State; } // AssignedTo. if (AssignedTo != @new.AssignedTo) { changesStringBuilder.AppendFormat(formatter.AssignedTo(AssignedTo, @new.AssignedTo)); changesStringBuilder.AppendLine(); AssignedTo = @new.AssignedTo; } // Priority. if (Priority != @new.Priority) { changesStringBuilder.AppendFormat(formatter.Priority(Priority, @new.Priority)); changesStringBuilder.AppendLine(); Priority = @new.Priority; } // Description. if (Description != @new.Description) { changesStringBuilder.AppendFormat(formatter.Description(Description, @new.Description)); changesStringBuilder.AppendLine(); Description = @new.Description; } string changes = changesStringBuilder.ToString(); if (string.IsNullOrEmpty(changes)) { return(false); } UpdatePrivate(db.DB); TicketHistory ticketHistory = NewHistory(changes); ticketHistory.Add(db); return(true); }
public static TicketHistory GetTicketHistory(int id) { TicketsHistoryTableAdapter tableAdapter = Database.TicketsHistoryTableAdapter; PeygirDatabaseDataSet.TicketsHistoryDataTable rows = tableAdapter.GetDataByID(id); if (rows.Count == 1) { // Found. TicketHistory ticketsHistory = new TicketHistory(rows[0]); return ticketsHistory; } // Not found. return null; }
public static TicketHistory[] GetTicketsHistory() { TicketsHistoryTableAdapter tableAdapter = Database.TicketsHistoryTableAdapter; PeygirDatabaseDataSet.TicketsHistoryDataTable rows = tableAdapter.GetData(); // Create list. List<TicketHistory> ticketsHistory = new List<TicketHistory>(); foreach (var row in rows) { // Add. TicketHistory ticketHistory = new TicketHistory(row); ticketsHistory.Add(ticketHistory); } return ticketsHistory.ToArray(); }