//////////////////////////////////////////////////////////////////////// // METHOD: Execute public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { // Verify whether the current job has a version or not // Get the current job IJTXJobManager pJobManager = m_ipDatabase.JobManager; IJTXJob2 pJob = pJobManager.GetJob(jobID) as IJTXJob2; // Check for a data workspace IJTXDataWorkspaceName pJobDataWorkspace = pJob.ActiveDatabase; if (pJobDataWorkspace == null) { MessageBox.Show("No data workspace selected for job"); return(3); } // Check if version exists if (pJob.VersionExists()) { MessageBox.Show("Job version has been defined"); return(1); } else { MessageBox.Show("No version defined for job"); return(2); } }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { if (jobID <= 0) { throw (new ArgumentOutOfRangeException("JobID", jobID, "Job ID must be a positive value")); } string strNotifType = ""; string strSubscribers = ""; if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strNotifType)) { throw new ArgumentNullException(m_expectedArgs[0], string.Format("\nMissing the {0} parameter!", m_expectedArgs[0])); } bool bSubscribers = StepUtilities.GetArgument(ref argv, m_expectedArgs[1], true, out strSubscribers); IJTXJob ipJob = m_ipDatabase.JobManager.GetJob(jobID); if (bSubscribers) UpdateSubscriberList(strNotifType, strSubscribers, "add"); JTXUtilities.SendNotification(strNotifType, m_ipDatabase, ipJob, null); if (bSubscribers) UpdateSubscriberList(strNotifType, strSubscribers, "remove"); return 0; }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { if (jobID <= 0) { throw (new ArgumentOutOfRangeException("JobID", jobID, "Job ID must be a positive value")); } string strNotifType = ""; string strSubscribers = ""; if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strNotifType)) { throw new ArgumentNullException(m_expectedArgs[0], string.Format("\nMissing the {0} parameter!", m_expectedArgs[0])); } bool bSubscribers = StepUtilities.GetArgument(ref argv, m_expectedArgs[1], true, out strSubscribers); IJTXJob ipJob = m_ipDatabase.JobManager.GetJob(jobID); if (bSubscribers) { UpdateSubscriberList(strNotifType, strSubscribers, "add"); } JTXUtilities.SendNotification(strNotifType, m_ipDatabase, ipJob, null); if (bSubscribers) { UpdateSubscriberList(strNotifType, strSubscribers, "remove"); } return(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; }
//////////////////////////////////////////////////////////////////////// // METHOD: Execute public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { // Verify whether an AOI has been defined for the current job try { // Get the current job IJTXJobManager pJobManager = m_ipDatabase.JobManager; IJTXJob2 pJob = pJobManager.GetJob(jobID) as IJTXJob2; // Check if AOI exists if (pJob.AOIExtent != null) { // AOI exists return(1); } else { // AOI does not exist return(2); } } catch (Exception ex) { throw ex; } }
//////////////////////////////////////////////////////////////////////// // METHOD: Execute public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { // Verify whether the current job has a version or not // Get the current job IJTXJobManager pJobManager = m_ipDatabase.JobManager; IJTXJob2 pJob = pJobManager.GetJob(jobID) as IJTXJob2; // Check for a data workspace IJTXDataWorkspaceName pJobDataWorkspace = pJob.ActiveDatabase; if (pJobDataWorkspace == null) { MessageBox.Show("No data workspace selected for job"); return 3; } // Check if version exists if (pJob.VersionExists()) { MessageBox.Show("Job version has been defined"); return 1; } else { MessageBox.Show("No version defined for job"); return 2; } }
//////////////////////////////////////////////////////////////////////// // METHOD: Execute public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { // Verify whether an AOI has been defined for the current job try { // Get the current job IJTXJobManager pJobManager = m_ipDatabase.JobManager; IJTXJob2 pJob = pJobManager.GetJob(jobID) as IJTXJob2; // Check if AOI exists if (pJob.AOIExtent != null) { // AOI exists return 1; } else { // AOI does not exist return 2; } } catch (Exception ex) { throw ex; } }
//////////////////////////////////////////////////////////////////////// // METHOD: Execute public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { // Present form to user for choosing the data workspace // they want to work with for the current job. JTXSamples.DataWorkspaceSelectorDialog frmDataWSSelector = new JTXSamples.DataWorkspaceSelectorDialog(); frmDataWSSelector.StartPosition = FormStartPosition.CenterParent; // Populate the list of data workspaces configured for the JTX system IJTXDatabaseConnectionManager pDBConnManager = new JTXDatabaseConnectionManagerClass(); IJTXDatabaseConnection pDBConnection = pDBConnManager.GetConnection(m_ipDatabase.Alias); for (int a = 0; a < pDBConnection.DataWorkspaceCount; a++) { IJTXWorkspaceConfiguration pDataWorkspace = pDBConnection.get_DataWorkspace(a); frmDataWSSelector.DWName = pDataWorkspace.Name; } // Pass some other information to the form frmDataWSSelector.JTXDB = m_ipDatabase; IJTXJobManager pJobManager = m_ipDatabase.JobManager; IJTXJob2 pJob = pJobManager.GetJob(jobID) as IJTXJob2; frmDataWSSelector.theJob = pJob; if (frmDataWSSelector.ShowDialog() == DialogResult.OK) { return(1); } return(0); }
//////////////////////////////////////////////////////////////////////// // METHOD: Execute public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { // Present form to user for choosing the data workspace // they want to work with for the current job. JTXSamples.DataWorkspaceSelectorDialog frmDataWSSelector = new JTXSamples.DataWorkspaceSelectorDialog(); frmDataWSSelector.StartPosition = FormStartPosition.CenterParent; // Populate the list of data workspaces configured for the JTX system IJTXDatabaseConnectionManager pDBConnManager = new JTXDatabaseConnectionManagerClass(); IJTXDatabaseConnection pDBConnection = pDBConnManager.GetConnection(m_ipDatabase.Alias); for (int a = 0; a < pDBConnection.DataWorkspaceCount; a++) { IJTXWorkspaceConfiguration pDataWorkspace = pDBConnection.get_DataWorkspace(a); frmDataWSSelector.DWName = pDataWorkspace.Name; } // Pass some other information to the form frmDataWSSelector.JTXDB = m_ipDatabase; IJTXJobManager pJobManager = m_ipDatabase.JobManager; IJTXJob2 pJob = pJobManager.GetJob(jobID) as IJTXJob2; frmDataWSSelector.theJob = pJob; if (frmDataWSSelector.ShowDialog() == DialogResult.OK) { return 1; } return 0; }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { int retVal = 0; // This is a little convoluted, but was set up this way to allow this function // potentially being called from within a loop. retVal = addAttachments(jobID, stepID, ref argv, ref ipFeedback); return retVal; }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { int retVal = 0; // This is a little convoluted, but was set up this way to allow this function // potentially being called from within a loop. retVal = addAttachments(jobID, stepID, ref argv, ref ipFeedback); return(retVal); }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int JobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { System.Diagnostics.Debug.Assert(m_ipDatabase != null); IJTXJob pJob = m_ipDatabase.JobManager.GetJob(JobID); //Automatic status assignment IJTXConfiguration pConfig = m_ipDatabase.ConfigurationManager; IJTXConfigurationProperties pConfigProps = (IJTXConfigurationProperties)pConfig; IJTXWorkflowConfiguration pWFConfig = (IJTXWorkflowConfiguration)pJob; IJTXWorkflowExecution pWFExec = (IJTXWorkflowExecution)pJob; int[] iSteps = pWFExec.GetCurrentSteps(); if (iSteps.Length == 1) { if (pWFExec.IsLastStep(iSteps[0])) { pWFExec.MoveNext(iSteps[0], (int)nullReturnType.null_return); } } pJob.Close(); pJob.EndDate = System.DateTime.Now; if (pConfigProps.PropertyExists(Constants.JTX_PROPERTY_AUTO_STATUS_ASSIGN)) { string strAutoAssign = pConfigProps.GetProperty(Constants.JTX_PROPERTY_AUTO_STATUS_ASSIGN); if (strAutoAssign == "TRUE") { pJob.Status = m_ipDatabase.ConfigurationManager.GetStatus("Closed"); } } pJob.Store(); IJTXActivityType pActType = pConfig.GetActivityType("CloseJob"); if (pActType != null) { pJob.LogJobAction(pActType, null, ""); } JTXUtilities.SendNotification(Constants.NOTIF_JOB_CLOSED, m_ipDatabase, pJob, null); return(0); }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int JobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { System.Diagnostics.Debug.Assert(m_ipDatabase != null); IJTXJob pJob = m_ipDatabase.JobManager.GetJob(JobID); //Automatic status assignment IJTXConfiguration pConfig = m_ipDatabase.ConfigurationManager; IJTXConfigurationProperties pConfigProps = (IJTXConfigurationProperties)pConfig; IJTXWorkflowConfiguration pWFConfig = (IJTXWorkflowConfiguration)pJob; IJTXWorkflowExecution pWFExec = (IJTXWorkflowExecution)pJob; int[] iSteps = pWFExec.GetCurrentSteps(); if (iSteps.Length == 1) { if (pWFExec.IsLastStep(iSteps[0])) { pWFExec.MoveNext(iSteps[0], (int)nullReturnType.null_return); } } pJob.Close(); pJob.EndDate = System.DateTime.Now; if (pConfigProps.PropertyExists(Constants.JTX_PROPERTY_AUTO_STATUS_ASSIGN)) { string strAutoAssign = pConfigProps.GetProperty(Constants.JTX_PROPERTY_AUTO_STATUS_ASSIGN); if (strAutoAssign == "TRUE") { pJob.Status = m_ipDatabase.ConfigurationManager.GetStatus("Closed"); } } pJob.Store(); IJTXActivityType pActType = pConfig.GetActivityType("CloseJob"); if (pActType != null) { pJob.LogJobAction(pActType, null, ""); } JTXUtilities.SendNotification(Constants.NOTIF_JOB_CLOSED, m_ipDatabase, pJob, null); return 0; }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { IJTXJobManager ipJobManager = m_ipDatabase.JobManager; IJTXConfiguration ipConfig = m_ipDatabase.ConfigurationManager; IJTXJob ipJob = ipJobManager.GetJob(jobID); string strAssignType = ""; string strAssignTo = ""; if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strAssignType)) { throw new ArgumentNullException(m_expectedArgs[0], string.Format("\nMissing the {0} parameter!", m_expectedArgs[0])); } if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[1], true, out strAssignTo)) { throw new ArgumentNullException(m_expectedArgs[1], string.Format("\nMissing the {0} parameter!", m_expectedArgs[1])); } if (strAssignType == "group") { if (ipConfig.GetUserGroup(strAssignTo) == null) { throw new ArgumentOutOfRangeException(m_expectedArgs[1], string.Format("\nThe group {0} is not a group defined in the JTX database!", strAssignTo)); } ipJob.AssignedType = jtxAssignmentType.jtxAssignmentTypeGroup; } else { if (ipConfig.GetUser(strAssignTo) == null) { throw new ArgumentOutOfRangeException(m_expectedArgs[1], string.Format("\nThe user {0} is not a user defined in the JTX database!", strAssignTo)); } ipJob.AssignedType = jtxAssignmentType.jtxAssignmentTypeUser; } ipJob.AssignedTo = strAssignTo; ipJob.Store(); return(0); }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { if (jobID <= 0) { throw (new ArgumentOutOfRangeException("JobID", jobID, "Job ID must be a positive value")); } System.Diagnostics.Debug.Assert(m_ipDatabase != null); IJTXJob pJob = m_ipDatabase.JobManager.GetJob(jobID); string strValue = ""; if (StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strValue) || StepUtilities.GetArgument(ref argv, m_expectedArgs[1], true, out strValue)) { if (pJob.VersionExists()) { pJob.DeleteVersion(null); } } if (StepUtilities.GetArgument(ref argv, m_expectedArgs[2], true, out strValue) || StepUtilities.GetArgument(ref argv, m_expectedArgs[3], true, out strValue)) { if (pJob.MXDExists()) { pJob.DeleteMXD(); } } if (StepUtilities.GetArgument(ref argv, m_expectedArgs[4], true, out strValue) || StepUtilities.GetArgument(ref argv, m_expectedArgs[5], true, out strValue)) { IJTXAttachmentSet attachments = pJob.Attachments; for (int i = attachments.Count - 1; i >= 0; i--) { int id = (attachments.get_Item(i).ID); pJob.DeleteAttachment(id); } } return(0); }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { IJTXJobManager ipJobManager = m_ipDatabase.JobManager; IJTXConfiguration ipConfig = m_ipDatabase.ConfigurationManager; IJTXJob ipJob = ipJobManager.GetJob(jobID); string strAssignType = ""; string strAssignTo = ""; if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strAssignType)) { throw new ArgumentNullException(m_expectedArgs[0], string.Format("\nMissing the {0} parameter!", m_expectedArgs[0])); } if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[1], true, out strAssignTo)) { throw new ArgumentNullException(m_expectedArgs[1], string.Format("\nMissing the {0} parameter!", m_expectedArgs[1])); } if (strAssignType == "group") { if (ipConfig.GetUserGroup(strAssignTo) == null) { throw new ArgumentOutOfRangeException(m_expectedArgs[1], string.Format("\nThe group {0} is not a group defined in the JTX database!", strAssignTo)); } ipJob.AssignedType = jtxAssignmentType.jtxAssignmentTypeGroup; } else { if (ipConfig.GetUser(strAssignTo) == null) { throw new ArgumentOutOfRangeException(m_expectedArgs[1], string.Format("\nThe user {0} is not a user defined in the JTX database!", strAssignTo)); } ipJob.AssignedType = jtxAssignmentType.jtxAssignmentTypeUser; } ipJob.AssignedTo = strAssignTo; ipJob.Store(); return 0; }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int JobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { System.Diagnostics.Debug.Assert(m_ipDatabase != null); if (!ConfigurationCache.IsInitialized) { ConfigurationCache.InitializeCache(m_ipDatabase); } IJTXJobManager jobMan = m_ipDatabase.JobManager; IJTXJob2 m_ParentJob = (IJTXJob2)jobMan.GetJob(JobID); if (!GetInputParams(argv)) { return(0); } return(CreateJobs(m_ParentJob)); }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { // Get the arguments string sHoldTypeName = ""; string sHoldRemarks = ""; bool bHoldType = StepUtilities.GetArgument(ref argv, "HoldType", true, out sHoldTypeName); if (!bHoldType) { MessageBox.Show("Invalid arguments entered. No hold type entered."); return(-1); } bool bHoldRemarks = StepUtilities.GetArgument(ref argv, "HoldRemarks", true, out sHoldRemarks); // Get the hold type IJTXConfiguration pJTXConfig = m_ipDatabase.ConfigurationManager; IJTXHoldType pHoldType = pJTXConfig.GetHoldType(sHoldTypeName); if (pHoldType == null) { MessageBox.Show("Invalid hold type name entered: " + sHoldTypeName); return(-1); } // Get the job IJTXJobManager pJobManager = m_ipDatabase.JobManager; IJTXJob pJob = pJobManager.GetJob(jobID); IJTXJobHolds pJobHolds = pJob as IJTXJobHolds; // Add new job hold IJTXJobHold pNewHold = pJobHolds.CreateHold(pHoldType); if (bHoldRemarks) { pNewHold.HoldComments = sHoldRemarks; pNewHold.Store(); } return(0); }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { if (jobID <= 0) { throw (new ArgumentOutOfRangeException("JobID", jobID, "Job ID must be a positive value")); } System.Diagnostics.Debug.Assert(m_ipDatabase != null); IJTXJob pJob = m_ipDatabase.JobManager.GetJob(jobID); string strValue = ""; if (StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strValue) || StepUtilities.GetArgument(ref argv, m_expectedArgs[1], true, out strValue)) { if (pJob.VersionExists()) { pJob.DeleteVersion(null); } } if (StepUtilities.GetArgument(ref argv, m_expectedArgs[2], true, out strValue) || StepUtilities.GetArgument(ref argv, m_expectedArgs[3], true, out strValue)) { if (pJob.MXDExists()) { pJob.DeleteMXD(); } } if (StepUtilities.GetArgument(ref argv, m_expectedArgs[4], true, out strValue) || StepUtilities.GetArgument(ref argv, m_expectedArgs[5], true, out strValue)) { IJTXAttachmentSet attachments = pJob.Attachments; for (int i = attachments.Count - 1; i >= 0; i--) { int id = (attachments.get_Item(i).ID); pJob.DeleteAttachment(id); } } return 0; }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int JobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { if (JobID <= 0) { throw new ArgumentOutOfRangeException("JobID", JobID, "Job ID must be a positive value"); } try { string strTemp = ""; bool bAttach = false; if (StepUtilities.GetArgument(ref argv, m_expectedArgs[1], false, out strTemp)) { bAttach = true; } string strResolution; if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[2], false, out strResolution)) { strResolution = "1200"; } int iResolution = 1200; if (!Int32.TryParse(strResolution, out iResolution)) { iResolution = 1200; } string outputPath = ""; if (!bAttach) { SaveFileDialog pSaveFileDialog = new SaveFileDialog(); pSaveFileDialog.Filter = "PDF files (*.pdf)|*.pdf"; pSaveFileDialog.Title = "Choose output location..."; string strInitDir = ""; if (StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strInitDir)) { if (System.IO.Directory.Exists(strInitDir)) { pSaveFileDialog.InitialDirectory = strInitDir; } } if (pSaveFileDialog.ShowDialog() != DialogResult.OK) { return(-1); } outputPath = pSaveFileDialog.FileName; } string inputPath = JTXUtilities.SaveJobMXD(JobID); if (bAttach) { outputPath = SystemUtilities.GetTemporaryFileLocation(inputPath, "pdf"); } // delete output file if it already exists System.IO.FileInfo fi = new System.IO.FileInfo(outputPath); if (fi.Exists) { fi.Delete(); } MapDocumentClass map = new MapDocumentClass(); if (!map.get_IsMapDocument(inputPath)) { throw new ApplicationException("Invalid map or specified map not found."); } map.Open(inputPath, null); IActiveView pActiveView = (IActiveView)map.PageLayout; IExport pExport = new ExportPDFClass(); pExport.ExportFileName = outputPath; tagRECT deviceFrameRect; deviceFrameRect.left = 0; deviceFrameRect.right = 800; deviceFrameRect.top = 0; deviceFrameRect.bottom = 600; pActiveView.ScreenDisplay.DisplayTransformation.set_DeviceFrame(ref deviceFrameRect); int iOutputResolution = iResolution; int iScreenResolution = 96; pExport.Resolution = iOutputResolution; IOutputRasterSettings pOutputRasterSettings = (IOutputRasterSettings)pExport; pOutputRasterSettings.ResampleRatio = 1; tagRECT exportRect; exportRect.left = pActiveView.ExportFrame.left * (iOutputResolution / iScreenResolution); exportRect.top = pActiveView.ExportFrame.top * (iOutputResolution / iScreenResolution); exportRect.right = pActiveView.ExportFrame.right * (iOutputResolution / iScreenResolution); exportRect.bottom = pActiveView.ExportFrame.bottom * (iOutputResolution / iScreenResolution); IEnvelope pPixelBoundsEnv = new EnvelopeClass(); pPixelBoundsEnv.PutCoords(exportRect.left, exportRect.top, exportRect.right, exportRect.bottom); pExport.PixelBounds = pPixelBoundsEnv; int hdc = pExport.StartExporting(); pActiveView.Output(hdc, iOutputResolution, ref exportRect, null, null); pExport.FinishExporting(); pExport.Cleanup(); if (bAttach) { JTXUtilities.AddAttachmentToJob(JobID, outputPath, jtxFileStorageType.jtxStoreInDB); } return(0); } catch (Exception ex) { throw ex; } }
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); }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int JobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { if (JobID <= 0) { throw new ArgumentOutOfRangeException("JobID", JobID, "Job ID must be a positive value"); } try { string strTemp = ""; bool bAttach = false; if (StepUtilities.GetArgument(ref argv, m_expectedArgs[1], false, out strTemp)) { bAttach = true; } string strResolution; if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[2], false, out strResolution)) { strResolution = "1200"; } int iResolution = 1200; if (!Int32.TryParse(strResolution, out iResolution)) { iResolution = 1200; } string outputPath = ""; if (!bAttach) { SaveFileDialog pSaveFileDialog = new SaveFileDialog(); pSaveFileDialog.Filter = "PDF files (*.pdf)|*.pdf"; pSaveFileDialog.Title = "Choose output location..."; string strInitDir = ""; if (StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strInitDir)) { if (System.IO.Directory.Exists(strInitDir)) { pSaveFileDialog.InitialDirectory = strInitDir; } } if (pSaveFileDialog.ShowDialog() != DialogResult.OK) { return -1; } outputPath = pSaveFileDialog.FileName; } string inputPath = JTXUtilities.SaveJobMXD(JobID); if (bAttach) { outputPath = SystemUtilities.GetTemporaryFileLocation(inputPath, "pdf"); } // delete output file if it already exists System.IO.FileInfo fi = new System.IO.FileInfo(outputPath); if (fi.Exists) { fi.Delete(); } MapDocumentClass map = new MapDocumentClass(); if (!map.get_IsMapDocument(inputPath)) throw new ApplicationException("Invalid map or specified map not found."); map.Open(inputPath, null); IActiveView pActiveView = (IActiveView)map.PageLayout; IExport pExport = new ExportPDFClass(); pExport.ExportFileName = outputPath; tagRECT deviceFrameRect; deviceFrameRect.left = 0; deviceFrameRect.right = 800; deviceFrameRect.top = 0; deviceFrameRect.bottom = 600; pActiveView.ScreenDisplay.DisplayTransformation.set_DeviceFrame(ref deviceFrameRect); int iOutputResolution = iResolution; int iScreenResolution = 96; pExport.Resolution = iOutputResolution; IOutputRasterSettings pOutputRasterSettings = (IOutputRasterSettings)pExport; pOutputRasterSettings.ResampleRatio = 1; tagRECT exportRect; exportRect.left = pActiveView.ExportFrame.left * (iOutputResolution / iScreenResolution); exportRect.top = pActiveView.ExportFrame.top * (iOutputResolution / iScreenResolution); exportRect.right = pActiveView.ExportFrame.right * (iOutputResolution / iScreenResolution); exportRect.bottom = pActiveView.ExportFrame.bottom * (iOutputResolution / iScreenResolution); IEnvelope pPixelBoundsEnv = new EnvelopeClass(); pPixelBoundsEnv.PutCoords(exportRect.left, exportRect.top, exportRect.right, exportRect.bottom); pExport.PixelBounds = pPixelBoundsEnv; int hdc = pExport.StartExporting(); pActiveView.Output(hdc, iOutputResolution, ref exportRect, null, null); pExport.FinishExporting(); pExport.Cleanup(); if (bAttach) { JTXUtilities.AddAttachmentToJob(JobID, outputPath, jtxFileStorageType.jtxStoreInDB); } return 0; } catch (Exception ex) { throw ex; } }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { if (jobID <= 0) { throw (new ArgumentOutOfRangeException("JobID", jobID, "Job ID must be a positive value")); } System.Diagnostics.Debug.Assert(m_ipDatabase != null); IJTXJobManager pJobMan = m_ipDatabase.JobManager; IJTXJob2 pJob = pJobMan.GetJob(jobID) as IJTXJob2; // Make sure all the information exists to create this verion if (pJob.ActiveDatabase == null) { System.Windows.Forms.MessageBox.Show("Job does not have a data workspace"); return(-1); } if (pJob.ParentVersion == "") { System.Windows.Forms.MessageBox.Show("Job does not have a parent version"); return(-1); } string strVersionNameOverride; bool bVNOverride = StepUtilities.GetArgument(ref argv, m_expectedArgs[1], true, out strVersionNameOverride); if (pJob.VersionName == "" & !bVNOverride) { System.Windows.Forms.MessageBox.Show("The job does not have a version name"); return(-1); } IVersion pNewVersion; string strVersionName; if (bVNOverride) { strVersionName = strVersionNameOverride; } else { strVersionName = pJob.VersionName; } int index = strVersionName.IndexOf(".", 0); if (index >= 0) { strVersionName = strVersionName.Substring(index + 1); } esriVersionAccess verAccess = esriVersionAccess.esriVersionAccessPrivate; string strVerScope = ""; if (StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strVerScope)) { strVerScope = strVerScope.ToLower().Trim(); if (strVerScope == "public") { verAccess = esriVersionAccess.esriVersionAccessPublic; } else if (strVerScope == "protected") { verAccess = esriVersionAccess.esriVersionAccessProtected; } } pJob.VersionName = strVersionName; pNewVersion = pJob.CreateVersion(verAccess); if (pNewVersion == null) { throw (new System.SystemException("Unable to create version")); } IPropertySet pOverrides = new PropertySetClass(); pOverrides.SetProperty("[VERSION]", pNewVersion.VersionName); IJTXActivityType pActType = m_ipDatabase.ConfigurationManager.GetActivityType(Constants.ACTTYPE_CREATE_VERSION); if (pActType != null) { pJob.LogJobAction(pActType, pOverrides, ""); } JTXUtilities.SendNotification(Constants.NOTIF_VERSION_CREATED, m_ipDatabase, pJob, pOverrides); System.Runtime.InteropServices.Marshal.ReleaseComObject(pNewVersion); return(0); }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { // Get the arguments string sHoldTypeName = ""; string sHoldRemarks = ""; bool bHoldType = StepUtilities.GetArgument(ref argv, "HoldType", true, out sHoldTypeName); if (!bHoldType) { MessageBox.Show("Invalid arguments entered. No hold type entered."); return -1; } bool bHoldRemarks = StepUtilities.GetArgument(ref argv, "HoldRemarks", true, out sHoldRemarks); // Get the hold type IJTXConfiguration pJTXConfig = m_ipDatabase.ConfigurationManager; IJTXHoldType pHoldType = pJTXConfig.GetHoldType(sHoldTypeName); if (pHoldType == null) { MessageBox.Show("Invalid hold type name entered: " + sHoldTypeName); return -1; } // Get the job IJTXJobManager pJobManager = m_ipDatabase.JobManager; IJTXJob pJob = pJobManager.GetJob(jobID); IJTXJobHolds pJobHolds = pJob as IJTXJobHolds; // Add new job hold IJTXJobHold pNewHold = pJobHolds.CreateHold(pHoldType); if (bHoldRemarks) { pNewHold.HoldComments = sHoldRemarks; pNewHold.Store(); } return 0; }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { if (jobID <= 0) { throw (new ArgumentOutOfRangeException("JobID", jobID, "Job ID must be a positive value")); } System.Diagnostics.Debug.Assert(m_ipDatabase != null); IJTXJobManager pJobMan = m_ipDatabase.JobManager; IJTXJob2 pJob = pJobMan.GetJob(jobID) as IJTXJob2; // Make sure all the information exists to create this verion if (pJob.ActiveDatabase == null) { System.Windows.Forms.MessageBox.Show("Job does not have a data workspace"); return -1; } if (pJob.ParentVersion == "") { System.Windows.Forms.MessageBox.Show("Job does not have a parent version"); return -1; } string strVersionNameOverride; bool bVNOverride = StepUtilities.GetArgument(ref argv, m_expectedArgs[1], true, out strVersionNameOverride); if (pJob.VersionName == "" & !bVNOverride) { System.Windows.Forms.MessageBox.Show("The job does not have a version name"); return -1; } IVersion pNewVersion; string strVersionName; if (bVNOverride) strVersionName = strVersionNameOverride; else strVersionName = pJob.VersionName; int index = strVersionName.IndexOf(".", 0); if (index >= 0) { strVersionName = strVersionName.Substring(index + 1); } esriVersionAccess verAccess = esriVersionAccess.esriVersionAccessPrivate; string strVerScope = ""; if (StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strVerScope)) { strVerScope = strVerScope.ToLower().Trim(); if (strVerScope == "public") { verAccess = esriVersionAccess.esriVersionAccessPublic; } else if (strVerScope == "protected") { verAccess = esriVersionAccess.esriVersionAccessProtected; } } pJob.VersionName = strVersionName; pNewVersion = pJob.CreateVersion(verAccess); if (pNewVersion == null) { throw (new System.SystemException("Unable to create version")); } IPropertySet pOverrides = new PropertySetClass(); pOverrides.SetProperty("[VERSION]", pNewVersion.VersionName); IJTXActivityType pActType = m_ipDatabase.ConfigurationManager.GetActivityType(Constants.ACTTYPE_CREATE_VERSION); if (pActType != null) pJob.LogJobAction(pActType, pOverrides, ""); JTXUtilities.SendNotification(Constants.NOTIF_VERSION_CREATED, m_ipDatabase, pJob, pOverrides); System.Runtime.InteropServices.Marshal.ReleaseComObject(pNewVersion); return 0; }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { #if (!SERVER) StatusForm sfd = null; #endif bool success = true; // Reset the message logging this.ClearCachedLogMessages(); try { Log("ExecuteGPTool.Execute beginning.."); // Define variables string strToolboxPath = ""; string strTool = ""; string strToolboxRoot = ""; string strToolboxName = ""; // Get the toolbox name (check for errors) if (!StepUtilities.GetArgument(ref argv, "toolboxpath", true, out strToolboxPath) || strToolboxPath.Equals(String.Empty)) { success = false; Log("Error getting 'toolboxpath' argument"); #if (!SERVER) MessageBox.Show("Missing toolbox argument."); #endif } // Get the tool name (check for errors) else if (!StepUtilities.GetArgument(ref argv, "tool", true, out strTool) || strTool.Equals(String.Empty)) { success = false; Log("Error getting 'tool' argument"); #if (!SERVER) MessageBox.Show("Missing tool argument."); #endif } else { #if (!SERVER) // Display status dialog sfd = new StatusForm(); sfd.ToolName = strTool; sfd.Show(); sfd.Refresh(); #endif // Get directory of toolbox strToolboxRoot = Path.GetDirectoryName(strToolboxPath); // Get toolbox name without .tbx extension strToolboxName = Path.GetFileNameWithoutExtension(strToolboxPath); // Open toolbox and tool IWorkspaceFactory pToolboxWorkspaceFactory = new ToolboxWorkspaceFactoryClass(); IToolboxWorkspace pToolboxWorkspace = pToolboxWorkspaceFactory.OpenFromFile(strToolboxRoot, 0) as IToolboxWorkspace; IGPToolbox pGPToolbox = pToolboxWorkspace.OpenToolbox(strToolboxName); IGPTool pGPTool = pGPToolbox.OpenTool(strTool); Log("ExecuteGPTool.Execute successfully opened Tool " + strTool + " in Toolbox " + strToolboxPath + ".."); // Generate the arrays for parameters IVariantArray parameters = new VarArrayClass(); // For Execute method ESRI.ArcGIS.esriSystem.IArray pParameterArray = pGPTool.ParameterInfo; // For Validate and InvokeModal methods // Get parameter "pairs"; "GetDoubleArguments" supports the GP-style, // two-colon argument strings, like "/param:tool_param_name:tool_param_value" string[] argNames; string[] argValues; if (StepUtilities.GetDoubleArguments(ref argv, "param", true, out argNames, out argValues)) { // Stash away the variables that were passed in Dictionary<string, string> argTable = new Dictionary<string, string>(); for (int i = 0; i < argNames.Length; i++) { string uppercaseName = argNames[i].ToUpper(); argTable[uppercaseName] = argValues[i]; } // The GP tool's parameter list may include parameters that weren't specified in the // JTX step arguments. So iterate through the tool's parameters, setting the values // from the input where you can. Where no value was passed in, just skip the // parameter and go with the default. for (int i = 0; i < pParameterArray.Count; i++) { IGPParameter pGPParam = (IGPParameter)pParameterArray.get_Element(i); IGPParameterEdit pGPParamEdit = (IGPParameterEdit)pGPParam; string uppercaseName = pGPParam.Name.ToUpper(); // Override the default value, if something was passed in if (argTable.ContainsKey(uppercaseName)) { IGPDataType pGPType = pGPParam.DataType; string strValue = argTable[uppercaseName]; pGPParamEdit.Value = pGPType.CreateValue(strValue); Log("ExecuteGPTool.Execute Tool Parameter = " + uppercaseName + ", Value = " + strValue + ".."); } // Always stash away the current parameter value, since we need the complete list // for "Execute" below. parameters.Add(pGPParam.Value); } } Log("ExecuteGPTool.Execute successfully setup parameter values.."); // Initialize the geoprocessor IGeoProcessor pGP = new GeoProcessorClass(); // Create callback object for GP messages JTXGPCallback pCallback = new JTXGPCallback(); // Set up the geoprocessor pGP.AddToolbox(strToolboxPath); pGP.RegisterGeoProcessorEvents(pCallback); Log("ExecuteGPTool.Execute created and registered GeoProcessor.."); // Create the messages object and a bool to pass to InvokeModal method IGPMessages pGPMessages = pGPTool.Validate(pParameterArray, true, null); IGPMessages pInvokeMessages = new GPMessagesClass(); string strMessage = ""; // Check for error messages if (pGPMessages.MaxSeverity == esriGPMessageSeverity.esriGPMessageSeverityError) { #if (!SERVER) // Only want to invoke a modal dialog if we're running on a workstation // Set a reference to IGPCommandHelper2 interface IGPToolCommandHelper2 pToolHelper = new GPToolCommandHelperClass() as IGPToolCommandHelper2; pToolHelper.SetTool(pGPTool); bool pOK = true; // Open tool GUI pToolHelper.InvokeModal(0, pParameterArray, out pOK, out pInvokeMessages); if (pOK == true) { bool bFailureMessages; strMessage = ConvertGPMessagesToString(pInvokeMessages, out bFailureMessages); success = !bFailureMessages; } else { success = false; } #else Log("ExecuteGPTool.Execute Tool Validate failed.."); // If we're running on a server, then just indicate a failure. (Someone will // have to use the JTX application to fix the step arguments, if they can be // fixed.) success = false; #endif } else // If there are no error messages, execute the tool { Log("ExecuteGPTool.Execute successfully validated parameter values, About to Execute.."); IGPMessages ipMessages = new GPMessagesClass(); try { pGPTool.Execute(pParameterArray, null, new GPEnvironmentManagerClass(), ipMessages); Log("ExecuteGPTool.Execute completed call to pGPTool.Execute()"); } catch (System.Runtime.InteropServices.COMException ex) { success = false; Log("ExecuteGPTool.Execute Tool Execute failed, Message = " + ex.Message + ", DataCode = " + ex.ErrorCode + ", Data = " + ex.StackTrace); } // Get Messages bool bFailureMessages = false; strMessage += this.ConvertGPMessagesToString(ipMessages, out bFailureMessages); Log("ExecuteGPTool.Execute got messages from tool"); Log("*** GP MESSAGES ***" + System.Environment.NewLine + strMessage + System.Environment.NewLine); Log("*** END GP MESSAGES ***"); // If tool failed during execution, indicate a failure if (pGP.MaxSeverity == (int)esriGPMessageSeverity.esriGPMessageSeverityError) { success = false; Log("ExecuteGPTool.Execute Found Error messages from the tool.."); } } // Call AttachMsg try { IJTXJobManager ipJobManager = m_ipDatabase.JobManager; IJTXJob ipJob = ipJobManager.GetJob(jobID); AttachMsg(ipJob, strTool, this.GetCachedLogMessages()); this.ClearCachedLogMessages(); } catch (Exception ex) { string strEx = ex.Message; Log("Caught exception: " + ex.Message); } pGP.UnRegisterGeoProcessorEvents(pCallback); } } catch (Exception ex2) { success = false; Log("Caught exception: " + ex2.Message); #if (!SERVER) string msg = ""; if (ex2.InnerException == null) { msg = "Inner Exception is null"; } else { msg = "Inner Exception is not null"; } MessageBox.Show("Stack Trace: " + ex2.StackTrace + Environment.NewLine + "Message: " + ex2.Message + Environment.NewLine + "Source: " + ex2.Source + Environment.NewLine + msg); #endif } // Clean up #if (!SERVER) if (sfd != null) { sfd.Close(); } #endif // Indicate success or failure if (success == true) { return 1; } else { return 0; } }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int JobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { System.Diagnostics.Debug.Assert(m_ipDatabase != null); string strValue = ""; int jobTypeID = 0; if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strValue)) { throw new ArgumentNullException(m_expectedArgs[0], string.Format("\nMissing the {0} parameter!", m_expectedArgs[0])); } if (!Int32.TryParse(strValue, out jobTypeID)) { throw new ArgumentNullException(m_expectedArgs[0], "Argument must be an integrer!"); } IJTXJobType pJobType = m_ipDatabase.ConfigurationManager.GetJobTypeByID(jobTypeID); IJTXJobManager pJobMan = m_ipDatabase.JobManager; IJTXJob pNewJob = pJobMan.CreateJob(pJobType, 0, true); IJTXActivityType pActType = m_ipDatabase.ConfigurationManager.GetActivityType(Constants.ACTTYPE_CREATE_JOB); if (pActType != null) { pNewJob.LogJobAction(pActType, null, ""); } JTXUtilities.SendNotification(Constants.NOTIF_JOB_CREATED, m_ipDatabase, pNewJob, null); // Assign a status to the job if the Auto Assign Job Status setting is enabled IJTXConfigurationProperties pConfigProps = (IJTXConfigurationProperties)m_ipDatabase.ConfigurationManager; if (pConfigProps.PropertyExists(Constants.JTX_PROPERTY_AUTO_STATUS_ASSIGN)) { string strAutoAssign = pConfigProps.GetProperty(Constants.JTX_PROPERTY_AUTO_STATUS_ASSIGN); if (strAutoAssign == "TRUE") { pNewJob.Status = m_ipDatabase.ConfigurationManager.GetStatus("Created"); } } // Associate the current job with the new job with a parent-child relationship pNewJob.ParentJob = JobID; // Assign the job as specified in the arguments string strAssignTo = ""; if (StepUtilities.GetArgument(ref argv, m_expectedArgs[1], true, out strAssignTo)) { pNewJob.AssignedType = jtxAssignmentType.jtxAssignmentTypeGroup; pNewJob.AssignedTo = strAssignTo; } else if (StepUtilities.GetArgument(ref argv, m_expectedArgs[2], true, out strAssignTo)) { pNewJob.AssignedType = jtxAssignmentType.jtxAssignmentTypeUser; pNewJob.AssignedTo = strAssignTo; } pNewJob.Store(); // Copy the workflow to the new job WorkflowUtilities.CopyWorkflowXML(m_ipDatabase, pNewJob); // Create 1-1 extended property entries IJTXAuxProperties pAuxProps = (IJTXAuxProperties)pNewJob; System.Array contNames = pAuxProps.ContainerNames; IEnumerator contNamesEnum = contNames.GetEnumerator(); contNamesEnum.Reset(); while (contNamesEnum.MoveNext()) { string strContainerName = (string)contNamesEnum.Current; IJTXAuxRecordContainer pAuxContainer = pAuxProps.GetRecordContainer(strContainerName); if (pAuxContainer.RelationshipType == esriRelCardinality.esriRelCardinalityOneToOne) { pAuxContainer.CreateRecord(); } } m_ipDatabase.LogMessage(5, 1000, System.Diagnostics.Process.GetCurrentProcess().MainWindowTitle); // Update Application message about the new job if (System.Diagnostics.Process.GetCurrentProcess().MainWindowTitle.Length > 0) //if its not running in server { MessageBox.Show("Created " + pJobType.Name + " Job " + pNewJob.ID, "Job Created", MessageBoxButtons.OK, MessageBoxIcon.Information); } return 0; }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int JobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { System.Diagnostics.Debug.Assert(m_ipDatabase != null); if (!ConfigurationCache.IsInitialized) ConfigurationCache.InitializeCache(m_ipDatabase); IJTXJobManager jobMan = m_ipDatabase.JobManager; IJTXJob2 m_ParentJob = (IJTXJob2)jobMan.GetJob(JobID); if (!GetInputParams(argv)) return 0; return CreateJobs(m_ParentJob); }
/// <summary> /// Called when a step of this type is executed in the workflow. /// </summary> /// <param name="JobID">ID of the job being executed</param> /// <param name="StepID">ID of the step being executed</param> /// <param name="argv">Array of arguments passed into the step's execution</param> /// <param name="ipFeedback">Feedback object to return status messages and files</param> /// <returns>Return code of execution for workflow path traversal</returns> public int Execute(int JobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback) { System.Diagnostics.Debug.Assert(m_ipDatabase != null); string strValue = ""; int jobTypeID = 0; if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strValue)) { throw new ArgumentNullException(m_expectedArgs[0], string.Format("\nMissing the {0} parameter!", m_expectedArgs[0])); } if (!Int32.TryParse(strValue, out jobTypeID)) { throw new ArgumentNullException(m_expectedArgs[0], "Argument must be an integrer!"); } IJTXJobType pJobType = m_ipDatabase.ConfigurationManager.GetJobTypeByID(jobTypeID); IJTXJobManager pJobMan = m_ipDatabase.JobManager; IJTXJob pNewJob = pJobMan.CreateJob(pJobType, 0, true); IJTXActivityType pActType = m_ipDatabase.ConfigurationManager.GetActivityType(Constants.ACTTYPE_CREATE_JOB); if (pActType != null) { pNewJob.LogJobAction(pActType, null, ""); } JTXUtilities.SendNotification(Constants.NOTIF_JOB_CREATED, m_ipDatabase, pNewJob, null); // Assign a status to the job if the Auto Assign Job Status setting is enabled IJTXConfigurationProperties pConfigProps = (IJTXConfigurationProperties)m_ipDatabase.ConfigurationManager; if (pConfigProps.PropertyExists(Constants.JTX_PROPERTY_AUTO_STATUS_ASSIGN)) { string strAutoAssign = pConfigProps.GetProperty(Constants.JTX_PROPERTY_AUTO_STATUS_ASSIGN); if (strAutoAssign == "TRUE") { pNewJob.Status = m_ipDatabase.ConfigurationManager.GetStatus("Created"); } } // Associate the current job with the new job with a parent-child relationship pNewJob.ParentJob = JobID; // Assign the job as specified in the arguments string strAssignTo = ""; if (StepUtilities.GetArgument(ref argv, m_expectedArgs[1], true, out strAssignTo)) { pNewJob.AssignedType = jtxAssignmentType.jtxAssignmentTypeGroup; pNewJob.AssignedTo = strAssignTo; } else if (StepUtilities.GetArgument(ref argv, m_expectedArgs[2], true, out strAssignTo)) { pNewJob.AssignedType = jtxAssignmentType.jtxAssignmentTypeUser; pNewJob.AssignedTo = strAssignTo; } pNewJob.Store(); // Copy the workflow to the new job WorkflowUtilities.CopyWorkflowXML(m_ipDatabase, pNewJob); // Create 1-1 extended property entries IJTXAuxProperties pAuxProps = (IJTXAuxProperties)pNewJob; System.Array contNames = pAuxProps.ContainerNames; IEnumerator contNamesEnum = contNames.GetEnumerator(); contNamesEnum.Reset(); while (contNamesEnum.MoveNext()) { string strContainerName = (string)contNamesEnum.Current; IJTXAuxRecordContainer pAuxContainer = pAuxProps.GetRecordContainer(strContainerName); if (pAuxContainer.RelationshipType == esriRelCardinality.esriRelCardinalityOneToOne) { pAuxContainer.CreateRecord(); } } m_ipDatabase.LogMessage(5, 1000, System.Diagnostics.Process.GetCurrentProcess().MainWindowTitle); // Update Application message about the new job if (System.Diagnostics.Process.GetCurrentProcess().MainWindowTitle.Length > 0) //if its not running in server { MessageBox.Show("Created " + pJobType.Name + " Job " + pNewJob.ID, "Job Created", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(0); }