예제 #1
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);
     }
 }
예제 #2
0
        /// <summary>
        /// Adds, removes and re-orders master page zones.
        /// </summary>
        /// <param name="tenantId">Tenant identifier.</param>
        /// <param name="masterPageId">Identifier of master page whose zones are added, removed or re-ordered.</param>
        /// <param name="masterPageZones">Updated list of master page zones.</param>
        /// <param name="unitOfWork">Unit of work.</param>
        public void UpdateZones(long tenantId, long masterPageId, List <MasterPageZone> masterPageZones, IUnitOfWork unitOfWork = null)
        {
            IUnitOfWork localUnitOfWork = unitOfWork == null?_unitOfWorkFactory.CreateUnitOfWork() : null;

            try
            {
                MasterPageZoneCollection masterPageZoneCollection = new MasterPageZoneCollection();
                foreach (MasterPageZone zone in masterPageZones)
                {
                    masterPageZoneCollection.Add(zone);
                }
                IDatabaseManager dbm = _databaseManagerFactory.GetDatabaseManager(unitOfWork ?? localUnitOfWork);
                dbm.SetSQL(_sqlManager.GetSql("Sql.UpdateMasterPageZones.sql"));
                dbm.AddParameter("@TenantId", FieldType.BigInt, tenantId);
                dbm.AddParameter("@MasterPageId", FieldType.BigInt, masterPageId);
                dbm.AddTypedParameter("@MasterPageZones", FieldType.Structured, masterPageZoneCollection.Count == 0 ? null : masterPageZoneCollection, "cms.MasterPageZoneTableType");
                dbm.ExecuteNonQuery();
                if (localUnitOfWork != null)
                {
                    localUnitOfWork.Commit();
                }
            }
            catch
            {
                if (localUnitOfWork != null)
                {
                    localUnitOfWork.Rollback();
                }
                throw;
            }
            finally
            {
                if (localUnitOfWork != null)
                {
                    localUnitOfWork.Dispose();
                }
            }
        }