Exemplo n.º 1
0
        /// <summary>
        /// 通知处理程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void ContentItemNoticeModule_After(ContentItem sender, AuditEventArgs eventArgs)
        {
            AuditService auditService   = new AuditService();
            bool?        auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

            if (auditDirection == true)
            {
                long toUserId = sender.UserId;

                NoticeService noticeService = Tunynet.DIContainer.Resolve <NoticeService>();
                Notice        notice        = Notice.New();

                notice.UserId             = toUserId;
                notice.ApplicationId      = CmsConfig.Instance().ApplicationId;
                notice.TypeId             = NoticeTypeIds.Instance().Manage();
                notice.LeadingActorUserId = sender.UserId;
                notice.LeadingActor       = sender.Author;
                notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.UserId));
                notice.RelativeObjectId   = sender.ContentItemId;
                notice.RelativeObjectName = sender.Title;
                notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().ContentItemDetail(sender.ContentItemId));
                notice.TemplateName       = NoticeTemplateNames.Instance().ContributeAccepted();
                noticeService.Create(notice);
            }
        }
Exemplo n.º 2
0
        void auditControl_AuditCompleted(object sender, AuditEventArgs e)
        {
            CloseProcess();

            if (e.Action == AuditEventArgs.AuditAction.Audit)
            {
                if (e.Result != AuditEventArgs.AuditResult.Error)
                {
                    CommonFunction.ShowMessage("审核成功!");
                }
            }
            else if (e.Action == AuditEventArgs.AuditAction.Submit)
            {
                CommonFunction.ShowMessage("提交成功!");
            }
            else if (e.Result == AuditEventArgs.AuditResult.Cancel)
            {
                return;
            }
            if (auditControl.OrderEntity != null)
            {
                this.EditForm.OrderEntity = auditControl.OrderEntity;
            }
            this.EditForm.AuditinitForm(true);
            IsNeedToRefresh = true;

            //            IsClose = true;
            RefreshUI(RefreshedTypes.AuditInfo);
            RefreshUI(RefreshedTypes.All);
            OnRefreshData();
            OnClose();
        }
Exemplo n.º 3
0
        protected override void OnAuditing(object sender, AuditEventArgs e)
        {
            try
            {
                this.OrderEntity.FBEntity.CollectionEntity.Clear();

                var           posts     = (this.OrderEntity.LoginUser as LoginUserData).PostInfos;
                EmployeerData ownerInfo = this.OrderEntity.GetOwnerInfo();

                var finds = posts.Where(item => item.Company.Value.ToString() == ownerInfo.Company.Value.ToString());
                if (finds.Count() > 0)
                {
                    var          user = finds.FirstOrDefault();
                    AuditControl ac   = sender as AuditControl;
                    ac.AuditEntity.CreateCompanyID    = user.Company.Value.ToString();
                    ac.AuditEntity.CreateDepartmentID = user.Department.Value.ToString();
                    ac.AuditEntity.CreatePostID       = user.Post.Value.ToString();
                }



                base.OnAuditing(sender, e);
            }
            catch (Exception ex)
            {
                e.Result = AuditEventArgs.AuditResult.Cancel;
                CommonFunction.ShowErrorMessage("提交或审核异常, " + ex.ToString());
            }
        }
Exemplo n.º 4
0
        void AuditControlFB_AuditCompleted(object sender, AuditEventArgs e)
        {
            if (curAuditEventArgs == null)
            {
                curAuditEventArgs = e;
            }

            if (this.AuditCompleted != null)
            {
                this.AuditCompleted(this, curAuditEventArgs);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 通知处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        void CommentNoticeEventModule_After(Comment sender, AuditEventArgs eventArgs)
        {
            AuditService auditService   = new AuditService();
            bool?        auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

            if (auditDirection == true)
            {
                var urlGetter       = CommentUrlGetterFactory.Get(sender.TenantTypeId);
                var commentedObject = urlGetter.GetCommentedObject(sender.CommentedObjectId);
                var senderUser      = sender.User();
                if (urlGetter == null || commentedObject == null)
                {
                    return;
                }
                //文章有新评论时,自动通知原作者
                var toUserIds = new List <long>();
                //评论相关的atuserid
                List <long> userids = new AtUserService(TenantTypeIds.Instance().Comment()).GetAtUserIds(sender.Id);

                if (!userids.Contains(commentedObject.UserId))
                {
                    toUserIds.Add(commentedObject.UserId);
                }

                if (sender.ParentId > 0 && !userids.Contains(sender.ToUserId))
                {
                    toUserIds.Add(sender.ToUserId);
                }

                foreach (var toUserId in toUserIds)
                {
                    //通知的对象排除掉自己
                    if (toUserId == sender.UserId)
                    {
                        continue;
                    }


                    Notice notice = Notice.New();
                    notice.UserId          = toUserId;
                    notice.ApplicationId   = 0;
                    notice.TypeId          = NoticeTypeIds.Instance().Reply();
                    notice.LeadingActor    = senderUser != null ? senderUser.DisplayName : "匿名用户";
                    notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(UserIdToUserNameDictionary.GetUserName(sender.UserId)));

                    notice.RelativeObjectName = StringUtility.Trim(commentedObject.Name, 60);
                    notice.RelativeObjectId   = sender.Id;
                    notice.RelativeObjectUrl  = SiteUrls.FullUrl(urlGetter.GetCommentDetailUrl(sender.CommentedObjectId, sender.Id, commentedObject.UserId)) ?? string.Empty;
                    notice.TemplateName       = sender.ParentId > 0 ? NoticeTemplateNames.Instance().NewReply() : NoticeTemplateNames.Instance().NewComment();
                    new NoticeService().Create(notice);
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 通知处理程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void BarPostNoticeModule_After(BarPost sender, AuditEventArgs eventArgs)
        {
            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;
                }

                long toUserId = barThread.UserId;

                //自己给自己的帖子进行回帖,不必通知
                if (sender.UserId == barThread.UserId)
                {
                    return;
                }

                if (sender.ParentId > 0)
                {
                    BarPostService barPostService = new BarPostService();
                    BarPost        parentPost     = barPostService.Get(sender.ParentId);

                    if (parentPost == null || (parentPost.UserId == sender.UserId))
                    {
                        return;
                    }
                    toUserId = parentPost.UserId;
                }

                NoticeService noticeService = Tunynet.DIContainer.Resolve <NoticeService>();
                Notice        notice        = Notice.New();

                notice.UserId             = toUserId;
                notice.ApplicationId      = BarConfig.Instance().ApplicationId;
                notice.TypeId             = NoticeTypeIds.Instance().Reply();
                notice.LeadingActorUserId = sender.UserId;
                notice.LeadingActor       = sender.Author;
                notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.UserId));
                notice.RelativeObjectId   = sender.PostId;
                notice.RelativeObjectName = HtmlUtility.TrimHtml(barThread.Subject, 64);
                notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().ThreadDetailGotoPost(sender.PostId));
                notice.TemplateName       = NoticeTemplateNames.Instance().NewReply();
                noticeService.Create(notice);
            }
        }
