コード例 #1
0
        private void BarPost_After(BarPost barPost, CommonEventArgs commonEventArgs)
        {
            if (barPost == null)
            {
                return;
            }

            if (barSearcher == null)
            {
                barSearcher = (BarSearcher)SearcherFactory.GetSearcher(BarSearcher.CODE);
            }

            //添加索引
            if (commonEventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                barSearcher.InsertBarPost(barPost);
            }

            //删除索引
            if (commonEventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                barSearcher.DeleteBarPost(barPost.PostId);
            }

            //更新索引
            if (commonEventArgs.EventOperationType == EventOperationType.Instance().Update())
            {
                barSearcher.UpdateBarPost(barPost);
            }
        }
コード例 #2
0
        /// <summary>
        /// 取消关注后更新缓存
        /// </summary>
        /// <param name="sender">关注实体</param>
        /// <param name="eventArgs">事件参数</param>
        void CancelFollowEventModule_After(FollowEntity sender, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                CategoryService service = new CategoryService();
                service.ClearCategoriesFromItem(sender.Id, sender.UserId, TenantTypeIds.Instance().User());

                //更新用户缓存
                ICacheService cacheService = DIContainer.Resolve<ICacheService>();
                RealTimeCacheHelper realTimeCacheHelper = EntityData.ForType(typeof(User)).RealTimeCacheHelper;
                if (cacheService.EnableDistributedCache)
                {
                    realTimeCacheHelper.IncreaseEntityCacheVersion(sender.UserId);
                }
                else
                {
                    string cacheKey = realTimeCacheHelper.GetCacheKeyOfEntity(sender.UserId);
                    User user = cacheService.Get<User>(cacheKey);
                    if (user != null && user.FollowedCount > 0)
                    {
                        user.FollowedCount--;
                    }
                }
            }
        }
コード例 #3
0
        private void MicroblogEntity_After(MicroblogEntity microblogEntity, CommonEventArgs commonEventArgs)
        {
            if (microblogEntity == null)
            {
                return;
            }

            if (microblogSearcher == null)
            {
                microblogSearcher = (MicroblogSearcher)SearcherFactory.GetSearcher(MicroblogSearcher.CODE);
            }

            //添加索引
            if (commonEventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                microblogSearcher.Insert(microblogEntity);
            }

            //删除索引
            if (commonEventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                microblogSearcher.Delete(microblogEntity.MicroblogId);
            }

            //更新索引
            if (commonEventArgs.EventOperationType == EventOperationType.Instance().Update() || commonEventArgs.EventOperationType == EventOperationType.Instance().Approved() || commonEventArgs.EventOperationType == EventOperationType.Instance().Disapproved())
            {
                microblogSearcher.Update(microblogEntity);
            }
        }
コード例 #4
0
ファイル: CmsIndexEventModule.cs プロジェクト: hbulzy/SYS
        /// <summary>
        /// 资讯增量索引
        /// </summary>
        private void ContentItem_After(ContentItem cms, CommonEventArgs eventArgs)
        {
            if (cms == null)
            {
                return;
            }

            if (cmsSearcher == null)
            {
                cmsSearcher = (CmsSearcher)SearcherFactory.GetSearcher(CmsSearcher.CODE);
            }

            //添加索引
            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                cmsSearcher.Insert(cms);
            }

            //删除索引
            if (eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                cmsSearcher.Delete(cms.ContentItemId);
            }

            //更新索引
            if (eventArgs.EventOperationType == EventOperationType.Instance().Update() || eventArgs.EventOperationType == EventOperationType.Instance().Approved() || eventArgs.EventOperationType == EventOperationType.Instance().Disapproved())
            {
                cmsSearcher.Update(cms);
            }
        }
