//////////////////////////////////////////////////////////////////////// // METHOD: CreateExtendedPropertyRecord private bool CreateExtendedPropertyRecord(IJTXJob job, ExtendedPropertyIdentifier child) { IJTXAuxProperties pAuxProps = (IJTXAuxProperties)job; IJTXAuxRecordContainer pAuxContainer = pAuxProps.GetRecordContainer(child.LongTableName); if (!string.IsNullOrEmpty(m_paramExtendedProperties) && pAuxContainer == null) { string msg = string.Format( "Unable to set extended property for child job {0}. Unable to find child job's extended property table: {1}", job.ID, child.LongTableName); m_ipDatabase.LogMessage(3, 2000, msg); } System.Array contNames = pAuxProps.ContainerNames; System.Collections.IEnumerator contNamesEnum = contNames.GetEnumerator(); contNamesEnum.Reset(); while (contNamesEnum.MoveNext()) { try { string strContainerName = (string)contNamesEnum.Current; if (!string.IsNullOrEmpty(m_paramExtendedProperties) && (strContainerName.ToUpper()).Equals(child.LongTableName.ToUpper())) { pAuxContainer = pAuxProps.GetRecordContainer(strContainerName); if (pAuxContainer.RelationshipType != esriRelCardinality.esriRelCardinalityOneToOne) { throw new Exception("The table relationship is not one-to-one."); } IJTXAuxRecord childRecord = pAuxContainer.GetRecords().get_Item(0);//pAuxContainer.CreateRecord(); SetExtendedPropertyValues(childRecord, child); JobUtilities.LogJobAction(m_ipDatabase, job, Constants.ACTTYPE_UPDATE_EXT_PROPS, "", null); } } catch (Exception ex) { string msg = string.Format( "Unable to create extended property {0} in record for jobid {1}. ERROR: {2}", child.FieldName, job.ID, ex.Message); m_ipDatabase.LogMessage(3, 2000, msg); } } return(true); }
/// <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); }