diff --git a/Library/Network/Http/Router.cs b/Library/Network/Http/Router.cs
index b10d9c0..06983a5 100644
--- a/Library/Network/Http/Router.cs
+++ b/Library/Network/Http/Router.cs
@@ -316,8 +316,14 @@ namespace Serein.Library.Web
{
return false;
}
-
- var routeValues = GetUrlData(url); // 解析 URL 获取路由参数
+ if (!HandleModels.TryGetValue(httpMethod, out var modules))
+ {
+ return false;
+ }
+ if (!modules.TryGetValue(template, out var config))
+ {
+ return false;
+ }
ControllerBase controllerInstance = (ControllerBase)SereinIOC.Instantiate(controllerType);
@@ -326,47 +332,25 @@ namespace Serein.Library.Web
return false; // 未找到控制器实例
}
+ object invokeResult;
+ var routeValues = GetUrlData(url); // 解析 URL 获取路由参数
controllerInstance.Url = url.AbsolutePath;
-
-
- if (!HandleModels.TryGetValue(httpMethod, out var modules))
- {
- return false;
- }
- if (!modules.TryGetValue(template,out var config))
- {
- return false;
- }
-
-
-
-
- dynamic invokeResult;
switch (httpMethod)
{
case "GET":
- invokeResult = config.HandleGet(controllerInstance, routeValues);
+ invokeResult = await config.HandleGet(controllerInstance, routeValues);
break;
case "POST":
var requestBody = await ReadRequestBodyAsync(request); // 读取请求体内容
controllerInstance.BobyData = requestBody;
var requestJObject = JObject.Parse(requestBody);
- invokeResult = config.HandlePost(controllerInstance, requestJObject, routeValues);
+ invokeResult = await config.HandlePost(controllerInstance, requestJObject, routeValues);
break;
default:
invokeResult = null;
break;
}
- object result;
- try
- {
- result = invokeResult.Result;
- }
- catch (Exception)
- {
- result = invokeResult;
- }
- Return(response, result); // 返回结果
+ Return(response, invokeResult); // 返回结果
return true;
}
diff --git a/Net462DllTest/Net462DllTest.csproj b/Net462DllTest/Net462DllTest.csproj
index 795dd79..ab55b01 100644
--- a/Net462DllTest/Net462DllTest.csproj
+++ b/Net462DllTest/Net462DllTest.csproj
@@ -99,8 +99,8 @@
{73B272E8-222D-4D08-A030-F1E1DB70B9D1}
Serein.Library.Framework
-
- {9FCE93C2-2278-46F3-96AB-CDAAFF27A55F}
+
+ {5e19d0f2-913a-4d1c-a6f8-1e1227baa0e3}
Serein.Library
diff --git a/Net462DllTest/View/FromWorkBenchView.cs b/Net462DllTest/View/FromWorkBenchView.cs
index 5390649..30d6f7b 100644
--- a/Net462DllTest/View/FromWorkBenchView.cs
+++ b/Net462DllTest/View/FromWorkBenchView.cs
@@ -49,7 +49,7 @@ namespace Net462DllTest
private void FromWorkBenchView_FormClosing(object sender, FormClosingEventArgs e)
{
- ViewModel.CommandCloseForm?.Execute();
+ ViewModel.CommandCloseForm.Execute();
}
private void button2_Click(object sender, EventArgs e)
diff --git a/Net462DllTest/ViewModel/FromWorkBenchViewModel.cs b/Net462DllTest/ViewModel/FromWorkBenchViewModel.cs
index cea7980..4f60a8c 100644
--- a/Net462DllTest/ViewModel/FromWorkBenchViewModel.cs
+++ b/Net462DllTest/ViewModel/FromWorkBenchViewModel.cs
@@ -132,6 +132,10 @@ namespace Net462DllTest.ViewModel
CommandGetParkingSpace = new RelayCommand((p) =>
{
viewManagement.TriggerSignal(SelectedSignal, SpcaeNumber);
+ });
+ CommandCloseForm = new RelayCommand((p) =>
+ {
+
});
diff --git a/Net462DllTest/Web/PlcSocketService.cs b/Net462DllTest/Web/PlcSocketService.cs
index 1c5cdb4..3233991 100644
--- a/Net462DllTest/Web/PlcSocketService.cs
+++ b/Net462DllTest/Web/PlcSocketService.cs
@@ -82,6 +82,7 @@ namespace Net462DllTest.Web
});
context.Env.IOC.Run((socketServer) =>
{
+ socketServer.MsgHandleHelper.RemoteModule(this);
socketServer?.Stop(); // 关闭 Web 服务
});
MyPlc.Close();
@@ -105,8 +106,6 @@ namespace Net462DllTest.Web
string ip = "192.168.10.100",
int port = 102)
{
- MyPlc.Model.Set(PlcVarName.DoorVar, (Int16)1);
- MyPlc.Model.Get(PlcVarName.DoorVar);
if (MyPlc.Client is null)
{
try