Beispiel #1
0
        public async Task <ContentPageResponse> GenerateContentPage(ContentPageRequest contentPageRequest)
        {
            var response = new ContentPageResponse();

            try
            {
                //查询实体
                var entity = await GetEntity(contentPageRequest.Type, contentPageRequest.Id);

                if (entity == null)
                {
                    throw new Exception("未找到对应的内容数据");
                }
                //将富文本转为html
                var targetHtml = entity.Attributes["mcs_contenttext"]?.ToString();
                if (string.IsNullOrWhiteSpace(targetHtml))
                {
                    throw new Exception("该内容页没有正文内容");
                }
                //防乱码,加入滚动条样式,后期改为模板读取
                targetHtml = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />" + @"<style>
                      /* 设置滚动条的样式 */
                  ::-webkit-scrollbar{
                      width: 3px;
                  }
                  /*滚动槽*/
                  ::-webkit-scrollbar-track{
                      box-shadow: inset 0 0 6px rgba(0,0,0,0.1);
                      border-radius: 10px;
                  }
                  /* 滚动条滑块 */
                  ::-webkit-scrollbar-thumb {
                      border-radius: 10px;
                      background: rgba(0, 0, 0, 0.1);
                      box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.15);
                  }
                  </style>" + targetHtml;
                //写入目标地址
                var resultPath = @"HtmlResources/Fronts/" + entity.Attributes["mcs_frontcontentid"].ToString();
                var targetPath = Directory.GetCurrentDirectory() + @"\wwwroot\" + resultPath;
                if (!Directory.Exists(targetPath))
                {
                    Directory.CreateDirectory(targetPath);
                }
                var fileName = "/" + entity.EntityName.ToString() + ".html";
                File.WriteAllText(targetPath + fileName, targetHtml);
                response.Url = resultPath + fileName;
            }
            catch (Exception ex)
            {
                response.IsSuccess = false;
                response.Url       = ex.Message + ";" + ex.InnerException?.Message;
            }
            return(response);
        }
Beispiel #2
0
 public async Task <ContentPageResponse> GenerateContentPage(ContentPageRequest contentPageRequest)
 {
     return(await _contentmanagementService.GenerateContentPage(contentPageRequest));
 }
 public async Task <ContentPageResponse> GenerateContentPage(ContentPageRequest contentPageRequest)
 {
     return(await _appContentManagement.GenerateContentPage(contentPageRequest));
 }