Administrator 2 months ago
parent
commit
aee911cc20
  1. 20
      UserClass/AsyncTcpClient.cs
  2. 2
      View/imgQR.xaml.cs
  3. 8
      ViewModel/MainWindowViewModel.cs

20
UserClass/AsyncTcpClient.cs

@ -103,21 +103,17 @@ namespace SunlightAggregationManager.UserClass
MainWindowViewModel.Updata_Memory(MainWindowViewModel._userData, "User='" + deserializedPerson?.User + "'", myDict);
Console.WriteLine("[Log on]User[" + deserializedPerson?.User + "]Note[" + (deserializedPerson?.Dat ?? "unknown") + "]");
CommandC(deserializedPerson?.Dat ?? "NOT", deserializedPerson!);
CommandC(deserializedPerson?.Dat ?? "NOT", deserializedPerson!);
}
else
{//停用账号关闭连接
client.SendAsync("Account Deactivated");
client.SendAsync("Account Deactivated");
}
}
else
{ //无效账号关闭连接
client.SendAsync("Invalid Account");
client.SendAsync("Invalid Account");
}
}
catch (Exception ex)
{//错误
@ -134,12 +130,22 @@ namespace SunlightAggregationManager.UserClass
await tcpClient.SetupAsync(new TouchSocketConfig()
.SetSingleStreamDataHandlingAdapter(() => new PeriodPackageAdapter())//以超时周期和包
.SetRemoteIPHost(ip)
.SetKeepAliveValue(options => //心跳
{
options.AckInterval = 2000;
options.Interval = 30 * 1000;
})
.ConfigurePlugins(a =>
{
a.UseReconnection<TouchSocket.Sockets.TcpClient>(options =>
{
options.PollingInterval = TimeSpan.FromSeconds(3);
});
})
.ConfigureContainer(a =>
{
}));
await tcpClient.ConnectAsync();//调用连接,当连接不成功时,会抛出异常。

2
View/imgQR.xaml.cs

@ -99,7 +99,7 @@ namespace SunlightAggregationManager.View
{
string text_APP = "TEST"; //
string text_LINK = MainWindowViewModel.MachineIP + ":"+ MainWindowViewModel.MachineIPP1 +
",HTTP//:" + MainWindowViewModel.SERVERIP + "/" + MainWindowViewModel.Enterprise;
"," + MainWindowViewModel.SERVERIP + "/"+ MainWindowViewModel.Enterprise;
// 要生成二维码的内容
imgQR_CREATE(text_APP, imgQR_app);

8
ViewModel/MainWindowViewModel.cs

@ -31,6 +31,7 @@ namespace SunlightAggregationManager.ViewModel
public static string MachineIP = "";
public static int MachineIPP1 = 7789;
public static int MachineIPP2 = 7790;
public static int MachineHTTPP = 7791;
public static string Enterprise = "";
public static string TCP_E = "0";
public static string HTTP_E = "0";
@ -127,15 +128,14 @@ namespace SunlightAggregationManager.ViewModel
}
if (HTTP_E == "1")//启动tcp(内网直连)
{
int P1;
try
{
P1 = int.Parse(Configini.IniReadvalue("NETWORK", "HTTP_PORT"));
MachineHTTPP = int.Parse(Configini.IniReadvalue("NETWORK", "HTTP_PORT"));
}
catch (Exception) { P1 = 7791; }
catch (Exception) { MachineHTTPP = 7791; }
Service.Rows.Add(2, "RUN", "HTTP");
AsyncHttpServer.Configuration(P1);
AsyncHttpServer.Configuration(MachineHTTPP);
}
else
{

Loading…
Cancel
Save