예제 #1
0
 /// <summary>
 /// 为群组添加标签时触发
 /// </summary>
 private void AddTagsToGroup_BatchAfter(IEnumerable<string> senders, TagEventArgs eventArgs)
 {
     if (eventArgs.TenantTypeId == TenantTypeIds.Instance().Group())
     {
         long groupId = eventArgs.ItemId;
         if (groupSearcher == null)
         {
             groupSearcher = (GroupSearcher)SearcherFactory.GetSearcher(GroupSearcher.CODE);
         }
         groupSearcher.Update(groupService.Get(groupId));
     }
 }
예제 #2
0
 /// <summary>
 /// 删除和更新分类时触发
 /// </summary>
 private void DeleteUpdateCategories_Before(Category sender, CommonEventArgs eventArgs)
 {
     if (sender.TenantTypeId == TenantTypeIds.Instance().Group())
     {
         if (eventArgs.EventOperationType == EventOperationType.Instance().Delete() || eventArgs.EventOperationType == EventOperationType.Instance().Update())
         {
             IEnumerable<long> groupIds = categoryService.GetItemIds(sender.CategoryId, false);
             if (groupSearcher == null)
             {
                 groupSearcher = (GroupSearcher)SearcherFactory.GetSearcher(GroupSearcher.CODE);
             }
             groupSearcher.Update(groupService.GetGroupEntitiesByIds(groupIds));
         }
     }
 }
예제 #3
0
 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));
     }
 }
예제 #4
0
        /// <summary>
        /// 群组增量索引
        /// </summary>
        private void GroupEntity_After(GroupEntity group, CommonEventArgs eventArgs)
        {
            if (group == null)
            {
                return;
            }

            if (groupSearcher == null)
            {
                groupSearcher = (GroupSearcher)SearcherFactory.GetSearcher(GroupSearcher.CODE);
            }

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

            //删除索引
            if (eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                groupSearcher.Delete(group.GroupId);
            }

            //更新索引
            if (eventArgs.EventOperationType == EventOperationType.Instance().Update() || eventArgs.EventOperationType == EventOperationType.Instance().Approved() || eventArgs.EventOperationType == EventOperationType.Instance().Disapproved())
            {
                groupSearcher.Update(group);
            }
        }
예제 #5
0
 /// <summary>
 /// 删除和更新标签时触发
 /// </summary>
 private void DeleteUpdateTags_Before(Tag sender, CommonEventArgs eventArgs)
 {
     if (sender.TenantTypeId == TenantTypeIds.Instance().Group())
     {
         if (eventArgs.EventOperationType == EventOperationType.Instance().Delete() || eventArgs.EventOperationType == EventOperationType.Instance().Update())
         {
             //根据标签获取所有使用该标签的(内容项)群组
             IEnumerable<long> groupIds = tagService.GetItemIds(sender.TagName, null);
             if (groupSearcher == null)
             {
                 groupSearcher = (GroupSearcher)SearcherFactory.GetSearcher(GroupSearcher.CODE);
             }
             groupSearcher.Update(groupService.GetGroupEntitiesByIds(groupIds));
         }
     }
 }