/// <summary>
 /// 审核状态发生变化时处理积分
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="eventArgs"></param>
 private void TopicEntityPointModule_After(TopicEntity 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().Topic_CreateTopic();
         if (eventArgs.OldAuditStatus == null)
             eventOperationType = EventOperationType.Instance().Create();
         else
             eventOperationType = EventOperationType.Instance().Approved();
     }
     else if (auditDirection == false) //减积分
     {
         pointItemKey = PointItemKeys.Instance().Topic_DeleteTopic();
         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.TopicName);
     }
     pointService.GenerateByRole(sender.UserId, pointItemKey, description, eventOperationType == EventOperationType.Instance().Create() || eventOperationType == EventOperationType.Instance().Delete() && eventArgs.OperatorInfo.OperatorUserId == sender.UserId);
 }
 /// <summary>
 /// 检查用户是否接收动态
 /// </summary>
 /// <param name="activityService"></param>
 /// <param name="isPublic">群组是否为公开群组</param>
 /// <param name="userId">UserId</param>
 /// <param name="activity">动态</param>
 /// <returns>接收动态返回true,否则返回false</returns>
 private bool IsReceiveActivity(ActivityService activityService, bool isPublic, long userId, Activity activity)
 {
     if (isPublic)
     {
         //检查用户是否已在信息发布者的粉丝圈里面
         FollowService followService = new FollowService();
         if (followService.IsFollowed(userId, activity.UserId))
             return false;
     }
     //检查用户是否已屏蔽群组
     if (new UserBlockService().IsBlockedGroup(userId, activity.OwnerId))
         return false;
     //检查用户是否接收该动态项目
     Dictionary<string, bool> userSettings = activityService.GetActivityItemUserSettings(userId);
     if (userSettings.ContainsKey(activity.ActivityItemKey))
         return userSettings[activity.ActivityItemKey];
     else
     {
         //如果用户没有设置从默认设置获取
         ActivityItem activityItem = activityService.GetActivityItem(activity.ActivityItemKey);
         if (activityItem != null)
             return activityItem.IsUserReceived;
         else
             return true;
     }
 }
        /// <summary>
        /// 动态处理程序
        /// </summary>
        /// <param name="group"></param>
        /// <param name="eventArgs"></param>
        private void TopicEntityActivityModule_After(TopicEntity 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().CreateTopic();
                actvityOfBar.ApplicationId = TopicConfig.Instance().ApplicationId;
                actvityOfBar.IsOriginalThread = true;
                actvityOfBar.IsPrivate = !group.IsPublic;
                actvityOfBar.UserId = group.UserId;
                actvityOfBar.ReferenceId = 0;//没有涉及到的实体
                actvityOfBar.ReferenceTenantTypeId = string.Empty;
                actvityOfBar.SourceId = group.TopicId;
                actvityOfBar.TenantTypeId = TenantTypeIds.Instance().Topic();
                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().Topic(), group.TopicId);
            }
        }
 /// <summary>
 /// 获取接收人UserId集合
 /// </summary>
 /// <param name="activityService">动态业务逻辑类</param>
 /// <param name="ownerId">动态拥有者Id</param>
 /// <param name="userId">动态发布者Id</param>
 /// <param name="activityItemKey">动态项目标识</param>
 /// <returns></returns>
 IEnumerable<long> IActivityReceiverGetter.GetReceiverUserIds(ActivityService activityService, Activity activity)
 {
     SubscribeService subscribeService = new SubscribeService(TenantTypeIds.Instance().BlogThread());
     IEnumerable<long> followerUserIds = subscribeService.GetUserIdsOfObject(activity.OwnerId);
     if (followerUserIds == null)
         return new List<long>();
     return followerUserIds.Where(n => IsReceiveActivity(activityService, n, activity));
 }
        /// <summary>
        /// 检查用户是否接收动态
        /// </summary>
        /// <param name="userId">UserId</param>
        /// <param name="activityItemKey">动态项目标识</param>
        /// <param name="fromOwnerId">动态拥有者</param>
        /// <returns>接收动态返回true,否则返回false</returns>
        private bool IsReceiveActivity(ActivityService activityService, long userId, Activity activity)
        {
            //首先检查是否屏蔽用户
            UserBlockService userBlockService = new UserBlockService();

            if (userBlockService.IsBlockedUser(userId, activity.OwnerId))
            {
                return(false);
            }

            //被验证用户为黑名单用户
            PrivacyService privacyService = new PrivacyService();

            if (privacyService.IsStopedUser(activity.OwnerId, userId))
            {
                return(false);
            }

            //判断指定对象可见
            Dictionary <int, IEnumerable <ContentPrivacySpecifyObject> > dictionary = new ContentPrivacyService().GetPrivacySpecifyObjects(activity.TenantTypeId, activity.SourceId);

            if (dictionary != null && dictionary.Count() > 0)
            {
                foreach (var pair in dictionary)
                {
                    IPrivacySpecifyObjectValidator privacySpecifyUserGetter = DIContainer.ResolveNamed <IPrivacySpecifyObjectValidator>(pair.Key.ToString());
                    foreach (var specifyObject in pair.Value)
                    {
                        if (privacySpecifyUserGetter.Validate(activity.OwnerId, userId, specifyObject.SpecifyObjectId))
                        {
                            return(true);
                        }
                    }
                }
                return(false);
            }

            //检查用户是否接收该动态项目
            Dictionary <string, bool> userSettings = activityService.GetActivityItemUserSettings(userId);

            if (userSettings.ContainsKey(activity.ActivityItemKey))
            {
                return(userSettings[activity.ActivityItemKey]);
            }
            else
            {
                //如果用户没有设置从默认设置获取
                ActivityItem activityItem = activityService.GetActivityItem(activity.ActivityItemKey);
                if (activityItem != null)
                {
                    return(activityItem.IsUserReceived);
                }
                else
                {
                    return(true);
                }
            }
        }
        /// <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);
            }
        }
 //done:zhengw,by mazq 缺少注释
 //zhengw回复:已修改
 /// <summary>
 /// 获取接收人UserId集合
 /// </summary>
 /// <param name="activityService">动态业务逻辑类</param>
 /// <param name="activity">动态</param>
 /// <returns></returns>
 IEnumerable<long> IActivityReceiverGetter.GetReceiverUserIds(ActivityService activityService, Activity activity)
 {
     //1、获取用户的所有粉丝,然后通过IsReceiveActivity()检查,是否给该粉丝推送动态;
     FollowService followService = new FollowService();
     IEnumerable<long> followerUserIds = followService.GetTopFollowerUserIds(activity.OwnerId, Follow_SortBy.DateCreated_Desc, ValueUtility.GetSqlMaxInt());
     if (followerUserIds == null)
         return new List<long>();
     return followerUserIds.Where(n => IsReceiveActivity(activityService, n, activity));
 }
