Пример #1
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);
 }
 /// <summary>
 /// 转换为RecommendItemType用于数据库存储
 /// </summary>
 /// <returns></returns>
 public RecommendItemType AsRecommendItemType()
 {
     RecommendService recommendService = new RecommendService();
     RecommendItemType recommendType = recommendService.GetRecommendType(TypeId);
     recommendType.Name = this.Name;
     recommendType.HasFeaturedImage = this.HasFeaturedImage;
     recommendType.Description = this.Description ?? string.Empty;
     return recommendType;
 }
        /// <summary>
        /// 任务执行的内容
        /// </summary>
        /// <param name="taskDetail">任务配置状态信息</param>
        public void Execute(TaskDetail taskDetail)
        {
            RecommendService recommendService = new RecommendService();

            recommendService.DeleteExpiredRecommendItems();
        }
Пример #4
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));
            }
        }
 /// <summary>
 /// 任务执行的内容
 /// </summary>
 /// <param name="taskDetail">任务配置状态信息</param>
 public void Execute(TaskDetail taskDetail)
 {
     RecommendService recommendService = new RecommendService();
     recommendService.DeleteExpiredRecommendItems();
 }
Пример #6
0
 public ActionResult _RecommendContentItems(string recommendTypeId = null, int topNumber = 8)
 {
     IEnumerable<RecommendItem> recommendItems = new RecommendService().GetTops(topNumber, recommendTypeId);
     ViewData["recommendTypeId"] = recommendTypeId;
     return View(recommendItems);
 }
Пример #7
0
 public ActionResult _RecommendComments(string recommendTypeId = null, int topNumber = 5)
 {
     if (CmsConfig.Instance().EnableSocialComment)
         return new EmptyResult();
     IEnumerable<RecommendItem> recommendItems = new RecommendService().GetTops(topNumber, recommendTypeId);
     ViewData["recommendTypeId"] = recommendTypeId;
     return View(recommendItems);
 }
Пример #8
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、@用户(看到了)
        }
Пример #9
0
 /// <summary>
 /// 转换为RecommendItem用于数据库存储
 /// </summary>
 public RecommendItem AsRecommendItem()
 {
     RecommendItem item = null;
     //创建
     if (Id == 0)
     {
         item = RecommendItem.New();
         item.DateCreated = DateTime.UtcNow;
     }//编辑
     else
     {
         RecommendService recommendService = new RecommendService();
         item = recommendService.Get(Id);
         //处理删除后再点确定按钮报错情况
         if (item == null)
         {
             Id = 0;
             item = RecommendItem.New();
             item.DateCreated = DateTime.UtcNow;
         }
     }
     if (ExpiredDate == null)
     {
         item.ExpiredDate = DateTime.UtcNow.AddYears(100);
     }
     else
     {
         item.ExpiredDate = ExpiredDate.Value;
     }
     if (!string.IsNullOrEmpty(FeaturedImage))
     {
         item.FeaturedImage = FeaturedImage;
     }
     item.UserId = UserId;
     item.IsLink = IsLink;
     item.ItemName = RecommendItemName;
     item.ReferrerId = UserContext.CurrentUser.UserId;
     item.ReferrerName = UserContext.CurrentUser.DisplayName;
     item.ItemId = ItemId;
     item.TenantTypeId = TenantTypeId;
     item.TypeId = TypeId;
     item.LinkAddress = LinkAddress ?? string.Empty;
     return item;
 }