Esempio n. 1
0
        /// <summary>
        /// 更新帖吧
        /// </summary>
        /// <param name="section">帖吧</param>
        /// <param name="userId">当前操作人</param>
        /// <param name="managerIds">管理员用户Id</param>
        /// <param name="sectionedFile">帖吧标识图</param>
        public void Update(BarSection section, long userId, IEnumerable <long> managerIds, Stream sectionedFile)
        {
            EventBus <BarSection> .Instance().OnBefore(section, new CommonEventArgs(EventOperationType.Instance().Update()));



            //上传Logo
            if (sectionedFile != null)
            {
                LogoService logoService = new LogoService(TenantTypeIds.Instance().BarSection());
                section.LogoImage = logoService.UploadLogo(section.SectionId, sectionedFile);
            }

            auditService.ChangeAuditStatusForUpdate(userId, section);
            barSectionRepository.Update(section);

            if (managerIds != null && managerIds.Count() > 0)
            {
                List <long> mangagerIds_list = managerIds.ToList();
                mangagerIds_list.Remove(section.UserId);
                managerIds = mangagerIds_list;
            }
            barSectionRepository.UpdateManagerIds(section.SectionId, managerIds);

            if (section.TenantTypeId == TenantTypeIds.Instance().Bar())
            {
                SubscribeService subscribeService = new SubscribeService(TenantTypeIds.Instance().BarSection());

                //帖吧主、吧管理员自动关注本帖吧
                int  followedCount = 0;
                bool result        = subscribeService.Subscribe(section.SectionId, section.UserId);
                if (result)
                {
                    followedCount++;
                }
                if (managerIds != null && managerIds.Count() > 0)
                {
                    foreach (var managerId in managerIds)
                    {
                        result = subscribeService.Subscribe(section.SectionId, managerId);
                        if (result)
                        {
                            followedCount++;
                        }
                    }
                }

                //增加帖吧的被关注数
                CountService countService = new CountService(TenantTypeIds.Instance().BarSection());
                countService.ChangeCount(CountTypes.Instance().FollowedCount(), section.SectionId, section.UserId, followedCount, true);
            }
            EventBus <BarSection> .Instance().OnAfter(section, new CommonEventArgs(EventOperationType.Instance().Update()));
        }
Esempio n. 2
0
        /// <summary>
        /// 关注日志操作
        /// </summary>
        public JsonResult _Subscribe(string spaceKey, long threadId)
        {
            IUser currentUser = UserContext.CurrentUser;

            if (currentUser == null)
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "必须先登录,才能继续操作")));
            }

            BlogThread blogThread = blogService.Get(threadId);

            if (blogThread == null)
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "找不到要被关注的日志")));
            }

            if (subscribeService.IsSubscribed(threadId, currentUser.UserId))
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "您已经关注过该日志")));
            }

            subscribeService.Subscribe(threadId, currentUser.UserId);

            return(Json(new StatusMessageData(StatusMessageType.Success, "关注成功")));
        }
        /// <summary>
        /// 处理关注事件
        /// </summary>
        /// <param name="requestMessage">请求消息</param>
        /// <returns></returns>
        public override IResponseMessageBase OnEvent_SubscribeRequest(RequestMessageEvent_Subscribe requestMessage)
        {
            SubscribeService ss = new SubscribeService();

            ss.Subscribe(requestMessage);

            return(null);
        }
Esempio n. 4
0
 public async Task Subscribe()
 {
     await _subscribeService.Subscribe(Context);
 }
