Esempio n. 1
0
        /// <summary>
        /// 新建实体时使用
        /// </summary>
        //todo:需要检查成员初始化的类型是否正确
        public static BarRating New()
        {
            BarRating barRating = new BarRating()
            {
                UserDisplayName = string.Empty,
                Reason          = string.Empty,
                IP          = WebUtility.GetIP(),
                DateCreated = DateTime.UtcNow
            };

            return(barRating);
        }
Esempio n. 2
0
        /// <summary>
        /// 创建评分
        /// </summary>
        /// <param name="rating">评分</param>
        /// <returns>true-评分成功,false-评分失败(可能今日评分已超过限额)</returns>
        public bool Create(BarRating rating)
        {
            BarThreadService barThreadService = new BarThreadService();
            BarThread thread = barThreadService.Get(rating.ThreadId);
            EventBus<BarRating>.Instance().OnBefore(rating, new CommonEventArgs(EventOperationType.Instance().Create()));
            bool result = false;

            bool.TryParse(barRatingRepository.Insert(rating).ToString(), out result);

            if (result)
            {
                //给楼主加威望/交易积分
                IUserService userService = DIContainer.Resolve<IUserService>();
                userService.ChangePoints(thread.UserId, 0, rating.ReputationPoints, rating.TradePoints);
                PointService pointService = new PointService();
                pointService.CreateRecord(thread.UserId, "帖子评分", "发布的帖子被其他用户评分", 0, rating.ReputationPoints, rating.TradePoints);

                EventBus<BarRating>.Instance().OnAfter(rating, new CommonEventArgs(EventOperationType.Instance().Create()));
            }
            return result;
        }
        void BarRatingEventModule_After(BarRating sender, CommonEventArgs eventArgs)
        {
            ActivityService activityService = new ActivityService();
            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                Activity actvity = Activity.New();
                actvity.ActivityItemKey = ActivityItemKeys.Instance().CreateBarRating();
                actvity.ApplicationId = BarConfig.Instance().ApplicationId;

                BarThreadService barThreadService = new BarThreadService();
                BarThread barThread = barThreadService.Get(sender.ThreadId);
                if (barThread == null)
                    return;
                var barUrlGetter = BarUrlGetterFactory.Get(barThread.TenantTypeId);
                if (barUrlGetter == null)
                    return;

                actvity.IsOriginalThread = true;
                actvity.IsPrivate = barUrlGetter.IsPrivate(barThread.SectionId);
                actvity.OwnerId = barThread.SectionId;
                actvity.OwnerName = barThread.BarSection.Name;
                actvity.OwnerType = barUrlGetter.ActivityOwnerType;
                actvity.ReferenceId = barThread.ThreadId;
                actvity.ReferenceTenantTypeId = TenantTypeIds.Instance().BarThread();
                actvity.SourceId = sender.RatingId;
                actvity.TenantTypeId = TenantTypeIds.Instance().BarRating();
                actvity.UserId = sender.UserId;

                //自己回复自己时,不向自己的动态收件箱推送动态
                if (actvity.UserId == barThread.UserId)
                    activityService.Generate(actvity, false);
                else
                    activityService.Generate(actvity, true);
            }
            else
            {
                activityService.DeleteSource(TenantTypeIds.Instance().BarRating(), sender.RatingId);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 创建评分
        /// </summary>
        /// <param name="rating">评分</param>
        /// <returns>true-评分成功,false-评分失败(可能今日评分已超过限额)</returns>
        public bool Create(BarRating rating)
        {
            BarThreadService barThreadService = new BarThreadService();
            BarThread        thread           = barThreadService.Get(rating.ThreadId);

            EventBus <BarRating> .Instance().OnBefore(rating, new CommonEventArgs(EventOperationType.Instance().Create()));

            bool result = false;


            bool.TryParse(barRatingRepository.Insert(rating).ToString(), out result);

            if (result)
            {
                //给楼主加威望/交易积分
                IUserService userService = DIContainer.Resolve <IUserService>();
                userService.ChangePoints(thread.UserId, 0, rating.ReputationPoints, rating.TradePoints);
                PointService pointService = new PointService();
                pointService.CreateRecord(thread.UserId, "帖子评分", "发布的帖子被其他用户评分", 0, rating.ReputationPoints, rating.TradePoints);

                EventBus <BarRating> .Instance().OnAfter(rating, new CommonEventArgs(EventOperationType.Instance().Create()));
            }
            return(result);
        }
Esempio n. 5
0
        /// <summary>
        /// 新建实体时使用
        /// </summary>
        //todo:需要检查成员初始化的类型是否正确
        public static BarRating New()
        {
            BarRating barRating = new BarRating()
            {
                UserDisplayName = string.Empty,
                Reason = string.Empty,
                IP = WebUtility.GetIP(),
                DateCreated = DateTime.UtcNow

            };
            return barRating;
        }