Esempio n. 1
0
 /// <summary>
 /// 更新推荐内容
 /// </summary>
 /// <param name="item">推荐内容实体</param>
 /// <returns>更新成功返回true,失败返回false</returns>
 public void Update(RecommendItem item)
 {
     //设计要点
     //1、需要触发的事件:OnAfter;
     recommendItemRepository.Update(item);
     EventBus <RecommendItem> .Instance().OnAfter(item, new CommonEventArgs(EventOperationType.Instance().Update()));
 }
Esempio n. 2
0
 /// <summary>
 /// 上传Logo
 /// </summary>
 /// <param name="recommendId">推荐Id</param>
 /// <param name="stream">Logo文件流</param>
 public void UploadLogo(long recommendId, Stream stream)
 {
     if (stream != null)
     {
         RecommendItem recommend   = this.Get(recommendId);
         LogoService   logoService = new LogoService(TenantTypeIds.Instance().Recommend());
         recommend.FeaturedImage = logoService.UploadLogo(recommendId, stream);
         this.Update(recommend);
     }
 }
Esempio n. 3
0
        /// <summary>
        ///  推荐内容
        /// </summary>
        public static RecommendItem New()
        {
            RecommendItem recommendItem = new RecommendItem()
            {
                ItemName      = string.Empty,
                FeaturedImage = string.Empty,
                ReferrerName  = string.Empty,
                DateCreated   = DateTime.UtcNow,
                ExpiredDate   = DateTime.UtcNow
            };

            return(recommendItem);
        }
Esempio n. 4
0
        /// <summary>
        /// 变更推荐内容的排列顺序
        /// </summary>
        /// <param name="id">待调整的推荐Id</param>
        /// <param name="referenceId">参照推荐Id</param>
        public void ChangeDisplayOrder(long id, long referenceId)
        {
            //设计要点
            //1、交换id和referenceId对应推荐内容的DisplayOrder

            RecommendItem item          = recommendItemRepository.Get(id);
            RecommendItem referenceItem = recommendItemRepository.Get(referenceId);
            long          itemId        = item.DisplayOrder;

            item.DisplayOrder = referenceItem.DisplayOrder;
            recommendItemRepository.Update(item);
            referenceItem.DisplayOrder = itemId;
            recommendItemRepository.Update(referenceItem);
        }
Esempio n. 5
0
        /// <summary>
        /// 删除推荐内容
        /// </summary>
        /// <param name="recommendId">推荐Id</param>
        /// <returns>删除成功返回true,失败返回false</returns>
        public bool Delete(long recommendId)
        {
            //设计要点
            //1、需要触发的事件:OnAfter;
            //2、同时删除Logo
            RecommendItem item   = recommendItemRepository.Get(recommendId);
            int           result = recommendItemRepository.Delete(item);

            if (result > 0)
            {
                DeleteLogo(recommendId);
                EventBus <RecommendItem> .Instance().OnAfter(item, new CommonEventArgs(EventOperationType.Instance().Delete()));
            }
            return(result > 0);
        }
Esempio n. 6
0
        /// <summary>
        /// 推荐积分处理
        /// </summary>
        /// <param name="sender">推荐实体</param>
        /// <param name="eventArgs">事件参数</param>
        void RecommendPointModule_After(RecommendItem sender, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType != EventOperationType.Instance().Create())
            {
                return;
            }
            string pointItemKey = string.Empty;
            PointService pointService = new PointService();
            string description = string.Empty;
            TenantTypeService tenantTypeService = new TenantTypeService();

            var urlGetter = RecommendUrlGetterFactory.Get(sender.TenantTypeId);

            NoticeService noticeService = new NoticeService();
            Notice notice = Notice.New();
            notice.TypeId = NoticeTypeIds.Instance().Hint();

            //notice.TemplateName = "FollowUser";
            notice.UserId = sender.UserId;
            notice.LeadingActorUserId = sender.ReferrerId;
            notice.LeadingActor = sender.ReferrerName;
            notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.ReferrerId));
            notice.RelativeObjectId = sender.UserId;
            notice.RelativeObjectName = sender.ItemName;
            notice.RelativeObjectUrl = sender.DetailUrl;

            if (sender.TenantTypeId == TenantTypeIds.Instance().User())
            {
                pointItemKey = PointItemKeys.Instance().RecommendUser();
                description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_RecommendUser"));
                notice.TemplateName = NoticeTemplateNames.Instance().ManagerRecommendedUser();
            }
            else
            {
                pointItemKey = PointItemKeys.Instance().RecommendContent();
                TenantType tenantType = tenantTypeService.Get(sender.TenantTypeId);
                if (tenantType == null)
                    return;
                description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_RecommendContent"), tenantType.Name, sender.ItemName);
                notice.TemplateName = NoticeTemplateNames.Instance().ManagerRecommended();
            }

            noticeService.Create(notice);
            pointService.GenerateByRole(sender.UserId, pointItemKey, description);
        }