Esempio n. 5
0
        /// <summary>
        /// 创建帖吧
        /// </summary>
        /// <param name="section">帖吧</param>
        /// <param name="userId">当前操作人</param>
        /// <param name="managerIds">管理员用户Id</param>
        /// <param name="logoFile">帖吧标识图</param>
        /// <returns>是否创建成功</returns>
        public bool Create(BarSection section, long userId, IEnumerable <long> managerIds, Stream logoFile)
        {
            EventBus <BarSection> .Instance().OnBefore(section, new CommonEventArgs(EventOperationType.Instance().Create()));

            //设置审核状态
            auditService.ChangeAuditStatusForCreate(userId, section);

            if (!(section.SectionId > 0))
            {
                section.SectionId = IdGenerator.Next();
            }

            long id = 0;

            long.TryParse(barSectionRepository.Insert(section).ToString(), out id);

            if (id > 0)
            {
                if (managerIds != null && managerIds.Count() > 0)
                {
                    List <long> mangagerIds_list = managerIds.ToList();
                    mangagerIds_list.Remove(section.UserId);
                    managerIds = mangagerIds_list;
                    barSectionRepository.UpdateManagerIds(id, managerIds);
                }
                if (section.TenantTypeId == TenantTypeIds.Instance().Bar())
                {
                    //帖吧主、吧管理员自动关注本帖吧
                    SubscribeService subscribeService = new SubscribeService(TenantTypeIds.Instance().BarSection());
                    int  followedCount = 0;
                    bool result        = subscribeService.Subscribe(section.SectionId, section.UserId);
                    if (result)
                    {
                        followedCount++;
                    }
                    if (managerIds != null && managerIds.Count() > 0)
                    {
                        foreach (var managerId in managerIds)
                        {
                            result = subscribeService.Subscribe(section.SectionId, managerId);
                            if (result)
                            {
                                followedCount++;
                            }
                        }
                    }
                    //增加帖吧的被关注数
                    CountService countService = new CountService(TenantTypeIds.Instance().BarSection());
                    countService.ChangeCount(CountTypes.Instance().FollowedCount(), section.SectionId, section.UserId, followedCount, true);
                }



                //上传Logo
                if (logoFile != null)
                {
                    LogoService logoService = new LogoService(TenantTypeIds.Instance().BarSection());
                    section.LogoImage = logoService.UploadLogo(section.SectionId, logoFile);
                    barSectionRepository.Update(section);
                }
                EventBus <BarSection> .Instance().OnAfter(section, new CommonEventArgs(EventOperationType.Instance().Create()));

                EventBus <BarSection, AuditEventArgs> .Instance().OnAfter(section, new AuditEventArgs(section.AuditStatus, null));
            }
            return(id > 0);
        }
