Exemple #1
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
        /// unique ID string used by Workflow Manager to identify 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 whose ID is to be retrieved
        /// </param>
        /// <returns>
        /// The ID string for the specified data workspace; returns the empty string if
        /// no matching workspace can be found.
        /// </returns>
        public static string LookupWorkspaceId(IJTXDatabase3 wmxDb, string wsName)
        {
            string id = string.Empty;

            // 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))
                {
                    id = allValues.get_Item(i).DatabaseID;
                    break;
                }
            }

            return(id);
        }