示例#1
0
        /// <summary>
        /// Delete all attachments from defect
        /// </summary>
        /// <param name="bug">TDAPIOLELib.Bug Object</param>
        /// <returns>True if Successfull</returns>
        public Boolean DeleteAllAttachments(TDAPIOLELib.Bug bug)
        {
            TDAPIOLELib.AttachmentFactory OAttachmentFactory;

            OAttachmentFactory = bug.Attachments;
            TDAPIOLELib.List AttachmentsList = OAttachmentFactory.NewList("");

            foreach (TDAPIOLELib.Attachment OAttach in AttachmentsList)
            {
                OAttachmentFactory.RemoveItem(OAttach.ID);
            }

            return(true);
        }
示例#2
0
        /// <summary>
        /// Delete defect attachment by name
        /// </summary>
        /// <param name="bug">TDAPIOLELib.Bug Object</param>
        /// <param name="attachmentName">Name of attachment</param>
        /// <returns>True if successfull</returns>
        public Boolean DeleteAttachmentByName(TDAPIOLELib.Bug bug, String attachmentName)
        {
            TDAPIOLELib.AttachmentFactory OAttachmentFactory;

            OAttachmentFactory = bug.Attachments;
            TDAPIOLELib.List AttachmentsList = OAttachmentFactory.NewList("");

            foreach (TDAPIOLELib.Attachment OAttach in AttachmentsList)
            {
                if (OAttach.Name.EndsWith(attachmentName))
                {
                    OAttachmentFactory.RemoveItem(OAttach.ID);
                    break;
                }
            }

            return(true);
        }
示例#3
0
        /// <summary>
        /// Downloads defect attachments
        /// </summary>
        /// <param name="bug"></param>
        /// <param name="attachmentDownloadPath"></param>
        /// <returns>True if Successfull</returns>
        public Boolean DownloadAttachments(TDAPIOLELib.Bug bug, String attachmentDownloadPath)
        {
            try
            {
                TDAPIOLELib.AttachmentFactory OAttachmentFactory;
                TDAPIOLELib.ExtendedStorage   OExtendedStorage;

                if (bug.HasAttachment)
                {
                    if ((System.IO.Directory.Exists(attachmentDownloadPath)) == false)
                    {
                        throw (new Exception("Attachment download path does not exist"));
                    }

                    //System.IO.Directory.CreateDirectory(AttachmentDownloadPath + "\\" + OBug.ID.ToString());

                    OAttachmentFactory = bug.Attachments;

                    foreach (TDAPIOLELib.Attachment OAttachment in OAttachmentFactory.NewList(""))
                    {
                        OExtendedStorage            = OAttachment.AttachmentStorage;
                        OExtendedStorage.ClientPath = attachmentDownloadPath;// + "\\" + OBug.ID.ToString();
                        OAttachment.Load(true, OAttachment.Name);
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }