Esempio n. 1
0
        public JsonResult _DeleteRecommend(long recommendId)
        {
            RecommendItem recommendItem = recommendService.Get(recommendId);

            if (recommendItem == null)
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "找不到所要删除的推荐内容!")));
            }
            if (!new Authorizer().RecommendItem_Manage(recommendItem.TenantTypeId))
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "您没有管理权限")));
            }
            StatusMessageData message = null;
            bool result = recommendService.Delete(recommendId);

            if (result)
            {
                message = new StatusMessageData(StatusMessageType.Success, "删除成功!");
            }
            else
            {
                message = new StatusMessageData(StatusMessageType.Error, "删除失败!");
            }
            return(Json(message));

            //已修改
        }
Esempio n. 2
0
        /// <summary>
        /// 删除相册
        /// </summary>
        /// <remarks>
        /// 1.删除相册时同时删除相册下的所有照片以及照片的圈人;
        /// 2.注意需要删除动态,通过EventModule处理;
        /// 3.注意需要扣除新建相册时增加的积分,通过EventModule处理;
        /// 4.需要触发的事件:1)Delete的OnBefore、OnAfter;2)审核状态变更
        /// </remarks>
        /// <param name="album">相册对象</param>
        public void DeleteAlbum(Album album)
        {
            //删除相册下相片
            int pageCount = 1;
            int pageIndex = 1;

            do
            {
                PagingDataSet <Photo> photos = this.GetPhotosOfAlbum(null, album.AlbumId, true, SortBy_Photo.DateCreated_Desc, null, 100, pageIndex);
                foreach (Photo photo in photos)
                {
                    this.DeletePhoto(photo);
                }
                pageCount = photos.PageCount;
                pageIndex++;
            } while (pageIndex <= pageCount);

            //删除相册的推荐
            RecommendService recommendService = new RecommendService();

            recommendService.Delete(album.AlbumId, TenantTypeIds.Instance().Album());

            EventBus <Album> .Instance().OnBefore(album, new CommonEventArgs(EventOperationType.Instance().Delete()));

            albumRepository.Delete(album);

            EventBus <Album> .Instance().OnAfter(album, new CommonEventArgs(EventOperationType.Instance().Delete()));

            EventBus <Album, AuditEventArgs> .Instance().OnAfter(album, new AuditEventArgs(album.AuditStatus, null));
        }
        public ActionResult _ChangeGiftStatus(IEnumerable <long> giftIds, bool isEnabled)
        {
            if (giftIds == null)
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "找不到要操作的商品,操作失败!")));
            }
            RecommendService recommendService = new RecommendService();

            foreach (var item in giftIds)
            {
                pointMallService.SetEnabled(pointMallService.GetGift(item), isEnabled);
                if (!isEnabled)
                {
                    //删除该商品上的推荐
                    recommendService.Delete(item, TenantTypeIds.Instance().PointGift());
                }
            }
            string message;

            if (isEnabled)
            {
                message = "上架操作成功!";
            }
            else
            {
                message = "下架操作成功!";
            }
            return(Json(new StatusMessageData(StatusMessageType.Success, message)));
        }