Beispiel #8
0
        /// <summary>
        /// 动态处理程序
        /// </summary>
        /// <param name="groupMember"></param>
        /// <param name="eventArgs"></param>
        private void GroupMemberActivityModule_After(GroupMember groupMember, CommonEventArgs eventArgs)
        {
            ActivityService activityService = new ActivityService();
            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                //生成动态
                if (groupMember == null)
                    return;
                var group = new GroupService().Get(groupMember.GroupId);
                if (group == null)
                    return;
                //生成Owner为群组的动态
                Activity actvityOfGroup = Activity.New();
                actvityOfGroup.ActivityItemKey = ActivityItemKeys.Instance().CreateGroupMember();
                actvityOfGroup.ApplicationId = GroupConfig.Instance().ApplicationId;
                actvityOfGroup.IsOriginalThread = true;
                actvityOfGroup.IsPrivate = !group.IsPublic;
                actvityOfGroup.UserId = groupMember.UserId;
                actvityOfGroup.ReferenceId = 0;
                actvityOfGroup.ReferenceTenantTypeId = string.Empty;
                actvityOfGroup.SourceId = groupMember.Id;
                actvityOfGroup.TenantTypeId = TenantTypeIds.Instance().User();
                actvityOfGroup.OwnerId = group.GroupId;
                actvityOfGroup.OwnerName = group.GroupName;
                actvityOfGroup.OwnerType = ActivityOwnerTypes.Instance().Group();

                activityService.Generate(actvityOfGroup, false);

                //生成Owner为用户的动态
                Activity actvityOfUser = Activity.New();
                actvityOfUser.ActivityItemKey = ActivityItemKeys.Instance().JoinGroup();
                actvityOfUser.ApplicationId = actvityOfGroup.ApplicationId;
                actvityOfUser.HasImage = actvityOfGroup.HasImage;
                actvityOfUser.HasMusic = actvityOfGroup.HasMusic;
                actvityOfUser.HasVideo = actvityOfGroup.HasVideo;
                actvityOfUser.IsOriginalThread = actvityOfGroup.IsOriginalThread;
                actvityOfUser.IsPrivate = actvityOfGroup.IsPrivate;
                actvityOfUser.UserId = actvityOfGroup.UserId;
                actvityOfUser.ReferenceId = actvityOfGroup.ReferenceId;
                actvityOfGroup.ReferenceTenantTypeId = actvityOfGroup.ReferenceTenantTypeId;
                actvityOfUser.SourceId = actvityOfGroup.SourceId;

                actvityOfUser.TenantTypeId = actvityOfGroup.TenantTypeId;
                actvityOfUser.OwnerId = groupMember.UserId;
                actvityOfUser.OwnerName = groupMember.User.DisplayName;
                actvityOfUser.OwnerType = ActivityOwnerTypes.Instance().User();
                activityService.Generate(actvityOfUser, false);
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete()) //删除动态
            {
                activityService.DeleteSource(TenantTypeIds.Instance().User(), groupMember.UserId);
            }
        }
 /// <summary>
 /// 获取接收人UserId集合
 /// </summary>
 /// <param name="activityService">动态业务逻辑类</param>
 /// <param name="activity">动态</param>
 /// <returns></returns>
 IEnumerable<long> IActivityReceiverGetter.GetReceiverUserIds(ActivityService activityService, Activity activity)
 {
     GroupService groupService = new GroupService();
     IEnumerable<long> userIds = groupService.GetUserIdsOfGroup(activity.OwnerId);
     bool isPublic = false;
     var group = groupService.Get(activity.OwnerId);
     if (group != null)
         isPublic = group.IsPublic;
     if (userIds == null)
         return new List<long>();
     return userIds.Where(n => IsReceiveActivity(activityService, isPublic, n, activity));
 }
