Exemplo n.º 1
0
        /// <summary>
        ///     Gets the page template blobs for the specific type and users (optional)
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="pageTemplateType">Type of the page template.</param>
        /// <param name="userName">The page template user names.</param>
        /// <returns>
        ///     Returns a <see cref="IEnumerable{KeyValuePair{TKey, TValue}}" /> representing the page template and blob
        ///     value.
        /// </returns>
        public static IEnumerable <KeyValuePair <IMMPageTemplateName, IMemoryBlobStream> > GetBlobPageTemplates(this IMMPageTemplateManager source, mmPageTemplateType pageTemplateType, params string[] userName)
        {
            var filter = new QueryFilterClass();

            filter.WhereClause = "TEMPLATE IS NOT NULL";

            if (userName != null && userName.Any())
            {
                filter.WhereClause = string.Format("{0} AND USERNAME IN ('{1}')", filter.WhereClause, string.Join("','", userName));
            }

            ((IQueryFilterDefinition2)filter).PostfixClause = "ORDER BY USERNAME";

            var system = pageTemplateType == mmPageTemplateType.mmPTTSystem;

            return(GetPageTemplatesImpl(source, system, filter, row =>
            {
                var name = (string)row.Value[row.Fields.FindField("NAME")];
                var blob = (IMemoryBlobStream)row.Value[row.Fields.FindField("TEMPLATE")];

                var i = new MMPageTemplateNameClass();
                i.Initialize(row.OID, name, pageTemplateType);

                return new KeyValuePair <IMMPageTemplateName, IMemoryBlobStream>(i, blob);
            }));
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Gets the unopened page templates with the specified type and name.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="pageTemplateType">Type of the page template.</param>
        /// <param name="userName">Name of the page template.</param>
        /// <returns>
        ///     Returns a <see cref="IEnumerable{IMMPageTemplate}" /> representing the page templates.
        /// </returns>
        public static IEnumerable <IMMPageTemplate> GetUnopenedPageTemplates(this IMMPageTemplateManager source, mmPageTemplateType pageTemplateType, string userName)
        {
            var items = source.GetPageTemplateNames(pageTemplateType);

            foreach (var i in items.AsEnumerable())
            {
                yield return(source.GetUnopenedPageTemplate(i));
            }
        }