Exemplo n.º 7
0
        public static void Main()
        {
            Audit           testAudit = new Audit("AuditTrail.dat");
            BankTransaction testTran  = new BankTransaction(500);
            AuditEventArgs  testArg   = new AuditEventArgs(testTran);

            testAudit.RecordTransaction(null, testArg);

            BankTransaction testTran2 = new BankTransaction(-200);
            AuditEventArgs  testArg2  = new AuditEventArgs(testTran2);

            testAudit.RecordTransaction(null, testArg2);

            testAudit.Close();
        }
Exemplo n.º 8
0
        /// <summary>
        /// 动态处理程序
        /// </summary>
        /// <param name="blogThread"></param>
        /// <param name="eventArgs"></param>
        private void BlogThreadActivityModule_After(BlogThread blogThread, AuditEventArgs eventArgs)
        {
            //生成动态
            ActivityService activityService = new ActivityService();
            AuditService    auditService    = new AuditService();

            bool?auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

            if (auditDirection == true)
            {
                //初始化Owner为用户的动态
                Activity activityOfUser = Activity.New();
                activityOfUser.ActivityItemKey = ActivityItemKeys.Instance().CreateBlogThread();
                activityOfUser.ApplicationId   = BlogConfig.Instance().ApplicationId;

                //判断是否有图片、音频、视频
                AttachmentService        attachmentService = new AttachmentService(TenantTypeIds.Instance().BlogThread());
                IEnumerable <Attachment> attachments       = attachmentService.GetsByAssociateId(blogThread.ThreadId);
                if (attachments != null && attachments.Any(n => n.MediaType == MediaType.Image))
                {
                    activityOfUser.HasImage = true;
                }

                activityOfUser.HasMusic              = false;
                activityOfUser.HasVideo              = false;
                activityOfUser.IsOriginalThread      = !blogThread.IsReproduced;
                activityOfUser.IsPrivate             = blogThread.PrivacyStatus == PrivacyStatus.Private ? true : false;
                activityOfUser.UserId                = blogThread.UserId;
                activityOfUser.ReferenceId           = 0;
                activityOfUser.ReferenceTenantTypeId = string.Empty;
                activityOfUser.SourceId              = blogThread.ThreadId;
                activityOfUser.TenantTypeId          = TenantTypeIds.Instance().BlogThread();
                activityOfUser.OwnerId               = blogThread.UserId;
                activityOfUser.OwnerName             = blogThread.Author;
                activityOfUser.OwnerType             = ActivityOwnerTypes.Instance().User();

                //是否是公开的(用于是否推送站点动态)
                bool isPublic = blogThread.PrivacyStatus == PrivacyStatus.Public ? true : false;

                //生成动态
                activityService.Generate(activityOfUser, true, isPublic);
            }
            //删除动态
            else if (auditDirection == false)
            {
                activityService.DeleteSource(TenantTypeIds.Instance().BlogThread(), blogThread.ThreadId);
            }
        }
Exemplo n.º 9
0
 void AuditControl_AfterAudit(object sender, AuditEventArgs e)
 {
     if (e.Result == SMT.SaaS.FrameworkUI.AuditControl.AuditEventArgs.AuditResult.Auditing)
     {
         //this.Order.States = "审核中";
         MessageBox.Show("审核通过了");
         return;
     }
     else if (e.Result == SMT.SaaS.FrameworkUI.AuditControl.AuditEventArgs.AuditResult.Successful)
     {
         //this.Order.States = "审核通过";
     }
     else if (e.Result == SMT.SaaS.FrameworkUI.AuditControl.AuditEventArgs.AuditResult.Fail)
     {
         //this.Order.States = "审核不通过";
     }
 }
