Exemplo n.º 1
0
        /// <summary>
        /// Gets template page zone element type from database manager data reader.
        /// </summary>
        /// <param name="dbm">Database manager.</param>
        /// <returns>A populated template page zone element type object.</returns>
        private TemplatePageZoneElementType GetTemplatePageZoneElementTypeFromDatabaseManager(IDatabaseManager dbm)
        {
            TemplatePageZoneElementType templatePageZoneElementType = new TemplatePageZoneElementType
            {
                TenantId           = (long)dbm.DataReaderValue("TenantId"),
                TemplatePageId     = (long)dbm.DataReaderValue("TemplatePageId"),
                TemplatePageZoneId = (long)dbm.DataReaderValue("TemplatePageZoneId"),
                ElementTypeId      = (Guid)dbm.DataReaderValue("ElementTypeId")
            };

            return(templatePageZoneElementType);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets template from database manager result.
        /// </summary>
        /// <param name="dbm">Database manager.</param>
        /// <param name="loadAll">Set true to load template template pages, zones, configurable element types and elements. Otherwise only main template details loaded.</param>
        /// <returns>Template (or null if template not found).</returns>
        private Template GetTemplate(IDatabaseManager dbm, bool loadAll)
        {
            // Get template
            Template template = GetTemplateFromDatabaseManager(dbm);

            // If we are not reading entire template we can return result now
            if (!loadAll)
            {
                return(template);
            }

            // Get template pages and then construct template page hierarchy
            dbm.Read();
            Dictionary <long, TemplatePage> templatePagesById = new Dictionary <long, TemplatePage>();

            while (dbm.Read())
            {
                TemplatePage templatePage = GetTemplatePageFromDatabaseManager(dbm);
                templatePagesById.Add(templatePage.TemplatePageId, templatePage);
            }
            template.Page = GetTemplatePageHierarchy(templatePagesById);

            // Get template page zones
            Dictionary <long, TemplatePageZone> templatePageZonesById = new Dictionary <long, TemplatePageZone>();

            while (dbm.Read())
            {
                TemplatePageZone templatePageZone = GetTemplatePageZoneFromDatabaseManager(dbm);
                templatePagesById[templatePageZone.TemplatePageId].TemplatePageZones.Add(templatePageZone);
                templatePageZonesById.Add(templatePageZone.TemplatePageZoneId, templatePageZone);
            }

            // Get the element types that can exist in a template page zone when admin type is configurable
            while (dbm.Read())
            {
                TemplatePageZoneElementType templatePageZoneElementType = GetTemplatePageZoneElementTypeFromDatabaseManager(dbm);
                templatePageZonesById[templatePageZoneElementType.TemplatePageZoneId].TemplatePageZoneElementTypes.Add(templatePageZoneElementType);
            }

            // Get template page zone elements
            while (dbm.Read())
            {
                TemplatePageZoneElement templatePageZoneElement = GetTemplatePageZoneElementFromDatabaseManager(dbm);
                templatePageZonesById[templatePageZoneElement.TemplatePageZoneId].TemplatePageZoneElements.Add(templatePageZoneElement);
            }

            // Return the result
            return(template);
        }