////////////////////////////////////////////////////////////////////////
        // 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);
        }
Exemple #2
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);
        }