Exemplo n.º 10
0
        private void DoAuditResult(AuditResult result)
        {
            try
            {
                var dataResult = result.DataResult;
                curAuditEventArgs = null;
                if (result.FBEntity != null)
                {
                    var newOrderEntity = new OrderEntity(result.FBEntity);
                    if (result.DataResult == null)
                    {
                        MessageBox.Show("流程返回结果为空,请联系管理员:" + result.Successful.ToString());
                    }
                    else
                    {
                        if (!(result.DataResult.FlowResult == SMT.Saas.Tools.FlowWFService.FlowResult.SUCCESS ||
                              result.DataResult.FlowResult == SMT.Saas.Tools.FlowWFService.FlowResult.END))
                        {
                            newOrderEntity.IsReSubmit = this.OrderEntity.IsReSubmit;
                        }
                        this.orderEntity = newOrderEntity;

                        this.SaveFBEntity = null;
                    }
                }
                else
                {
                    orderEntity = null;
                }

                if (!string.IsNullOrEmpty(result.Exception))
                {
                    curAuditEventArgs = new AuditEventArgs(AuditEventArgs.AuditResult.Cancel, null);
                    CommonFunction.ShowErrorMessage(result.Exception);
                }
                else if (dataResult.FlowResult == SMT.Saas.Tools.FlowWFService.FlowResult.FAIL)
                {
                    curAuditEventArgs = new AuditEventArgs(AuditEventArgs.AuditResult.Error, null);
                    CommonFunction.ShowErrorMessage(dataResult.Err);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("流程返回结果后处理报错,请联系管理员:" + ex.ToString());
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 评论资讯动态处理程序
        /// </summary>
        /// <param name="comment"></param>
        /// <param name="eventArgs"></param>
        private void CmsCommentActivityEventModule_After(Comment comment, AuditEventArgs eventArgs)
        {
            NoticeService noticeService = new NoticeService();
            ContentItem   contentItem   = null;

            if (comment.TenantTypeId == TenantTypeIds.Instance().ContentItem())
            {
                //生成动态
                ActivityService activityService = new ActivityService();
                AuditService    auditService    = new AuditService();
                bool?           auditDirection  = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);
                if (auditDirection == true)
                {
                    //创建评论的动态[关注评论者的粉丝可以看到该评论]
                    Activity activity = Activity.New();
                    activity.ActivityItemKey = ActivityItemKeys.Instance().CreateCmsComment();
                    activity.ApplicationId   = CmsConfig.Instance().ApplicationId;

                    ContentItemService contentItemService = new ContentItemService();
                    contentItem = contentItemService.Get(comment.CommentedObjectId);
                    if (contentItem == null || contentItem.UserId == comment.UserId)
                    {
                        return;
                    }
                    activity.IsOriginalThread      = true;
                    activity.IsPrivate             = false;
                    activity.OwnerId               = comment.UserId;
                    activity.OwnerName             = comment.Author;
                    activity.OwnerType             = ActivityOwnerTypes.Instance().User();
                    activity.ReferenceId           = contentItem.ContentItemId;
                    activity.ReferenceTenantTypeId = TenantTypeIds.Instance().ContentItem();
                    activity.SourceId              = comment.Id;
                    activity.TenantTypeId          = TenantTypeIds.Instance().Comment();
                    activity.UserId = comment.UserId;

                    activityService.Generate(activity, false);
                }
                else if (auditDirection == false)
                {
                    activityService.DeleteSource(TenantTypeIds.Instance().Comment(), comment.Id);
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// 审核状态发生变化时处理积分
        /// </summary>
        /// <param name="blogThread">日志</param>
        /// <param name="eventArgs">事件</param>
        private void BlogThreadPointModule_After(BlogThread blogThread, AuditEventArgs eventArgs)
        {
            AuditService auditService = new AuditService();

            string pointItemKey       = string.Empty;
            string eventOperationType = string.Empty;

            bool?auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

            if (auditDirection == true) //加积分
            {
                pointItemKey = PointItemKeys.Instance().Blog_CreateThread();
                if (eventArgs.OldAuditStatus == null)
                {
                    eventOperationType = EventOperationType.Instance().Create();
                }
                else
                {
                    eventOperationType = EventOperationType.Instance().Approved();
                }
            }
            else if (auditDirection == false) //减积分
            {
                pointItemKey = PointItemKeys.Instance().Blog_DeleteThread();
                if (eventArgs.NewAuditStatus == null)
                {
                    eventOperationType = EventOperationType.Instance().Delete();
                }
                else
                {
                    eventOperationType = EventOperationType.Instance().Disapproved();
                }
            }

            if (!string.IsNullOrEmpty(pointItemKey))
            {
                PointService pointService = new PointService();

                string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "日志", blogThread.Subject);
                pointService.GenerateByRole(blogThread.UserId, pointItemKey, description);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 积分处理程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void BarPostPointModule_After(BarPost sender, AuditEventArgs eventArgs)
        {
            AuditService auditService   = new AuditService();
            bool?        auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

            string pointItemKey       = string.Empty;
            string eventOperationType = string.Empty;

            if (auditDirection == true) //加积分
            {
                pointItemKey = PointItemKeys.Instance().CreateComment();
                if (eventArgs.OldAuditStatus == null)
                {
                    eventOperationType = EventOperationType.Instance().Create();
                }
                else
                {
                    eventOperationType = EventOperationType.Instance().Approved();
                }
            }
            else if (auditDirection == false) //减积分
            {
                pointItemKey = PointItemKeys.Instance().DeleteComment();
                if (eventArgs.NewAuditStatus == null)
                {
                    eventOperationType = EventOperationType.Instance().Delete();
                }
                else
                {
                    eventOperationType = EventOperationType.Instance().Disapproved();
                }
            }

            if (!string.IsNullOrEmpty(pointItemKey))
            {
                PointService pointService = new PointService();


                string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "回帖", HtmlUtility.TrimHtml(sender.GetBody(), 32));
                pointService.GenerateByRole(sender.UserId, pointItemKey, description, eventOperationType == EventOperationType.Instance().Create() || eventOperationType == EventOperationType.Instance().Delete() && eventArgs.OperatorInfo.OperatorUserId == sender.UserId);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 动态处理程序
        /// </summary>
        private void PhotoActivityModule_After(Album album, AuditEventArgs eventArgs)
        {
            //生成动态
            ActivityService activityService = new ActivityService();
            AuditService    auditService    = new AuditService();

            bool?auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

            if (auditDirection == true)
            {
                //如果是新上传了照片,则更新最后修改时间
                if (activityService.UpdateLastModified(TenantTypeIds.Instance().Album(), album.AlbumId))
                {
                    return;
                }
                //初始化Owner为用户的动态
                Activity activity = Activity.New();
                activity.ActivityItemKey       = ActivityItemKeys.Instance().CreatePhoto();
                activity.ApplicationId         = PhotoConfig.Instance().ApplicationId;
                activity.HasImage              = true;
                activity.HasMusic              = false;
                activity.HasVideo              = false;
                activity.IsOriginalThread      = true;
                activity.IsPrivate             = album.PrivacyStatus == PrivacyStatus.Private ? true : false;
                activity.UserId                = album.UserId;
                activity.ReferenceId           = 0;
                activity.ReferenceTenantTypeId = string.Empty;
                activity.SourceId              = album.AlbumId;
                activity.TenantTypeId          = TenantTypeIds.Instance().Album();
                activity.OwnerId               = album.UserId;
                activity.OwnerName             = album.Author;
                activity.OwnerType             = ActivityOwnerTypes.Instance().User();
                //是否是公开的(用于是否推送站点动态)
                bool isPublic = album.PrivacyStatus == PrivacyStatus.Public ? true : false;

                activityService.Generate(activity, true, isPublic);
            }
            else if (auditDirection == false) //删除动态
            {
                activityService.DeleteSource(TenantTypeIds.Instance().Album(), album.AlbumId);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// 审核状态发生变化时处理积分
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void BarThreadPointModule_After(BarThread sender, AuditEventArgs eventArgs)
        {
            string          pointItemKey       = string.Empty;
            string          eventOperationType = string.Empty;
            ActivityService activityService    = new ActivityService();
            AuditService    auditService       = new AuditService();
            bool?           auditDirection     = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

            if (auditDirection == true) //加积分
            {
                pointItemKey = PointItemKeys.Instance().Bar_CreateThread();
                if (eventArgs.OldAuditStatus == null)
                {
                    eventOperationType = EventOperationType.Instance().Create();
                }
                else
                {
                    eventOperationType = EventOperationType.Instance().Approved();
                }
            }
            else if (auditDirection == false) //减积分
            {
                pointItemKey = PointItemKeys.Instance().Bar_DeleteThread();
                if (eventArgs.NewAuditStatus == null)
                {
                    eventOperationType = EventOperationType.Instance().Delete();
                }
                else
                {
                    eventOperationType = EventOperationType.Instance().Disapproved();
                }
            }
            if (!string.IsNullOrEmpty(pointItemKey))
            {
                PointService pointService = new PointService();



                string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "帖子", sender.Subject);
                pointService.GenerateByRole(sender.UserId, pointItemKey, description, eventOperationType == EventOperationType.Instance().Create() || eventOperationType == EventOperationType.Instance().Delete() && eventArgs.OperatorInfo.OperatorUserId == sender.UserId);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// 审核状态发生变化时处理积分
        /// </summary>
        /// <param name="sender">微博实体</param>
        /// <param name="eventArgs">时间参数</param>
        private void MicroblogPointModule_After(MicroblogEntity sender, AuditEventArgs eventArgs)
        {
            string          pointItemKey = string.Empty, eventOperationType = string.Empty;
            ActivityService activityService = new ActivityService();
            AuditService    auditService    = new AuditService();

            bool?auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

            if (auditDirection == true) //加积分
            {
                pointItemKey = PointItemKeys.Instance().Microblog_CreateMicroblog();
                if (eventArgs.OldAuditStatus == null)
                {
                    eventOperationType = EventOperationType.Instance().Create();
                }
                else
                {
                    eventOperationType = EventOperationType.Instance().Approved();
                }
            }
            else if (auditDirection == false) //减积分
            {
                pointItemKey = PointItemKeys.Instance().Microblog_DeleteMicroblog();
                if (eventArgs.NewAuditStatus == null)
                {
                    eventOperationType = EventOperationType.Instance().Delete();
                }
                else
                {
                    eventOperationType = EventOperationType.Instance().Disapproved();
                }
            }

            if (!string.IsNullOrEmpty(pointItemKey))
            {
                PointService pointService = new PointService();

                string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "微博", Tunynet.Utilities.HtmlUtility.TrimHtml(sender.Body, 15));
                pointService.GenerateByRole(sender.UserId, pointItemKey, description, eventOperationType == EventOperationType.Instance().Create() || eventOperationType == EventOperationType.Instance().Delete() && eventArgs.OperatorInfo.OperatorUserId == sender.UserId);
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// 审核状态发生变化时处理积分
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void GroupEntityPointModule_After(GroupEntity sender, AuditEventArgs eventArgs)
        {
            string          pointItemKey       = string.Empty;
            string          eventOperationType = string.Empty;
            string          description        = string.Empty;
            ActivityService activityService    = new ActivityService();
            AuditService    auditService       = new AuditService();
            PointService    pointService       = new PointService();
            bool?           auditDirection     = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

            if (auditDirection == true) //加积分
            {
                pointItemKey = PointItemKeys.Instance().Group_CreateGroup();
                if (eventArgs.OldAuditStatus == null)
                {
                    eventOperationType = EventOperationType.Instance().Create();
                }
                else
                {
                    eventOperationType = EventOperationType.Instance().Approved();
                }
            }
            else if (auditDirection == false) //减积分
            {
                pointItemKey = PointItemKeys.Instance().Group_DeleteGroup();
                if (eventArgs.NewAuditStatus == null)
                {
                    eventOperationType = EventOperationType.Instance().Delete();
                }
                else
                {
                    eventOperationType = EventOperationType.Instance().Disapproved();
                }
            }
            if (!string.IsNullOrEmpty(pointItemKey))
            {
                description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "群组", sender.GroupName);
            }
            pointService.GenerateByRole(sender.UserId, pointItemKey, description);
        }
Exemplo n.º 18
0
        /// <summary>
        /// 照片审核触发的事件
        /// </summary>
        private void PhotoPointModule_After(Photo photo, AuditEventArgs eventArgs)
        {
            AuditService auditService = new AuditService();

            string pointItemKey       = string.Empty;
            string eventOperationType = string.Empty;

            bool?auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

            if (auditDirection == true) //加积分
            {
                pointItemKey = PointItemKeys.Instance().Photo_UploadPhoto();
                if (eventArgs.OldAuditStatus == null)
                {
                    eventOperationType = EventOperationType.Instance().Create();
                }
                else
                {
                    eventOperationType = EventOperationType.Instance().Approved();
                }
            }
            else if (auditDirection == false) //减积分
            {
                pointItemKey = PointItemKeys.Instance().Photo_DeletePhoto();
                if (eventArgs.NewAuditStatus == null)
                {
                    eventOperationType = EventOperationType.Instance().Delete();
                }
                else
                {
                    eventOperationType = EventOperationType.Instance().Disapproved();
                }
            }

            if (!string.IsNullOrEmpty(pointItemKey))
            {
                string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "照片", HtmlUtility.TrimHtml(photo.Description, 64));
                pointService.GenerateByRole(photo.UserId, pointItemKey, description, eventOperationType == EventOperationType.Instance().Create() || eventOperationType == EventOperationType.Instance().Delete() && eventArgs.OperatorInfo.OperatorUserId == photo.UserId);
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// 评论动态处理
        /// </summary>
        /// <param name="comment"></param>
        /// <param name="eventArgs"></param>
        private void CommentActivityEventModule_After(Comment comment, AuditEventArgs eventArgs)
        {
            bool? auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);
            Photo photo          = null;

            if (comment.TenantTypeId == TenantTypeIds.Instance().Photo() && comment.UserId != comment.ToUserId)
            {
                if (auditDirection == true)
                {
                    photo = photoService.GetPhoto(comment.CommentedObjectId);
                    Activity activityOfFollower = Activity.New();
                    activityOfFollower.ActivityItemKey       = ActivityItemKeys.Instance().CommentPhoto();
                    activityOfFollower.ApplicationId         = PhotoConfig.Instance().ApplicationId;
                    activityOfFollower.HasImage              = false;
                    activityOfFollower.HasMusic              = false;
                    activityOfFollower.HasVideo              = false;
                    activityOfFollower.IsOriginalThread      = true;
                    activityOfFollower.IsPrivate             = photo.PrivacyStatus == PrivacyStatus.Private ? true : false;
                    activityOfFollower.UserId                = comment.UserId;
                    activityOfFollower.ReferenceId           = photo.PhotoId;
                    activityOfFollower.ReferenceTenantTypeId = TenantTypeIds.Instance().Photo();
                    activityOfFollower.SourceId              = comment.Id;
                    activityOfFollower.TenantTypeId          = TenantTypeIds.Instance().Comment();
                    activityOfFollower.OwnerId               = comment.UserId;
                    activityOfFollower.OwnerName             = comment.Author;
                    activityOfFollower.OwnerType             = ActivityOwnerTypes.Instance().User();

                    //是否是公开的(用于是否推送站点动态)
                    bool isPublic = photo.PrivacyStatus == PrivacyStatus.Public ? true : false;

                    activityService.Generate(activityOfFollower, true, isPublic);
                }
                else
                {
                    activityService.DeleteSource(TenantTypeIds.Instance().Comment(), comment.Id);
                }
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// 动态处理程序
        /// </summary>
        /// <param name="group"></param>
        /// <param name="eventArgs"></param>
        private void GroupEntityActivityModule_After(GroupEntity group, AuditEventArgs eventArgs)
        {
            //生成动态
            ActivityService activityService = new ActivityService();
            AuditService    auditService    = new AuditService();
            bool?           auditDirection  = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

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

                //生成Owner为用户的动态
                Activity actvityOfBar = Activity.New();
                actvityOfBar.ActivityItemKey       = ActivityItemKeys.Instance().CreateGroup();
                actvityOfBar.ApplicationId         = GroupConfig.Instance().ApplicationId;
                actvityOfBar.IsOriginalThread      = true;
                actvityOfBar.IsPrivate             = !group.IsPublic;
                actvityOfBar.UserId                = group.UserId;
                actvityOfBar.ReferenceId           = 0;//没有涉及到的实体
                actvityOfBar.ReferenceTenantTypeId = string.Empty;
                actvityOfBar.SourceId              = group.GroupId;
                actvityOfBar.TenantTypeId          = TenantTypeIds.Instance().Group();
                actvityOfBar.OwnerId               = group.UserId;
                actvityOfBar.OwnerName             = group.User.DisplayName;
                actvityOfBar.OwnerType             = ActivityOwnerTypes.Instance().User();

                activityService.Generate(actvityOfBar, true);
            }
            else if (auditDirection == false) //删除动态
            {
                activityService.DeleteSource(TenantTypeIds.Instance().Group(), group.GroupId);
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// 微博动态
        /// </summary>
        /// <param name="sender">微博实体</param>
        /// <param name="eventArgs">事件参数</param>
        private void MicroblogActivityModule_After(MicroblogEntity sender, AuditEventArgs eventArgs)
        {
            ActivityService activityService = new ActivityService();
            bool?           auditDirection  = new AuditService().ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

            if (auditDirection == true)
            {
                var microblogUrlGetter = MicroblogUrlGetterFactory.Get(sender.TenantTypeId);
                if (microblogUrlGetter == null)
                {
                    return;
                }

                Activity actvity = Activity.New();
                actvity.ActivityItemKey  = ActivityItemKeys.Instance().CreateMicroblog();
                actvity.ApplicationId    = MicroblogConfig.Instance().ApplicationId;
                actvity.HasImage         = sender.HasPhoto;
                actvity.HasMusic         = sender.HasMusic;
                actvity.HasVideo         = sender.HasVideo;
                actvity.IsOriginalThread = !sender.IsForward;
                actvity.IsPrivate        = false;
                actvity.SourceId         = sender.MicroblogId;
                actvity.TenantTypeId     = TenantTypeIds.Instance().Microblog();
                actvity.UserId           = sender.UserId;
                //生成Owner为用户的动态
                if (microblogUrlGetter.ActivityOwnerType == ActivityOwnerTypes.Instance().User())
                {
                    Activity actvityOfUser = Activity.New();
                    actvityOfUser.ActivityItemKey  = actvity.ActivityItemKey;
                    actvityOfUser.ApplicationId    = actvity.ApplicationId;
                    actvityOfUser.HasImage         = actvity.HasImage;
                    actvityOfUser.HasMusic         = actvity.HasMusic;
                    actvityOfUser.HasVideo         = actvity.HasVideo;
                    actvityOfUser.IsOriginalThread = actvity.IsOriginalThread;
                    actvityOfUser.IsPrivate        = actvity.IsPrivate;
                    actvityOfUser.UserId           = actvity.UserId;
                    actvityOfUser.ReferenceId      = actvity.ReferenceId;
                    actvityOfUser.SourceId         = actvity.SourceId;
                    actvityOfUser.TenantTypeId     = actvity.TenantTypeId;

                    actvityOfUser.OwnerId   = sender.UserId;
                    actvityOfUser.OwnerName = sender.User.DisplayName;
                    actvityOfUser.OwnerType = ActivityOwnerTypes.Instance().User();
                    activityService.Generate(actvityOfUser, true);
                }
                else
                {
                    actvity.OwnerId   = sender.OwnerId;
                    actvity.OwnerType = microblogUrlGetter.ActivityOwnerType;
                    actvity.OwnerName = microblogUrlGetter.GetOwnerName(sender.OwnerId);
                    activityService.Generate(actvity, false);

                    //生成Owner为用户的动态
                    if (!microblogUrlGetter.IsPrivate(sender.OwnerId))
                    {
                        Activity actvityOfUser = Activity.New();
                        actvityOfUser.ActivityItemKey  = actvity.ActivityItemKey;
                        actvityOfUser.ApplicationId    = actvity.ApplicationId;
                        actvityOfUser.HasImage         = actvity.HasImage;
                        actvityOfUser.HasMusic         = actvity.HasMusic;
                        actvityOfUser.HasVideo         = actvity.HasVideo;
                        actvityOfUser.IsOriginalThread = actvity.IsOriginalThread;
                        actvityOfUser.IsPrivate        = actvity.IsPrivate;
                        actvityOfUser.UserId           = actvity.UserId;
                        actvityOfUser.ReferenceId      = actvity.ReferenceId;
                        actvityOfUser.SourceId         = actvity.SourceId;
                        actvityOfUser.TenantTypeId     = actvity.TenantTypeId;

                        actvityOfUser.OwnerId   = sender.UserId;
                        actvityOfUser.OwnerName = sender.User.DisplayName;
                        actvityOfUser.OwnerType = ActivityOwnerTypes.Instance().User();
                        activityService.Generate(actvityOfUser, false);
                    }
                }
            }
            else if (auditDirection == false) //删除动态
            {
                activityService.DeleteSource(TenantTypeIds.Instance().Microblog(), sender.MicroblogId);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// 回答审核状态变更事件
        /// </summary>
        private void AskAnswerAuditEventModule_After(AskAnswer answer, AuditEventArgs eventArgs)
        {
            bool?auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

            //审核状态发生变化时处理积分
            string pointItemKey       = string.Empty;
            string eventOperationType = string.Empty;

            if (auditDirection == true) //加积分
            {
                pointItemKey = PointItemKeys.Instance().Ask_CreateAnswer();
                if (eventArgs.OldAuditStatus == null)
                {
                    eventOperationType = EventOperationType.Instance().Create();
                }
                else
                {
                    eventOperationType = EventOperationType.Instance().Approved();
                }
            }
            else if (auditDirection == false) //减积分
            {
                pointItemKey = PointItemKeys.Instance().Ask_DeleteAnswer();
                if (eventArgs.NewAuditStatus == null)
                {
                    eventOperationType = EventOperationType.Instance().Delete();
                }
                else
                {
                    eventOperationType = EventOperationType.Instance().Disapproved();
                }
            }

            if (!string.IsNullOrEmpty(pointItemKey))
            {
                AskQuestion question    = answer.Question;
                string      description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "回答", HtmlUtility.TrimHtml(answer.Body, 10));
                pointService.GenerateByRole(answer.UserId, pointItemKey, description, eventOperationType == EventOperationType.Instance().Create() || eventOperationType == EventOperationType.Instance().Delete());

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

            //审核状态发生变化时生成动态
            if (auditDirection == true)
            {
                AskQuestion question = answer.Question;

                //创建回答的动态[关注回答者的粉丝可以看到该回答]
                Activity activityOfFollower = Activity.New();
                activityOfFollower.ActivityItemKey = ActivityItemKeys.Instance().CreateAskAnswer();
                activityOfFollower.ApplicationId   = AskConfig.Instance().ApplicationId;
                //判断是否有图片、音频、视频
                AttachmentService        attachmentService = new AttachmentService(TenantTypeIds.Instance().AskAnswer());
                IEnumerable <Attachment> attachments       = attachmentService.GetsByAssociateId(answer.AnswerId);
                if (attachments != null && attachments.Any(n => n.MediaType == MediaType.Image))
                {
                    activityOfFollower.HasImage = true;
                }
                activityOfFollower.IsOriginalThread      = true;
                activityOfFollower.IsPrivate             = false;
                activityOfFollower.TenantTypeId          = TenantTypeIds.Instance().AskAnswer();
                activityOfFollower.SourceId              = answer.AnswerId;
                activityOfFollower.UserId                = answer.UserId;
                activityOfFollower.ReferenceId           = answer.QuestionId;
                activityOfFollower.ReferenceTenantTypeId = TenantTypeIds.Instance().AskQuestion();
                activityOfFollower.OwnerId               = answer.UserId;
                activityOfFollower.OwnerName             = answer.Author;
                activityOfFollower.OwnerType             = ActivityOwnerTypes.Instance().User();
                activityService.Generate(activityOfFollower, true);

                //创建回答的动态[关注该问题的用户可以看到该回答]
                Activity activityOfQuestionSubscriber = Activity.New();
                activityOfQuestionSubscriber.ActivityItemKey       = ActivityItemKeys.Instance().CreateAskAnswer();
                activityOfQuestionSubscriber.ApplicationId         = AskConfig.Instance().ApplicationId;
                activityOfQuestionSubscriber.HasImage              = activityOfFollower.HasImage;
                activityOfQuestionSubscriber.IsOriginalThread      = true;
                activityOfQuestionSubscriber.IsPrivate             = false;
                activityOfQuestionSubscriber.TenantTypeId          = TenantTypeIds.Instance().AskAnswer();
                activityOfQuestionSubscriber.SourceId              = answer.AnswerId;
                activityOfQuestionSubscriber.UserId                = answer.UserId;
                activityOfQuestionSubscriber.ReferenceId           = answer.QuestionId;
                activityOfQuestionSubscriber.ReferenceTenantTypeId = TenantTypeIds.Instance().AskQuestion();
                activityOfQuestionSubscriber.OwnerId               = question.QuestionId;
                activityOfQuestionSubscriber.OwnerName             = question.Subject;
                activityOfQuestionSubscriber.OwnerType             = ActivityOwnerTypes.Instance().AskQuestion();
                activityService.Generate(activityOfQuestionSubscriber, false);
            }
            else if (auditDirection == false)
            {
                activityService.DeleteSource(TenantTypeIds.Instance().AskAnswer(), answer.AnswerId);
            }
        }
Exemplo n.º 23
0
 void auditControl_Auditing(object sender, AuditEventArgs e)
 {
     ShowProcess();
     OnAuditing(sender, e);
 }
Exemplo n.º 24
0
 protected virtual void OnAuditing(object sender, AuditEventArgs e)
 {
 }
Exemplo n.º 25
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);
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// 评论日志动态处理程序
        /// </summary>
        /// <param name="comment"></param>
        /// <param name="eventArgs"></param>
        private void BlogCommentActivityEventModule_After(Comment comment, AuditEventArgs eventArgs)
        {
            NoticeService noticeService = new NoticeService();
            BlogThread    blogThread    = null;

            if (comment.TenantTypeId == TenantTypeIds.Instance().BlogThread())
            {
                //生成动态
                ActivityService activityService = new ActivityService();
                AuditService    auditService    = new AuditService();
                bool?           auditDirection  = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);
                if (auditDirection == true)
                {
                    //创建评论的动态[关注评论者的粉丝可以看到该评论]
                    Activity activity = Activity.New();
                    activity.ActivityItemKey = ActivityItemKeys.Instance().CreateBlogComment();
                    activity.ApplicationId   = BlogConfig.Instance().ApplicationId;

                    BlogService blogService = new BlogService();
                    blogThread = blogService.Get(comment.CommentedObjectId);
                    if (blogThread == null || blogThread.UserId == comment.UserId)
                    {
                        return;
                    }
                    activity.IsOriginalThread      = true;
                    activity.IsPrivate             = false;
                    activity.OwnerId               = comment.UserId;
                    activity.OwnerName             = comment.Author;
                    activity.OwnerType             = ActivityOwnerTypes.Instance().User();
                    activity.ReferenceId           = blogThread.ThreadId;
                    activity.ReferenceTenantTypeId = TenantTypeIds.Instance().BlogThread();
                    activity.SourceId              = comment.Id;
                    activity.TenantTypeId          = TenantTypeIds.Instance().Comment();
                    activity.UserId = comment.UserId;

                    //是否是公开的(用于是否推送站点动态)
                    bool isPublic = blogThread.PrivacyStatus == PrivacyStatus.Public ? true : false;
                    activityService.Generate(activity, false, isPublic);

                    //创建评论的动态[关注该日志的用户可以看到该评论]
                    Activity activityOfBlogComment = Activity.New();
                    activityOfBlogComment.ActivityItemKey       = activity.ActivityItemKey;
                    activityOfBlogComment.ApplicationId         = activity.ApplicationId;
                    activityOfBlogComment.IsOriginalThread      = activity.IsOriginalThread;
                    activityOfBlogComment.IsPrivate             = activity.IsPrivate;
                    activityOfBlogComment.ReferenceId           = activity.ReferenceId;
                    activityOfBlogComment.ReferenceTenantTypeId = activity.ReferenceTenantTypeId;
                    activityOfBlogComment.SourceId     = activity.SourceId;
                    activityOfBlogComment.TenantTypeId = activity.TenantTypeId;
                    activityOfBlogComment.UserId       = activity.UserId;

                    activityOfBlogComment.OwnerId   = blogThread.ThreadId;
                    activityOfBlogComment.OwnerName = blogThread.ResolvedSubject;
                    activityOfBlogComment.OwnerType = ActivityOwnerTypes.Instance().Blog();

                    activityService.Generate(activityOfBlogComment, false, isPublic);
                }
                else if (auditDirection == false)
                {
                    activityService.DeleteSource(TenantTypeIds.Instance().Comment(), comment.Id);
                }
            }
        }
 /// <summary>
 /// 增删改等触发的事件
 /// </summary>
 private void JournalsEventModule_After(Journal repair, AuditEventArgs eventArgs)
 {
     //todo:可以在这里处理动态、通知、积分
 }
Exemplo n.º 28
0
        /// <summary>
        /// 问题审核状态变更事件
        /// </summary>
        private void AskQuestionAuditEventModule_After(AskQuestion question, AuditEventArgs eventArgs)
        {
            bool?auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

            //审核状态发生变化时处理积分
            string pointItemKey       = string.Empty;
            string eventOperationType = string.Empty;

            if (auditDirection == true) //加积分
            {
                pointItemKey = PointItemKeys.Instance().Ask_CreateQuestion();
                if (eventArgs.OldAuditStatus == null)
                {
                    eventOperationType = EventOperationType.Instance().Create();
                }
                else
                {
                    eventOperationType = EventOperationType.Instance().Approved();
                }
            }
            else if (auditDirection == false) //减积分
            {
                pointItemKey = PointItemKeys.Instance().Ask_DeleteQuestion();
                if (eventArgs.NewAuditStatus == null)
                {
                    eventOperationType = EventOperationType.Instance().Delete();
                }
                else
                {
                    eventOperationType = EventOperationType.Instance().Disapproved();
                }
            }

            if (!string.IsNullOrEmpty(pointItemKey))
            {
                string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "问题", question.Subject);
                pointService.GenerateByRole(question.UserId, pointItemKey, description, eventOperationType == EventOperationType.Instance().Create() || eventOperationType == EventOperationType.Instance().Delete() && eventArgs.OperatorInfo.OperatorUserId == question.UserId);

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

            //审核状态发生变化时生成动态
            if (auditDirection == true)
            {
                //1.创建发布问题的动态[关注发布者的粉丝可以看到该动态]
                Activity activityOfFollower = Activity.New();
                activityOfFollower.ActivityItemKey = ActivityItemKeys.Instance().CreateAskQuestion();
                activityOfFollower.ApplicationId   = AskConfig.Instance().ApplicationId;
                //判断是否有图片、音频、视频
                AttachmentService        attachmentService = new AttachmentService(TenantTypeIds.Instance().AskQuestion());
                IEnumerable <Attachment> attachments       = attachmentService.GetsByAssociateId(question.QuestionId);
                if (attachments != null && attachments.Any(n => n.MediaType == MediaType.Image))
                {
                    activityOfFollower.HasImage = true;
                }
                activityOfFollower.IsOriginalThread      = true;
                activityOfFollower.IsPrivate             = false;
                activityOfFollower.TenantTypeId          = TenantTypeIds.Instance().AskQuestion();
                activityOfFollower.SourceId              = question.QuestionId;
                activityOfFollower.UserId                = question.UserId;
                activityOfFollower.ReferenceId           = 0;
                activityOfFollower.ReferenceTenantTypeId = string.Empty;
                activityOfFollower.OwnerId               = question.UserId;
                activityOfFollower.OwnerName             = question.Author;
                activityOfFollower.OwnerType             = ActivityOwnerTypes.Instance().User();
                activityService.Generate(activityOfFollower, true);

                //2.创建发布问题的动态[关注问题所属标签的用户可以看到该动态]
                Activity activityOfTagSubscriber = Activity.New();
                activityOfTagSubscriber.ActivityItemKey       = ActivityItemKeys.Instance().CreateAskQuestion();
                activityOfTagSubscriber.ApplicationId         = AskConfig.Instance().ApplicationId;
                activityOfTagSubscriber.HasImage              = activityOfFollower.HasImage;
                activityOfTagSubscriber.IsOriginalThread      = true;
                activityOfTagSubscriber.IsPrivate             = false;
                activityOfTagSubscriber.TenantTypeId          = TenantTypeIds.Instance().AskQuestion();
                activityOfTagSubscriber.SourceId              = question.QuestionId;
                activityOfTagSubscriber.UserId                = question.UserId;
                activityOfTagSubscriber.ReferenceId           = 0;
                activityOfTagSubscriber.ReferenceTenantTypeId = string.Empty;

                IEnumerable <Tag> tags = tagService.GetTopTagsOfItem(question.QuestionId, 100);
                foreach (var tag in tags)
                {
                    activityOfTagSubscriber.OwnerId   = tag.TagId;
                    activityOfTagSubscriber.OwnerName = tag.TagName;
                    activityOfTagSubscriber.OwnerType = ActivityOwnerTypes.Instance().AskTag();
                    activityService.Generate(activityOfTagSubscriber, false);
                }
            }
            //删除动态
            else if (auditDirection == false)
            {
                activityService.DeleteSource(TenantTypeIds.Instance().AskQuestion(), question.QuestionId);
            }
        }
Exemplo n.º 29
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.º 30
0
        /// <summary>
        /// 评论的相关事件处理
        /// </summary>
        private void CommentEventModule_After(Comment comment, AuditEventArgs eventArgs)
        {
            if (comment.TenantTypeId != TenantTypeIds.Instance().AskQuestion() && comment.TenantTypeId != TenantTypeIds.Instance().AskAnswer())
            {
                return;
            }

            bool?       auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);
            AskQuestion question       = null;

            //评论问题
            if (comment.TenantTypeId == TenantTypeIds.Instance().AskQuestion())
            {
                //生成动态
                if (auditDirection == true)
                {
                    question = askService.GetQuestion(comment.CommentedObjectId);
                    if (question.UserId != comment.UserId)
                    {
                        //创建评论的动态[关注评论者的粉丝可以看到该评论]
                        Activity activityOfFollower = Activity.New();
                        activityOfFollower.ActivityItemKey       = ActivityItemKeys.Instance().CommentAskQuestion();
                        activityOfFollower.ApplicationId         = AskConfig.Instance().ApplicationId;
                        activityOfFollower.IsOriginalThread      = true;
                        activityOfFollower.IsPrivate             = false;
                        activityOfFollower.TenantTypeId          = TenantTypeIds.Instance().Comment();
                        activityOfFollower.SourceId              = comment.Id;
                        activityOfFollower.UserId                = comment.UserId;
                        activityOfFollower.ReferenceId           = question.QuestionId;
                        activityOfFollower.ReferenceTenantTypeId = TenantTypeIds.Instance().AskQuestion();
                        activityOfFollower.OwnerId               = comment.UserId;
                        activityOfFollower.OwnerName             = comment.Author;
                        activityOfFollower.OwnerType             = ActivityOwnerTypes.Instance().User();
                        activityService.Generate(activityOfFollower, true);

                        //创建评论的动态[关注该问题的用户可以看到该评论]
                        Activity activityOfQuestionSubscriber = Activity.New();
                        activityOfQuestionSubscriber.ActivityItemKey       = ActivityItemKeys.Instance().CommentAskQuestion();
                        activityOfQuestionSubscriber.ApplicationId         = AskConfig.Instance().ApplicationId;
                        activityOfQuestionSubscriber.IsOriginalThread      = true;
                        activityOfQuestionSubscriber.IsPrivate             = false;
                        activityOfQuestionSubscriber.TenantTypeId          = TenantTypeIds.Instance().Comment();
                        activityOfQuestionSubscriber.SourceId              = comment.Id;
                        activityOfQuestionSubscriber.UserId                = comment.UserId;
                        activityOfQuestionSubscriber.ReferenceId           = question.QuestionId;
                        activityOfQuestionSubscriber.ReferenceTenantTypeId = TenantTypeIds.Instance().AskQuestion();
                        activityOfQuestionSubscriber.OwnerId               = question.QuestionId;
                        activityOfQuestionSubscriber.OwnerName             = question.Subject;
                        activityOfQuestionSubscriber.OwnerType             = ActivityOwnerTypes.Instance().AskQuestion();
                        activityService.Generate(activityOfQuestionSubscriber, false);
                    }
                }
                else if (auditDirection == false)
                {
                    activityService.DeleteSource(TenantTypeIds.Instance().Comment(), comment.Id);
                }
            }
            //评论回答
            else if (comment.TenantTypeId == TenantTypeIds.Instance().AskAnswer())
            {
                //生成动态
                if (auditDirection == true)
                {
                    AskAnswer answer = askService.GetAnswer(comment.CommentedObjectId);
                    question = answer.Question;
                    if (answer.UserId != comment.UserId)
                    {
                        //创建评论的动态[关注评论者的粉丝可以看到该评论]
                        Activity activityOfFollower = Activity.New();
                        activityOfFollower.ActivityItemKey       = ActivityItemKeys.Instance().CommentAskAnswer();
                        activityOfFollower.ApplicationId         = AskConfig.Instance().ApplicationId;
                        activityOfFollower.IsOriginalThread      = true;
                        activityOfFollower.IsPrivate             = false;
                        activityOfFollower.TenantTypeId          = TenantTypeIds.Instance().Comment();
                        activityOfFollower.SourceId              = comment.Id;
                        activityOfFollower.UserId                = comment.UserId;
                        activityOfFollower.ReferenceId           = answer.AnswerId;
                        activityOfFollower.ReferenceTenantTypeId = TenantTypeIds.Instance().AskAnswer();
                        activityOfFollower.OwnerId               = comment.UserId;
                        activityOfFollower.OwnerName             = comment.Author;
                        activityOfFollower.OwnerType             = ActivityOwnerTypes.Instance().User();
                        activityService.Generate(activityOfFollower, true);

                        //创建评论的动态[关注该问题的用户可以看到该评论]
                        Activity activityOfQuestionSubscriber = Activity.New();
                        activityOfQuestionSubscriber.ActivityItemKey       = ActivityItemKeys.Instance().CommentAskAnswer();
                        activityOfQuestionSubscriber.ApplicationId         = AskConfig.Instance().ApplicationId;
                        activityOfQuestionSubscriber.IsOriginalThread      = true;
                        activityOfQuestionSubscriber.IsPrivate             = false;
                        activityOfQuestionSubscriber.TenantTypeId          = TenantTypeIds.Instance().Comment();
                        activityOfQuestionSubscriber.SourceId              = comment.Id;
                        activityOfQuestionSubscriber.UserId                = comment.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);
                    }
                }
                else if (auditDirection == false)
                {
                    activityService.DeleteSource(TenantTypeIds.Instance().Comment(), comment.Id);
                }
            }

            ////关注的问题有新评论时,自动通知关注者
            //IEnumerable<long> userIds = subscribeService.GetUserIdsOfObject(question.QuestionId);
            //foreach (var userId in userIds)
            //{
            //    //通知的对象排除掉自己
            //    if (userId == comment.UserId)
            //    {
            //        continue;
            //    }

            //    Notice notice = Notice.New();
            //    notice.UserId = userId;
            //    notice.ApplicationId = AskConfig.Instance().ApplicationId;
            //    notice.TypeId = NoticeTypeIds.Instance().Hint();
            //    notice.LeadingActor = comment.Author;
            //    notice.LeadingActorUrl =SiteUrls.FullUrl(SiteUrls.Instance().AskUser(UserIdToUserNameDictionary.GetUserName(comment.UserId)));
            //    notice.RelativeObjectName = HtmlUtility.TrimHtml(question.Subject, 64);
            //    notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().AskQuestionDetail(question.QuestionId));
            //    notice.TemplateName = NoticeTemplateNames.Instance().NewAskComment();
            //    noticeService.Create(notice);
            //}

            //评论者自动关注该问题
            if (!subscribeService.IsSubscribed(question.QuestionId, comment.UserId))
            {
                subscribeService.Subscribe(question.QuestionId, comment.UserId);

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