Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightAggregationManager
This commit is contained in:
commit
9b010a4998
2 files changed
+30
-1
No files matched your search
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using SunlightAggregationManager.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Sockets;
|
||||
|
||||
@@ -13,11 +15,26 @@ namespace SunlightAggregationManager.UserClass
|
||||
{
|
||||
await TcpClient(tcpClient, "tcp://"+ip);
|
||||
}
|
||||
|
||||
public static async void TcpTransmit(object Dat)
|
||||
{
|
||||
//发送字符串数据
|
||||
try
|
||||
{
|
||||
await tcpClient.SendAsync(JsonSerializer.Serialize(Dat));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Tcp:" + ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task TcpClient(TouchSocket.Sockets.TcpClient tcpClient, string ip)
|
||||
{
|
||||
tcpClient.Connecting = (client, e) => { return EasyTask.CompletedTask; };//即将连接到服务器,此时已经创建socket,但是还未建立tcp
|
||||
tcpClient.Connected = (client, e) =>
|
||||
{
|
||||
//设定显示状态
|
||||
System.Data.DataRow targetRow =ViewModel.MainWindowViewModel._service.Select("ID = 1").FirstOrDefault()!;
|
||||
if (targetRow != null)
|
||||
{
|
||||
@@ -25,6 +42,15 @@ namespace SunlightAggregationManager.UserClass
|
||||
targetRow["Status"] = "Connected";
|
||||
targetRow.EndEdit();
|
||||
}
|
||||
//发送本机信息到转发服务器
|
||||
Dictionary<string, object> myDict = new Dictionary<string, object>();
|
||||
myDict.Add("Enterprise", MainWindowViewModel.Enterprise);
|
||||
myDict.Add("MachineName", MainWindowViewModel.MachineName);
|
||||
myDict.Add("SERVERNAME", MainWindowViewModel.SERVERNAME);
|
||||
myDict.Add("SERVERUSER", MainWindowViewModel.SERVERUSER);
|
||||
myDict.Add("SERRVERPASWORD", MainWindowViewModel.SERRVERPASWORD);
|
||||
myDict.Add("MachineVer", MainWindowViewModel.MachineVer);
|
||||
TcpTransmit(myDict);
|
||||
return EasyTask.CompletedTask;
|
||||
};//成功连接到服务器
|
||||
tcpClient.Closing = (client, e) => { return EasyTask.CompletedTask; };//即将从服务器断开连接。此处仅主动断开才有效。
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace SunlightAggregationManager.ViewModel
|
||||
public static string SQLUSER = "";
|
||||
public static string SQLPASWORD = "";
|
||||
public static string MachineName = "SERVER";
|
||||
public static string MachineVer = "1.0.0";
|
||||
public static string Enterprise = "";
|
||||
public static string TCP_E = "0";
|
||||
public static string HTTP_E = "0";
|
||||
public static string TLS_E = "0";
|
||||
@@ -55,6 +57,7 @@ namespace SunlightAggregationManager.ViewModel
|
||||
SQLUSER = Configini.IniReadvalue("SQL_SERVER", "SQL4");
|
||||
SQLPASWORD = Configini.IniReadvalue("SQL_SERVER", "SQL5");
|
||||
MachineName = Configini.IniReadvalue("SYS", "Name");
|
||||
Enterprise = Configini.IniReadvalue("SYS", "Enterprise");
|
||||
TCP_E = Configini.IniReadvalue("NETWORK", "TCP");
|
||||
HTTP_E = Configini.IniReadvalue("NETWORK", "HTTP");
|
||||
TLS_E = Configini.IniReadvalue("NETWORK", "TLS");
|
||||
|
||||
Reference in new issue
Block a user