Esempio n. 4
0
        /// <summary>
        /// 删除日志
        /// </summary>
        /// <param name="blogThread">日志实体</param>
        public void Delete(BlogThread blogThread)
        {
            //删除日志可能会影响:
            //1、站点分类,在EventModule中处理
            //2、拥有者分类,在EventModule中处理
            //3、日志对应的动态(可在EventModule中处理,可参考贴吧)
            //4、其它数据的删除由各模块自动处理
            //需要触发的事件参见《设计说明书-日志》;

            if (blogThread == null)
            {
                return;
            }

            CategoryService categoryService = new CategoryService();

            var sender = new CommentService().GetCommentedObjectComments(blogThread.ThreadId);

            //删除用户分类关联
            categoryService.ClearCategoriesFromItem(blogThread.ThreadId, blogThread.OwnerId, TenantTypeIds.Instance().BlogThread());

            //删除站点分类关联(投稿到)
            categoryService.ClearCategoriesFromItem(blogThread.ThreadId, 0, TenantTypeIds.Instance().BlogThread());

            //删除标签关联
            TagService tagService = new TagService(TenantTypeIds.Instance().BlogThread());

            tagService.ClearTagsFromItem(blogThread.ThreadId, blogThread.OwnerId);

            //删除推荐记录
            RecommendService recommendService = new RecommendService();

            recommendService.Delete(blogThread.ThreadId, blogThread.TenantTypeId);

            //删除订阅记录todo:libsh
            //SubscribeService subscribeService = new SubscribeService(TenantTypeIds.Instance().BlogThread());


            //用户内容计数-1
            if (!blogThread.IsDraft)
            {
                OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                ownerDataService.Change(blogThread.UserId, OwnerDataKeys.Instance().ThreadCount(), -1);
            }

            EventBus <BlogThread> .Instance().OnBefore(blogThread, new CommonEventArgs(EventOperationType.Instance().Delete()));

            blogThreadRepository.Delete(blogThread);

            EventBus <BlogThread> .Instance().OnAfter(blogThread, new CommonEventArgs(EventOperationType.Instance().Delete()));

            EventBus <BlogThread, AuditEventArgs> .Instance().OnAfter(blogThread, new AuditEventArgs(blogThread.AuditStatus, null));

            if (sender != null)
            {
                EventBus <Comment> .Instance().OnBatchAfter(sender, new CommonEventArgs(EventOperationType.Instance().Delete()));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 删除话题、标签后删除推荐
        /// </summary>
        /// <param name="tag"></param>
        /// <param name="eventArgs"></param>
        void DeleteTag_After(Tag tag, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType != EventOperationType.Instance().Delete() || tag == null)
            {
                return;
            }
            RecommendService recommendService = new RecommendService();

            recommendService.Delete(tag.TagId, tag.TenantTypeId);
        }
Esempio n. 6
0
        /// <summary>
        /// 删除照片
        /// </summary>
        /// <remarks>
        /// 1.更新所属相册计数PhotoCount-1
        /// 2.更新用户内容计数OwnerData-1
        /// 3.如果照片是封面,需要将相册的CoverId属性重置为0
        /// 4.需要调用TagService.ClearTagsFromItem删除标签关联
        /// 5.需要同步删除照片圈人
        /// 6.通过EventModule处理动态和积分的变化;
        /// 7.需要触发的事件:1)Delete的OnBefore、OnAfter;2)审核状态变更
        /// </remarks>
        /// <param name="photo">照片对象</param>
        public void DeletePhoto(Photo photo)
        {
            //删除与标签的关联
            TagService tagService = new TagService(TenantTypeIds.Instance().Photo());

            tagService.ClearTagsFromItem(photo.PhotoId, photo.UserId);

            //删除照片推荐
            RecommendService recommendService = new RecommendService();

            recommendService.Delete(photo.PhotoId, TenantTypeIds.Instance().Photo());

            //相册计数PhotoCount-1及封面
            Album album = photo.Album;

            album.PhotoCount--;
            if (photo.PhotoId == album.CoverId)
            {
                album.CoverId = 0;
            }
            albumRepository.Update(album);

            //删除圈人
            IEnumerable <PhotoLabel> photoLabels = this.GetLabelsOfPhoto(null, photo.PhotoId);

            foreach (PhotoLabel photolabel in photoLabels)
            {
                photoLabelRepository.Delete(photolabel);
            }

            //删除照片磁盘物理文件
            if (!string.IsNullOrEmpty(photo.RelativePath))
            {
                TenantAttachmentSettings tenantAttachmentSettings = TenantAttachmentSettings.GetRegisteredSettings(TenantTypeIds.Instance().Photo());
                IStoreProvider           storeProvider            = DIContainer.ResolveNamed <IStoreProvider>(tenantAttachmentSettings.StoreProviderName);
                string relativePath = storeProvider.GetRelativePath(photo.RelativePath, true);
                string fileName     = photo.RelativePath.Remove(0, relativePath.Length).Trim('\\').Trim('/');
                storeProvider.DeleteFiles(relativePath, fileName);
            }

            photoRepository.Delete(photo);

            EventBus <Photo> .Instance().OnBefore(photo, new CommonEventArgs(EventOperationType.Instance().Delete()));

            //用户内容计数OwnerData-1
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());

            ownerDataService.Change(photo.UserId, OwnerDataKeys.Instance().PhotoCount(), -1);

            //通过EventModule处理动态和积分的变化;
            EventBus <Photo> .Instance().OnAfter(photo, new CommonEventArgs(EventOperationType.Instance().Delete()));

            EventBus <Photo, AuditEventArgs> .Instance().OnAfter(photo, new AuditEventArgs(photo.AuditStatus, null));
        }
