Пример #1
0
        private int addAttachments(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback)
        {
            // Get a handle to the job
            IJTXJobManager pJobManager = m_ipDatabase.JobManager;
            IJTXJob2 pJob = pJobManager.GetJob(jobID) as IJTXJob2;
            IJTXJob2 pParentJob = pJobManager.GetJob(pJob.ParentJob) as IJTXJob2;

            // Prompt the user to choose whether the attachment should be embedded
            // into the database or merely stored as a URL, UNC path, etc.
            AttachmentTypeDialog atd = new AttachmentTypeDialog();

            // Check to see if this job has a parent.  If so, enable the "attach to parent" dialog.
            if (pParentJob == null)
            {
                atd.EnableSelectParent = false;
            }
            else
            {
                atd.EnableSelectParent = true;
            }

            atd.ShowDialog();
            if (atd.isNoneSelected())
            {
                return 0;
            }

            // Set the file storage type, according to what the user selected.
            bool embedAttachment = atd.isEmbeddedSelected();
            jtxFileStorageType fileStorageType;
            if (embedAttachment)
            {
                fileStorageType = jtxFileStorageType.jtxStoreInDB;
            }
            else
            {
                fileStorageType = jtxFileStorageType.jtxStoreAsLink;
            }

            // Prompt the user to select the file(s) to be attached.
            System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
            ofd.CheckFileExists = true;
            ofd.Multiselect = false;
            ofd.ShowDialog();

            // Add each file that the user selected.
            foreach (string filename in ofd.FileNames)
            {
                if (atd.AttachToCurrent)
                {
                    pJob.AddAttachment(filename, fileStorageType, "");
                }
                if (atd.AttachToParent)
                {
                    pParentJob.AddAttachment(filename, fileStorageType, "");
                }
            }

            return 1;
        }
Пример #2
0
        private int addAttachments(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback)
        {
            // Get a handle to the job
            IJTXJobManager pJobManager = m_ipDatabase.JobManager;
            IJTXJob2       pJob        = pJobManager.GetJob(jobID) as IJTXJob2;
            IJTXJob2       pParentJob  = pJobManager.GetJob(pJob.ParentJob) as IJTXJob2;

            // Prompt the user to choose whether the attachment should be embedded
            // into the database or merely stored as a URL, UNC path, etc.
            AttachmentTypeDialog atd = new AttachmentTypeDialog();

            // Check to see if this job has a parent.  If so, enable the "attach to parent" dialog.
            if (pParentJob == null)
            {
                atd.EnableSelectParent = false;
            }
            else
            {
                atd.EnableSelectParent = true;
            }

            atd.ShowDialog();
            if (atd.isNoneSelected())
            {
                return(0);
            }

            // Set the file storage type, according to what the user selected.
            bool embedAttachment = atd.isEmbeddedSelected();
            jtxFileStorageType fileStorageType;

            if (embedAttachment)
            {
                fileStorageType = jtxFileStorageType.jtxStoreInDB;
            }
            else
            {
                fileStorageType = jtxFileStorageType.jtxStoreAsLink;
            }

            // Prompt the user to select the file(s) to be attached.
            System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
            ofd.CheckFileExists = true;
            ofd.Multiselect     = false;
            ofd.ShowDialog();

            // Add each file that the user selected.
            foreach (string filename in ofd.FileNames)
            {
                if (atd.AttachToCurrent)
                {
                    pJob.AddAttachment(filename, fileStorageType, "");
                }
                if (atd.AttachToParent)
                {
                    pParentJob.AddAttachment(filename, fileStorageType, "");
                }
            }

            return(1);
        }