示例#1
0
 /// <summary>
 /// Get a list of all the action attachments for this ticket - include only the latest for each filename
 /// </summary>
 public static void ReadActionAttachmentsForTicket(int ticketID, ActionAttachmentsByTicketID ticketActionAttachments, out AttachmentProxy[] attachments)
 {
     attachments = null;
     try
     {
         using (ConnectionContext connection = new ConnectionContext())
         {
             TicketModel ticketModel = connection.Ticket(ticketID);
             AttachmentAPI.ReadActionAttachmentsForTicket(ticketModel, ticketActionAttachments, out attachments);
         }
     }
     catch (Exception ex)
     {
         Data_API.LogMessage(ActionLogType.Delete, ReferenceType.Attachments, ticketID, "failed to read action attachments", ex);
     }
 }
示例#2
0
        /// <summary> Read most recent filenames for this ticket </summary>
        public static void ReadActionAttachmentsForTicket(TicketModel ticketModel, ActionAttachmentsByTicketID ticketActionAttachments, out AttachmentProxy[] mostRecentByFilename)
        {
            switch (ticketActionAttachments)
            {
            case ActionAttachmentsByTicketID.ByFilename:
            {
                DataContext         db          = ticketModel.Connection._db;
                Table <ActionProxy> actionTable = db.GetTable <ActionProxy>();
                int[] actionID = (from a in actionTable where a.TicketID == ticketModel.TicketID select a.ActionID).ToArray();

                Table <AttachmentProxy> attachmentTable = db.GetTable <AttachmentProxy>();
                AttachmentProxy[]       allAttachments  = attachmentTable.Where(a => actionID.Contains(a.RefID)).ToArray();
                List <AttachmentProxy>  tmp             = new List <AttachmentProxy>();
                foreach (AttachmentProxy attachment in allAttachments)
                {
                    if (!tmp.Exists(a => a.FileName == attachment.FileName))
                    {
                        tmp.Add(attachment);
                    }
                }
                mostRecentByFilename = tmp.ToArray();
            }
            break;

            case ActionAttachmentsByTicketID.KnowledgeBase:
            {
                string query = SelectActionAttachmentProxy + $"JOIN Actions ac ON a.ActionID = ac.ActionID WHERE ac.TicketID = {ticketModel.TicketID} AND ac.IsKnowledgeBase = 1";
                mostRecentByFilename = ticketModel.ExecuteQuery <AttachmentProxy>(query).ToArray();
            }
            break;

            default:
                mostRecentByFilename = null;
                break;
            }
        }