コード例 #5
0
 void SetStatusInvitationnForJoinGroupEventModule_After(Invitation sender, CommonEventArgs eventArgs)
 {
     if (eventArgs.EventOperationType == EventOperationType.Instance().Update())
     {
         InvitationService invitationService = DIContainer.Resolve<InvitationService>();
         Invitation invitation = invitationService.Get(sender.Id);
         if (invitation != null && invitation.InvitationTypeKey == InvitationTypeKeys.Instance().InviteJoinGroup() && invitation.Status == InvitationStatus.Accept)
         {
             GroupService groupService = new GroupService();
             GroupMember member=GroupMember.New();
             member.GroupId=sender.RelativeObjectId;
             member.UserId = sender.UserId;
             member.IsManager = false;
             groupService.CreateGroupMember(member);
         }
         else if (invitation != null && invitation.InvitationTypeKey == InvitationTypeKeys.Instance().ApplyJoinGroup() && invitation.Status == InvitationStatus.Accept)
         {
             GroupService groupService = new GroupService();
             GroupMember member = GroupMember.New();
             member.GroupId = sender.RelativeObjectId;
             member.UserId = sender.SenderUserId;
             member.IsManager = false;
             groupService.CreateGroupMember(member);
             IEnumerable<long> a= groupService.GetGroupMemberApplies(sender.RelativeObjectId,GroupMemberApplyStatus.Pending,20,1).Where(n=>n.UserId==sender.SenderUserId).Select(m=>m.Id);
             groupService.ApproveGroupMemberApply(a,true);
         }
         else if (invitation != null && invitation.InvitationTypeKey == InvitationTypeKeys.Instance().ApplyJoinGroup() && invitation.Status == InvitationStatus.Refuse)
         {
             GroupService groupService = new GroupService();
             IEnumerable<long> a = groupService.GetGroupMemberApplies(sender.RelativeObjectId, GroupMemberApplyStatus.Pending, 20, 1).Where(n => n.UserId == sender.SenderUserId).Select(m => m.Id);
             groupService.ApproveGroupMemberApply(a,false);
         }
     }
 }
コード例 #6
0
ファイル: RecommendEventModule.cs プロジェクト: hbulzy/SYS
 /// <summary>
 /// 删除话题、标签后删除推荐
 /// </summary>
 /// <param name="tag"></param>
 /// <param name="eventArgs"></param>
 void DeleteTag_After(Tag tag, CommonEventArgs eventArgs)
 {
     if (eventArgs.EventOperationType != EventOperationType.Instance().Delete() || tag == null)
     {
         return;
     }
     RecommendService recommendService = new RecommendService();
     recommendService.Delete(tag.TagId, tag.TenantTypeId);
 }
コード例 #7
0
 /// <summary>
 /// 创建邀请记录之后的方法
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="eventArgs"></param>
 void CreateInviteFriendRecordEventModule_After(InviteFriendRecord sender, CommonEventArgs eventArgs)
 {
     if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
     {
         PointService pointService = new PointService();
         string userName = UserIdToUserNameDictionary.GetUserName(sender.UserId);
         string invitedName = UserIdToUserNameDictionary.GetUserName(sender.InvitedUserId);
         string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_CreateInviteFriendRecord"), userName, invitedName);
         pointService.GenerateByRole(sender.UserId, PointItemKeys.Instance().InviteUserRegister(), description, true);
     }
 }
コード例 #8
0
ファイル: GroupMemberEventModule.cs プロジェクト: hbulzy/SYS
        /// <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);
            }
        }
コード例 #9
0
        private void FollowUser_After(FollowEntity followEntity,CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType == EventOperationType.Instance().Update() || eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                if (searcher == null)
                {
                    searcher = (FollowUserSearcher)SearcherFactory.GetSearcher(FollowUserSearcher.CODE);
                }

                searcher.Update(followEntity.UserId);
            }
        }
コード例 #10
0
ファイル: GroupIndexEventModule.cs プロジェクト: hbulzy/SYS
 private void DeleteItemInTags(ItemInTag sender, CommonEventArgs eventArgs)
 {
     if (sender.TenantTypeId == TenantTypeIds.Instance().Group())
     {
         long groupId = sender.ItemId;
         if (groupSearcher == null)
         {
             groupSearcher = (GroupSearcher)SearcherFactory.GetSearcher(GroupSearcher.CODE);
         }
         groupSearcher.Update(groupService.Get(groupId));
     }
 }
