예제 #1
0
        /// <summary>
        /// 判断是否关注了被判定用户
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="toUserId">被判定用户Id</param>
        /// <param name="groupNames">被关注用户所属分组</param>
        /// <returns>true-关注,false-没关注</returns>
        public bool IsFollowed(long userId, long toUserId, out IEnumerable <string> groupNames)
        {
            bool isFollow = followRepository.IsFollowed(userId, toUserId);

            groupNames = null;
            if (isFollow)
            {
                FollowEntity followEntity = followRepository.Get(userId, toUserId);
                groupNames = categoryService.GetCategoriesOfItem(followEntity.Id, userId, TenantTypeIds.Instance().User()).Select(n => n.CategoryName);
            }

            return(isFollow);
        }
예제 #2
0
        /// <summary>
        /// 解析内容用于创建话题
        /// </summary>
        /// <param name="body">待解析的内容</param>
        /// <param name="ownerId">标签拥有者Id</param>
        /// <param name="associateId">关联项Id</param>
        /// <param name="tenantTypeId">租户类型Id</param>
        public void ResolveBodyForEdit(string body, long ownerId, long associateId, string tenantTypeId)
        {
            if (!body.Contains("#") || string.IsNullOrEmpty(body))
            {
                return;
            }

            Regex rg = new Regex(@"(?<=(?<!\&)(\#)(?!\d\;))[^\#@]*(?=(?<!\&)(\#)(?![0-9]+\;))", RegexOptions.Multiline | RegexOptions.Singleline);
            Match m  = rg.Match(body);

            if (!m.Success)
            {
                return;
            }

            IList <string> tagNames = new List <string>();
            int            i = 0, index = -1;

            while (m != null)
            {
                if (i % 2 == 1)
                {
                    m = m.NextMatch();
                    i++;
                    continue;
                }

                if (index == m.Index)
                {
                    break;
                }

                index = m.Index;

                if (!string.IsNullOrEmpty(m.Value) && !tagNames.Contains(m.Value))
                {
                    tagNames.Add(m.Value);
                }
                else
                {
                    continue;
                }

                m = m.NextMatch();
                i++;
            }

            if (tagNames.Count > 0)
            {
                CountService countService = new CountService(TenantTypeIds.Instance().Tag());
                AddTagsToItem(tagNames.ToArray(), ownerId, associateId);

                Dictionary <string, long> tagNamesWithIds = GetTagNamesWithIdsOfItem(associateId);
                if (tagNamesWithIds != null)
                {
                    foreach (KeyValuePair <string, long> pair in tagNamesWithIds)
                    {
                        countService.ChangeCount(CountTypes.Instance().ItemCounts(), pair.Value, ownerId, 1);
                    }
                }
            }
        }