Пример #1
0
        /// <summary>
        /// Deletes page zone elements that are associated with list of master page zone element identifiers.
        /// </summary>
        /// <param name="tenantId">Website tenant identifier.</param>
        /// <param name="masterPageId">Master page identifier.</param>
        /// <param name="masterPageZoneId">Master page zone identifier.</param>
        /// <param name="masterPageZoneElementIds">List of master page zone element identifiers, identifying page zone elements to delete.</param>
        /// <param name="unitOfWork">Unit of work.</param>
        public void DeletePageZoneElementsByMasterPageZoneElementIds(long tenantId, long masterPageId, long masterPageZoneId, List <long> masterPageZoneElementIds, IUnitOfWork unitOfWork = null)
        {
            IDatabaseManager dbm = _databaseManagerFactory.GetDatabaseManager(unitOfWork);

            try
            {
                MasterPageZoneElementCollection masterPageZoneElementCollection = new MasterPageZoneElementCollection();
                foreach (long masterPageZoneElementId in masterPageZoneElementIds)
                {
                    masterPageZoneElementCollection.Add(new MasterPageZoneElement {
                        MasterPageZoneElementId = masterPageZoneElementId
                    });
                }
                dbm.SetSQL(_sqlManager.GetSql("Sql.DeletePageZoneElementsByMasterPageZoneElementIds.sql"));
                dbm.AddParameter("@TenantId", FieldType.BigInt, tenantId);
                dbm.AddParameter("@MasterPageId", FieldType.BigInt, masterPageId);
                dbm.AddParameter("@MasterPageZoneId", FieldType.BigInt, masterPageZoneId);
                dbm.AddTypedParameter("@MasterPageZoneElements", FieldType.Structured, masterPageZoneElementCollection.Count == 0 ? null : masterPageZoneElementCollection, "cms.MasterPageZoneElementTableType");
                dbm.ExecuteNonQuery();
            }
            finally
            {
                if (unitOfWork == null)
                {
                    dbm.Dispose();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Retrieves distinct list of element identifiers that are associated with the supplied list of master page zone element identifiers.
        /// </summary>
        /// <param name="tenantId">Website tenant identifier.</param>
        /// <param name="masterPageId">Master page identifier.</param>
        /// <param name="masterPageZoneId">Master page zone identifier.</param>
        /// <param name="masterPageZoneElementIds">List of master page zone element identifiers, whose associated elements are returned.</param>
        /// <param name="unitOfWork">Unit of work.</param>
        /// <returns>Distinct list of element identifiers associated with supplied list of master page zone element identifiers.</returns>
        public List <long> ListPageElementsByMasterPageZoneElementIds(long tenantId, long masterPageId, long masterPageZoneId, List <long> masterPageZoneElementIds, IUnitOfWork unitOfWork = null)
        {
            IDatabaseManager dbm = _databaseManagerFactory.GetDatabaseManager(unitOfWork);

            try
            {
                MasterPageZoneElementCollection masterPageZoneElementCollection = new MasterPageZoneElementCollection();
                foreach (long masterPageZoneElementId in masterPageZoneElementIds)
                {
                    masterPageZoneElementCollection.Add(new MasterPageZoneElement {
                        MasterPageZoneElementId = masterPageZoneElementId
                    });
                }
                dbm.SetSQL(_sqlManager.GetSql("Sql.ListPageElementsByMasterPageZoneElementIds.sql"));
                dbm.AddParameter("@TenantId", FieldType.BigInt, tenantId);
                dbm.AddParameter("@MasterPageId", FieldType.BigInt, masterPageId);
                dbm.AddParameter("@MasterPageZoneId", FieldType.BigInt, masterPageZoneId);
                dbm.AddTypedParameter("@MasterPageZoneElements", FieldType.Structured, masterPageZoneElementCollection.Count == 0 ? null : masterPageZoneElementCollection, "cms.MasterPageZoneElementTableType");
                dbm.ExecuteReader();
                List <long> elementIds = new List <long>();
                while (dbm.Read())
                {
                    elementIds.Add((long)dbm.DataReaderValue("ElementId"));
                }
                return(elementIds);
            }
            finally
            {
                if (unitOfWork == null)
                {
                    dbm.Dispose();
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Add master page SQL parameters.
        /// </summary>
        /// <param name="masterPage">Master page.</param>
        /// <param name="dbm">The database manager where parameters are added.</param>
        private void AddMasterPageParameters(MasterPage masterPage, IDatabaseManager dbm)
        {
            MasterPageZoneCollection            masterPageZoneCollection            = new MasterPageZoneCollection();
            MasterPageZoneElementTypeCollection masterPageZoneElementTypeCollection = new MasterPageZoneElementTypeCollection();
            MasterPageZoneElementCollection     masterPageZoneElementCollection     = new MasterPageZoneElementCollection();

            PopulateMasterPageCollections(masterPage, masterPageZoneCollection, masterPageZoneElementTypeCollection, masterPageZoneElementCollection);
            AddMasterPageDetailsParameters(masterPage, dbm);
            dbm.AddTypedParameter("@MasterPageZones", FieldType.Structured, masterPageZoneCollection.Count == 0 ? null : masterPageZoneCollection, "cms.MasterPageZoneTableType");
            dbm.AddTypedParameter("@MasterPageZoneElementTypes", FieldType.Structured, masterPageZoneElementTypeCollection.Count == 0 ? null : masterPageZoneElementTypeCollection, "cms.MasterPageZoneElementTypeTableType");
            dbm.AddTypedParameter("@MasterPageZoneElements", FieldType.Structured, masterPageZoneElementCollection.Count == 0 ? null : masterPageZoneElementCollection, "cms.MasterPageZoneElementTableType");
        }
Пример #4
0
        /// <summary>
        /// Adds master page zone SQL parameters.
        /// </summary>
        /// <param name="masterPageZone">Master page zone.</param>
        /// <param name="dbm">The database manager where parameters are added.</param>
        private void AddMasterPageZoneParameters(MasterPageZone masterPageZone, IDatabaseManager dbm)
        {
            MasterPageZoneElementTypeCollection masterPageZoneElementTypeCollection = new MasterPageZoneElementTypeCollection();
            MasterPageZoneElementCollection     masterPageZoneElementCollection     = new MasterPageZoneElementCollection();

            PopulateMasterPageZoneCollections(masterPageZone, masterPageZoneElementTypeCollection, masterPageZoneElementCollection);
            dbm.AddParameter("@Name", FieldType.NVarChar, MasterPageLengths.ZoneNameMaxLength, masterPageZone.Name);
            dbm.AddParameter("@SortOrder", FieldType.Int, masterPageZone.SortOrder);
            dbm.AddParameter("@AdminType", FieldType.Int, (int)masterPageZone.AdminType);
            dbm.AddParameter("@ContentType", FieldType.Int, (int)masterPageZone.ContentType);
            dbm.AddParameter("@BeginRender", FieldType.NVarChar, -1, masterPageZone.BeginRender ?? (object)DBNull.Value);
            dbm.AddParameter("@EndRender", FieldType.NVarChar, -1, masterPageZone.EndRender ?? (object)DBNull.Value);
            dbm.AddTypedParameter("@MasterPageZoneElementTypes", FieldType.Structured, masterPageZoneElementTypeCollection.Count == 0 ? null : masterPageZoneElementTypeCollection, "cms.MasterPageZoneElementTypeTableType");
            dbm.AddTypedParameter("@MasterPageZoneElements", FieldType.Structured, masterPageZoneElementCollection.Count == 0 ? null : masterPageZoneElementCollection, "cms.MasterPageZoneElementTableType");
        }
Пример #5
0
 /// <summary>
 /// Get zone, zone element and zone element type collections for table types.
 /// </summary>
 /// <param name="masterPage">Master page.</param>
 /// <param name="masterPageZoneCollection">Master page zone collection.</param>
 /// <param name="masterPageZoneElementTypeCollection">Master page zone element type collection.</param>
 /// <param name="masterPageZoneElementCollection">Master page zone element collection.</param>
 private void PopulateMasterPageCollections(MasterPage masterPage, MasterPageZoneCollection masterPageZoneCollection, MasterPageZoneElementTypeCollection masterPageZoneElementTypeCollection, MasterPageZoneElementCollection masterPageZoneElementCollection)
 {
     foreach (MasterPageZone masterPageZone in masterPage.MasterPageZones)
     {
         masterPageZoneCollection.Add(masterPageZone);
         PopulateMasterPageZoneCollections(masterPageZone, masterPageZoneElementTypeCollection, masterPageZoneElementCollection);
     }
 }
Пример #6
0
 /// <summary>
 /// Populates zone element and zone element type collections for table types.
 /// </summary>
 /// <param name="masterPageZone">Master page zone.</param>
 /// <param name="masterPageZoneElementTypeCollection">Master page zone element type collection.</param>
 /// <param name="masterPageZoneElementCollection">Master page zone element collection.</param>
 private void PopulateMasterPageZoneCollections(MasterPageZone masterPageZone, MasterPageZoneElementTypeCollection masterPageZoneElementTypeCollection, MasterPageZoneElementCollection masterPageZoneElementCollection)
 {
     foreach (MasterPageZoneElementType masterPageZoneElementType in masterPageZone.MasterPageZoneElementTypes)
     {
         masterPageZoneElementType.MasterPageZoneSortOrder = masterPageZone.SortOrder;
         masterPageZoneElementTypeCollection.Add(masterPageZoneElementType);
     }
     foreach (MasterPageZoneElement masterPageZoneElement in masterPageZone.MasterPageZoneElements)
     {
         masterPageZoneElement.MasterPageZoneSortOrder = masterPageZone.SortOrder;
         masterPageZoneElementCollection.Add(masterPageZoneElement);
     }
 }