Esempio n. 6
0
        /// <summary>
        /// 回答被赞同的相关事件处理
        /// </summary>
        private void AskAnswerSupportEventModule_After(long objectId, SupportOpposeEventArgs eventArgs)
        {
            if (eventArgs.TenantTypeId == TenantTypeIds.Instance().AskAnswer())
            {
                //如果不是第一次顶踩,则不处理
                if (!eventArgs.FirstTime)
                {
                    return;
                }

                if (eventArgs.EventOperationType == EventOperationType.Instance().Support())
                {
                    AskAnswer   answer   = askService.GetAnswer(objectId);
                    AskQuestion question = answer.Question;

                    //创建顶回答的动态[关注回答者的粉丝可以看到该顶信息]
                    Activity activityOfFollower = Activity.New();
                    activityOfFollower.ActivityItemKey       = ActivityItemKeys.Instance().SupportAskAnswer();
                    activityOfFollower.ApplicationId         = AskConfig.Instance().ApplicationId;
                    activityOfFollower.IsOriginalThread      = true;
                    activityOfFollower.IsPrivate             = false;
                    activityOfFollower.TenantTypeId          = TenantTypeIds.Instance().AskAnswer();
                    activityOfFollower.SourceId              = answer.AnswerId;
                    activityOfFollower.UserId                = eventArgs.UserId;
                    activityOfFollower.ReferenceId           = answer.AnswerId;
                    activityOfFollower.ReferenceTenantTypeId = TenantTypeIds.Instance().AskAnswer();
                    activityOfFollower.OwnerId               = eventArgs.UserId;
                    activityOfFollower.OwnerName             = userService.GetFullUser(eventArgs.UserId).DisplayName;
                    activityOfFollower.OwnerType             = ActivityOwnerTypes.Instance().User();
                    activityService.Generate(activityOfFollower, true);

                    //创建顶回答的动态[关注该问题的用户可以看到该顶信息]
                    Activity activityOfQuestionSubscriber = Activity.New();
                    activityOfQuestionSubscriber.ActivityItemKey       = ActivityItemKeys.Instance().SupportAskAnswer();
                    activityOfQuestionSubscriber.ApplicationId         = AskConfig.Instance().ApplicationId;
                    activityOfQuestionSubscriber.IsOriginalThread      = true;
                    activityOfQuestionSubscriber.IsPrivate             = false;
                    activityOfQuestionSubscriber.TenantTypeId          = TenantTypeIds.Instance().AskAnswer();
                    activityOfQuestionSubscriber.SourceId              = answer.AnswerId;
                    activityOfQuestionSubscriber.UserId                = eventArgs.UserId;
                    activityOfQuestionSubscriber.ReferenceId           = answer.AnswerId;
                    activityOfQuestionSubscriber.ReferenceTenantTypeId = TenantTypeIds.Instance().AskAnswer();
                    activityOfQuestionSubscriber.OwnerId               = question.QuestionId;
                    activityOfQuestionSubscriber.OwnerName             = question.Subject;
                    activityOfQuestionSubscriber.OwnerType             = ActivityOwnerTypes.Instance().AskQuestion();
                    activityService.Generate(activityOfQuestionSubscriber, false);

                    //处理积分和威望
                    string pointItemKey = PointItemKeys.Instance().Ask_BeSupported();

                    //回答收到赞同时产生积分
                    string eventOperationType = EventOperationType.Instance().Support();
                    string description        = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "回答", question.Subject);
                    pointService.GenerateByRole(answer.UserId, pointItemKey, description);

                    //记录用户的威望
                    PointItem pointItem = pointService.GetPointItem(pointItemKey);
                    ownerDataService.Change(answer.UserId, OwnerDataKeys.Instance().UserAskReputation(), pointItem.ReputationPoints);


                    //赞同者自动关注问题
                    if (!subscribeService.IsSubscribed(question.QuestionId, eventArgs.UserId))
                    {
                        subscribeService.Subscribe(question.QuestionId, eventArgs.UserId);

                        //问题关注数计数,用于“可能感兴趣的问题”关联表查询
                        countService.ChangeCount(CountTypes.Instance().QuestionFollowerCount(), question.QuestionId, question.UserId, 1, false);
                    }

                    //增加赞同的用户计数
                    ownerDataService.Change(answer.UserId, OwnerDataKeys.Instance().AnswerSupportCount(), 1);
                }
                else if (eventArgs.EventOperationType == EventOperationType.Instance().Oppose())
                {
                    AskAnswer   answer   = askService.GetAnswer(objectId);
                    AskQuestion question = answer.Question;

                    //处理积分和威望
                    string pointItemKey = PointItemKeys.Instance().Ask_BeOpposed();

                    //回答收到反对时产生积分
                    string eventOperationType = EventOperationType.Instance().Oppose();
                    string description        = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "回答", question.Subject);
                    pointService.GenerateByRole(answer.UserId, pointItemKey, description);

                    //记录用户的威望
                    PointItem pointItem = pointService.GetPointItem(pointItemKey);
                    ownerDataService.Change(answer.UserId, OwnerDataKeys.Instance().UserAskReputation(), pointItem.ReputationPoints);


                    //反对者自动关注问题
                    if (!subscribeService.IsSubscribed(question.QuestionId, eventArgs.UserId))
                    {
                        subscribeService.Subscribe(answer.QuestionId, eventArgs.UserId);

                        //问题关注数计数,用于“可能感兴趣的问题”关联表查询
                        countService.ChangeCount(CountTypes.Instance().QuestionFollowerCount(), question.QuestionId, question.UserId, 1, false);
                    }

                    //增加反对的用户计数
                    ownerDataService.Change(answer.UserId, OwnerDataKeys.Instance().AnswerOpposeCount(), 1);
                }
            }
        }