コード例 #1
0
        /// <summary>
        ///     Gets the page templates based on the filter and function delegate.
        /// </summary>
        /// <typeparam name="TKey">The type of the key.</typeparam>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="source">The source.</param>
        /// <param name="system">if set to <c>true</c> if the page template manager references the system tables.</param>
        /// <param name="filter">The filter.</param>
        /// <param name="func">The function delegate that returns the key/value pair of the page template information.</param>
        /// <returns>
        ///     Returns a <see cref="KeyValuePair{TKey, TValue}" /> representing the page templates
        /// </returns>
        private static IEnumerable <KeyValuePair <TKey, TValue> > GetPageTemplatesImpl <TKey, TValue>(IMMPageTemplateManager source, bool system, IQueryFilter filter, Func <IRow, KeyValuePair <TKey, TValue> > func)
        {
            var utils     = new MMTableUtilsClass();
            var tableName = utils.GetFullSystemTableName(source.Workspace, system ? SystemPageTemplates : UserPageTemplates);
            var table     = utils.OpenTable(tableName, (IFeatureWorkspace)source.Workspace);

            var cursor = table.Search(filter, true);

            var cr = new ComReleaser();

            cr.ManageLifetime(cursor);

            return(cursor.AsEnumerable().Select(func));
        }
コード例 #2
0
        /// <summary>
        ///     Gets the user names that are associated with the user page templates.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <returns>
        ///     Returns a <see cref="IEnumerable{String}" /> representing the unique user names.
        /// </returns>
        public static IEnumerable <string> GetUserNames(this IMMPageTemplateManager source)
        {
            var userNames = new List <string>();
            var utils     = new MMTableUtilsClass();

            string[] tables = { UserPageTemplates, SystemPageTemplates };
            foreach (var t in tables)
            {
                var tableName = utils.GetFullSystemTableName(source.Workspace, t);
                var reader    = source.Workspace.ExecuteReader(string.Format("SELECT DISTINCT(USERNAME) FROM {0}", tableName));
                userNames.AddRange(reader.AsEnumerable().Select(o => o.GetValue(0, string.Empty)).ToArray());
            }

            return(userNames);
        }
コード例 #3
0
        /// <summary>
        ///     Adds the version information to the GDBM_POST_QUEUE table.
        /// </summary>
        /// <param name="version">The version.</param>
        /// <param name="priority">The priority.</param>
        /// <param name="nodeID">The node ID.</param>
        /// <param name="nodeTypeName">Name of the node type.</param>
        /// <param name="nodeTypeID">The node type ID.</param>
        /// <param name="nonPxPostCode">The non px post code.</param>
        /// <remarks>
        ///     You must write a row into the GDBM_POST_QUEUE table and populate the NON_PX_POST_CODE field with some value (it
        ///     doesn't matter what).
        ///     You must also have a corresponding Post Type configured in the GDBM for the "Plain Version" node.
        ///     This Post Type must have the appropriate Post Code you used in the post queue table (this is how GDBM matches the
        ///     version in the posting queue
        ///     table to the correct posting behavior).
        /// </remarks>
        public static bool Enqueue(IVersion version, int priority, int nodeID, string nodeTypeName, int nodeTypeID, string nonPxPostCode)
        {
            if (!version.HasParent())
            {
                return(false);
            }

            IWorkspace    workspace  = (IWorkspace)version;
            IMMTableUtils tableUtils = new MMTableUtilsClass();
            var           table      = tableUtils.OpenSystemTable(workspace, "GDBM_POST_QUEUE");

            if (table == null)
            {
                return(false);
            }

            var indexes = table.Fields.ToDictionary();

            int    index        = version.VersionName.IndexOf(".", StringComparison.Ordinal);
            string versionOwner = version.VersionName.Substring(0, index);
            string versionName  = version.VersionName.Substring(index + 1, version.VersionName.Length - index - 1);

            IRow row = table.CreateRow();

            row.Value[indexes["CURRENTUSER"]]      = workspace.ConnectionProperties.GetProperty("USER", Environment.UserName);
            row.Value[indexes["VERSION_OWNER"]]    = versionOwner;
            row.Value[indexes["VERSION_NAME"]]     = versionName;
            row.Value[indexes["DESCRIPTION"]]      = version.Description;
            row.Value[indexes["SUBMIT_TIME"]]      = DateTime.Now;
            row.Value[indexes["PRIORITY"]]         = priority;
            row.Value[indexes["PX_NODE_ID"]]       = nodeID;
            row.Value[indexes["NODE_TYPE_NAME"]]   = nodeTypeName;
            row.Value[indexes["NODE_TYPE_ID"]]     = nodeTypeID;
            row.Value[indexes["NON_PX_POST_CODE"]] = nonPxPostCode;
            row.Store();

            return(true);
        }