//////////////////////////////////////////////////////////////////////// // METHOD: CreateDependencyOnParentJob private void CreateDependencyOnParentJob(IJTXJobDependencies dependencyManager, IJTXJob2 pParentJob, int childJobID) { IJTXJobDependency dependency = dependencyManager.CreateDependency(pParentJob.ID); dependency.DepJobID = childJobID; dependency.DepOnType = jtxDependencyType.jtxDependencyTypeStatus; IJTXStatus statusType = null; if (!m_paramHasStatusType) { statusType = m_ipDatabase.ConfigurationManager.GetStatus("Closed"); } else { statusType = m_ipDatabase.ConfigurationManager.GetStatus(m_paramStatusType); } dependency.DepOnValue = statusType.ID; dependency.HeldOnType = jtxDependencyType.jtxDependencyTypeStep; IJTXWorkflowExecution parentWorkflow = pParentJob as IJTXWorkflowExecution; int[] currentSteps = parentWorkflow.GetCurrentSteps(); int dependentStep = currentSteps[0]; if (m_paramDependNextStep) { IJTXWorkflowConfiguration workflowConf = pParentJob as IJTXWorkflowConfiguration; try { dependentStep = workflowConf.GetAllNextSteps(currentSteps[0])[0]; } catch (IndexOutOfRangeException) { MessageBox.Show(Properties.Resources.NoNextStep, Properties.Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } dependency.HeldOnValue = dependentStep; dependency.Store(); IPropertySet props = new PropertySetClass(); props.SetProperty("[DEPENDENCY]", dependency.ID); JobUtilities.LogJobAction(m_ipDatabase, pParentJob, Constants.ACTTYPE_ADD_DEPENDENCY, "", props); }
//////////////////////////////////////////////////////////////////////// // METHOD: CreateDependencyOnParentJob private void CreateDependencyOnParentJob(IJTXJobDependencies dependencyManager, IJTXJob2 pParentJob, int childJobID) { IJTXJobDependency dependency = dependencyManager.CreateDependency(pParentJob.ID); dependency.DepJobID = childJobID; dependency.DepOnType = jtxDependencyType.jtxDependencyTypeStatus; IJTXStatus statusType = null; if (!m_paramHasStatusType) statusType = m_ipDatabase.ConfigurationManager.GetStatus("Closed"); else statusType = m_ipDatabase.ConfigurationManager.GetStatus(m_paramStatusType); dependency.DepOnValue = statusType.ID; dependency.HeldOnType = jtxDependencyType.jtxDependencyTypeStep; IJTXWorkflowExecution parentWorkflow = pParentJob as IJTXWorkflowExecution; int[] currentSteps = parentWorkflow.GetCurrentSteps(); int dependentStep = currentSteps[0]; if (m_paramDependNextStep) { IJTXWorkflowConfiguration workflowConf = pParentJob as IJTXWorkflowConfiguration; try { dependentStep = workflowConf.GetAllNextSteps(currentSteps[0])[0]; } catch (IndexOutOfRangeException) { MessageBox.Show(Properties.Resources.NoNextStep, Properties.Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } dependency.HeldOnValue = dependentStep; dependency.Store(); IPropertySet props = new PropertySetClass(); props.SetProperty("[DEPENDENCY]", dependency.ID); JobUtilities.LogJobAction(m_ipDatabase, pParentJob, Constants.ACTTYPE_ADD_DEPENDENCY, "", props); }
//////////////////////////////////////////////////////////////////////// // METHOD: SetJobProperties private IJTXJob SetJobProperties(IJTXJobManager pJobMan, IJTXJob pJob, IJTXJob2 pParentJob) { m_ipDatabase.LogMessage(5, 2000, "Before LogJobAction (CreateJobs)"); IJTXActivityType pActType = m_ipDatabase.ConfigurationManager.GetActivityType(Constants.ACTTYPE_COMMENT); pParentJob.LogJobAction(pActType, null, String.Format(Properties.Resources.ActTypeMessage, pJob.ID.ToString())); if (!string.IsNullOrEmpty(m_paramExtendedProperties)) { m_ipDatabase.LogMessage(5, 2000, "Before Create Extended Properties"); ExtendedPropertyIdentifier childExProps = new ExtendedPropertyIdentifier(); try { ParseExtendedPropertiesParam(out childExProps); } catch (Exception ex) { string msg = string.Format( "Unable to read parent job's extended property. Job ID: {0} ERROR: {1}", pParentJob.ID, ex.Message); m_ipDatabase.LogMessage(3, 1000, msg); } try { CreateExtendedPropertyRecord(pJob, childExProps); } catch (Exception ex) { string msg = string.Format( "Unable to set child job's extended property. Child Job ID: {0} ERROR: {1}", pJob.ID, ex.Message); m_ipDatabase.LogMessage(3, 1000, msg); } m_ipDatabase.LogMessage(5, 2000, "After Create Extended Properties"); } // Create dependencies on parent job if configured m_ipDatabase.LogMessage(5, 2000, "Before Setting Dependencies"); if (m_paramDependNextStep || m_paramDependThisStep) { IJTXJobDependencies ipDependencyManager = pJobMan as IJTXJobDependencies; CreateDependencyOnParentJob(ipDependencyManager, pParentJob, pJob.ID); } m_ipDatabase.LogMessage(5, 2000, "After Setting Dependencies"); // Create or assign version if configured m_ipDatabase.LogMessage(5, 2000, "Before Versioning"); if (m_paramCreateVersionType != CreateVersionType.None) { if (pParentJob.ActiveDatabase != null && !String.IsNullOrEmpty(pJob.ParentVersion) && (m_paramCreateVersionType != CreateVersionType.UseParentJobsVersion || pParentJob.VersionExists())) { CreateChildVersion(ref pJob); } else { MessageBox.Show("Could not create version. Please ensure parent data workspace and versions are set correctly", Properties.Resources.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else if (m_paramAssignVersionType != AssignVersionType.None) { if (pParentJob.ActiveDatabase != null) { AssignChildVersion(pParentJob, ref pJob); } else { MessageBox.Show("Could not assign version. Please ensure parent data workspace is set correctly", Properties.Resources.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } m_ipDatabase.LogMessage(5, 2000, "After Versioning"); // Store the job and save the changes m_ipDatabase.LogMessage(5, 2000, "Before Storing Job"); pJob.Store(); m_ipDatabase.LogMessage(5, 2000, "After Storing Job"); return(pJob); }