Beispiel #10
0
        //done:zhengw,by mazq 缺少注释
        //zhengw回复:已修改

        /// <summary>
        /// 获取接收人UserId集合
        /// </summary>
        /// <param name="activityService">动态业务逻辑类</param>
        /// <param name="activity">动态</param>
        /// <returns></returns>
        IEnumerable <long> IActivityReceiverGetter.GetReceiverUserIds(ActivityService activityService, Activity activity)
        {
            //1、获取用户的所有粉丝,然后通过IsReceiveActivity()检查,是否给该粉丝推送动态;
            FollowService      followService   = new FollowService();
            IEnumerable <long> followerUserIds = followService.GetTopFollowerUserIds(activity.OwnerId, Follow_SortBy.DateCreated_Desc, ValueUtility.GetSqlMaxInt());

            if (followerUserIds == null)
            {
                return(new List <long>());
            }
            return(followerUserIds.Where(n => IsReceiveActivity(activityService, n, activity)));
        }
        /// <summary>
        /// 生成动态操作链接
        /// </summary>       
        public static MvcHtmlString ActivityOperation(this HtmlHelper htmlHelper, long activityId)
        {
            if (activityId <= 0)
                return MvcHtmlString.Empty;

            var activity = new ActivityService().Get(activityId);
            if (activity == null)
                return MvcHtmlString.Empty;
            bool isSiteActivity = htmlHelper.ViewContext.HttpContext.Request.QueryString.Get<bool>("isSiteActivity");
            bool isOwnerActivity = htmlHelper.ViewContext.HttpContext.Request.QueryString.Get<bool>("isOwnerActivity");
            var user = DIContainer.Resolve<IUserService>().GetUser(activity.UserId);
            return htmlHelper.DisplayForModel("ActivityOperation", new { activity = activity, isSiteActivity = isSiteActivity, isOwnerActivity = isOwnerActivity, user = user });
        }
 /// <summary>
 /// 屏蔽用户/取消屏蔽时动态处理
 /// </summary>
 /// <param name="sender">关注实体</param>
 /// <param name="eventArgs">事件参数</param>
 void UserBlockedObjectActivityEventModule_After(UserBlockedObject sender, CommonEventArgs eventArgs)
 {
     int ownerType = -1;
     if (sender.ObjectType == BlockedObjectTypes.Instance().User())
         ownerType = ActivityOwnerTypes.Instance().User();
     else if (sender.ObjectType == BlockedObjectTypes.Instance().Group())
         ownerType = ActivityOwnerTypes.Instance().Group();
     else
         return;
     ActivityService activityService = new ActivityService();
     if (EventOperationType.Instance().Create() == eventArgs.EventOperationType)
     {
         activityService.RemoveInboxAboutOwner(sender.UserId, sender.ObjectId, ownerType);
     }
     else if (EventOperationType.Instance().Delete() == eventArgs.EventOperationType)
     {
         activityService.TraceBackInboxAboutOwner(sender.UserId, sender.ObjectId, ownerType);
     }
 }
        /// <summary>
        /// 检查用户是否接收动态
        /// </summary>
        /// <param name="userId">UserId</param>
        /// <param name="activityItemKey">动态项目标识</param>
        /// <param name="fromOwnerId">动态拥有者</param>
        /// <returns>接收动态返回true,否则返回false</returns>
        private bool IsReceiveActivity(ActivityService activityService, long userId, Activity activity)
        {
            //首先检查是否屏蔽用户
            UserBlockService userBlockService = new UserBlockService();
            if (userBlockService.IsBlockedUser(userId, activity.OwnerId))
                return false;

            //被验证用户为黑名单用户
            PrivacyService privacyService = new PrivacyService();
            if (privacyService.IsStopedUser(activity.OwnerId, userId))
                return false;

            //判断指定对象可见
            Dictionary<int, IEnumerable<ContentPrivacySpecifyObject>> dictionary = new ContentPrivacyService().GetPrivacySpecifyObjects(activity.TenantTypeId, activity.SourceId);
            if (dictionary != null && dictionary.Count() > 0)
            {
                foreach (var pair in dictionary)
                {
                    IPrivacySpecifyObjectValidator privacySpecifyUserGetter = DIContainer.ResolveNamed<IPrivacySpecifyObjectValidator>(pair.Key.ToString());
                    foreach (var specifyObject in pair.Value)
                    {
                        if (privacySpecifyUserGetter.Validate(activity.OwnerId, userId, specifyObject.SpecifyObjectId))
                            return true;
                    }
                }
                return false;
            }

            //检查用户是否接收该动态项目
            Dictionary<string, bool> userSettings = activityService.GetActivityItemUserSettings(userId);
            if (userSettings.ContainsKey(activity.ActivityItemKey))
                return userSettings[activity.ActivityItemKey];
            else
            {
                //如果用户没有设置从默认设置获取
                ActivityItem activityItem = activityService.GetActivityItem(activity.ActivityItemKey);
                if (activityItem != null)
                    return activityItem.IsUserReceived;
                else
                    return true;
            }
        }
 //todo:mazq,by zhengw:走查以下代码:用户关注帖吧时,要追溯该帖吧的动态
 /// <summary>
 /// 关注帖吧事件处理程序
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="eventArgs"></param>
 void SubscribeBarSectionEventModule_After(long sender, SubscribeEventArgs eventArgs)
 {
     if (eventArgs.TenantTypeId != TenantTypeIds.Instance().BarSection())
         return;
     ActivityService activityService = new ActivityService();
     if (EventOperationType.Instance().Create() == eventArgs.EventOperationType)
     {
         activityService.TraceBackInboxAboutOwner(eventArgs.UserId, sender, ActivityOwnerTypes.Instance().BarSection());
         //用户内容计数
         OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
         ownerDataService.Change(eventArgs.UserId, OwnerDataKeys.Instance().FollowSectionCount(), 1);
     }
     else if (EventOperationType.Instance().Delete() == eventArgs.EventOperationType)
     {
         activityService.RemoveInboxAboutOwner(eventArgs.UserId, sender, ActivityOwnerTypes.Instance().BarSection());
         //用户内容计数
         OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
         ownerDataService.Change(eventArgs.UserId, OwnerDataKeys.Instance().FollowSectionCount(), -1);
     }
 }
        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);
            }
        }
