/// <summary>
        /// Demonstrates how to delete individual attachments. 
        /// </summary>
        /// <param name="ticket"></param>
        public static void DeleteAllAttachments(Ticket ticket)
        {
            if (ticket.Ticket_Attachments != null)
            {
                var ticketGuids = ticket.Ticket_Attachments.Select(att => att.Guid).ToList();
                foreach (var guid in ticketGuids)
                {
                    //Must use this method to ensure the last attachment gets deleted properly
                    //You can modify the list directly to delete attachments,
                    //  but deleting the last attachment is equivalent to deleting all attachments.
                    //  We add a check to prevent this from happening accidentally
                    ticket.DeleteAttachment(guid);
                }

                //remove the attachments on the server
                var response = Service.Update(ticket);
            }
        }
示例#2
0
 public Ticket(Ticket ticket)
     : base(ticket)
 {
     if (ticket != null)
     {
         ActionHistory = new List<ActionHistory>(ticket.ActionHistory);
         Actions = new List<Action>(ticket.Actions);
         Additional_Contact = ticket.Additional_Contact;
         Assigned_To = ticket.Assigned_To;
         Cc_Csr = ticket.Cc_Csr;
         Cc_Customer = ticket.Cc_Customer;
         Date_Created = ticket.Date_Created;
         Date_Updated = ticket.Date_Updated;
         Department = ticket.Department;
         Email_Notification = ticket.Email_Notification;
         Email_Notification_Additional_Contact = ticket.Email_Notification_Additional_Contact;
         Entered_By = ticket.Entered_By;
         Hide_From_Customer = ticket.Hide_From_Customer;
         Id = ticket.Id;
         Ticket_Asset = ticket.Ticket_Asset;
         Ticket_Attachments = new List<Attachment>(ticket.Ticket_Attachments);
         if (ticket.Ticket_Customer != null)
         {
             Ticket_Customer = ticket.Ticket_Customer;
         }
         if (ticket.Ticket_Children != null)
         {
             Ticket_Children = new List<Ticket>(ticket.Ticket_Children);
         }
         Ticket_Number = ticket.Ticket_Number;
         if (ticket.Ticket_Parent != null)
         {
             Ticket_Parent = ticket.Ticket_Parent;
         }
         Ticket_Product = ticket.Ticket_Product;
         Ticket_Queue = ticket.Ticket_Queue;
         Ticket_Status = ticket.Ticket_Status;
     }
 }
        /// <summary>
        /// Convenience method to remove all attachments for the ticket on the server
        /// </summary>
        /// <param name="ticket"></param>
        public static void DeleteAllAttachmentsBulk(Ticket ticket)
        {
            ticket.DeleteAllAttachments();

            var response = Service.Update(ticket);
        }
 public static void AddAttachment(Ticket ticket, string fileName, string fileContents)
 {
     ticket.AddAttachment(Service, fileContents, "text/plain", fileName);
     var response = Service.Update(ticket);
 }