Exemplo n.º 1
0
        /// <summary>
        /// Compare resources on two servers, delete those only on the public server and report by email those only on the editing server.
        /// </summary>
        /// <param name="cmsContext">The CMS context.</param>
        /// <param name="startGallery">The start gallery.</param>
        private static void DeleteResources(CmsContext cmsContext, ResourceGallery startGallery)
        {
            // Compare resources for that gallery on edit and public environments
            var results      = CompareResources(startGallery);
            var onlyOnPublic = results[0] as Dictionary <string, HierarchyItem>;

            // Delete those which shouldn't be there
            try
            {
                foreach (HierarchyItem item in onlyOnPublic.Values)
                {
                    if (item.CanDelete && !item.IsDeleted)
                    {
                        item.Delete();
                        log.Info(String.Format(CultureInfo.CurrentCulture, Properties.Resources.LogDeleting, item.Path));
                    }
                }

                cmsContext.CommitAll();
            }
            catch (Exception)
            {
                cmsContext.RollbackAll();
                throw;
            }
        }
Exemplo n.º 2
0
 private void ExtendChannel(DateTime newExpiry, Guid channelGuid)
 {
     using (CmsContext cms = CmsUtilities.GetAdminContext(PublishingMode.Update))
     {
         Channel channelToExtend = cms.Searches.GetByGuid(channelGuid.ToString("B")) as Channel;
         foreach (Posting posting in channelToExtend.Postings)
         {
             if (this.updateExpired || posting.State != PostingState.Expired)
             {
                 posting.ExpiryDate = newExpiry;
                 posting.Approve();
             }
         }
         cms.CommitAll();
     }
 }