Esempio n. 7
0
 /// <summary>
 /// 创建推荐内容
 /// </summary>
 /// <param name="item">推荐内容实体</param>
 /// <returns>创建成功返回true,失败返回false</returns>
 public bool Create(RecommendItem item)
 {
     //设计要点
     //1、需要触发的事件:OnAfter;
     //2、需确保itemId+recommendTypeId不存在才能创建,避免同一内容被重复推荐
     //3、DisplayOrder需要和主键Id保持一致;
     long itemId = 0;
     long.TryParse(recommendItemRepository.Insert(item).ToString(), out itemId);
     if (itemId > 0)
     {
         item.DisplayOrder = itemId;
         recommendItemRepository.Update(item);
         EventBus<RecommendItem>.Instance().OnAfter(item, new CommonEventArgs(EventOperationType.Instance().Create()));
         return true;
     }
     else
     {
         return false;
     }
 }
Esempio n. 8
0
        /// <summary>
        /// 资讯操作日志事件处理
        /// </summary>
        private void RecommendOperationLogEventModule_After(RecommendItem sender, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType == EventOperationType.Instance().Create()
               || eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                TenantTypeService tenantTypeService = new TenantTypeService();
                TenantType tenantType = tenantTypeService.Get(sender.TenantTypeId);
                if (tenantType == null)
                    return;

                OperationLogEntry entry = new OperationLogEntry(eventArgs.OperatorInfo);
                entry.ApplicationId = tenantType.ApplicationId;
                entry.Source = tenantType.Name;
                entry.OperationType = eventArgs.EventOperationType;
                entry.OperationObjectName = sender.ItemName;
                entry.OperationObjectId = sender.ItemId;
                entry.Description = string.Format(ResourceAccessor.GetString("OperationLog_Pattern_" + eventArgs.EventOperationType), tenantType.Name + "推荐", entry.OperationObjectName);

                OperationLogService logService = Tunynet.DIContainer.Resolve<OperationLogService>();
                logService.Create(entry);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 创建推荐内容
        /// </summary>
        /// <param name="item">推荐内容实体</param>
        /// <returns>创建成功返回true,失败返回false</returns>
        public bool Create(RecommendItem item)
        {
            //设计要点
            //1、需要触发的事件:OnAfter;
            //2、需确保itemId+recommendTypeId不存在才能创建,避免同一内容被重复推荐
            //3、DisplayOrder需要和主键Id保持一致;
            long itemId = 0;

            long.TryParse(recommendItemRepository.Insert(item).ToString(), out itemId);
            if (itemId > 0)
            {
                item.DisplayOrder = itemId;
                recommendItemRepository.Update(item);
                EventBus <RecommendItem> .Instance().OnAfter(item, new CommonEventArgs(EventOperationType.Instance().Create()));

                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 10
0
 /// <summary>
 /// 更新推荐内容
 /// </summary>
 /// <param name="item">推荐内容实体</param>
 /// <returns>更新成功返回true,失败返回false</returns>
 public void Update(RecommendItem item)
 {
     //设计要点
     //1、需要触发的事件:OnAfter;
     recommendItemRepository.Update(item);
     EventBus<RecommendItem>.Instance().OnAfter(item, new CommonEventArgs(EventOperationType.Instance().Update()));
 }
Esempio n. 11
0
        /// <summary>
        ///  推荐内容
        /// </summary>
        public static RecommendItem New()
        {
            RecommendItem recommendItem = new RecommendItem()
            {
                ItemName = string.Empty,
                FeaturedImage = string.Empty,
                ReferrerName = string.Empty,
                DateCreated = DateTime.UtcNow,
                ExpiredDate = DateTime.UtcNow

            };
            return recommendItem;
        }