Ver Fonte

Fix 补全丢失文件

YueYunyun há 1 ano atrás
pai
commit
cb07bd5bfe

+ 2 - 0
.gitignore

@@ -201,6 +201,8 @@ PublishScripts/
 **/[Pp]ackages/*
 # except build/, which is used as an MSBuild target.
 !**/[Pp]ackages/build/
+!**/Application/[Pp]ackages/*
+
 # Uncomment if necessary however generally it will be regenerated when needed
 #!**/[Pp]ackages/repositories.config
 # NuGet v3's project.json files produces more ignorable files

+ 42 - 0
SourceCode/We.Engine/WeEngine.Runtime/Application/Packages/Dto/FunctionDto.cs

@@ -0,0 +1,42 @@
+using System.Collections.Generic;
+using System.Linq;
+using IwbZero.IwbBase;
+using WeEngine.Functions;
+
+namespace WeEngine.Application.Packages.Dto
+{
+    public class FunctionDto:IIwbId
+    {
+        public FunctionDto(ExprFunction eFun)
+        {
+            Id = eFun.Id;
+            Name = eFun.FunctionName;
+            Description = eFun.FunctionDesc;
+            Params = new List<FunParamDto>();
+            if (eFun.Params != null && eFun.Params.Any())
+            {
+                foreach (var eFunParam in eFun.Params)
+                {
+                    Params.Add(new FunParamDto()
+                    {
+                        Index =eFunParam.Index,
+                        ParamName = eFunParam.Name,
+                        ParamType = eFunParam.ExprType
+                    });
+                }
+            }
+        }
+
+        public string Id { get; set; }
+        public string Name { get; set; }
+        public string Description { get; set; }
+        public List<FunParamDto> Params { get; set; }
+    }
+
+    public class FunParamDto
+    {
+        public int Index { get; set; }
+        public string ParamName { get; set; }
+        public string ParamType { get; set; }
+    }
+}

+ 66 - 0
SourceCode/We.Engine/WeEngine.Runtime/Application/Packages/EnginePackageAppService.cs

@@ -0,0 +1,66 @@
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using IwbZero.AppServiceBase;
+using WeEngine.Application.Packages.Dto;
+using WeEngine.Functions;
+
+namespace WeEngine.Application.Packages
+{
+    /// <summary>
+    ///演练方案包维护
+    /// </summary>
+    public class EnginePackageAppService : IwbZeroAppServiceBase, IEnginePackageAppService
+    {
+        public EnginePackageAppService()
+        {
+            PackageBasePath = $"{WeEngineConst.DataFileBasePath}Packages/";
+        }
+        private string PackageBasePath { get; }
+
+        /// <summary>
+        /// 预加载方案包
+        /// </summary>
+        /// <param name="packageNo"></param>
+        public void PreLoadPackage(string packageNo)
+        {
+            CacheManager.GetCache(EngineCacheName.Package).Remove(packageNo);
+            CacheManager.GetPackageXml(packageNo);
+        }
+
+        /// <summary>
+        /// 重新加载方案包
+        /// </summary>
+        /// <param name="packageNo"></param>
+        public void ReLoadPackage(string packageNo)
+        {
+            var path = $"{PackageBasePath}{packageNo}/";
+            if (Directory.Exists(path))
+            {
+                Directory.Delete(path, true);
+            }
+            PreLoadPackage(packageNo);
+        }
+
+        /// <summary>
+        /// 查询引擎函数
+        /// </summary>
+        /// <returns></returns>
+        public List<FunctionDto> QueryFunctions()
+        {
+            var funList= new List<FunctionDto>();
+            var exprFunList= ExprFunction.LoadByXml(ExprFunction.GetFunXmlNode());
+            if (exprFunList.Any())
+            {
+                foreach (var exprFun in exprFunList)
+                {
+                    if (exprFun.IsPublic)
+                    {
+                        funList.Add(new FunctionDto(exprFun));
+                    }
+                }
+            }
+            return funList;
+        }
+    }
+}

+ 33 - 0
SourceCode/We.Engine/WeEngine.Runtime/Application/Packages/IEnginePackageAppService.cs

@@ -0,0 +1,33 @@
+using System.Collections.Generic;
+using Abp.Application.Services;
+using Abp.Web.Models;
+using WeEngine.Application.Packages.Dto;
+
+namespace WeEngine.Application.Packages
+{
+    /// <summary>
+    /// 引擎运行
+    /// </summary>
+    [DontWrapResult]
+    public interface IEnginePackageAppService : IApplicationService
+    {
+
+        /// <summary>
+        /// 预加载方案包
+        /// </summary>
+        /// <param name="packageNo">方案包编号</param>
+        void PreLoadPackage(string packageNo);
+
+        /// <summary>
+        /// 重新加载方案包
+        /// </summary>
+        /// <param name="packageNo">方案包编号</param>
+        void ReLoadPackage(string packageNo);
+
+        /// <summary>
+        /// 查询引擎支持的函数
+        /// </summary>
+        /// <returns></returns>
+        List<FunctionDto> QueryFunctions();
+    }
+}