Beispiel #16
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);
            }
        }
Beispiel #17
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);
                }
            }
        }
Beispiel #18
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);
            }
        }
Beispiel #19
0
        /// <summary>
        /// 隐私状态发生变化时,同时更新动态的私有状态
        /// </summary>
        /// <param name="blogThread">日志</param>
        /// <param name="eventArgs">事件</param>
        private void BlogThreadAcitivityPrivicyChangeEventModule_After(BlogThread blogThread, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType == EventOperationType.Instance().Create() ||
            eventArgs.EventOperationType == EventOperationType.Instance().Update())
            {
                ActivityService activityService = new ActivityService();
                Activity activity = activityService.Get(TenantTypeIds.Instance().BlogThread(), blogThread.ThreadId);
                if (activity == null)
                {
                    return;
                }

                bool newIsPrivate = blogThread.PrivacyStatus == PrivacyStatus.Private ? true : false;
                //是否是公开的(用于是否推送站点动态)
                bool isPublic = blogThread.PrivacyStatus == PrivacyStatus.Public ? true : false;
                if (activity.IsPrivate != newIsPrivate)
                {
                    activityService.UpdatePrivateStatus(activity.ActivityId, newIsPrivate,isPublic);
                }
            }
        }
Beispiel #20
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);
            }
        }
