コード例 #1
0
        public AssociatedInfo GetAssociatedInfo(long associateId, string tenantTypeId = "")
        {
            MicroblogService microblogService = new MicroblogService();
            MicroblogEntity  microblog        = microblogService.Get(associateId);

            if (microblog != null)
            {
                IMicroblogUrlGetter urlGetter = MicroblogUrlGetterFactory.Get(microblog.TenantTypeId);
                return(new AssociatedInfo()
                {
                    DetailUrl = urlGetter.MicroblogDetail(microblog.MicroblogId),
                    Subject = HtmlUtility.TrimHtml(microblog.GetResolvedBody(), 16)
                });
            }
            return(null);
        }
コード例 #2
0
        /// <summary>
        /// 内容处理
        /// </summary>
        /// <param name="body">待处理内容</param>
        /// <param name="associateId">待处理相关项Id</param>
        /// <param name="userId">相关项作者</param>
        /// <param name="ownerId">拥有者Id</param>
        /// <returns></returns>
        public string Process(string body, string ownerTenantTypeId, long associateId, long userId, long ownerId)
        {
            string        tenantTypeId  = TenantTypeIds.Instance().Microblog();
            AtUserService atUserService = new AtUserService(tenantTypeId);

            body = atUserService.ResolveBodyForDetail(body, associateId, userId, AtUserTagGenerate);

            TagService tagService = new TagService(tenantTypeId);

            Func <KeyValuePair <string, long>, long, string> topicTagGenerate = delegate(KeyValuePair <string, long> _tagNameWithId, long _ownerId)
            {
                return(string.Format("<a href=\"{1}\">#{0}#</a>", _tagNameWithId.Key, MicroblogUrlGetterFactory.Get(ownerTenantTypeId).TopicDetail(_tagNameWithId.Key.Trim(), _ownerId)));
            };

            body = tagService.ResolveBodyForDetail(body, associateId, ownerId, topicTagGenerate);

            body = body.Replace("\n", "<br/>");

            EmotionService emotionService = DIContainer.Resolve <EmotionService>();

            body = emotionService.EmoticonTransforms(body);

            ParsedMediaService parsedMediaService = DIContainer.Resolve <ParsedMediaService>();

            body = parsedMediaService.ResolveBodyForDetail(body, associateId, userId, UrlTagGenerate);

            return(body);
        }