コード例 #11
0
 private void DeleteItemInTags(ItemInTag sender, CommonEventArgs eventArgs)
 {
     if (sender.TenantTypeId == TenantTypeIds.Instance().User())
     {
         long userId = sender.ItemId;
         if (userSearcher == null)
         {
             userSearcher = (UserSearcher)SearcherFactory.GetSearcher(UserSearcher.CODE);
         }
         userSearcher.Update(userService.GetFullUser(userId));
     }
 }
コード例 #12
0
 void SetStatusInvitationEventModule_After(Invitation sender, CommonEventArgs eventArgs)
 {
     if (eventArgs.EventOperationType == EventOperationType.Instance().Update())
     {
         InvitationService invitationService = DIContainer.Resolve<InvitationService>();
         Invitation invitation = invitationService.Get(sender.Id);
         if (invitation != null && invitation.InvitationTypeKey == InvitationTypeKeys.Instance().InviteFollow() && invitation.Status == InvitationStatus.Accept)
         {
             FollowService followService = new FollowService();
             followService.Follow(invitation.UserId, invitation.SenderUserId);
         }
     }
 }
コード例 #13
0
ファイル: RoleEventModule.cs プロジェクト: hbulzy/SYS
 void UserInRole_After(UserInRole sender, CommonEventArgs eventArgs)
 {
     RoleService roleService = new RoleService();
     var role = roleService.Get(sender.RoleName);
     if (role == null)
         return;
     NoticeService noticeService = Tunynet.DIContainer.Resolve<NoticeService>();
     Notice notice = Notice.New();
     notice.UserId = sender.UserId;
     notice.TypeId = NoticeTypeIds.Instance().Hint();
     notice.TemplateName = "RoleAdd";
     notice.RelativeObjectName = role.FriendlyRoleName;
     noticeService.Create(notice);
 }
コード例 #14
0
ファイル: CommentEventModule.cs プロジェクト: hbulzy/SYS
        /// <summary>
        /// 评论的积分处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        void CommentCreatAndDeleteEventModel_After(Comment sender, CommonEventArgs eventArgs)
        {
            PointService pointService = new PointService();
            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_CreateComment"), sender.Author, sender.Subject);
                pointService.GenerateByRole(sender.UserId, PointItemKeys.Instance().CreateComment(), description, true);
            }

            if (eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_DeleteComment"), sender.Author, sender.Subject);
                pointService.GenerateByRole(sender.UserId, PointItemKeys.Instance().DeleteComment(), description, true);
            }
        }
コード例 #15
0
 /// <summary>
 /// 首次上传头像加分
 /// </summary>
 /// <param name="sender">用户实体</param>
 /// <param name="eventArgs">事件参数</param>
 public void AutoNoModeratedUserNoticeEventModule_After(User sender, CommonEventArgs eventArgs)
 {
     if (eventArgs.EventOperationType == EventOperationType.Instance().AutoNoModeratedUser())
     {
         Notice notice = Notice.New();
         notice.UserId = sender.UserId;
         notice.ApplicationId = 0;
         notice.TypeId = NoticeTypeIds.Instance().Hint();
         notice.TemplateName = "AutoNoModeratedUser";
         notice.RelativeObjectName = "我的权限";
         notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().UserModerated(sender.UserName));
         notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().ListNotices(sender.UserName, null, null));
         noticeService.Create(notice);
     }
 }
コード例 #16
0
 /// <summary>
 /// 删除和更新分类时触发
 /// </summary>
 private void DeleteUpdateCategories_Before(Category sender, CommonEventArgs eventArgs)
 {
     if (sender.TenantTypeId == TenantTypeIds.Instance().Journals())
     {
         if (eventArgs.EventOperationType == EventOperationType.Instance().Delete() || eventArgs.EventOperationType == EventOperationType.Instance().Update())
         {
             IEnumerable<long> blogThreadIds = categoryService.GetItemIds(sender.CategoryId, false);
             if (journalSearcher == null)
             {
                 journalSearcher = (JournalSearcher)SearcherFactory.GetSearcher(JournalSearcher.CODE);
             }
             journalSearcher.Update(journalService.GetJournalsByIds(blogThreadIds));
         }
     }
 }
