Ejemplo n.º 1
0
        /// <summary>
        /// Deletes and de-indexes a page attachment.
        /// </summary>
        /// <param name="provider">The provider.</param>
        /// <param name="pageFullName">The page full name.</param>
        /// <param name="name">The attachment name.</param>
        /// <returns><c>true</c> if the attachment was deleted, <c>false</c> otherwise.</returns>
        public static bool DeletePageAttachment(IFilesStorageProviderV40 provider, string pageFullName, string name)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }
            if (pageFullName == null)
            {
                throw new ArgumentNullException("pageFullName");
            }
            if (pageFullName.Length == 0)
            {
                throw new ArgumentException("Page Full Name cannot be empty", "pageFullName");
            }
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (name.Length == 0)
            {
                throw new ArgumentException("Name cannot be empty", "name");
            }

            PageContent page = Pages.FindPage(provider.CurrentWiki, pageFullName);

            if (page == null)
            {
                return(false);
            }

            bool done = provider.DeletePageAttachment(pageFullName, name);

            if (!done)
            {
                return(false);
            }

            SearchClass.UnindexPageAttachment(name, page);

            Host.Instance.OnAttachmentActivity(provider.GetType().FullName, name, pageFullName, null, FileActivity.AttachmentDeleted);

            return(true);
        }