Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement
This commit is contained in:
commit
f92275f2d9
3 files changed
+36
-16
No files matched your search
@@ -924,4 +924,7 @@
|
|||||||
<data name="Today" xml:space="preserve">
|
<data name="Today" xml:space="preserve">
|
||||||
<value>今天</value>
|
<value>今天</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Test" xml:space="preserve">
|
||||||
|
<value>測試</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -23,6 +23,8 @@ using Newtonsoft.Json;
|
|||||||
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
||||||
using SunlightCentralizedControlManagement_SCCM_.View;
|
using SunlightCentralizedControlManagement_SCCM_.View;
|
||||||
using TcpClient = TouchSocket.Sockets.TcpClient;
|
using TcpClient = TouchSocket.Sockets.TcpClient;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||||
{/// <summary>
|
{/// <summary>
|
||||||
@@ -30,13 +32,19 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class AsyncTcpClient
|
public class AsyncTcpClient
|
||||||
{
|
{
|
||||||
public static async Task<bool> TcpClient(TcpClient tcpClient, string ip,string port)
|
public static async Task TcpClient(TcpClient tcpClient, string ip,string port)
|
||||||
{
|
{
|
||||||
//TcpClient tcpClient = new TcpClient();
|
//TcpClient tcpClient = new TcpClient();
|
||||||
tcpClient.Connecting = (client, e) => { return EasyTask.CompletedTask; };//即将连接到服务器,此时已经创建socket,但是还未建立tcp
|
tcpClient.Connecting = (client, e) => { return EasyTask.CompletedTask; };//即将连接到服务器,此时已经创建socket,但是还未建立tcp
|
||||||
tcpClient.Connected = (client, e) =>
|
tcpClient.Connected = (client, e) =>
|
||||||
{
|
{
|
||||||
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "' AND port='" + client.Port + "'").First();
|
||||||
|
drEmployee.BeginEdit();
|
||||||
|
drEmployee["State"] = "101";
|
||||||
|
drEmployee.EndEdit();
|
||||||
|
drEmployee.AcceptChanges();
|
||||||
|
drEmployee.ClearErrors();
|
||||||
|
|
||||||
return EasyTask.CompletedTask;
|
return EasyTask.CompletedTask;
|
||||||
};//成功连接到服务器
|
};//成功连接到服务器
|
||||||
tcpClient.Closing = (client, e) => { return EasyTask.CompletedTask; };//即将从服务器断开连接。此处仅主动断开才有效。
|
tcpClient.Closing = (client, e) => { return EasyTask.CompletedTask; };//即将从服务器断开连接。此处仅主动断开才有效。
|
||||||
@@ -58,13 +66,24 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
.SetRemoteIPHost(ip+":"+port)
|
.SetRemoteIPHost(ip+":"+port)
|
||||||
.ConfigurePlugins(a =>
|
.ConfigurePlugins(a =>
|
||||||
{
|
{
|
||||||
|
a.UseCheckClear()
|
||||||
|
.SetCheckClearType(CheckClearType.All)
|
||||||
|
.SetTick(TimeSpan.FromSeconds(30))
|
||||||
|
.SetOnClose((c, t) =>
|
||||||
|
{
|
||||||
|
c.TryShutdown();
|
||||||
|
});
|
||||||
a.UseTcpReconnection();//触发型重连
|
a.UseTcpReconnection();//触发型重连
|
||||||
})
|
})
|
||||||
.ConfigureContainer(a =>
|
.ConfigureContainer(a =>
|
||||||
{
|
{
|
||||||
// a.AddConsoleLogger();//添加一个日志注入
|
// a.AddConsoleLogger();//添加一个日志注入
|
||||||
}));
|
}));
|
||||||
try
|
|
||||||
|
// Result result = await
|
||||||
|
_ = tcpClient.TryConnectAsync();
|
||||||
|
// return result.IsSuccess;
|
||||||
|
/* try
|
||||||
{
|
{
|
||||||
await tcpClient.ConnectAsync();//调用连接,当连接不成功时,会抛出异常。
|
await tcpClient.ConnectAsync();//调用连接,当连接不成功时,会抛出异常。
|
||||||
return true;
|
return true;
|
||||||
@@ -72,7 +91,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,9 +106,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
|
|
||||||
private readonly TcpClient[] MachiensTcpClient = new TcpClient[999];
|
private readonly TcpClient[] MachiensTcpClient = new TcpClient[999];
|
||||||
public int Machinesdata_Count;
|
public int Machinesdata_Count;
|
||||||
public async void TcpClientNEW()
|
public void TcpClientNEW()
|
||||||
{
|
{
|
||||||
bool Machine_ = false;
|
// bool Machine_ ;
|
||||||
DataRow[] machinesdata = Machines.Select("PORT>0 AND IP<>''", "id asc");//获取连接有效的组
|
DataRow[] machinesdata = Machines.Select("PORT>0 AND IP<>''", "id asc");//获取连接有效的组
|
||||||
Machinesdata_Count = machinesdata.Count();
|
Machinesdata_Count = machinesdata.Count();
|
||||||
|
|
||||||
@@ -116,14 +116,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
{
|
{
|
||||||
MachiensTcpClient[i] = new TcpClient();
|
MachiensTcpClient[i] = new TcpClient();
|
||||||
DataRow dt = machinesdata[i];
|
DataRow dt = machinesdata[i];
|
||||||
|
Updata_Machines(Machines, Convert.ToInt16(dt["ID"]), "State", "800");
|
||||||
Machine_ = await AsyncTcpClient.TcpClient(MachiensTcpClient[i] //建立tcp连接
|
_ = AsyncTcpClient.TcpClient(MachiensTcpClient[i] //建立tcp连接
|
||||||
, Selet_Machines(MainWindowViewModel.Machines, "IP", Convert.ToInt16(dt["ID"])).ToString()
|
, Selet_Machines(Machines, "IP", Convert.ToInt16(dt["ID"])).ToString()
|
||||||
, Selet_Machines(MainWindowViewModel.Machines, "PORT", Convert.ToInt16(dt["ID"])).ToString());
|
, Selet_Machines(Machines, "PORT", Convert.ToInt16(dt["ID"])).ToString());
|
||||||
|
}
|
||||||
if (!Machine_) Updata_Machines(Machines , Convert.ToInt16(dt["ID"]), "State" ,"309" );
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string SYS_WorkNumder; //工单号
|
public static string SYS_WorkNumder; //工单号
|
||||||
public static int SYS_AT1; //附缸1-3
|
public static int SYS_AT1; //附缸1-3
|
||||||
|
|||||||
Reference in new issue
Block a user