/// <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);
        }
        /// <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);
        }
        /// <summary>
        /// Add Attachments to defect
        /// </summary>
        /// <param name="bug">TDAPIOLELib.Bug Object</param>
        /// <param name="attachmentsPath">List of attachment paths</param>
        /// <returns>True if Successfull</returns>
        public Boolean AddAttachment(TDAPIOLELib.Bug bug, List <String> attachmentsPath)
        {
            TDAPIOLELib.AttachmentFactory OAttachmentFactory;
            TDAPIOLELib.Attachment        OAttachment;

            OAttachmentFactory = bug.Attachments;

            foreach (String AP in attachmentsPath)
            {
                if (System.IO.File.Exists(AP))
                {
                    OAttachment          = OAttachmentFactory.AddItem(System.DBNull.Value);
                    OAttachment.FileName = AP;
                    OAttachment.Type     = Convert.ToInt16(TDAPIOLELib.tagTDAPI_ATTACH_TYPE.TDATT_FILE);
                    OAttachment.Post();
                }
            }

            return(true);
        }
        /// <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;
            }
        }
Beispiel #5
0
        /// <summary>
        /// Add a single design step to the test. Added design step will be the last design step.
        /// <para/> returns TDAPIOLELib.DesignStep Object
        /// </summary>
        /// <param name="test">TDAPIOLELib.Test Object</param>
        /// <param name="description">Description of the design step</param>
        /// <param name="expectedResult">Expected result of the design step</param>
        /// <param name="attachmentPath">attachment path of the design step</param>
        /// <returns>TDAPIOLELib.DesignStep Object</returns>
        public TDAPIOLELib.DesignStep AddSingleDeignStep(TDAPIOLELib.Test test, String description, String expectedResult, String attachmentPath = "")
        {
            TDAPIOLELib.DesignStep        ODesignStep;
            TDAPIOLELib.DesignStepFactory ODesignStepFactory;

            ODesignStepFactory = test.DesignStepFactory;

            int StepCounter = ODesignStepFactory.NewList("").Count + 1;

            ODesignStep                    = ODesignStepFactory.AddItem(System.DBNull.Value);
            ODesignStep.StepName           = "Step " + StepCounter;
            ODesignStep.StepDescription    = description;
            ODesignStep.StepExpectedResult = expectedResult;
            ODesignStep.Post();

            if (attachmentPath != "")
            {
                TDAPIOLELib.AttachmentFactory OAttachmentFactory;
                TDAPIOLELib.Attachment        OAttachment;

                OAttachmentFactory = ODesignStep.Attachments;
                if (System.IO.File.Exists(attachmentPath))
                {
                    OAttachment          = OAttachmentFactory.AddItem(System.DBNull.Value);
                    OAttachment.FileName = attachmentPath;
                    OAttachment.Type     = Convert.ToInt16(TDAPIOLELib.tagTDAPI_ATTACH_TYPE.TDATT_FILE);
                    OAttachment.Post();
                }
                else
                {
                    throw (new Exception("File Not Found : " + attachmentPath));
                }
            }

            return(ODesignStep);
        }