コード例 #17
0
 /// <summary>
 /// 删除和更新分类时触发
 /// </summary>
 private void DeleteUpdateCategories_Before(Category sender, CommonEventArgs eventArgs)
 {
     if (sender.TenantTypeId == TenantTypeIds.Instance().Topic())
     {
         if (eventArgs.EventOperationType == EventOperationType.Instance().Delete() || eventArgs.EventOperationType == EventOperationType.Instance().Update())
         {
             IEnumerable<long> groupIds = categoryService.GetItemIds(sender.CategoryId, false);
             if (groupSearcher == null)
             {
                 groupSearcher = (TopicSearcher)SearcherFactory.GetSearcher(TopicSearcher.CODE);
             }
             groupSearcher.Update(topicService.GetTopicEntitiesByIds(groupIds));
         }
     }
 }
コード例 #18
0
ファイル: BarSectionEventModule.cs プロジェクト: hbulzy/SYS
        /// <summary>
        /// 贴吧所在呈现区域拥有者自动创建贴吧事件
        /// </summary>
        /// <param name="sender">群组实体</param>
        /// <param name="eventArgs">事件参数</param>
        void AutoMaintainBarSectionModule_After(GroupEntity sender, CommonEventArgs eventArgs)
        {
            BarSectionService barSectionService = new BarSectionService();
            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {

                BarSection barSection = BarSection.New();

                barSection.TenantTypeId = TenantTypeIds.Instance().Group();
                barSection.SectionId = sender.GroupId;
                barSection.OwnerId = sender.GroupId;
                barSection.UserId = sender.UserId;
                barSection.Name = sender.GroupName;
                barSection.IsEnabled = true;
                barSection.LogoImage = sender.Logo;
                barSection.ThreadCategoryStatus = ThreadCategoryStatus.NotForceEnabled;
                barSectionService.Create(barSection, sender.UserId, null, null);
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Update())
            {
                BarSection barSection = barSectionService.Get(sender.GroupId);
                barSection.UserId = sender.UserId;
                barSection.Name = sender.GroupName;
                barSection.LogoImage = sender.Logo;

                IList<long> managerIds = null;
                if (barSection.SectionManagers != null)
                {
                    managerIds = barSection.SectionManagers.Select(n => n.UserId).ToList();
                }
                barSectionService.Update(barSection, sender.UserId, managerIds, null);
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Approved() || eventArgs.EventOperationType == EventOperationType.Instance().Disapproved())
            {
                BarSection barSection = barSectionService.Get(sender.GroupId);
                barSection.AuditStatus = sender.AuditStatus;
                IList<long> managerIds = null;
                if (barSection.SectionManagers != null)
                {
                    managerIds = barSection.SectionManagers.Select(n => n.UserId).ToList();
                }
                barSectionService.Update(barSection, sender.UserId, managerIds, null);
            }
            else
            {
                barSectionService.Delete(sender.GroupId);
            }
        }
コード例 #19
0
ファイル: GroupEventModule.cs プロジェクト: hbulzy/SYS
 /// <summary>
 /// 修改皮肤文件的使用人数
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="eventArgs"></param>
 private void ChangeThemeAppearanceUserCountModule_After(GroupEntity sender, CommonEventArgs eventArgs)
 {
     var themeService = new ThemeService();
     PresentAreaService presentAreaService = new PresentAreaService();
     if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
     {
         var presentArea = presentAreaService.Get(PresentAreaKeysOfBuiltIn.GroupSpace);
         themeService.ChangeThemeAppearanceUserCount(PresentAreaKeysOfBuiltIn.GroupSpace, null, presentArea.DefaultThemeKey + "," + presentArea.DefaultAppearanceKey);
     }
     else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete())
     {
         var presentArea = presentAreaService.Get(PresentAreaKeysOfBuiltIn.GroupSpace);
         string defaultThemeAppearance = presentArea.DefaultThemeKey + "," + presentArea.DefaultAppearanceKey;
         if (!sender.IsUseCustomStyle)
             themeService.ChangeThemeAppearanceUserCount(PresentAreaKeysOfBuiltIn.GroupSpace, !string.IsNullOrEmpty(sender.ThemeAppearance) ? sender.ThemeAppearance : defaultThemeAppearance, null);
     }
 }