Beispiel #21
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);
            }
        }
        public ActionResult _NewActivity()
        {
            long microblogId = Request.QueryString.Get<long>("microblogId", 0);
            if (microblogId <= 0)
                return new EmptyResult();
            Activity activity = new ActivityService().Get(TenantTypeIds.Instance().Microblog(), microblogId);
            if (activity == null)
                return new EmptyResult();
            if (UserContext.CurrentUser == null || activity.UserId != UserContext.CurrentUser.UserId)
                return new EmptyResult();

            MicroblogEntity entity = microBlogService.Get(activity.SourceId);
            ViewData["ActivityId"] = activity.ActivityId;
            return View("_Microblog", entity);
        }
        private void DeleteUserEventMoudle_After(IUser sender, DeleteUserEventArgs eventArgs)
        {
            IUserService userService = DIContainer.Resolve<IUserService>();

            #region 数据
            //清除应用数据
            applicationService.DeleteUser(sender.UserId, eventArgs.TakeOverUserName, eventArgs.TakeOverAll);

            //删除用户信息
            new UserProfileService().Delete(sender.UserId);

            //清除用户内容计数数据
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
            ownerDataService.ClearOwnerData(sender.UserId);

            //清除用户关于分类的数据
            CategoryService categoryService = new CategoryService();
            categoryService.CleanByUser(sender.UserId);

            //清除用户动态
            ActivityService activityService = new ActivityService();
            activityService.CleanByUser(sender.UserId);

            //清除用户评论
            new CommentService().DeleteUserComments(sender.UserId, false);

            #endregion

            #region 消息

            //清除用户关于私信的数据
            MessageService messageService = new MessageService();
            messageService.ClearSessionsFromUser(sender.UserId);

            //清除请求的用户数据
            InvitationService invitationService = new InvitationService();
            invitationService.CleanByUser(sender.UserId);

            //清除通知的用户数据
            NoticeService noticeService = new NoticeService();
            noticeService.CleanByUser(sender.UserId);

            InviteFriendService inviteFriendService = new InviteFriendService();
            inviteFriendService.CleanByUser(sender.UserId);

            //清除站外提醒的用户数据
            ReminderService reminderService = new ReminderService();
            reminderService.CleanByUser(sender.UserId);

            #endregion

            #region 关注/访客

            //清除用户关于关注用户的数据
            FollowService followService = new FollowService();
            followService.CleanByUser(sender.UserId);

            //清除访客记录的用户数据
            VisitService visitService = new VisitService(string.Empty);
            visitService.CleanByUser(sender.UserId);

            #endregion

            #region 帐号

            //清除帐号绑定数据
            var accountBindingService = new AccountBindingService();
            var accountBindings = new AccountBindingService().GetAccountBindings(sender.UserId);
            foreach (var accountBinding in accountBindings)
            {
                accountBindingService.DeleteAccountBinding(accountBinding.UserId, accountBinding.AccountTypeKey);
            }

            #endregion

            #region 装扮

            //调整皮肤文件使用次数
            var user = userService.GetFullUser(sender.UserId);
            if (user == null)
                return;
            var presentArea = new PresentAreaService().Get(PresentAreaKeysOfBuiltIn.UserSpace);
            string defaultThemeAppearance = string.Join(",", presentArea.DefaultThemeKey, presentArea.DefaultAppearanceKey);
            if (!user.IsUseCustomStyle)
                new ThemeService().ChangeThemeAppearanceUserCount(PresentAreaKeysOfBuiltIn.UserSpace, null, !string.IsNullOrEmpty(user.ThemeAppearance) ? user.ThemeAppearance : defaultThemeAppearance);

            #endregion
        }
