170 lines
3.8 KiB
C#
170 lines
3.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using System.Management.Automation;
|
|
using System.Management.Automation.Runspaces;
|
|
using System.Security;
|
|
using System.Diagnostics;
|
|
using System.Net;
|
|
using Renci.SshNet;
|
|
|
|
namespace PublishSite
|
|
{
|
|
public partial class PublishForm : Form
|
|
{
|
|
public PublishForm()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
|
|
public string CurrentEnv = "Local";
|
|
|
|
public string Host = "";
|
|
|
|
public string UserName = "";
|
|
|
|
public string Password = "";
|
|
|
|
|
|
|
|
|
|
private void PublishForm_Load(object sender, EventArgs e)
|
|
{
|
|
string remoteComputerName = "123.56.94.154"; // 远程计算机名称
|
|
string userName = "Administrator"; // 用户名
|
|
string password = "WHxckj2019"; // 密码
|
|
|
|
|
|
string localFilePath = $@"D:\testUpload.txt";
|
|
string remoteFilePath = $@"C:\temp\testUpload.txt";
|
|
|
|
|
|
CopyFileToRemote(localFilePath, remoteFilePath, remoteComputerName, userName, password);
|
|
}
|
|
|
|
private void startBakBtn_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
#region 服务的创建与删除
|
|
|
|
private void createService_Btn_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void deleteService_Btn_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void selectPathBtn_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 测试环境发布
|
|
|
|
private void vuePublishBtn_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
|
|
using (var client = new SshClient("123.56.94.154", "Administrator", "WHxckj2019"))
|
|
{
|
|
// 连接到远程服务器
|
|
client.Connect();
|
|
|
|
//&& ./IRaCIS_Vue_Web.bat
|
|
string command = $@"cd C:\Users\Administrator\VueSourceCode && npm i && npm run build";
|
|
|
|
|
|
using (var cmd = client.CreateCommand(command))
|
|
{
|
|
|
|
Console.WriteLine("开始执行");
|
|
|
|
Console.WriteLine(command);
|
|
|
|
|
|
var output = cmd.Execute();
|
|
|
|
Console.WriteLine(output);
|
|
|
|
|
|
var output3 = cmd.Execute($@"xcopy /Y /Q ""C:\Users\Administrator\VueSourceCode\dist\index.html"" ""D:\Develop\PublishSite\IRaCIS.Vue.Web\dist\""");
|
|
|
|
Console.WriteLine(output);
|
|
|
|
Console.WriteLine("发布成功");
|
|
}
|
|
|
|
// 断开SSH连接
|
|
client.Disconnect();
|
|
}
|
|
}
|
|
|
|
private void netCorePublishBtn_Click(object sender, EventArgs e)
|
|
{
|
|
using (var client = new SshClient("123.56.94.154", "Administrator", "WHxckj2019"))
|
|
{
|
|
// 连接到远程服务器
|
|
client.Connect();
|
|
|
|
//&& ./IRaCIS_Vue_Web.bat
|
|
string command = $@"cd C:\Users\Administrator\bat\ && ./IRaCIS_Core_API.bat";
|
|
|
|
|
|
using (var cmd = client.CreateCommand(command))
|
|
{
|
|
|
|
Console.WriteLine("开始执行");
|
|
|
|
Console.WriteLine(command);
|
|
|
|
var output = cmd.Execute();
|
|
|
|
Console.WriteLine(output);
|
|
|
|
Console.WriteLine("发布成功");
|
|
}
|
|
|
|
// 断开SSH连接
|
|
client.Disconnect();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region 服务的启动与停止
|
|
|
|
private void startServiceBtn_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void stopServiceBtn_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
}
|
|
}
|