예제 #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;
            }
        }