コード例 #20
0
ファイル: RecommendEventModule.cs プロジェクト: hbulzy/SYS
        /// <summary>
        /// 推荐积分处理
        /// </summary>
        /// <param name="sender">推荐实体</param>
        /// <param name="eventArgs">事件参数</param>
        void RecommendPointModule_After(RecommendItem sender, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType != EventOperationType.Instance().Create())
            {
                return;
            }
            string pointItemKey = string.Empty;
            PointService pointService = new PointService();
            string description = string.Empty;
            TenantTypeService tenantTypeService = new TenantTypeService();

            var urlGetter = RecommendUrlGetterFactory.Get(sender.TenantTypeId);

            NoticeService noticeService = new NoticeService();
            Notice notice = Notice.New();
            notice.TypeId = NoticeTypeIds.Instance().Hint();

            //notice.TemplateName = "FollowUser";
            notice.UserId = sender.UserId;
            notice.LeadingActorUserId = sender.ReferrerId;
            notice.LeadingActor = sender.ReferrerName;
            notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.ReferrerId));
            notice.RelativeObjectId = sender.UserId;
            notice.RelativeObjectName = sender.ItemName;
            notice.RelativeObjectUrl = sender.DetailUrl;

            if (sender.TenantTypeId == TenantTypeIds.Instance().User())
            {
                pointItemKey = PointItemKeys.Instance().RecommendUser();
                description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_RecommendUser"));
                notice.TemplateName = NoticeTemplateNames.Instance().ManagerRecommendedUser();
            }
            else
            {
                pointItemKey = PointItemKeys.Instance().RecommendContent();
                TenantType tenantType = tenantTypeService.Get(sender.TenantTypeId);
                if (tenantType == null)
                    return;
                description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_RecommendContent"), tenantType.Name, sender.ItemName);
                notice.TemplateName = NoticeTemplateNames.Instance().ManagerRecommended();
            }

            noticeService.Create(notice);
            pointService.GenerateByRole(sender.UserId, pointItemKey, description);
        }
コード例 #21
0
        void PermissionOperationLogEventMoudle_BatchAfter(IEnumerable<PermissionItemInUserRole> senders, CommonEventArgs eventArgs)
        {
            //只记录批量更新操作
            if (eventArgs.EventOperationType != EventOperationType.Instance().Update())
                return;
            OperationLogService logService = Tunynet.DIContainer.Resolve<OperationLogService>();
            PermissionService permissionService = new PermissionService();

            OperationLogEntry entry = new OperationLogEntry(eventArgs.OperatorInfo);

            entry.ApplicationId = 0;
            entry.Source = string.Empty;
            entry.OperationType = eventArgs.EventOperationType;
            IEnumerable<string> roleNames = senders.Select(n => n.RoleName).Distinct();
            entry.OperationObjectName = string.Join(",", roleNames);
            entry.OperationObjectId = 0;
            entry.Description = string.Format(ResourceAccessor.GetString("OperationLog_Pattern_" + eventArgs.EventOperationType), "权限", entry.OperationObjectName);
            logService.Create(entry);
        }
コード例 #22
0
 /// <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);
     }
 }
コード例 #23
0
        /// <summary>
        /// 资讯操作日志事件处理
        /// </summary>
        private void ContentFolderOperationLogEventModule_After(ContentFolder sender, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType == EventOperationType.Instance().Create()
                || eventArgs.EventOperationType == EventOperationType.Instance().Update()
                || eventArgs.EventOperationType == EventOperationType.Instance().Delete()
                )
            {
                OperationLogEntry entry = new OperationLogEntry(eventArgs.OperatorInfo);
                entry.ApplicationId = CmsConfig.Instance().ApplicationId;
                entry.Source = CmsConfig.Instance().ApplicationName;
                entry.OperationType = eventArgs.EventOperationType;
                entry.OperationObjectName = sender.FolderName;
                entry.OperationObjectId = sender.ContentFolderId;
                entry.Description = string.Format(ResourceAccessor.GetString("OperationLog_Pattern_" + eventArgs.EventOperationType, entry.ApplicationId), "资讯栏目", entry.OperationObjectName);

                OperationLogService logService = Tunynet.DIContainer.Resolve<OperationLogService>();
                logService.Create(entry);
            }
        }
