Beispiel #1
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)
        {
            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);
        }