diff --git a/SlnMesnac.Serilog/SerilogExtensions.cs b/SlnMesnac.Serilog/SerilogExtensions.cs
index d65e0b6..6f9b303 100644
--- a/SlnMesnac.Serilog/SerilogExtensions.cs
+++ b/SlnMesnac.Serilog/SerilogExtensions.cs
@@ -46,9 +46,9 @@ namespace SlnMesnac.Serilog
#endregion
Log.Logger = new LoggerConfiguration().MinimumLevel.Information().WriteTo.Console()
- .WriteTo.File(Path.Combine(logPath, "Info.log"), LogEventLevel.Information, fileSizeLimitBytes: 5 * 1024)
- .WriteTo.File(Path.Combine(logPath, "Error.log"), LogEventLevel.Error, fileSizeLimitBytes: 5 * 1024)
- .WriteTo.File(Path.Combine(logPath, "Warn.log"), LogEventLevel.Warning, fileSizeLimitBytes: 5 * 1024)
+ .WriteTo.File(Path.Combine(logPath, "Info.log"), LogEventLevel.Information)
+ .WriteTo.File(Path.Combine(logPath, "Error.log"), LogEventLevel.Error)
+ .WriteTo.File(Path.Combine(logPath, "Warn.log"), LogEventLevel.Warning)
//.WriteTo.File(Path.Combine(logPath, "Debug.log"), LogEventLevel.Debug, fileSizeLimitBytes: 5 * 1024)
.CreateLogger();
app.UseSerilogRequestLogging();
diff --git a/SlnMesnac.TouchSocket/ApiServer.cs b/SlnMesnac.TouchSocket/ApiServer.cs
new file mode 100644
index 0000000..d704959
--- /dev/null
+++ b/SlnMesnac.TouchSocket/ApiServer.cs
@@ -0,0 +1,109 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using TouchSocket.Rpc;
+using TouchSocket.WebApi;
+
+#region << 版 本 注 释 >>
+/*--------------------------------------------------------------------
+* 版权所有 (c) 2024 WenJY 保留所有权利。
+* CLR版本:4.0.30319.42000
+* 机器名称:T14-GEN3-7895
+* 命名空间:SlnMesnac.TouchSocket
+* 唯一标识:649766cc-308e-4bf3-8d69-dea48ec40642
+*
+* 创建者:WenJY
+* 电子邮箱:
+* 创建时间:2024-09-04 10:51:54
+* 版本:V1.0.0
+* 描述:
+*
+*--------------------------------------------------------------------
+* 修改人:
+* 时间:
+* 修改说明:
+*
+* 版本:V1.0.0
+*--------------------------------------------------------------------*/
+#endregion << 版 本 注 释 >>
+namespace SlnMesnac.TouchSocket
+{
+ public class ApiServer: RpcServer
+ {
+
+ public delegate void RefreshScanInfoInCenterStart();
+ ///
+ /// 入库开始事件刷新
+ ///
+ public event RefreshScanInfoInCenterStart RefreshScanInfoInCenterStartEvent;
+
+ public delegate void RefreshScanInfoInCenterStop();
+ ///
+ /// 入库结束事件刷新
+ ///
+ public event RefreshScanInfoInCenterStop RefreshScanInfoInCenterStopEvent;
+
+ public delegate void RefreshScanInfoOutCenterStart();
+ ///
+ /// 出库开始事件刷新
+ ///
+ public event RefreshScanInfoOutCenterStart RefreshScanInfoOutCenterStartEvent;
+
+ public delegate void RefreshScanInfoOutCenterStop();
+ ///
+ /// 出库结束事件刷新
+ ///
+ public event RefreshScanInfoOutCenterStop RefreshScanInfoOutCenterStopEvent;
+
+ ///
+ /// 入库开始
+ ///
+ ///
+ ///
+ [EnableCors("cors")]
+ [WebApi(HttpMethodType.POST)]
+ public object getScanInfoInCenterStart(string messageHeader)
+ {
+ RefreshScanInfoInCenterStartEvent?.Invoke();
+ return true;
+ }
+
+ ///
+ /// 入库结束
+ ///
+ ///
+ ///
+ [EnableCors("cors")]
+ [WebApi(HttpMethodType.POST)]
+ public object getScanInfoInCenterStop(string messageHeader)
+ {
+ RefreshScanInfoInCenterStopEvent?.Invoke();
+ return true;
+ }
+
+ ///
+ /// 出库开始
+ ///
+ ///
+ ///
+ [WebApi(HttpMethodType.POST)]
+ public object getScanInfoOutCenterStart(string messageHeader)
+ {
+ RefreshScanInfoOutCenterStartEvent?.Invoke();
+ return true;
+ }
+
+ ///
+ /// 出库结束
+ ///
+ ///
+ ///
+ [WebApi(HttpMethodType.POST)]
+ public object getScanInfoOutCenterStop(string messageHeader)
+ {
+ RefreshScanInfoOutCenterStopEvent?.Invoke();
+ return true;
+ }
+
+ }
+}
diff --git a/SlnMesnac.TouchSocket/SlnMesnac.TouchSocket.csproj b/SlnMesnac.TouchSocket/SlnMesnac.TouchSocket.csproj
index 790191c..94f69ee 100644
--- a/SlnMesnac.TouchSocket/SlnMesnac.TouchSocket.csproj
+++ b/SlnMesnac.TouchSocket/SlnMesnac.TouchSocket.csproj
@@ -6,7 +6,9 @@
-
+
+
+
diff --git a/SlnMesnac.TouchSocket/TouchSocketSetup.cs b/SlnMesnac.TouchSocket/TouchSocketSetup.cs
index 31ca7db..637d77f 100644
--- a/SlnMesnac.TouchSocket/TouchSocketSetup.cs
+++ b/SlnMesnac.TouchSocket/TouchSocketSetup.cs
@@ -39,6 +39,9 @@ namespace SlnMesnac.TouchSocket
{
var _server = app.ApplicationServices.GetService();
_server.Init(20108);
+
+ var _apiServer = app.ApplicationServices.GetService();
+ _apiServer.Init();
return app;
}
}
diff --git a/SlnMesnac.TouchSocket/WebApiServer.cs b/SlnMesnac.TouchSocket/WebApiServer.cs
new file mode 100644
index 0000000..7c85740
--- /dev/null
+++ b/SlnMesnac.TouchSocket/WebApiServer.cs
@@ -0,0 +1,112 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading.Tasks;
+using TouchSocket.Core;
+using TouchSocket.Http;
+using TouchSocket.Rpc;
+using TouchSocket.Sockets;
+using TouchSocket.WebApi.Swagger;
+
+#region << 版 本 注 释 >>
+/*--------------------------------------------------------------------
+* 版权所有 (c) 2024 WenJY 保留所有权利。
+* CLR版本:4.0.30319.42000
+* 机器名称:T14-GEN3-7895
+* 命名空间:SlnMesnac.TouchSocket
+* 唯一标识:4e47989b-9d43-426e-b67a-529de3b1b0e8
+*
+* 创建者:WenJY
+* 电子邮箱:
+* 创建时间:2024-09-04 10:51:29
+* 版本:V1.0.0
+* 描述:
+*
+*--------------------------------------------------------------------
+* 修改人:
+* 时间:
+* 修改说明:
+*
+* 版本:V1.0.0
+*--------------------------------------------------------------------*/
+#endregion << 版 本 注 释 >>
+namespace SlnMesnac.TouchSocket
+{
+ public class WebApiServer
+ {
+ private ApiServer _apiServer;
+
+ public WebApiServer(ApiServer apiServer)
+ {
+ _apiServer = apiServer;
+ }
+
+ public void Init()
+ {
+ try
+ {
+ var service = new HttpService();
+ service.Setup(new TouchSocketConfig()
+ .SetListenIPHosts(7789)
+ .ConfigureContainer(a =>
+ {
+ a.AddRpcStore(store =>
+ {
+
+ store.RegisterServer(_apiServer);//注册服务
+ });
+
+ a.AddCors(corsOption =>
+ {
+ corsOption.Add("cors", corsBuilder =>
+ {
+ corsBuilder.AllowAnyMethod()
+ .AllowAnyOrigin();
+ });
+ });
+
+ a.AddLogger(logger =>
+ {
+ logger.AddConsoleLogger();
+ logger.AddFileLogger();
+ });
+ })
+ .ConfigurePlugins(a =>
+ {
+ a.UseCheckClear();
+
+ a.Add();
+
+ a.UseWebApi()
+ .ConfigureConverter(converter =>
+ {
+ converter.AddJsonSerializerFormatter(new Newtonsoft.Json.JsonSerializerSettings() { Formatting = Newtonsoft.Json.Formatting.None });
+ });
+
+ a.UseSwagger();//使用Swagger页面
+ //.UseLaunchBrowser();
+
+ a.UseDefaultHttpServicePlugin();
+ }));
+ service.Start();
+
+ Console.WriteLine("以下连接用于测试webApi");
+ Console.WriteLine($"使用:http://127.0.0.1:7789/swagger/index.html");
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.ToString());
+ }
+
+ //Console.ReadLine();
+ }
+ }
+
+ internal class AuthenticationPlugin : PluginBase, IHttpPlugin
+ {
+ public async Task OnHttpRequest(IHttpSocketClient client, HttpContextEventArgs e)
+ {
+ await e.InvokeNext();
+ }
+ }
+}
diff --git a/SlnMesnac.WPF/Startup.cs b/SlnMesnac.WPF/Startup.cs
index f65ebe7..e4251dc 100644
--- a/SlnMesnac.WPF/Startup.cs
+++ b/SlnMesnac.WPF/Startup.cs
@@ -12,6 +12,7 @@ using SlnMesnac.Rfid;
using SlnMesnac.Ioc;
using SlnMesnac.Plc;
using SlnMesnac.Extensions;
+using SlnMesnac.TouchSocket;
namespace SlnMesnac.WPF
{
@@ -71,6 +72,8 @@ namespace SlnMesnac.WPF
//启用Serilog中间件
app.UseSerilogExtensions();
+ app.UseTouchSocketExtensions();
+
app.UseRouting();
app.UseAuthorization();