コード例 #24
0
        /// <summary>
        /// 帖吧申请处理结果通知
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        void BarSectionNoticeEventModule_After(BarSection sender, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType == EventOperationType.Instance().Approved() || eventArgs.EventOperationType == EventOperationType.Instance().Disapproved())
            {

                IUserService userService = DIContainer.Resolve<IUserService>();
                NoticeService noticeService = DIContainer.Resolve<NoticeService>();
                User toUser = userService.GetFullUser(sender.UserId);
                if (toUser == null)
                    return;
                Notice notice = Notice.New();
                notice.UserId = sender.UserId;
                notice.ApplicationId = BarConfig.Instance().ApplicationId;
                notice.TypeId = NoticeTypeIds.Instance().Reply();
                notice.LeadingActorUserId = sender.UserId;
                notice.LeadingActor = toUser.DisplayName;
                notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(toUser.UserName));
                notice.RelativeObjectId = sender.SectionId;
                notice.RelativeObjectName = HtmlUtility.TrimHtml(sender.Name, 64);
                if (eventArgs.EventOperationType == EventOperationType.Instance().Approved())
                {
                    //通知吧主,其申请的帖吧通过了审核 
                    notice.TemplateName = NoticeTemplateNames.Instance().ManagerApproved();
                }
                else
                {
                    //通知吧主,其申请的帖吧未通过审核
                    notice.TemplateName = NoticeTemplateNames.Instance().ManagerDisapproved();
                }

                notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().SectionDetail(sender.SectionId));
                noticeService.Create(notice);
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                SubscribeService subscribeService = new SubscribeService(TenantTypeIds.Instance().BarSection());
                IEnumerable<long> userIds = subscribeService.GetTopUserIdsOfObject(sender.SectionId, int.MaxValue);

                foreach (long userId in userIds)
                    subscribeService.CancelSubscribe(sender.SectionId, userId);
            }
        }
コード例 #25
0
        /// <summary>
        /// 文章操作文章事件处理
        /// </summary>
        private void BlogOperationLogEventModule_After(BlogThread senders, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType == EventOperationType.Instance().Delete()
               || eventArgs.EventOperationType == EventOperationType.Instance().Approved()
               || eventArgs.EventOperationType == EventOperationType.Instance().Disapproved()
               || eventArgs.EventOperationType == EventOperationType.Instance().SetEssential()
               || eventArgs.EventOperationType == EventOperationType.Instance().CancelEssential())
            {
                OperationLogEntry entry = new OperationLogEntry(eventArgs.OperatorInfo);
                entry.ApplicationId = entry.ApplicationId;
                entry.Source = BlogConfig.Instance().ApplicationName;
                entry.OperationType = eventArgs.EventOperationType;
                entry.OperationObjectName = senders.Subject;
                entry.OperationObjectId = senders.ThreadId;
                entry.Description = string.Format(ResourceAccessor.GetString("OperationLog_Pattern_" + eventArgs.EventOperationType, entry.ApplicationId), "文章", entry.OperationObjectName);

                OperationLogService logService = Tunynet.DIContainer.Resolve<OperationLogService>();
                logService.Create(entry);
            }
        }
コード例 #26
0
ファイル: RoleEventModule.cs プロジェクト: hbulzy/SYS
 void UserInRole_BatchAfter(IEnumerable<UserInRole> sender, CommonEventArgs eventArgs)
 {
     if (sender == null || sender.Count() == 0)
         return;
     NoticeService noticeService = Tunynet.DIContainer.Resolve<NoticeService>();
     RoleService roleService = new RoleService();
     Notice notice = Notice.New();
     notice.UserId = sender.First().UserId;
     notice.TypeId = NoticeTypeIds.Instance().Hint();
     notice.TemplateName = "RolesChanged";
     List<Role> roles = new List<Role>();
     foreach (var s in sender)
     {
         var role = roleService.Get(s.RoleName);
         if (role == null)
             continue;
         roles.Add(role);
     }
     notice.RelativeObjectName = string.Join("、", roles.Select(n => n.FriendlyRoleName));
     noticeService.Create(notice);
 }