Esempio n. 7
0
        /// <summary>
        /// 删除帖吧
        /// </summary>
        /// <param name="sectionId">帖吧Id</param>
        public void Delete(long sectionId)
        {
            BarSection section = barSectionRepository.Get(sectionId);

            if (section == null)
            {
                return;
            }
            EventBus <BarSection> .Instance().OnBefore(section, new CommonEventArgs(EventOperationType.Instance().Delete()));

            //帖子
            BarThreadService barThreadService = new BarThreadService();

            barThreadService.DeletesBySectionId(sectionId);

            CategoryService categoryService = new CategoryService();

            //帖吧分类
            categoryService.ClearCategoriesFromItem(sectionId, null, TenantTypeIds.Instance().BarSection());

            //帖子分类
            var categories = categoryService.GetRootCategories(TenantTypeIds.Instance().BarThread(), sectionId);

            foreach (var category in categories)
            {
                categoryService.Delete(category.CategoryId);
            }
            //帖吧标签
            TagService tagService = new TagService(TenantTypeIds.Instance().BarThread());

            tagService.ClearTagsFromOwner(sectionId);

            //删除Logo
            DeleteLogo(sectionId);

            //删除推荐记录
            RecommendService recommendService = new RecommendService();

            recommendService.Delete(sectionId, TenantTypeIds.Instance().BarSection());

            int affectCount = barSectionRepository.Delete(section);

            if (affectCount > 0)
            {
                EventBus <BarSection> .Instance().OnAfter(section, new CommonEventArgs(EventOperationType.Instance().Delete()));

                EventBus <BarSection, AuditEventArgs> .Instance().OnAfter(section, new AuditEventArgs(null, section.AuditStatus));
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 删除词条
        /// </summary>
        /// <param name="wikiPage">词条实体</param>
        public void Delete(WikiPage wikiPage)
        {
            if (wikiPage == null)
            {
                return;
            }

            //todo:zhengw:需要处理词条版本

            CategoryService categoryService = new CategoryService();

            //删除站点分类关联(投稿到)
            categoryService.ClearCategoriesFromItem(wikiPage.PageId, 0, TenantTypeIds.Instance().WikiPage());

            //删除标签关联
            TagService tagService = new TagService(TenantTypeIds.Instance().WikiPage());

            tagService.ClearTagsFromItem(wikiPage.PageId, wikiPage.OwnerId);

            //删除推荐记录
            RecommendService recommendService = new RecommendService();

            recommendService.Delete(wikiPage.PageId, wikiPage.TenantTypeId);

            //用户创建词条数-1
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());

            ownerDataService.Change(wikiPage.UserId, OwnerDataKeys.Instance().PageCount(), -1);

            EventBus <WikiPage> .Instance().OnBefore(wikiPage, new CommonEventArgs(EventOperationType.Instance().Delete()));

            wikiPageRepository.Delete(wikiPage);

            EventBus <WikiPage> .Instance().OnAfter(wikiPage, new CommonEventArgs(EventOperationType.Instance().Delete()));

            EventBus <WikiPage, AuditEventArgs> .Instance().OnAfter(wikiPage, new AuditEventArgs(wikiPage.AuditStatus, null));
        }
Esempio n. 9
0
        /// <summary>
        /// 删除主题帖
        /// </summary>
        /// <param name="threadId">主题帖Id</param>
        public void Delete(long threadId)
        {
            BarThread thread = barThreadRepository.Get(threadId);

            if (thread == null)
            {
                return;
            }

            EventBus <BarThread> .Instance().OnBefore(thread, new CommonEventArgs(EventOperationType.Instance().Delete()));

            BarSectionService barSectionService = new BarSectionService();
            BarSection        barSection        = barSectionService.Get(thread.SectionId);

            if (barSection != null)
            {
                //帖子标签
                TagService tagService = new TagService(TenantTypeIds.Instance().BarThread());
                tagService.ClearTagsFromItem(threadId, barSection.SectionId);

                //帖子分类
                CategoryService categoryService = new CategoryService();
                categoryService.ClearCategoriesFromItem(threadId, barSection.SectionId, TenantTypeIds.Instance().BarThread());
            }

            //删除回帖
            BarPostService barPostService = new BarPostService();

            barPostService.DeletesByThreadId(threadId);

            //删除推荐记录
            RecommendService recommendService = new RecommendService();

            recommendService.Delete(threadId, TenantTypeIds.Instance().BarThread());

            int affectCount = barThreadRepository.Delete(thread);

            if (affectCount > 0)
            {
                //更新帖吧的计数
                CountService countService = new CountService(TenantTypeIds.Instance().BarSection());
                countService.ChangeCount(CountTypes.Instance().ThreadCount(), barSection.SectionId, barSection.UserId, -1, true);
                countService.ChangeCount(CountTypes.Instance().ThreadAndPostCount(), barSection.SectionId, barSection.UserId, -1, true);

                if (thread.TenantTypeId == TenantTypeIds.Instance().Group())
                {
                    //群组内容计数-1
                    OwnerDataService groupOwnerDataService = new OwnerDataService(TenantTypeIds.Instance().Group());
                    groupOwnerDataService.Change(thread.SectionId, OwnerDataKeys.Instance().ThreadCount(), -1);
                }
                else if (thread.TenantTypeId == TenantTypeIds.Instance().Bar())
                {
                    //用户内容计数-1
                    OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                    ownerDataService.Change(thread.UserId, OwnerDataKeys.Instance().ThreadCount(), -1);
                }
                EventBus <BarThread> .Instance().OnAfter(thread, new CommonEventArgs(EventOperationType.Instance().Delete()));

                EventBus <BarThread, AuditEventArgs> .Instance().OnAfter(thread, new AuditEventArgs(thread.AuditStatus, null));
            }


            //BarThread删除可能影响的:
            //1、附件 (看到了)
            //2、BarPost(看到了)
            //3、BarRating(看到了)
            //4、相关计数对象(看到了)
            //5、用户在应用中的数据(看到了)
            //6、@用户(看到了)
        }