Browse Source

新增模板缓存Manager

loki.wu 2 years ago
parent
commit
dde3bac946

+ 20 - 0
fis/Managers/Interfaces/IReportTemplateCacheManager.cs

@@ -0,0 +1,20 @@
+namespace fis.Managers.Interfaces
+{
+    internal interface IReportTemplateCacheManager : IFisManager
+    {
+        /// <summary>
+        /// 设置模板缓存
+        /// </summary>
+        /// <param name="code"></param>
+        /// <param name="json"></param>
+        void SetTemplateJson(string code, string json);
+
+
+        /// <summary>
+        /// 根据模板Code获取模板信息Json
+        /// </summary>
+        /// <param name="code"></param>
+        /// <returns></returns>
+        string GetTemplateByCode(string code);
+    }
+}

+ 45 - 0
fis/Managers/ReportTemplateCacheManager.cs

@@ -0,0 +1,45 @@
+using fis.Log;
+using fis.Managers.Interfaces;
+using System.Collections.Generic;
+
+namespace fis.Win.Managers
+{
+    internal class ReportTemplateCacheManager : IReportTemplateCacheManager
+    {
+        /// <summary>
+        ///  key: templateCode
+        ///  value: templateInfoJson
+        /// </summary>
+        private Dictionary<string, string> _templateInfos = new();
+
+        public void SetTemplateJson(string code,string json) 
+        {
+            if (_templateInfos.ContainsKey(code))
+            {
+                _templateInfos[code] = json;
+            }
+            else 
+            {
+                _templateInfos.Add(code, json);
+            }
+        }
+
+        public string GetTemplateByCode(string code)
+        {
+            if (_templateInfos.ContainsKey(code))
+            {
+                return _templateInfos[code];
+            }
+            else 
+            {
+                Logger.Write("GetTemplateByCode error,code not exist: " + code);
+            }
+            return string.Empty;
+        }
+
+        public void Dispose()
+        {
+            //
+        }
+    }
+}