Beispiel #24
0
        /// <summary>
        /// 关注用户动态
        /// </summary>
        /// <param name="activityId"></param>
        /// <returns></returns>
        public ActionResult _FollowUserActivity(long activityId)
        {
            ActivityService activityService = new ActivityService();
            Activity activity = activityService.Get(activityId);

            if (activity == null)
                return Content(string.Empty);

            IUser user = userService.GetUser(activity.OwnerId);
            if (user == null)
                return Content(string.Empty);

            IUser currentUser = UserContext.CurrentUser;
            IEnumerable<long> followedUserIds = followService.GetTopFollowedUserIds(user.UserId, 5, null, Follow_SortBy.DateCreated_Desc);
            var followedUsers = userService.GetFullUsers(followedUserIds).ToList();
            if (followedUsers.Count == 0)
            {
                return new EmptyResult();
            }

            ViewData["FollowUsers"] = followedUsers;
            ViewData["ActivityUserId"] = activity.UserId;

            return View(activity);
        }
        /// <summary>
        /// 关注用户/取消关注动态处理
        /// </summary>
        /// <param name="sender">关注实体</param>
        /// <param name="eventArgs">事件参数</param>
        void FollowActivityEventModule_After(FollowEntity sender, CommonEventArgs eventArgs)
        {
            ActivityService activityService = new ActivityService();
            if (EventOperationType.Instance().Create() == eventArgs.EventOperationType)
            {

                IUser user = DIContainer.Resolve<UserService>().GetUser(sender.UserId);
                if (user == null) return;

                Activity activity = Activity.New();

                activity.ActivityItemKey = ActivityItemKeys.Instance().FollowUser();
                activity.OwnerType = ActivityOwnerTypes.Instance().User();
                activity.OwnerId = sender.UserId;
                activity.OwnerName = user.DisplayName;
                activity.UserId = sender.UserId;
                activity.ReferenceId = sender.FollowedUserId;
                activity.TenantTypeId = TenantTypeIds.Instance().User();

                activityService.Generate(activity, false);

                activityService.TraceBackInboxAboutOwner(sender.UserId, sender.FollowedUserId, ActivityOwnerTypes.Instance().User());
            }
            else if (EventOperationType.Instance().Delete() == eventArgs.EventOperationType)
            {
                activityService.RemoveInboxAboutOwner(sender.UserId, sender.FollowedUserId, ActivityOwnerTypes.Instance().User());
            }
        }
        /// <summary>
        /// 创建资讯评论的动态块
        /// </summary>
        /// <param name="ActivityId"></param>
        /// <returns></returns>
        //[DonutOutputCache(CacheProfile = "Frequently")]
        public ActionResult _CreateCmsComment(long ActivityId)
        {
            Activity activity = new ActivityService().Get(ActivityId);
            if (activity == null)
                return Content(string.Empty);

            ContentItem contentItem = contentItemService.Get(activity.ReferenceId);
            if (contentItem == null)
                return Content(string.Empty);
            IEnumerable<Attachment> attachments = new AttachmentService(TenantTypeIds.Instance().ContentItem()).GetsByAssociateId(contentItem.ContentItemId);
            if (attachments != null && attachments.Count() > 0)
            {
                IEnumerable<Attachment> attachmentImages = attachments.Where(n => n.MediaType == MediaType.Image);
                if (attachmentImages != null && attachmentImages.Count() > 0)
                    ViewData["Attachments"] = attachmentImages.FirstOrDefault();
            }

            Comment comment = commentService.Get(activity.SourceId);
            if (comment == null)
                return Content(string.Empty);

            ViewData["contentItem"] = contentItem;
            ViewData["ActivityId"] = ActivityId;
            return View(comment);
        }