コード例 #1
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);
        }
コード例 #2
0
        public string Process(string body, string tenantTypeId, long associateId, long userId)
        {
            //解析附件、视频、音频、@用户、表情
            //todo:需要封装附件、视频、音频、@用户、表情解析的辅助方法,参照表情解析完成;
            //性能优化采用敏感词的替换算法,由宝声协助完成

            //解析at用户
            AtUserService atUserService = new AtUserService(tenantTypeId);

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

            AttachmentService        attachmentService = new AttachmentService(tenantTypeId);
            IEnumerable <Attachment> attachments       = attachmentService.GetsByAssociateId(associateId);

            if (attachments != null && attachments.Count() > 0)
            {
                IList <BBTag> bbTags       = new List <BBTag>();
                string        htmlTemplate = "<div class=\"tn-annexinlaid\"><a href=\"javascript:;\" target=\"_blank\" menu=\"#attachement-artdialog-{4}\">{0}</a>(<em>{1}</em>{2},<em>下载次数:{3}</em>)</div>";

                //解析文本中附件
                IEnumerable <Attachment> attachmentsFiles = attachments.Where(n => n.MediaType != MediaType.Image);
                foreach (var attachment in attachmentsFiles)
                {
                    bbTags.Add(AddBBTag(htmlTemplate, attachment));
                }

                body = HtmlUtility.BBCodeToHtml(body, bbTags);
            }

            body = new EmotionService().EmoticonTransforms(body);
            body = new ParsedMediaService().ResolveBodyForHtmlDetail(body, ParsedMediaTagGenerate);

            return(body);
        }
コード例 #3
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 ProcessForMobile(string body, string ownerTenantTypeId, long associateId, long userId, long ownerId)
        {
            ParsedMediaService parsedMediaService = DIContainer.Resolve <ParsedMediaService>();

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

            return(body);
        }
コード例 #4
0
ファイル: WikiBodyProcessor.cs プロジェクト: x1987624/SNS
        public string Process(string body, string tenantTypeId, long associateId, long userId)
        {
            AttachmentService        attachmentService = new AttachmentService(tenantTypeId);
            IEnumerable <Attachment> attachments       = attachmentService.GetsByAssociateId(associateId);

            if (attachments != null && attachments.Count() > 0)
            {
                IList <BBTag> bbTags       = new List <BBTag>();
                string        htmlTemplate = "<div class=\"tn-annexinlaid\"><a href=\"javascript:;\" target=\"_blank\" menu=\"#attachement-artdialog-{4}\">{0}</a>(<em>{1}</em>{2},<em>下载次数:{3}</em>)</div>";

                //解析文本中附件
                IEnumerable <Attachment> attachmentsFiles = attachments.Where(n => n.MediaType != MediaType.Image);
                foreach (var attachment in attachmentsFiles)
                {
                    bbTags.Add(AddBBTag(htmlTemplate, attachment));
                }

                body = HtmlUtility.BBCodeToHtml(body, bbTags);
            }
            body = new ParsedMediaService().ResolveBodyForHtmlDetail(body, ParsedMediaTagGenerate);
            return(body);
        }