Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 动态处理程序
        /// </summary>
        /// <param name="barThread"></param>
        /// <param name="eventArgs"></param>
        private void BarThreadActivityModule_After(BarThread barThread, AuditEventArgs eventArgs)
        {
            //1、通过审核的内容才生成动态;(不满足)
            //2、把通过审核的内容设置为未通过审核或者删除内容,需要移除动态;(不满足)
            //3、把未通过审核的内容通过审核,需要添加动态; (不满足)
            //4、详见动态需求说明

            //生成动态
            ActivityService activityService = new ActivityService();
            AuditService    auditService    = new AuditService();
            bool?           auditDirection  = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

            if (auditDirection == true) //生成动态
            {
                if (barThread.BarSection == null)
                {
                    return;
                }

                var barUrlGetter = BarUrlGetterFactory.Get(barThread.TenantTypeId);
                if (barUrlGetter == null)
                {
                    return;
                }

                //生成Owner为帖吧的动态
                Activity actvityOfBar = Activity.New();
                actvityOfBar.ActivityItemKey = ActivityItemKeys.Instance().CreateBarThread();
                actvityOfBar.ApplicationId   = BarConfig.Instance().ApplicationId;

                AttachmentService        attachmentService = new AttachmentService(TenantTypeIds.Instance().BarThread());
                IEnumerable <Attachment> attachments       = attachmentService.GetsByAssociateId(barThread.ThreadId);
                if (attachments != null && attachments.Any(n => n.MediaType == MediaType.Image))
                {
                    actvityOfBar.HasImage = true;
                }

                actvityOfBar.IsOriginalThread      = true;
                actvityOfBar.IsPrivate             = false;
                actvityOfBar.UserId                = barThread.UserId;
                actvityOfBar.ReferenceId           = 0;//没有涉及到的实体
                actvityOfBar.ReferenceTenantTypeId = string.Empty;
                actvityOfBar.SourceId              = barThread.ThreadId;
                actvityOfBar.TenantTypeId          = TenantTypeIds.Instance().BarThread();
                actvityOfBar.OwnerId               = barThread.SectionId;
                actvityOfBar.OwnerName             = barThread.BarSection.Name;
                actvityOfBar.OwnerType             = barUrlGetter.ActivityOwnerType;
                activityService.Generate(actvityOfBar, false);

                if (!barUrlGetter.IsPrivate(barThread.SectionId))
                {
                    //生成Owner为用户的动态
                    Activity actvityOfUser = Activity.New();
                    actvityOfUser.ActivityItemKey  = actvityOfBar.ActivityItemKey;
                    actvityOfUser.ApplicationId    = actvityOfBar.ApplicationId;
                    actvityOfUser.HasImage         = actvityOfBar.HasImage;
                    actvityOfUser.HasMusic         = actvityOfBar.HasMusic;
                    actvityOfUser.HasVideo         = actvityOfBar.HasVideo;
                    actvityOfUser.IsOriginalThread = actvityOfBar.IsOriginalThread;
                    actvityOfUser.IsPrivate        = actvityOfBar.IsPrivate;
                    actvityOfUser.UserId           = actvityOfBar.UserId;
                    actvityOfUser.ReferenceId      = actvityOfBar.ReferenceId;
                    actvityOfUser.SourceId         = actvityOfBar.SourceId;

                    actvityOfUser.TenantTypeId = actvityOfBar.TenantTypeId;
                    actvityOfUser.OwnerId      = barThread.UserId;
                    actvityOfUser.OwnerName    = barThread.User.DisplayName;
                    actvityOfUser.OwnerType    = ActivityOwnerTypes.Instance().User();
                    activityService.Generate(actvityOfUser, false);
                }
            }
            else if (auditDirection == false) //删除动态
            {
                activityService.DeleteSource(TenantTypeIds.Instance().BarThread(), barThread.ThreadId);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 动态处理程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void BarPostActivityModule_After(BarPost sender, AuditEventArgs eventArgs)
        {
            ActivityService activityService = new ActivityService();
            AuditService    auditService    = new AuditService();
            bool?           auditDirection  = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

            if (auditDirection == true) //生成动态
            {
                BarThreadService barThreadService = new BarThreadService();
                BarThread        barThread        = barThreadService.Get(sender.ThreadId);
                if (barThread == null)
                {
                    return;
                }
                if (sender.UserId == barThread.UserId)
                {
                    return;
                }
                var barUrlGetter = BarUrlGetterFactory.Get(barThread.TenantTypeId);
                if (barUrlGetter == null)
                {
                    return;
                }
                if (sender.ParentId > 0)
                {
                    BarPost parentPost = new BarPostService().Get(sender.ParentId);
                    if (parentPost == null)
                    {
                        return;
                    }
                    if (parentPost.UserId == sender.UserId)
                    {
                        return;
                    }
                }
                Activity actvity = Activity.New();
                actvity.ActivityItemKey = ActivityItemKeys.Instance().CreateBarPost();
                actvity.ApplicationId   = BarConfig.Instance().ApplicationId;
                //仅一级回复可以上传附件
                if (sender.ParentId == 0)
                {
                    AttachmentService        attachmentService = new AttachmentService(TenantTypeIds.Instance().BarPost());
                    IEnumerable <Attachment> attachments       = attachmentService.GetsByAssociateId(sender.PostId);
                    if (attachments != null && attachments.Any(n => n.MediaType == MediaType.Image))
                    {
                        actvity.HasImage = true;
                    }
                    //actvity.HasMusic = barThread.HasMusic;
                    //actvity.HasVideo = barThread.HasVideo;
                }

                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.PostId;
                actvity.TenantTypeId          = TenantTypeIds.Instance().BarPost();
                actvity.UserId = sender.UserId;

                //创建从属内容,不向自己的动态收件箱推送动态
                activityService.Generate(actvity, false);
            }
            else if (auditDirection == false) //删除动态
            {
                activityService.DeleteSource(TenantTypeIds.Instance().BarPost(), sender.PostId);
            }
        }