/// <summary> /// 删除和更新标签时触发 /// </summary> private void DeleteUpdateTags_Before(Tag sender, CommonEventArgs eventArgs) { if (sender.TenantTypeId == TenantTypeIds.Instance().BlogThread()) { if (eventArgs.EventOperationType == EventOperationType.Instance().Delete() || eventArgs.EventOperationType == EventOperationType.Instance().Update()) { //根据标签获取所有使用该标签的(内容项)日志 IEnumerable <long> blogThreadIds = tagService.GetItemIds(sender.TagName, null); if (blogSearcher == null) { blogSearcher = (BlogSearcher)SearcherFactory.GetSearcher(BlogSearcher.CODE); } blogSearcher.Update(blogService.GetBlogThreads(blogThreadIds)); } } }
private void Timer_CallBack(object sender, CommonEventArgs e) { if (locked) { return; } if (SkipEnable) { locked = true; } Action(); locked = false; }
/// <summary> /// 删除和更新标签时触发 /// </summary> private void DeleteUpdateTags_Before(Tag sender, CommonEventArgs eventArgs) { if (sender.TenantTypeId == TenantTypeIds.Instance().User()) { if (eventArgs.EventOperationType == EventOperationType.Instance().Delete() || eventArgs.EventOperationType == EventOperationType.Instance().Update()) { //根据标签获取所有使用该标签的(内容项)用户 IEnumerable <long> userIds = tagService.GetItemIds(sender.TagName, null); if (userSearcher == null) { userSearcher = (UserSearcher)SearcherFactory.GetSearcher(UserSearcher.CODE); } userSearcher.Update(userService.GetFullUsers(userIds)); } } }
/// <summary> /// 回答增量索引 /// </summary> /// <param name="answer"></param> /// <param name="eventArgs"></param> private void AskAnswer_After(AskAnswer answer, CommonEventArgs eventArgs) { if (answer == null) { return; } if (askSearcher == null) { askSearcher = (AskSearcher)SearcherFactory.GetSearcher(AskSearcher.CODE); } //创建回答、更新回答、删除回答时更新问题索引 if (eventArgs.EventOperationType == EventOperationType.Instance().Create() || eventArgs.EventOperationType == EventOperationType.Instance().Update() || eventArgs.EventOperationType == EventOperationType.Instance().Delete()) { askSearcher.Update(answer.Question); } }
/// <summary> /// 删除和更新标签时触发 /// </summary> private void DeleteUpdateTags_Before(Tag sender, CommonEventArgs eventArgs) { if (sender.TenantTypeId == TenantTypeIds.Instance().Topic()) { if (eventArgs.EventOperationType == EventOperationType.Instance().Delete() || eventArgs.EventOperationType == EventOperationType.Instance().Update()) { //根据标签获取所有使用该标签的(内容项)专题 IEnumerable <long> groupIds = tagService.GetItemIds(sender.TagName, null); if (groupSearcher == null) { groupSearcher = (TopicSearcher)SearcherFactory.GetSearcher(TopicSearcher.CODE); } groupSearcher.Update(topicService.GetTopicEntitiesByIds(groupIds)); } } }
/// <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); } 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); } }
/// <summary> /// 生成通知 /// </summary> /// <param name="sender">关注实体</param> /// <param name="eventArgs">事件参数</param> void FollowNoticeModule_After(FollowEntity sender, CommonEventArgs eventArgs) { if (EventOperationType.Instance().Create() == eventArgs.EventOperationType) { if (sender.IsQuietly) { return; } IUserService userService = DIContainer.Resolve <IUserService>(); //关注用户 IUser user = userService.GetUser(sender.UserId); if (user == null) { return; } IUser followedUser = userService.GetUser(sender.FollowedUserId); if (followedUser == null) { return; } NoticeService service = new NoticeService(); Notice notice = Notice.New(); notice.TypeId = NoticeTypeIds.Instance().Hint(); notice.TemplateName = "FollowUser"; notice.UserId = followedUser.UserId; notice.LeadingActorUserId = user.UserId; notice.LeadingActor = user.DisplayName; notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(user.UserName)); notice.RelativeObjectId = followedUser.UserId; notice.RelativeObjectName = followedUser.DisplayName; notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(followedUser.UserName)); service.Create(notice); } else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete()) { NoticeService service = new NoticeService(); IEnumerable <Notice> notices = service.GetTops(sender.FollowedUserId, 20).Where(n => n.TemplateName == "FollowUser").Where(n => n.LeadingActorUserId == sender.UserId); foreach (var notice in notices) { service.Delete(notice.Id); } } }
/// <summary> /// 处理加精、置顶等操作 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void BarThreadPointModuleForManagerOperation_After(BarThread sender, CommonEventArgs eventArgs) { NoticeService noticeService = new NoticeService(); string pointItemKey = string.Empty; if (eventArgs.EventOperationType == EventOperationType.Instance().SetEssential()) { pointItemKey = PointItemKeys.Instance().EssentialContent(); if (sender.UserId > 0) { Notice notice = Notice.New(); notice.UserId = sender.UserId; notice.ApplicationId = BarConfig.Instance().ApplicationId; notice.TypeId = NoticeTypeIds.Instance().Hint(); notice.LeadingActor = sender.Author; notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.UserId))); notice.RelativeObjectName = HtmlUtility.TrimHtml(sender.Subject, 64); notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().ThreadDetail(sender.ThreadId)); notice.TemplateName = NoticeTemplateNames.Instance().ManagerSetEssential(); noticeService.Create(notice); } } else if (eventArgs.EventOperationType == EventOperationType.Instance().SetSticky()) { pointItemKey = PointItemKeys.Instance().StickyContent(); if (sender.UserId > 0) { Notice notice = Notice.New(); notice.UserId = sender.UserId; notice.ApplicationId = BarConfig.Instance().ApplicationId; notice.TypeId = NoticeTypeIds.Instance().Hint(); notice.LeadingActor = sender.Author; notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.UserId))); notice.RelativeObjectName = HtmlUtility.TrimHtml(sender.Subject, 64); notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().ThreadDetail(sender.ThreadId)); notice.TemplateName = NoticeTemplateNames.Instance().ManagerSetSticky(); noticeService.Create(notice); } } if (!string.IsNullOrEmpty(pointItemKey)) { PointService pointService = new PointService(); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventArgs.EventOperationType), "帖子", sender.Subject); pointService.GenerateByRole(sender.UserId, pointItemKey, description); } }
/// <summary> /// 回答操作日志事件处理 /// </summary> private void AskAnswerOperationLogEventModule_After(AskAnswer senders, CommonEventArgs eventArgs) { if (eventArgs.EventOperationType == EventOperationType.Instance().Delete()) { OperationLogEntry entry = new OperationLogEntry(eventArgs.OperatorInfo); entry.ApplicationId = entry.ApplicationId; entry.Source = AskConfig.Instance().ApplicationName; entry.OperationType = eventArgs.EventOperationType; entry.OperationObjectName = StringUtility.Trim(senders.Body, 20); entry.OperationObjectId = senders.QuestionId; entry.Description = string.Format(ResourceAccessor.GetString("OperationLog_Pattern_" + eventArgs.EventOperationType), "回答", entry.OperationObjectName); OperationLogService logService = Tunynet.DIContainer.Resolve <OperationLogService>(); logService.Create(entry); } }
/// <summary> /// 设置/取消管理员通知处理程序 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void SetManagerNoticeEventModule_After(GroupMember sender, CommonEventArgs eventArgs) { if (eventArgs.EventOperationType != EventOperationType.Instance().SetGroupManager() && eventArgs.EventOperationType != EventOperationType.Instance().CancelGroupManager()) { return; } GroupService groupService = new GroupService(); GroupEntity entity = groupService.Get(sender.GroupId); if (entity == null) { return; } User senderUser = DIContainer.Resolve <IUserService>().GetFullUser(sender.UserId); if (senderUser == null) { return; } NoticeService noticeService = DIContainer.Resolve <NoticeService>(); Notice notice = Notice.New(); notice.UserId = sender.UserId; notice.ApplicationId = GroupConfig.Instance().ApplicationId; notice.TypeId = NoticeTypeIds.Instance().Hint(); notice.LeadingActorUserId = 0; notice.LeadingActor = string.Empty; notice.LeadingActorUrl = string.Empty; notice.RelativeObjectId = sender.GroupId; notice.RelativeObjectName = StringUtility.Trim(entity.GroupName, 64); notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().GroupHome(entity.GroupKey)); if (eventArgs.EventOperationType == EventOperationType.Instance().SetGroupManager()) { notice.TemplateName = NoticeTemplateNames.Instance().SetGroupManager(); } else { notice.TemplateName = NoticeTemplateNames.Instance().CannelGroupManager(); } noticeService.Create(notice); }
/// <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); } } }
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); }
public void OnMessageArrival(object sender, CommonEventArgs<ZLSoft.BusinessHome.Application.IMMessage> e) { try { if (this.tabControl.TabPages.Contains(this.tp3Message)) { //�ж��Ƿ��ǹ㲥��Ϣ bool isBroadcast = false; if (e.Data.Content[0] == 1) { isBroadcast = true; //�û�ԭֵ e.Data.Content[0] = 0; } string target; if (isBroadcast || e.Data.TargetUsers == null) { target = "all"; } else { StringBuilder str = new StringBuilder(); foreach (ZLSoft.BusinessHome.Application.UserBaseInfo item in e.Data.TargetUsers) { str.AppendFormat("{0};", item.UserName); } target = str.ToString().TrimEnd(";".ToCharArray()); } string rtfMsg = ZLSoft.BusinessHome.ApplicationFramework.Utils.SerializeHelper.BinaryDeserialize<string>(e.Data.Content); this.rtbP3Msg.Invoke(new EventHandler(delegate { this.rtbP3Msg.AppendText(string.Format("[{0}][From:{1}][To:{2}]\r\n", e.Data.CreateDate, e.Data.SourceUser.UserName, target)); P3AddRtfMsg(rtfMsg); this.rtbP3Msg.AppendText("\r\n"); })); } } catch (Exception ex) { Helper.ShowError(this, ex.Message); } }
/// <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); } }
/// <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); } } }
/// <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); } }
/// <summary> /// 关注后更新缓存 /// </summary> /// <param name="sender">关注实体</param> /// <param name="eventArgs">事件参数</param> void FollowUpdateCountModule_After(FollowEntity sender, CommonEventArgs eventArgs) { if (eventArgs.EventOperationType == EventOperationType.Instance().Create()) { //更新用户缓存 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++; } } } }
/// <summary> /// 隐私状态发生变化时,同时更新动态的私有状态 /// </summary> private void PhotoAcitivityPrivicyChangeEventModule_After(Album album, CommonEventArgs eventArgs) { if (eventArgs.EventOperationType == EventOperationType.Instance().Create() || eventArgs.EventOperationType == EventOperationType.Instance().Update()) { ActivityService activityService = new ActivityService(); Activity activity = activityService.Get(TenantTypeIds.Instance().Photo(), album.AlbumId); if (activity == null) { return; } bool newIsPrivate = album.PrivacyStatus == PrivacyStatus.Private ? true : false; //是否是公开的(用于是否推送站点动态) bool isPublic = album.PrivacyStatus == PrivacyStatus.Public ? true : false; if (activity.IsPrivate != newIsPrivate) { activityService.UpdatePrivateStatus(activity.ActivityId, newIsPrivate, isPublic); } } }
/// <summary> /// 资讯操作日志事件处理 /// </summary> private void CmsOperationLogEventModule_After(ContentItem sender, CommonEventArgs eventArgs) { if (eventArgs.EventOperationType == EventOperationType.Instance().Delete() || eventArgs.EventOperationType == EventOperationType.Instance().SetEssential() || eventArgs.EventOperationType == EventOperationType.Instance().CancelEssential() || eventArgs.EventOperationType == EventOperationType.Instance().SetFolderSticky() || eventArgs.EventOperationType == EventOperationType.Instance().SetGlobalSticky() || eventArgs.EventOperationType == EventOperationType.Instance().CancelFolderSticky() || eventArgs.EventOperationType == EventOperationType.Instance().CancelGlobalSticky()) { OperationLogEntry entry = new OperationLogEntry(eventArgs.OperatorInfo); entry.ApplicationId = CmsConfig.Instance().ApplicationId; entry.Source = CmsConfig.Instance().ApplicationName; entry.OperationType = eventArgs.EventOperationType; entry.OperationObjectName = sender.Title; entry.OperationObjectId = sender.ContentItemId; entry.Description = string.Format(ResourceAccessor.GetString("OperationLog_Pattern_" + eventArgs.EventOperationType, entry.ApplicationId), "资讯", entry.OperationObjectName); OperationLogService logService = Tunynet.DIContainer.Resolve <OperationLogService>(); logService.Create(entry); } }
void UserOperationLogEventMoudle_BatchAfter(IEnumerable <User> senders, CommonEventArgs eventArgs) { //只有批量激活用户、取消激活用户、管制用户、取消管制用户时,才记录到操作日志 if (eventArgs.EventOperationType == EventOperationType.Instance().ActivateUser() || eventArgs.EventOperationType == EventOperationType.Instance().CancelActivateUser() || eventArgs.EventOperationType == EventOperationType.Instance().ModerateUser() || eventArgs.EventOperationType == EventOperationType.Instance().CancelModerateUser()) { OperationLogService logService = new OperationLogService(); logService = Tunynet.DIContainer.Resolve <OperationLogService>(); IUserService userService = DIContainer.Resolve <IUserService>(); OperationLogEntry entry = new OperationLogEntry(eventArgs.OperatorInfo); entry.ApplicationId = 0; entry.Source = string.Empty; entry.OperationType = eventArgs.EventOperationType; IEnumerable <string> userNames = senders.Select(n => n.UserName); entry.OperationObjectName = string.Join(",", userNames); entry.OperationObjectId = 0; entry.Description = string.Format(ResourceAccessor.GetString("OperationLog_Pattern_" + eventArgs.EventOperationType), entry.OperationObjectName); logService.Create(entry); } }
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); } }
/// <summary> /// 照片操作日志事件处理 /// </summary> private void PhotoOperationLogEventModule_After(Photo 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 = PhotoConfig.Instance().ApplicationName; entry.OperationType = eventArgs.EventOperationType; entry.OperationObjectName = string.IsNullOrEmpty(senders.Description) ? "照片" : senders.Description; entry.OperationObjectId = senders.PhotoId; entry.Description = string.Format(ResourceAccessor.GetString("OperationLog_Pattern_" + eventArgs.EventOperationType, entry.ApplicationId), "照片", entry.OperationObjectName); OperationLogService logService = Tunynet.DIContainer.Resolve <OperationLogService>(); logService.Create(entry); } }
//照片增加、删除、更新、设置精华、取消精华 private void Photo_After(Photo photo, CommonEventArgs eventArgs) { if (photo == null) { return; } if (photoSearcher == null) { photoSearcher = (PhotoSearcher)SearcherFactory.GetSearcher(PhotoSearcher.CODE); } if (eventArgs.EventOperationType == EventOperationType.Instance().Create()) { photoSearcher.Insert(photo); } else if (eventArgs.EventOperationType == EventOperationType.Instance().Update() || eventArgs.EventOperationType == EventOperationType.Instance().Approved() || eventArgs.EventOperationType == EventOperationType.Instance().Disapproved()) { photoSearcher.Update(photo); } else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete()) { photoSearcher.Delete(photo); } }
/// <summary> /// 圈人动态处理 /// </summary> private void LabelPhotoActivityModule_After(PhotoLabel photoLabel, CommonEventArgs eventArgs) { Photo photo = photoService.GetPhoto(photoLabel.PhotoId); if (eventArgs.EventOperationType == EventOperationType.Instance().Create()) { //初始化Owner为用户的动态 Activity activity = Activity.New(); activity.ActivityItemKey = ActivityItemKeys.Instance().LabelPhoto(); activity.ApplicationId = PhotoConfig.Instance().ApplicationId; activity.HasImage = true; activity.HasMusic = false; activity.HasVideo = false; activity.IsOriginalThread = true; activity.IsPrivate = photoLabel.Photo.PrivacyStatus == PrivacyStatus.Private ? true : false; activity.UserId = photo.UserId; activity.ReferenceId = photoLabel.PhotoId; activity.ReferenceTenantTypeId = TenantTypeIds.Instance().Photo(); activity.SourceId = photoLabel.LabelId; activity.TenantTypeId = TenantTypeIds.Instance().PhotoLabel(); activity.OwnerId = photo.UserId; activity.OwnerName = photo.Author; activity.OwnerType = ActivityOwnerTypes.Instance().User(); //是否是公开的(用于是否推送站点动态) bool isPublic = photoLabel.Photo.PrivacyStatus == PrivacyStatus.Public ? true : false; activityService.Generate(activity, true, isPublic); //再为被圈用户生成动态 new ActivityRepository().InsertUserInboxs(activity.ActivityId, new long[] { photoLabel.ObjetId }); } else { activityService.DeleteSource(TenantTypeIds.Instance().PhotoLabel(), photoLabel.LabelId); } }
/// <summary> /// 照片圈人通知被圈人 /// </summary> /// <param name="photoLabel"></param> /// <param name="eventArgs"></param> public void PhotoLabeledNotice_After(PhotoLabel photoLabel, CommonEventArgs eventArgs) { if (photoLabel.Photo == null) { return; } //圈人的操作人 IUser user = DIContainer.Resolve <UserService>().GetUser(photoLabel.UserId); //给被圈的人发送通知 if (eventArgs.EventOperationType == EventOperationType.Instance().Create()) { Notice notice = Notice.New(); notice.UserId = photoLabel.ObjetId; notice.ApplicationId = PhotoConfig.Instance().ApplicationId; notice.TypeId = NoticeTypeIds.Instance().Hint(); notice.LeadingActor = user.DisplayName; notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().Home(user.UserName)); notice.RelativeObjectName = photoLabel.Photo.Description; notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().PhotoDetail(photoLabel.Photo.PhotoId)); notice.TemplateName = NoticeTemplateNames.Instance().PhotoLabeledNotice(); noticeService.Create(notice); } }
/// <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); } }
/// <summary> /// 日志增量索引 /// </summary> private void Journal_After(Journal journal, CommonEventArgs eventArgs) { if (journal == null) { return; } if (journalSearcher == null) { journalSearcher = (JournalSearcher)SearcherFactory.GetSearcher(JournalSearcher.CODE); } //添加索引 if (eventArgs.EventOperationType == EventOperationType.Instance().Create()) { //if (!journal.IsDraft) //{ journalSearcher.Insert(journal); //} } //删除索引 if (eventArgs.EventOperationType == EventOperationType.Instance().Delete()) { journalSearcher.Delete(journal.id); } //更新索引 if (eventArgs.EventOperationType == EventOperationType.Instance().Update() || eventArgs.EventOperationType == EventOperationType.Instance().Approved() || eventArgs.EventOperationType == EventOperationType.Instance().Disapproved()) { //if (!journal.IsDraft) //{ journalSearcher.Update(journal); //} } }
/// <summary> /// 照片圈人积分 /// </summary> public void PhotoLabelEventModule_After(PhotoLabel photoLabel, CommonEventArgs eventArgs) { string pointItemKey = string.Empty; string eventOperationType = string.Empty; //加积分 if (eventArgs.EventOperationType == EventOperationType.Instance().Create()) { pointItemKey = PointItemKeys.Instance().Photo_BeLabelled(); eventOperationType = EventOperationType.Instance().Create(); } //减积分 if (eventArgs.EventOperationType == EventOperationType.Instance().Delete()) { pointItemKey = PointItemKeys.Instance().Photo_BeLabelled_Delete(); eventOperationType = EventOperationType.Instance().Delete(); } if (!string.IsNullOrEmpty(pointItemKey)) { string description = string.Format("照片圈人", "", HtmlUtility.TrimHtml(photoLabel.Description, 64)); pointService.GenerateByRole(photoLabel.ObjetId, pointItemKey, description); } }
/// <summary> /// 日志增量索引 /// </summary> private void BlogThread_After(BlogThread blog, CommonEventArgs eventArgs) { if (blog == null) { return; } if (blogSearcher == null) { blogSearcher = (BlogSearcher)SearcherFactory.GetSearcher(BlogSearcher.CODE); } //添加索引 if (eventArgs.EventOperationType == EventOperationType.Instance().Create()) { if (!blog.IsDraft) { blogSearcher.Insert(blog); } } //删除索引 if (eventArgs.EventOperationType == EventOperationType.Instance().Delete()) { blogSearcher.Delete(blog.ThreadId); } //更新索引 if (eventArgs.EventOperationType == EventOperationType.Instance().Update()) { if (!blog.IsDraft) { blogSearcher.Update(blog); } } }
public void DoCollectSupplierEvent(object o, CommonEventArgs <AccountDetailModel> e) { Collect(e.Obj); }
public void DoPaySupplierEvent(object o, CommonEventArgs <AccountDetailModel> e) { Pay(e.Obj); }
/// <summary> /// ��SF�¼���Ӧ /// </summary> /// <param name="sender"></param> /// <param name="e"></param> static void PublicEvent_SmartFormOpening(object sender, CommonEventArgs<PluginControlBase> e) { //��ȡĬ�ϲ��� ResourceOperateInfo info = Services.ResourceService.GetDefaultResourceOperateByResourceID(e.Data.ResourceInfo.ID, false); if (info == null) { ShowError("û���ҵ������ܴ����Ĭ�ϲ���"); return; } info.LoadType = e.Data.CurrentLoadType; e.Data.OperateInfo = info; e.Data.ResourceService = Services.ResourceService; OpenResourcePluginControl(e.Data, e.Data.OperateInfo, e.Data.ResourceInfo, e.Data.Parameter); }