2024-11-08 17:30:51 +08:00
|
|
|
|
using Serein.Library;
|
|
|
|
|
|
using Serein.Library.Utils;
|
|
|
|
|
|
using System;
|
2024-10-15 10:55:41 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Net.Sockets;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
|
using System.Windows.Shapes;
|
|
|
|
|
|
|
2024-10-15 21:56:09 +08:00
|
|
|
|
namespace Serein.Workbench.Themes
|
2024-10-15 10:55:41 +08:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// WindowDialogInput.xaml 的交互逻辑
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public partial class WindowEnvRemoteLoginView : Window
|
|
|
|
|
|
{
|
|
|
|
|
|
private Action<string, int, string> ConnectRemoteFlowEnv;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 弹窗输入
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="connectRemoteFlowEnv"></param>
|
|
|
|
|
|
public WindowEnvRemoteLoginView(Action<string, int, string> connectRemoteFlowEnv)
|
|
|
|
|
|
{
|
|
|
|
|
|
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
ConnectRemoteFlowEnv = connectRemoteFlowEnv;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ButtonTestConnect_Client(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
var addres = this.TextBlockAddres.Text;
|
|
|
|
|
|
_ = int.TryParse(this.TextBlockPort.Text, out var port);
|
|
|
|
|
|
_ = Task.Run(() => {
|
|
|
|
|
|
bool success = false;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
TcpClient tcpClient = new TcpClient();
|
|
|
|
|
|
var result = tcpClient.BeginConnect(addres, port, null, null);
|
|
|
|
|
|
success = result.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(3));
|
|
|
|
|
|
}
|
2024-11-08 17:30:51 +08:00
|
|
|
|
catch
|
2024-10-15 10:55:41 +08:00
|
|
|
|
{
|
2024-11-08 17:30:51 +08:00
|
|
|
|
success = false;
|
2024-10-15 10:55:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (!success)
|
|
|
|
|
|
{
|
2024-11-08 17:30:51 +08:00
|
|
|
|
SereinEnv.WriteLine(InfoType.ERROR, $"无法连接远程:{addres}:{port}");
|
2024-10-15 10:55:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ButtonTestLoginEnv_Client(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
var addres = this.TextBlockAddres.Text;
|
|
|
|
|
|
_ = int.TryParse(this.TextBlockPort.Text, out var port);
|
|
|
|
|
|
var token = this.TextBlockToken.Text;
|
|
|
|
|
|
ConnectRemoteFlowEnv?.Invoke(addres, port, token);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|