Exemple #1
0
        ////////////////////////////////////////////////////////////////////////
        // METHOD: Execute
        public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback)
        {
            // Verify whether the current job has a version or not

            // Get the current job
            IJTXJobManager pJobManager = m_ipDatabase.JobManager;
            IJTXJob2       pJob        = pJobManager.GetJob(jobID) as IJTXJob2;

            // Check for a data workspace
            IJTXDataWorkspaceName pJobDataWorkspace = pJob.ActiveDatabase;

            if (pJobDataWorkspace == null)
            {
                MessageBox.Show("No data workspace selected for job");
                return(3);
            }

            // Check if version exists
            if (pJob.VersionExists())
            {
                MessageBox.Show("Job version has been defined");
                return(1);
            }
            else
            {
                MessageBox.Show("No version defined for job");
                return(2);
            }
        }
Exemple #2
0
        /// <summary>
        /// Builds a domain of the data workspace names in the system
        /// </summary>
        /// <param name="wmxDb">A reference to the active Workflow Manager database</param>
        /// <param name="extraValues">An array of string values to be added to the list</param>
        /// <returns>A coded value domain as an IGPDomain</returns>
        public static IGPDomain BuildWorkspaceDomain(IJTXDatabase3 wmxDb, string[] extraValues)
        {
            IGPCodedValueDomain         domain       = new GPCodedValueDomainClass();
            SortedList <string, string> sortedValues = new SortedList <string, string>();

            // Workflow Manager intentionally caches the data workspaces in the system.  To ensure
            // that we have the most current list of data workspaces, invalidate this cache
            // before attempting to retrieve the list from the system.
            wmxDb.InvalidateDataWorkspaceNames();

            // Sort the types first
            IJTXDataWorkspaceNameSet allValues = wmxDb.GetDataWorkspaceNames(null);

            for (int i = 0; i < allValues.Count; i++)
            {
                IJTXDataWorkspaceName ws = allValues.get_Item(i);
                sortedValues.Add(ws.Name, null);
            }

            // Add the extra values, if any
            if (extraValues != null)
            {
                foreach (string s in extraValues)
                {
                    sortedValues.Add(s, null);
                }
            }

            // Add the sorted types to the domain

            foreach (string value in sortedValues.Keys)
            {
                IGPValue tempGpVal = new GPStringClass();
                tempGpVal.SetAsText(value);
                domain.AddCode(tempGpVal, value);
            }

            return(domain as IGPDomain);
        }
        /// <summary>
        /// Given the human-readable name of a data workspace, this function returns the
        /// IJTXDataWorkspaceName object associated with this workspace connection.
        /// </summary>
        /// <param name="wmxDb">A reference to the active Workflow Manager database</param>
        /// <param name="wsName">
        /// The name of the data workspace to be looked up
        /// </param>
        /// <returns>
        /// The workspace name object for the specified data workspace; returns null if
        /// no matching workspace can be found.
        /// </returns>
        public static IJTXDataWorkspaceName LookupWorkspaceNameObj(IJTXDatabase3 wmxDb, string wsName)
        {
            IJTXDataWorkspaceName wsNameObj = null;

            // Workflow Manager intentionally caches the data workspaces in the system.  To ensure
            // that we have the most current list of data workspaces, invalidate this cache
            // before attempting to retrieve the list from the system.
            wmxDb.InvalidateDataWorkspaceNames();

            // Get the workspace list from the database
            IJTXDataWorkspaceNameSet allValues = wmxDb.GetDataWorkspaceNames(null);

            // Search for the workspace ID with the matching name
            for (int i = 0; i < allValues.Count; i++)
            {
                if (allValues.get_Item(i).Name.Equals(wsName))
                {
                    wsNameObj = allValues.get_Item(i);
                    break;
                }
            }

            return(wsNameObj);
        }
        /// <summary>
        /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="trackCancel"></param>
        /// <param name="envMgr"></param>
        /// <param name="msgs"></param>
        public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs)
        {
            // Do some common error-checking
            base.Execute(paramValues, trackCancel, envMgr, msgs);

            // Set the default properties for the specified job type
            try
            {
                IJTXConfiguration3     configMgr  = this.WmxDatabase.ConfigurationManager as IJTXConfiguration3;
                IJTXConfigurationEdit2 configEdit = this.WmxDatabase.ConfigurationManager as IJTXConfigurationEdit2;
                IJTXJobTypeEdit3       jobType    = configEdit.GetJobType(m_jobTypeName) as IJTXJobTypeEdit3;

                // Set the default data workspace for the selected job type
                if (m_dataWorkspaceName.Equals(C_OPT_NONE))
                {
                    jobType.DefaultDataWorkspace = null;
                    msgs.AddMessage("Clearing default data workspace for job type '" + m_jobTypeName + "'");
                }
                else
                {
                    // Translate the workspace name to a DB name object
                    IJTXDataWorkspaceName dwName =
                        Common.WmauHelperFunctions.LookupWorkspaceNameObj(this.WmxDatabase, m_dataWorkspaceName);

                    msgs.AddMessage("Default data workspace for job type '" + m_jobTypeName + "' is now '" + dwName.Name + "'");
                    jobType.DefaultDataWorkspace = dwName;
                }

                // Set the default parent version for the selected job type
                if (m_parentVersion.Equals(C_OPT_NONE))
                {
                    msgs.AddMessage("Clearing default parent version for job type '" + m_jobTypeName + "'");
                    jobType.DefaultParentVersionName_2 = string.Empty;
                }
                else
                {
                    msgs.AddMessage("Default parent version for job type '" + m_jobTypeName + "' is now '" + m_parentVersion + "'");
                    jobType.DefaultParentVersionName_2 = m_parentVersion;
                }

                // Save the changes to the job type
                jobType.Store();

                // Set the output parameter
                WmauParameterMap  paramMap     = new WmauParameterMap(paramValues);
                IGPParameterEdit3 outParamEdit = paramMap.GetParamEdit(C_PARAM_OUT_DATA_WORKSPACE);
                IGPString         outValue     = new GPStringClass();
                outValue.Value     = m_jobTypeName;
                outParamEdit.Value = outValue as IGPValue;

                msgs.AddMessage(Properties.Resources.MSG_DONE);
            }
            catch (WmauException wmEx)
            {
                try
                {
                    msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            catch (Exception ex)
            {
                WmauError error = new WmauError(WmauErrorCodes.C_UNSPECIFIED_ERROR);
                msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message);
            }
        }
        /// <summary>
        /// Required by IGPFunction2 interface; this function is called when the GP tool is ready to be executed.
        /// </summary>
        /// <param name="paramValues"></param>
        /// <param name="trackCancel"></param>
        /// <param name="envMgr"></param>
        /// <param name="msgs"></param>
        public override void Execute(IArray paramValues, ITrackCancel trackCancel, IGPEnvironmentManager envMgr, IGPMessages msgs)
        {
            // Do some common error-checking
            base.Execute(paramValues, trackCancel, envMgr, msgs);

            try
            {
                // Ensure that the current user has admin access to the current Workflow Manager DB
                if (!CurrentUserIsWmxAdministrator())
                {
                    throw new WmauException(WmauErrorCodes.C_USER_NOT_ADMIN_ERROR);
                }

                // Retrieve the parameter in which the data workspace names will be stored
                WmauParameterMap  paramMap  = new WmauParameterMap(paramValues);
                IGPParameter3     param     = paramMap.GetParam(C_PARAM_WORKSPACE_LIST);
                IGPParameterEdit3 paramEdit = paramMap.GetParamEdit(C_PARAM_WORKSPACE_LIST);

                // Set up the multi-value objects
                IGPMultiValue mvValue = new GPMultiValueClass();
                mvValue.MemberDataType = param.DataType;

                // Workflow Manager intentionally caches the data workspaces in the system.  To ensure
                // that we have the most current list of data workspaces, invalidate this cache
                // before attempting to retrieve the list from the system.
                this.WmxDatabase.InvalidateDataWorkspaceNames();

                // Get the list of names
                SortedList <string, string> sortedValues = new SortedList <string, string>();
                IJTXDataWorkspaceNameSet    allValues    = this.WmxDatabase.GetDataWorkspaceNames(null);
                for (int i = 0; i < allValues.Count; i++)
                {
                    IJTXDataWorkspaceName ws = allValues.get_Item(i);
                    sortedValues.Add(ws.Name, null);
                }

                // Add the names to the output parameter
                foreach (string name in sortedValues.Keys)
                {
                    IGPString strVal = new GPStringClass();
                    strVal.Value = name;
                    mvValue.AddValue(strVal as IGPValue);
                    msgs.AddMessage("Workspace: " + name);
                }
                paramEdit.Value = (IGPValue)mvValue;

                msgs.AddMessage(Properties.Resources.MSG_DONE);
            }
            catch (WmauException wmEx)
            {
                try
                {
                    msgs.AddError(wmEx.ErrorCodeAsInt, wmEx.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            catch (Exception ex)
            {
                try
                {
                    WmauError error = new WmauError(WmauErrorCodes.C_UNSPECIFIED_ERROR);
                    msgs.AddError(error.ErrorCodeAsInt, error.Message + "; " + ex.Message);
                }
                catch
                {
                    // Catch anything else that possibly happens
                }
            }
            finally
            {
                // Release any COM objects here!
            }
        }