Просмотр исходного кода

模板内容从数据库读取

lichunlei 5 месяцев назад
Родитель
Сommit
f1765991b6
1 измененных файлов с 7 добавлено и 1 удалено
  1. 7 1
      Task/MakeHelper.cs

+ 7 - 1
Task/MakeHelper.cs

@@ -1,8 +1,10 @@
 using System.Collections;
 using System.Text.RegularExpressions;
 using Common;
+using Infrastructure;
 using LitJson;
 using Microsoft.CodeAnalysis.CSharp.Scripting;
+using Services;
 
 namespace Tasks
 {
@@ -42,7 +44,11 @@ namespace Tasks
             //附加数据,原样返回
             string attach = jsonObj["attach"].ToString();
             //读取模板文件内容
-            string templateString = Function.ReadInstance("Template/" + modePath);
+            // string templateString = Function.ReadInstance("Template/" + modePath);
+            var templateService = App.GetRequiredService<IMakeTemplateService>();
+            var template = templateService.GetFirst(m => m.templateName == modePath);
+            if(template == null) return;
+            string templateString = template.templateContent;
             //解析模板内容
             string resultString = Util.Maker.StartMake(jsonObj["data"], templateString);
             //MQ回调解析的结果