public DialogResult ShowDialog(object[] argsIn, out object[] argsOut) { // Populate the combo boxes with the appropriate information IJTXConfiguration2 ipJTXConfig = m_ipDatabase.ConfigurationManager as IJTXConfiguration2; PopulateJobTypes(ipJTXConfig); PopulateUsers(ipJTXConfig); PopulateGroups(ipJTXConfig); // Populate the dialog with the existing argument information string strTemp = ""; if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[0], true, out strTemp)) { // Then the job type has been entered int iJobTypeID = Convert.ToInt32(strTemp); IJTXJobType ipJobType = ipJTXConfig.GetJobTypeByID(iJobTypeID); cmbJobTypes.SelectedItem = ipJobType.Name; } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[1], true, out strTemp)) { // Then a user group has been selected for the new job assignment chkGroup.Checked = true; chkUser.Checked = false; cmbUsers.Enabled = false; cmbGroups.SelectedItem = strTemp; } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[2], true, out strTemp)) { // Then a user has been selected for the new job assignment chkGroup.Checked = false; chkUser.Checked = true; cmbGroups.Enabled = false; cmbUsers.SelectedItem = strTemp; } // Show the dialog this.ShowDialog(); argsOut = m_Arguments.ToArray(); return(DialogResult); }
private void btnOK_Click(object sender, EventArgs e) { if (cmbJobTypes.SelectedItem.ToString() != "") { IJTXConfiguration ipJTXConfig = m_ipDatabase.ConfigurationManager; IJTXJobType ipJobType = ipJTXConfig.GetJobType(cmbJobTypes.SelectedItem.ToString()); m_Arguments.Add(StepUtilities.CreateSingleArgument(m_expectedArgs[0], ipJobType.ID.ToString())); } if (chkGroup.Checked) { m_Arguments.Add(StepUtilities.CreateSingleArgument(m_expectedArgs[1], cmbGroups.SelectedItem.ToString())); } else if (chkUser.Checked) { m_Arguments.Add(StepUtilities.CreateSingleArgument(m_expectedArgs[2], cmbUsers.SelectedItem.ToString())); } DialogResult = DialogResult.OK; this.Hide(); }
/// <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); }
//////////////////////////////////////////////////////////////////////// // METHOD: CreateJobs private int CreateJobs(IJTXJob2 pParentJob) { try { System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; bool bAutoCommit = ConfigurationCache.AutoCommitWorkflow; m_ipDatabase.LogMessage(5, 2000, "CreateJobs"); // Set the job template values IJTXJobManager2 pJobMan = m_ipDatabase.JobManager as IJTXJobManager2; IJTXJobDescription pJobDescription = new JTXJobDescriptionClass(); pJobDescription.Description = pParentJob.Description; pJobDescription.Priority = pParentJob.Priority; pJobDescription.ParentJobId = pParentJob.ID; pJobDescription.StartDate = pParentJob.StartDate; if (m_dueDate != Constants.NullDate) { pJobDescription.DueDate = m_dueDate; } else if (m_duration > 0) { pJobDescription.DueDate = System.DateTime.Now.AddDays(m_duration); } else { pJobDescription.DueDate = pParentJob.DueDate; } if (!String.IsNullOrEmpty(m_paramAssignToGroup)) { pJobDescription.AssignedType = jtxAssignmentType.jtxAssignmentTypeGroup; pJobDescription.AssignedTo = m_paramAssignToGroup; } else if (!String.IsNullOrEmpty(m_paramAssignToUser)) { pJobDescription.AssignedType = jtxAssignmentType.jtxAssignmentTypeUser; pJobDescription.AssignedTo = m_paramAssignToUser; } else { pJobDescription.AssignedType = jtxAssignmentType.jtxAssignmentTypeUnassigned; } pJobDescription.OwnedBy = ConfigurationCache.GetCurrentJTXUser().UserName; if (pParentJob.ActiveDatabase != null) { pJobDescription.DataWorkspaceID = pParentJob.ActiveDatabase.DatabaseID; } // Set the parent version. This only makes sense if the active workspace has been set if (pJobDescription.DataWorkspaceID != null) { if (m_paramCreateVersionType == CreateVersionType.None || m_paramCreateVersionType == CreateVersionType.UseParentJobsVersion) { pJobDescription.ParentVersionName = pParentJob.VersionName; // This has to be set here because setting the job workspace resets the value } else if (m_paramCreateVersionType == CreateVersionType.UseJobTypeDefaultSettings) { IJTXJobType pJobType = m_ipDatabase.ConfigurationManager.GetJobType(m_paramJobTypeName); if (pJobType != null) { pJobDescription.ParentVersionName = pJobType.DefaultParentVersionName; } } else if (m_paramCreateVersionType == CreateVersionType.UseParentJobsDefaultVersion) { pJobDescription.ParentVersionName = pParentJob.JobType.DefaultParentVersionName; } else if (m_paramCreateVersionType == CreateVersionType.UseParentJobsParentVersion) { pJobDescription.ParentVersionName = pParentJob.ParentVersion; } } // Determine the number of jobs to make m_ipDatabase.LogMessage(5, 2000, "Before Determining Number of Jobs"); IArray aoiList = null; int numJobs; if (!GetNumberOfJobs(pParentJob, ref aoiList, out numJobs)) { return(1); } if (numJobs <= 0) { MessageBox.Show(Properties.Resources.ZeroJobCount); return(0); } pJobDescription.AOIList = aoiList; m_ipDatabase.LogMessage(5, 2000, "After Determining Number of Jobs"); // Create the job objects m_ipDatabase.LogMessage(5, 2000, "Before CreateJobs"); pJobDescription.JobTypeName = m_paramJobTypeName; IJTXExecuteInfo pExecInfo; m_ipJobs = pJobMan.CreateJobsFromDescription(pJobDescription, numJobs, true, out pExecInfo); m_ipDatabase.LogMessage(5, 2000, "After CreateJobs"); // Populate the job data for (int i = 0; i < m_ipJobs.Count; ++i) { IJTXJob pJob = m_ipJobs.get_Item(i); SetJobProperties(pJobMan, pJob, pParentJob); } return(1); } catch (COMException ex) { if (ex.ErrorCode == (int)fdoError.FDO_E_SE_INVALID_COLUMN_VALUE) { MessageBox.Show(Properties.Resources.InvalidColumn, Properties.Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show(ex.Message); } return(0); } catch (Exception ex2) { MessageBox.Show(ex2.Message, Properties.Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(0); } finally { System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; } }
public DialogResult ShowDialog(object[] argsIn, out object[] argsOut) { // Populate the combo boxes with the appropriate information IJTXConfiguration2 ipJTXConfig = m_ipDatabase.ConfigurationManager as IJTXConfiguration2; PopulateJobTypes(ipJTXConfig); PopulateUsers(ipJTXConfig); PopulateGroups(ipJTXConfig); PopulateStatusTypes(ipJTXConfig); // Populate the dialog with the existing argument information string strTemp = ""; if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[0], true, out strTemp)) { // Then the job type has been entered IJTXJobType ipJobType = ipJTXConfig.GetJobType(strTemp); if (ipJobType != null) { cmbJobTypes.SelectedItem = ipJobType.Name; } } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[1], true, out strTemp)) { // Then a user group has been selected for the new job assignment chkGroup.Checked = true; chkUser.Checked = false; cmbUsers.Enabled = false; int idx = cmbGroups.Items.IndexOf(strTemp); cmbGroups.SelectedIndex = idx; if (idx < 0) { cmbGroups.Text = strTemp; } } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[2], true, out strTemp)) { // Then a user has been selected for the new job assignment chkGroup.Checked = false; chkUser.Checked = true; cmbGroups.Enabled = false; int idx = cmbUsers.Items.IndexOf(strTemp); cmbUsers.SelectedIndex = idx; if (idx < 0) { cmbUsers.Text = strTemp; } } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[3], true, out strTemp)) { // Then a dependency is being created ... chkDependThisStep.Checked = true; lblStatus.Enabled = true; cboDependentStatus.Enabled = true; } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[4], true, out strTemp)) { // Then a dependency is being created ... chkDependNextStep.Checked = true; lblStatus.Enabled = true; cboDependentStatus.Enabled = true; } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[5], true, out strTemp)) { // Then a user has been selected for the new job assignment lblStatus.Enabled = true; lblStatus.Enabled = true; cboDependentStatus.SelectedItem = strTemp; } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[6], true, out strTemp)) { // Then the parent job's AOI will be used by the child chkAssignParentAOIToChild.Checked = true; } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[7], true, out strTemp)) { // Then the number of child jobs and their AOIs will be determined by a // spatial overlap with an input feature class chkAssignParentAOIToChild.Enabled = false; radioButton_generateNumberJobs.Checked = true; txtAOIFeatureClassName.Enabled = true; txtAOIFeatureClassName.Text = strTemp; } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[8], true, out strTemp)) { // Then the user will specify the number of child jobs txtAOIFeatureClassName.Enabled = false; radioButton_DefineNumberOfJobs.Checked = true; lstNumberOfJobs.Value = Convert.ToDecimal(strTemp); chkAssignParentAOIToChild.Enabled = true; } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[9], true, out strTemp)) { // Then a version will be created for the child job(s) from the Default version chkCreateVersion.Checked = true; cboCreateVersionSetting.Enabled = true; int idx = cboCreateVersionSetting.Items.IndexOf(strTemp); cboCreateVersionSetting.SelectedIndex = idx; if (idx < 0) { cboCreateVersionSetting.Text = strTemp; } } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[10], true, out strTemp)) { // Then a version will be created for the child job(s) from the Default version chkAssignVersion.Checked = true; cboAssignVersionSetting.Enabled = true; int idx = cboAssignVersionSetting.Items.IndexOf(strTemp); cboAssignVersionSetting.SelectedIndex = idx; if (idx < 0) { cboAssignVersionSetting.Text = strTemp; } } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[11], true, out strTemp)) { // Then the user will not be able to modify any parameters that were pre-configured chkSetExtProps.Checked = true; txtSetExtProps.Text = strTemp; } if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[12], true, out strTemp)) { chkDueDate.Checked = true; dtpDueDate.Value = JTXUtilities.GenerateDateString(m_ipDatabase.JTXWorkspace, strTemp, false); } else if (StepUtilities.GetArgument(ref argsIn, m_expectedArgs[13], true, out strTemp)) { txtDuration.Text = strTemp; } // Show the dialog this.ShowDialog(); argsOut = m_Arguments.ToArray(); return(DialogResult); }