Beispiel #1
0
        /// <summary>
        /// Method to validate the configured arguments for the step type.  The
        /// logic of this method depends on the implementation of the custom step
        /// but typically checks for proper argument names and syntax.
        /// </summary>
        /// <param name="argv">Array of arguments configured for the step type</param>
        /// <returns>Returns 'true' if arguments are valid, 'false' if otherwise</returns>
        public bool ValidateArguments(ref object[] argv)
        {
            IJTXConfiguration ipConfig = m_ipDatabase.ConfigurationManager;

            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));
                }
            }
            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));
                }
            }
            return(true);
        }
Beispiel #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)
        {
            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);
        }