コード例 #27
0
        /// <summary>
        /// 微博操作文章事件处理
        /// </summary>
        private void MicroblogOperationLogEventModule_After(MicroblogEntity senders, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType == EventOperationType.Instance().Delete()
                || eventArgs.EventOperationType == EventOperationType.Instance().Approved()
                || eventArgs.EventOperationType == EventOperationType.Instance().Disapproved()
                || eventArgs.EventOperationType == EventOperationType.Instance().SetEssential()
                || eventArgs.EventOperationType == EventOperationType.Instance().SetSticky()
                || eventArgs.EventOperationType == EventOperationType.Instance().CancelEssential()
                || eventArgs.EventOperationType == EventOperationType.Instance().CancelSticky())
            {
                OperationLogEntry entry = new OperationLogEntry(eventArgs.OperatorInfo);
                entry.ApplicationId = entry.ApplicationId;
                entry.Source = MicroblogConfig.Instance().ApplicationName;
                entry.OperationType = eventArgs.EventOperationType;
                entry.OperationObjectName = StringUtility.Trim(senders.Body, 20);
                entry.OperationObjectId = senders.MicroblogId;
                entry.Description = string.Format(ResourceAccessor.GetString("OperationLog_Pattern_" + eventArgs.EventOperationType, entry.ApplicationId), "微博", entry.OperationObjectName);

                OperationLogService logService = Tunynet.DIContainer.Resolve<OperationLogService>();
                logService.Create(entry);
            }
        }
コード例 #28
0
        void BarRatingEventModule_After(BarRating sender, CommonEventArgs eventArgs)
        {
            ActivityService activityService = new ActivityService();
            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                Activity actvity = Activity.New();
                actvity.ActivityItemKey = ActivityItemKeys.Instance().CreateBarRating();
                actvity.ApplicationId = BarConfig.Instance().ApplicationId;

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

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

                //自己回复自己时,不向自己的动态收件箱推送动态
                if (actvity.UserId == barThread.UserId)
                    activityService.Generate(actvity, false);
                else
                    activityService.Generate(actvity, true);
            }
            else
            {
                activityService.DeleteSource(TenantTypeIds.Instance().BarRating(), sender.RatingId);
            }
        }
コード例 #29
0
ファイル: RecommendEventModule.cs プロジェクト: hbulzy/SYS
        /// <summary>
        /// 资讯操作日志事件处理
        /// </summary>
        private void RecommendOperationLogEventModule_After(RecommendItem sender, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType == EventOperationType.Instance().Create()
               || eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                TenantTypeService tenantTypeService = new TenantTypeService();
                TenantType tenantType = tenantTypeService.Get(sender.TenantTypeId);
                if (tenantType == null)
                    return;

                OperationLogEntry entry = new OperationLogEntry(eventArgs.OperatorInfo);
                entry.ApplicationId = tenantType.ApplicationId;
                entry.Source = tenantType.Name;
                entry.OperationType = eventArgs.EventOperationType;
                entry.OperationObjectName = sender.ItemName;
                entry.OperationObjectId = sender.ItemId;
                entry.Description = string.Format(ResourceAccessor.GetString("OperationLog_Pattern_" + eventArgs.EventOperationType), tenantType.Name + "推荐", entry.OperationObjectName);

                OperationLogService logService = Tunynet.DIContainer.Resolve<OperationLogService>();
                logService.Create(entry);
            }
        }
コード例 #30
0
ファイル: TagIndexEventModule.cs プロジェクト: hbulzy/SYS
 private void Tag_After(Tag sender, CommonEventArgs eventArgs)
 {
     if (sender==null)
     {
       return;
     }
     if (tagSearcher == null)
     {
         tagSearcher = (TagSearcher)SearcherFactory.GetSearcher(TagSearcher.CODE);
     }
     if (eventArgs.EventOperationType==EventOperationType.Instance().Create())
     {
         tagSearcher.InsertTag(sender);
     }
     else if(eventArgs.EventOperationType==EventOperationType.Instance().Delete())
     {
         tagSearcher.DeleteTag(sender.TagId);
     }
     else if (eventArgs.EventOperationType == EventOperationType.Instance().Update())
     {
         tagSearcher.UpdateTag(sender);
     }
 }