|
|
@@ -2,6 +2,7 @@
|
|
|
using YSAI.Core.@enum;
|
|
|
using YSAI.Core.data;
|
|
|
using YSAI.Unility;
|
|
|
+using Newtonsoft.Json.Linq;
|
|
|
|
|
|
namespace YSAI.Manage.Controllers
|
|
|
{
|
|
|
@@ -12,70 +13,65 @@ namespace YSAI.Manage.Controllers
|
|
|
[Route("api/[controller]/[action]")]
|
|
|
public class InfoOperateController : Controller
|
|
|
{
|
|
|
- ///// <summary>
|
|
|
- ///// 参数
|
|
|
- ///// </summary>
|
|
|
- ///// <param name="DType">库类型</param>
|
|
|
- ///// <returns>统一出参</returns>
|
|
|
- //[HttpGet]
|
|
|
- //public object Param(LibType DType)
|
|
|
- //{
|
|
|
- // switch (DType)
|
|
|
- // {
|
|
|
- // case LibType.DB:
|
|
|
- // return new DBData.Basics();
|
|
|
- // case LibType.Modbus:
|
|
|
- // return new ModbusClientData.Basics();
|
|
|
- // case LibType.OpcUa:
|
|
|
- // return new OpcUaClientData.Basics();
|
|
|
- // case LibType.OpcDa:
|
|
|
- // return new OpcDaClientData.Basics();
|
|
|
- // case LibType.OpcDaHttp:
|
|
|
- // return new OpcDaHttpData.Basics();
|
|
|
- // case LibType.S7:
|
|
|
- // return new S7ClientData.Basics();
|
|
|
- // case LibType.Kafka:
|
|
|
- // return new KafkaData.Basics();
|
|
|
- // case LibType.Mqtt:
|
|
|
- // return new MqttClientData.Basics();
|
|
|
- // case LibType.RabbitMQ:
|
|
|
- // return new RabbitMQData.Basics();
|
|
|
- // default:
|
|
|
- // return new OperateResult(false, "输入有误", 0.1);
|
|
|
- // }
|
|
|
- //}
|
|
|
+ /// <summary>
|
|
|
+ /// 文件夹路径
|
|
|
+ /// </summary>
|
|
|
+ private readonly string Path = $"{AppDomain.CurrentDomain.BaseDirectory}param";
|
|
|
+ /// <summary>
|
|
|
+ /// 参数文件名
|
|
|
+ /// </summary>
|
|
|
+ private readonly string ParamFileName = $"YSAI.*.Param.json";
|
|
|
+ /// <summary>
|
|
|
+ /// 参数详情文件名
|
|
|
+ /// </summary>
|
|
|
+ private readonly string ParamDetailsFileName = $"YSAI.*.ParamDetails.json";
|
|
|
|
|
|
- ///// <summary>
|
|
|
- ///// 参数详情
|
|
|
- ///// </summary>
|
|
|
- ///// <param name="DType">库类型</param>
|
|
|
- ///// <returns>统一出参</returns>
|
|
|
- //[HttpGet]
|
|
|
- //public OperateResult ParamDetails(LibType DType)
|
|
|
- //{
|
|
|
- // switch (DType)
|
|
|
- // {
|
|
|
- // case LibType.DB:
|
|
|
- // return new OperateResult(true, string.Empty, 0.1, RData: ReflexTool.GetClassAllPropertyData<DBData.Basics>(), RType: ResultType.Json);
|
|
|
- // case LibType.Modbus:
|
|
|
- // return new OperateResult(true, string.Empty, 0.1, RData: ReflexTool.GetClassAllPropertyData<ModbusClientData.Basics>(), RType: ResultType.Json);
|
|
|
- // case LibType.OpcUa:
|
|
|
- // return new OperateResult(true, string.Empty, 0.1, RData: ReflexTool.GetClassAllPropertyData<OpcUaClientData.Basics>(), RType: ResultType.Json);
|
|
|
- // case LibType.OpcDa:
|
|
|
- // return new OperateResult(true, string.Empty, 0.1, RData: ReflexTool.GetClassAllPropertyData<OpcDaClientData.Basics>(), RType: ResultType.Json);
|
|
|
- // case LibType.OpcDaHttp:
|
|
|
- // return new OperateResult(true, string.Empty, 0.1, RData: ReflexTool.GetClassAllPropertyData<OpcDaHttpData.Basics>(), RType: ResultType.Json);
|
|
|
- // case LibType.S7:
|
|
|
- // return new OperateResult(true, string.Empty, 0.1, RData: ReflexTool.GetClassAllPropertyData<S7ClientData.Basics>(), RType: ResultType.Json);
|
|
|
- // case LibType.Kafka:
|
|
|
- // return new OperateResult(true, string.Empty, 0.1, RData: ReflexTool.GetClassAllPropertyData<KafkaData.Basics>(), RType: ResultType.Json);
|
|
|
- // case LibType.Mqtt:
|
|
|
- // return new OperateResult(true, string.Empty, 0.1, RData: ReflexTool.GetClassAllPropertyData<MqttClientData.Basics>(), RType: ResultType.Json);
|
|
|
- // case LibType.RabbitMQ:
|
|
|
- // return new OperateResult(true, string.Empty, 0.1, RData: ReflexTool.GetClassAllPropertyData<RabbitMQData.Basics>(), RType: ResultType.Json);
|
|
|
- // default:
|
|
|
- // return new OperateResult(false, "输入有误", 0.1);
|
|
|
- // }
|
|
|
- //}
|
|
|
+ /// <summary>
|
|
|
+ /// 获取库类型集合
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet]
|
|
|
+ public List<string> LibTypes()
|
|
|
+ {
|
|
|
+ List<string> LTypes = new List<string>();
|
|
|
+ string[] Files = Directory.GetFiles(Path, ParamFileName, SearchOption.TopDirectoryOnly);
|
|
|
+ foreach (string File in Files)
|
|
|
+ {
|
|
|
+ LTypes.Add(FileTool.GetFileName(File).Split('.')[1]);
|
|
|
+ }
|
|
|
+ return LTypes;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 参数
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="LType">库类型</param>
|
|
|
+ /// <returns>统一出参</returns>
|
|
|
+ [HttpGet]
|
|
|
+ public object Param(string LType)
|
|
|
+ {
|
|
|
+ string path = $"{Path}//{ParamFileName.Replace("*", LType)}";
|
|
|
+ if (System.IO.File.Exists(path))
|
|
|
+ {
|
|
|
+ return FileTool.FileToString(path);
|
|
|
+ }
|
|
|
+ return new OperateResult(false, $"{LType} 不存在", 0.8);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 参数详情
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="LType">库类型</param>
|
|
|
+ /// <returns>统一出参</returns>
|
|
|
+ [HttpGet]
|
|
|
+ public object ParamDetails(string LType)
|
|
|
+ {
|
|
|
+ string path = $"{Path}//{ParamDetailsFileName.Replace("*", LType)}";
|
|
|
+ if (System.IO.File.Exists(path))
|
|
|
+ {
|
|
|
+ return FileTool.FileToString(path);
|
|
|
+ }
|
|
|
+ return new OperateResult(false, $"{LType} 不存在", 0.8);
|
|
|
+ }
|
|
|
}
|
|
|
}
|