private void cmdSave_Click(object sender, EventArgs e)
        {
            if (m_pJob.Name != txtJobName.Text)
            {
                m_pJob.Name = txtJobName.Text;
                m_pJob.Store();

                // Notify the extension that the job has been changed
                m_pExt.UpdateJob(this.ToString());
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
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)
        {
            IJTXJobManager    ipJobManager = m_ipDatabase.JobManager;
            IJTXConfiguration ipConfig     = m_ipDatabase.ConfigurationManager;
            IJTXJob           ipJob        = ipJobManager.GetJob(jobID);

            string strAssignType = "";
            string strAssignTo   = "";

            if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strAssignType))
            {
                throw new ArgumentNullException(m_expectedArgs[0], string.Format("\nMissing the {0} parameter!", m_expectedArgs[0]));
            }

            if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[1], true, out strAssignTo))
            {
                throw new ArgumentNullException(m_expectedArgs[1], string.Format("\nMissing the {0} parameter!", m_expectedArgs[1]));
            }

            if (strAssignType == "group")
            {
                if (ipConfig.GetUserGroup(strAssignTo) == null)
                {
                    throw new ArgumentOutOfRangeException(m_expectedArgs[1], string.Format("\nThe group {0} is not a group defined in the JTX database!", strAssignTo));
                }

                ipJob.AssignedType = jtxAssignmentType.jtxAssignmentTypeGroup;
            }
            else
            {
                if (ipConfig.GetUser(strAssignTo) == null)
                {
                    throw new ArgumentOutOfRangeException(m_expectedArgs[1], string.Format("\nThe user {0} is not a user defined in the JTX database!", strAssignTo));
                }

                ipJob.AssignedType = jtxAssignmentType.jtxAssignmentTypeUser;
            }

            ipJob.AssignedTo = strAssignTo;
            ipJob.Store();

            return(0);
        }
        ////////////////////////////////////////////////////////////////////////
        // 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;
        }
        ////////////////////////////////////////////////////////////////////////
        // 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);
        }
Exemplo n.º 6
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);
        }