Compare commits
16 commits
2037f1ac4a
...
be4e8124bf
Author | SHA1 | Date | |
---|---|---|---|
![]() |
be4e8124bf | ||
![]() |
cc947ba969 | ||
![]() |
154df8b5cc | ||
![]() |
2ffe3c4373 | ||
![]() |
617f75ba36 | ||
![]() |
fa64f0c6d5 | ||
![]() |
6df1dbd6ae | ||
28f391d008 | |||
8b2c594880 | |||
![]() |
59a8b3164a | ||
e8bc478035 | |||
20ee8714de | |||
394ee5fe06 | |||
4c90c08e89 | |||
90d71b0944 | |||
4bbbf445b3 |
13 changed files with 255 additions and 64 deletions
4
.github/workflows/build.yaml
vendored
4
.github/workflows/build.yaml
vendored
|
@ -41,6 +41,8 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
cp Tool/JsScript/* release/JsScript/
|
cp Tool/JsScript/* release/JsScript/
|
||||||
Compress-Archive -Path "release/*" -DestinationPath "FS_win_dotnet8.zip" -Force
|
Compress-Archive -Path "release/*" -DestinationPath "FS_win_dotnet8.zip" -Force
|
||||||
|
$version = $env:GITHUB_REF -replace 'refs/tags/', ''
|
||||||
|
Write-Host "VERSION=$version" >> $env:GITHUB_ENV
|
||||||
- name: Release
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
@ -48,6 +50,6 @@ jobs:
|
||||||
files: |
|
files: |
|
||||||
FS_win_dotnet8.zip
|
FS_win_dotnet8.zip
|
||||||
LICENSE
|
LICENSE
|
||||||
name: ${{ github.ref }}
|
name: ${{ env.VERSION}}
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: true
|
prerelease: true
|
||||||
|
|
|
@ -69,14 +69,14 @@ public class WebSocPipeLine<TSocket>(TSocket socket, bool isAES) : AbsPipeLine(i
|
||||||
using var content = new MultipartFormDataContent();
|
using var content = new MultipartFormDataContent();
|
||||||
using var fileStream = new FileStream(filePath, FileMode.Open);
|
using var fileStream = new FileStream(filePath, FileMode.Open);
|
||||||
// TODO 上传进度回调
|
// TODO 上传进度回调
|
||||||
// var progress = new Progress<double>(
|
var progress = new Progress<double>(
|
||||||
// (current) =>
|
(current) =>
|
||||||
// {
|
{
|
||||||
// progressCb(current);
|
progressCb(current);
|
||||||
// }
|
}
|
||||||
// );
|
);
|
||||||
//var fileContent = new ProgressStreamContent(fileStream, progress);
|
var fileContent = new ProgressStreamContent(fileStream, progress);
|
||||||
content.Add(new StreamContent(fileStream), "file", Path.GetFileName(filePath));
|
content.Add(fileContent, "file", Path.GetFileName(filePath));
|
||||||
var it = await client.PostAsync("http://" + url + "/UploadFile", content);
|
var it = await client.PostAsync("http://" + url + "/UploadFile", content);
|
||||||
if (it.StatusCode != System.Net.HttpStatusCode.OK)
|
if (it.StatusCode != System.Net.HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
|
@ -103,8 +103,8 @@ public class WebSocPipeLine<TSocket>(TSocket socket, bool isAES) : AbsPipeLine(i
|
||||||
|
|
||||||
protected override async Task Listen(Func<byte[], bool> receiveCb)
|
protected override async Task Listen(Func<byte[], bool> receiveCb)
|
||||||
{
|
{
|
||||||
//warning 最大支持1MB,这由需要同步的文件数量大小决定 UTF-8 每个字符,汉字视为4个字节,数字1个 ,英文字母2个。1MB=256KB*4,25万个字符能描述就行
|
//warning 最大支持10MB,这由需要同步的文件数量大小决定 UTF-8 每个字符,汉字视为4个字节,数字1个 ,英文字母2个。1MB=256KB*4,25万个字符能描述就行
|
||||||
var buffer = new byte[1024 * 1024];
|
var buffer = new byte[10 * 1024 * 1024];
|
||||||
|
|
||||||
while (Socket.State == WebSocketState.Open)
|
while (Socket.State == WebSocketState.Open)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,8 +4,12 @@ public enum SyncMsgType
|
||||||
{
|
{
|
||||||
Error = 0,
|
Error = 0,
|
||||||
General = 1,
|
General = 1,
|
||||||
|
|
||||||
|
//进度消息
|
||||||
Process = 2,
|
Process = 2,
|
||||||
// DirFilePack = 3
|
|
||||||
|
//文件展示消息
|
||||||
|
DirFileDiff = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SyncProcessStep
|
public enum SyncProcessStep
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
|
using System;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace Common;
|
namespace Common;
|
||||||
|
|
||||||
public class ProgressStreamContent(Stream stream_, IProgress<double> progress)
|
public class ProgressStreamContent(Stream stream_, IProgress<double> progress)
|
||||||
: StreamContent(stream_, 4096)
|
: StreamContent(stream_, 5 * 1024 * 1024)
|
||||||
{
|
{
|
||||||
private readonly Stream FileStream = stream_;
|
private readonly Stream FileStream = stream_;
|
||||||
private readonly int BufferSize = 4096;
|
private readonly int BufferSize = 5 * 1024 * 1024;
|
||||||
private readonly IProgress<double> Progress = progress;
|
private readonly IProgress<double> Progress = progress;
|
||||||
|
|
||||||
protected override async Task SerializeToStreamAsync(
|
protected override async Task SerializeToStreamAsync(
|
||||||
|
|
|
@ -9,7 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LocalServer", "LocalServer\
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServerTest", "ServerTest\ServerTest.csproj", "{0D507943-43A3-4227-903F-E123A5CAF7F4}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServerTest", "ServerTest\ServerTest.csproj", "{0D507943-43A3-4227-903F-E123A5CAF7F4}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{3EED9D63-BC7B-455F-BA15-95BB52311ED8}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Common", "Common\Common.csproj", "{3EED9D63-BC7B-455F-BA15-95BB52311ED8}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|
|
@ -146,6 +146,7 @@ public class DeployHelper(LocalSyncServer context)
|
||||||
ProcessStartInfo startbuildInfo =
|
ProcessStartInfo startbuildInfo =
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
|
//p:DeployOnBuild=true
|
||||||
FileName = LocalSyncServer.MSBuildAbPath, // The command to execute (can be any command line tool)
|
FileName = LocalSyncServer.MSBuildAbPath, // The command to execute (can be any command line tool)
|
||||||
Arguments =
|
Arguments =
|
||||||
$" {Context.NotNullSyncConfig.LocalProjectAbsolutePath} /t:ResolveReferences"
|
$" {Context.NotNullSyncConfig.LocalProjectAbsolutePath} /t:ResolveReferences"
|
||||||
|
@ -286,6 +287,11 @@ public class DiffFileAndPackHelper(LocalSyncServer context)
|
||||||
Context.NotNullSyncConfig.LocalRootPath
|
Context.NotNullSyncConfig.LocalRootPath
|
||||||
);
|
);
|
||||||
e.DiffDirInfo.WriteByThisInfo(PackOp);
|
e.DiffDirInfo.WriteByThisInfo(PackOp);
|
||||||
|
Context
|
||||||
|
.LocalPipe.SendMsg(
|
||||||
|
CreateMsg(JsonSerializer.Serialize(e.DiffDirInfo), SyncMsgType.DirFileDiff)
|
||||||
|
)
|
||||||
|
.Wait();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Context.LocalPipe.SendMsg(CreateMsg("文件差异比较成功!")).Wait();
|
Context.LocalPipe.SendMsg(CreateMsg("文件差异比较成功!")).Wait();
|
||||||
|
@ -318,6 +324,7 @@ public class DeployMSSqlHelper(LocalSyncServer context)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Context.LocalPipe.SendMsg(CreateMsg("正在打包数据库...")).Wait();
|
||||||
var arguments =
|
var arguments =
|
||||||
$" /Action:Extract /TargetFile:{LocalSyncServer.TempRootFile}/{Context.NotNullSyncConfig.Id.ToString()}/{Context.NotNullSyncConfig.Id.ToString()}.dacpac"
|
$" /Action:Extract /TargetFile:{LocalSyncServer.TempRootFile}/{Context.NotNullSyncConfig.Id.ToString()}/{Context.NotNullSyncConfig.Id.ToString()}.dacpac"
|
||||||
// 不要log file 了
|
// 不要log file 了
|
||||||
|
@ -387,7 +394,7 @@ public class UploadPackedHelper(LocalSyncServer context)
|
||||||
$"{LocalSyncServer.TempRootFile}/{Context.NotNullSyncConfig.Id}.zip",
|
$"{LocalSyncServer.TempRootFile}/{Context.NotNullSyncConfig.Id}.zip",
|
||||||
(double current) =>
|
(double current) =>
|
||||||
{
|
{
|
||||||
//这里可能需要降低获取上传进度的频率
|
// 每上传1Mb 更新一下进度
|
||||||
Context
|
Context
|
||||||
.LocalPipe.SendMsg(CreateMsg(current.ToString(), SyncMsgType.Process))
|
.LocalPipe.SendMsg(CreateMsg(current.ToString(), SyncMsgType.Process))
|
||||||
.Wait();
|
.Wait();
|
||||||
|
|
|
@ -53,6 +53,7 @@ public class SyncFilesController(RemoteSyncServerFactory factory, SqliteDbContex
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="file"></param>
|
/// <param name="file"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
[DisableRequestSizeLimit]
|
||||||
[HttpPost("/UploadFile")]
|
[HttpPost("/UploadFile")]
|
||||||
public async Task<IActionResult> UploadFile(IFormFile file)
|
public async Task<IActionResult> UploadFile(IFormFile file)
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,7 +41,7 @@ if (app.Environment.IsDevelopment())
|
||||||
}
|
}
|
||||||
app.UseWebSockets();
|
app.UseWebSockets();
|
||||||
|
|
||||||
//app.Urls.Clear();
|
app.Urls.Clear();
|
||||||
//app.Urls.Add("http://0.0.0.0:6819");
|
app.Urls.Add("http://0.0.0.0:6819");
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"TempDir": "D:\\FileSyncTest\\dtemp",
|
"TempDir": "D:\\FileSyncTest\\dtemp",
|
||||||
"NamePwds": [
|
"NamePwds": [
|
||||||
[ "Test", "t123" ]
|
[ "Test", "t123" ],
|
||||||
|
[ "FYMF", "FYMF" ]
|
||||||
],
|
],
|
||||||
"SqlPackageAbPath": "C:\\Users\\ZHAOLEI\\.dotnet\\tools\\sqlpackage.exe"
|
"SqlPackageAbPath": "C:\\Users\\ZHAOLEI\\.dotnet\\tools\\sqlpackage.exe"
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,23 +4,23 @@ import WebSocket from "ws";
|
||||||
//#region ############################## 配置文件 ###################################
|
//#region ############################## 配置文件 ###################################
|
||||||
|
|
||||||
const LocalHost = "127.0.0.1";
|
const LocalHost = "127.0.0.1";
|
||||||
const config = {
|
let config = {
|
||||||
//发布的名称,每个项目具有唯一的一个名称
|
//发布的名称,每个项目具有唯一的一个名称
|
||||||
Name: "FYMF",
|
Name: "Test",
|
||||||
RemotePwd: "FYMF",
|
RemotePwd: "t123",
|
||||||
//远程服务器地址,也就是发布的目的地,它是正式环境
|
//远程服务器地址,也就是发布的目的地,它是正式环境
|
||||||
RemoteUrl: "127.0.0.1:8007",
|
RemoteUrl: "127.0.0.1:6819",
|
||||||
//是否发布数据库 sqlserver
|
//是否发布数据库 sqlserver
|
||||||
IsDeployDb: true,
|
IsDeployDb: true,
|
||||||
//是否发布前重新构建项目
|
//是否发布前重新构建项目
|
||||||
IsDeployProject: false,
|
IsDeployProject: true,
|
||||||
//项目地址
|
//项目地址
|
||||||
LocalProjectAbsolutePath:
|
LocalProjectAbsolutePath:
|
||||||
"D:/git/HMES-H7-HNFY/HMES-H7-HNFYMF/HMES-H7-HNFYMF.WEB",
|
"D:/git/HMES-H7-HNFY/HMES-H7-HNFYMF/HMES-H7-HNFYMF.WEB",
|
||||||
//源文件目录地址,是要发布的文件根目录,它是绝对路径,!执行发布时将发布到这个目录!
|
//源文件目录地址,是要发布的文件根目录,它是绝对路径,!执行发布时将发布到这个目录!
|
||||||
LocalRootPath: "D:/FileSyncTest/src",
|
LocalRootPath: "D:/FileSyncTest/src",
|
||||||
//目标文件目录地址,也就是部署服务的机器上的项目文件根目录,它是绝对路径
|
//目标文件目录地址,也就是部署服务的机器上的项目文件根目录,它是绝对路径
|
||||||
RemoteRootPath: "D:/FYMF",
|
RemoteRootPath: "D:/FileSyncTest/dst",
|
||||||
//源数据库配置 SqlServer,将会同步数据库的结构
|
//源数据库配置 SqlServer,将会同步数据库的结构
|
||||||
SrcDb: {
|
SrcDb: {
|
||||||
//Host
|
//Host
|
||||||
|
@ -44,7 +44,7 @@ const config = {
|
||||||
ServerName: "127.0.0.1",
|
ServerName: "127.0.0.1",
|
||||||
DatabaseName: "HMES_H7_HNFYMF",
|
DatabaseName: "HMES_H7_HNFYMF",
|
||||||
User: "sa",
|
User: "sa",
|
||||||
Password: "Yuanmo520...",
|
Password: "0",
|
||||||
TrustServerCertificate: "True",
|
TrustServerCertificate: "True",
|
||||||
},
|
},
|
||||||
//子目录配置,每个子目录都有自己不同的发布策略,它是相对路径,即相对于LocalRootPath和RemoteRootPath(注意 '/',这将拼成一个完整的路径),文件数据依此进行,
|
//子目录配置,每个子目录都有自己不同的发布策略,它是相对路径,即相对于LocalRootPath和RemoteRootPath(注意 '/',这将拼成一个完整的路径),文件数据依此进行,
|
||||||
|
@ -73,6 +73,52 @@ const config = {
|
||||||
// }
|
// }
|
||||||
// ]
|
// ]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
Name: "FYMF",
|
||||||
|
RemoteUrl: "212.129.223.183:6819",
|
||||||
|
RemotePwd: "FYMF",
|
||||||
|
IsDeployDb: false,
|
||||||
|
IsDeployProject: false,
|
||||||
|
LocalProjectAbsolutePath: "D:/git/HMES-H7-HNFY/HMES-H7-HNFYMF/HMES-H7-HNFYMF.WEB",
|
||||||
|
LocalRootPath: "D:/FileSyncTest/src",
|
||||||
|
RemoteRootPath: "E:/HMES_H7_HNFY_PREON",
|
||||||
|
SrcDb: {
|
||||||
|
ServerName: "172.16.12.2",
|
||||||
|
DatabaseName: "HMES_H7_HNFYMF",
|
||||||
|
User: "hmes-h7",
|
||||||
|
Password: "Hmes-h7666",
|
||||||
|
TrustServerCertificate: "True",
|
||||||
|
SyncTablesData: [
|
||||||
|
"dbo.sys_Button",
|
||||||
|
"dbo.sys_Menu",
|
||||||
|
"dbo.sys_Module",
|
||||||
|
"dbo.sys_Page",
|
||||||
|
"dbo.CommonPara"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
DstDb: {
|
||||||
|
ServerName: "172.16.80.1",
|
||||||
|
DatabaseName: "HMES_H7_HNFYMF_PRE",
|
||||||
|
User: "hnfypre",
|
||||||
|
Password: "pre0823",
|
||||||
|
TrustServerCertificate: "True"
|
||||||
|
},
|
||||||
|
DirFileConfigs: [
|
||||||
|
{
|
||||||
|
DirPath: "/",
|
||||||
|
Excludes: [
|
||||||
|
"Web.config",
|
||||||
|
"Log",
|
||||||
|
"Content",
|
||||||
|
"fonts"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
ExecProcesses: []
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region ############################## 打印函数 ###################################
|
//#region ############################## 打印函数 ###################################
|
||||||
|
@ -82,20 +128,20 @@ let IsSuccess = false;
|
||||||
* 在新行打印错误信息
|
* 在新行打印错误信息
|
||||||
*/
|
*/
|
||||||
function PrintErrInNewLine(str) {
|
function PrintErrInNewLine(str) {
|
||||||
process.stdout.write("\n");
|
|
||||||
var chunk = chalk["red"]("[错误]: ");
|
var chunk = chalk["red"]("[错误]: ");
|
||||||
process.stdout.write(chunk);
|
process.stdout.write(chunk);
|
||||||
process.stdout.write(str);
|
process.stdout.write(str);
|
||||||
|
process.stdout.write("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在新行打印成功信息
|
* 在新行打印成功信息
|
||||||
*/
|
*/
|
||||||
function PrintSuccessInNewLine(str) {
|
function PrintSuccessInNewLine(str) {
|
||||||
process.stdout.write("\n");
|
|
||||||
var chunk = chalk["green"]("[成功]: ");
|
var chunk = chalk["green"]("[成功]: ");
|
||||||
process.stdout.write(chunk);
|
process.stdout.write(chunk);
|
||||||
process.stdout.write(str);
|
process.stdout.write(str);
|
||||||
|
process.stdout.write("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,8 +157,11 @@ function PrintCloseNewLine(str) {
|
||||||
/**
|
/**
|
||||||
* 在当前行打印一般信息,打印此行信息之前会清除当前行
|
* 在当前行打印一般信息,打印此行信息之前会清除当前行
|
||||||
*/
|
*/
|
||||||
function PrintGeneralInCurrentLine(str) {
|
function PrintProcessLine(str) {
|
||||||
process.stdout.write(`\r${str}`);
|
var chunk = chalk["yellow"]("[上传进度]: ");
|
||||||
|
process.stdout.write(chunk);
|
||||||
|
process.stdout.write(`${str}`);
|
||||||
|
process.stdout.write("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
@ -122,26 +171,59 @@ function PrintGeneralInCurrentLine(str) {
|
||||||
/**
|
/**
|
||||||
* 1-n. localServer 工作,此处只展示信息
|
* 1-n. localServer 工作,此处只展示信息
|
||||||
*/
|
*/
|
||||||
let ws = null;
|
|
||||||
function MsgCb(MsgIt) {
|
function getOpEmoj(Op) {
|
||||||
if (MsgIt.Type == 2) {
|
switch (Op) {
|
||||||
PrintGeneralInCurrentLine(MsgIt.Body);
|
case 0:
|
||||||
} else {
|
return "A";
|
||||||
if (MsgIt.Step <= 6) {
|
case 1:
|
||||||
PrintSuccessInNewLine(`(${MsgIt.Step}/6) ${MsgIt.Body}`);
|
return "M";
|
||||||
if (MsgIt.Step == 6) {
|
case 2:
|
||||||
if (MsgIt.Body == "发布完成!") {
|
return "D";
|
||||||
IsSuccess = true;
|
default:
|
||||||
ws.close();
|
return "DIR";
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (MsgIt == 7) {
|
|
||||||
PrintErrInNewLine(MsgIt.Body);
|
|
||||||
} else {
|
|
||||||
PrintCloseNewLine("(关闭)" + MsgIt.Body);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let ws = null;
|
||||||
|
function MsgCb(MsgIt) {
|
||||||
|
if (MsgIt.Step <= 6) {
|
||||||
|
if (MsgIt.Type == 2) {
|
||||||
|
PrintProcessLine(`(${MsgIt.Step}/6) ${MsgIt.Body}`);
|
||||||
|
if (parseFloat(MsgIt.Body) == 1) {
|
||||||
|
var chunk = chalk["green"]("[上传成功]");
|
||||||
|
process.stdout.write(chunk);
|
||||||
|
process.stdout.write("\n");
|
||||||
|
}
|
||||||
|
} else if (MsgIt.Type == 3) {
|
||||||
|
var it = JSON.parse(MsgIt.Body);
|
||||||
|
const f = (item) => {
|
||||||
|
PrintSuccessInNewLine(
|
||||||
|
`(${MsgIt.Step}/6) [${getOpEmoj(item.NextOp)}] ${item.FormatedPath}`
|
||||||
|
);
|
||||||
|
if (item.Children) {
|
||||||
|
item.Children.forEach((e) => {
|
||||||
|
f(e)
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f(it)
|
||||||
|
} else {
|
||||||
|
PrintSuccessInNewLine(`(${MsgIt.Step}/6) ${MsgIt.Body}`);
|
||||||
|
}
|
||||||
|
if (MsgIt.Step == 6) {
|
||||||
|
if (MsgIt.Body == "发布完成!") {
|
||||||
|
IsSuccess = true;
|
||||||
|
ws.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (MsgIt.Step == 7) {
|
||||||
|
PrintErrInNewLine(MsgIt.Body);
|
||||||
|
} else {
|
||||||
|
PrintCloseNewLine("(关闭)" + MsgIt.Body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
async function connectWebSocket() {
|
async function connectWebSocket() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
@ -183,10 +265,17 @@ async function connectWebSocket() {
|
||||||
}
|
}
|
||||||
(async function main() {
|
(async function main() {
|
||||||
try {
|
try {
|
||||||
|
// for(var i = 0;i<10;++i) {
|
||||||
|
// PrintGeneralInCurrentLine(`${i}`)
|
||||||
|
// }
|
||||||
|
// PrintSuccessInNewLine("11")
|
||||||
await connectWebSocket();
|
await connectWebSocket();
|
||||||
|
if (!IsSuccess) {
|
||||||
|
throw new Error("发布失败");
|
||||||
|
}
|
||||||
// console.log('WebSocket has closed');
|
// console.log('WebSocket has closed');
|
||||||
// The script will wait here until the WebSocket connection is closed
|
// The script will wait here until the WebSocket connection is closed
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Failed to connect or an error occurred:", err);
|
throw new Error(err);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -12,26 +12,27 @@ const options = ref({
|
||||||
tabSize: 2,
|
tabSize: 2,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let IsSuccess = false
|
||||||
let Pipe = null
|
let Pipe = null
|
||||||
const Msgs = ref([])
|
const Msgs = ref([])
|
||||||
const code = ref(`
|
const code = ref(`
|
||||||
config = {
|
config = {
|
||||||
//发布的名称,每个项目具有唯一的一个名称
|
//发布的名称,每个项目具有唯一的一个名称
|
||||||
Name: "FYMF",
|
Name: "Test",
|
||||||
RemotePwd: "FYMF",
|
RemotePwd: "t123",
|
||||||
//远程服务器地址,也就是发布的目的地,它是正式环境
|
//远程服务器地址,也就是发布的目的地,它是正式环境
|
||||||
RemoteUrl: "127.0.0.1:8007",
|
RemoteUrl: "127.0.0.1:6819",
|
||||||
//是否发布数据库 sqlserver
|
//是否发布数据库 sqlserver
|
||||||
IsDeployDb: true,
|
IsDeployDb: true,
|
||||||
//是否发布前重新构建项目
|
//是否发布前重新构建项目
|
||||||
IsDeployProject: false,
|
IsDeployProject: true,
|
||||||
//项目地址
|
//项目地址
|
||||||
LocalProjectAbsolutePath:
|
LocalProjectAbsolutePath:
|
||||||
"D:/git/HMES-H7-HNFY/HMES-H7-HNFYMF/HMES-H7-HNFYMF.WEB",
|
"D:/git/HMES-H7-HNFY/HMES-H7-HNFYMF/HMES-H7-HNFYMF.WEB",
|
||||||
//源文件目录地址,是要发布的文件根目录,它是绝对路径,!执行发布时将发布到这个目录!
|
//源文件目录地址,是要发布的文件根目录,它是绝对路径,!执行发布时将发布到这个目录!
|
||||||
LocalRootPath: "D:/FileSyncTest/src",
|
LocalRootPath: "D:/FileSyncTest/src",
|
||||||
//目标文件目录地址,也就是部署服务的机器上的项目文件根目录,它是绝对路径
|
//目标文件目录地址,也就是部署服务的机器上的项目文件根目录,它是绝对路径
|
||||||
RemoteRootPath: "D:/FYMF",
|
RemoteRootPath: "D:/FileSyncTest/dst",
|
||||||
//源数据库配置 SqlServer,将会同步数据库的结构
|
//源数据库配置 SqlServer,将会同步数据库的结构
|
||||||
SrcDb: {
|
SrcDb: {
|
||||||
//Host
|
//Host
|
||||||
|
@ -55,7 +56,7 @@ config = {
|
||||||
ServerName: "127.0.0.1",
|
ServerName: "127.0.0.1",
|
||||||
DatabaseName: "HMES_H7_HNFYMF",
|
DatabaseName: "HMES_H7_HNFYMF",
|
||||||
User: "sa",
|
User: "sa",
|
||||||
Password: "Yuanmo520...",
|
Password: "0",
|
||||||
TrustServerCertificate: "True",
|
TrustServerCertificate: "True",
|
||||||
},
|
},
|
||||||
//子目录配置,每个子目录都有自己不同的发布策略,它是相对路径,即相对于LocalRootPath和RemoteRootPath(注意 '/',这将拼成一个完整的路径),文件数据依此进行,
|
//子目录配置,每个子目录都有自己不同的发布策略,它是相对路径,即相对于LocalRootPath和RemoteRootPath(注意 '/',这将拼成一个完整的路径),文件数据依此进行,
|
||||||
|
@ -86,16 +87,52 @@ config = {
|
||||||
};
|
};
|
||||||
`)
|
`)
|
||||||
var CStatus = ref('None')
|
var CStatus = ref('None')
|
||||||
|
function getOpEmoj(Op) {
|
||||||
|
switch (Op) {
|
||||||
|
case 0:
|
||||||
|
return "➕";
|
||||||
|
case 1:
|
||||||
|
return "Ⓜ️";
|
||||||
|
case 2:
|
||||||
|
return "❌";
|
||||||
|
default:
|
||||||
|
return "📁";
|
||||||
|
}
|
||||||
|
}
|
||||||
function publishCB(MsgIt) {
|
function publishCB(MsgIt) {
|
||||||
|
console.log(MsgIt)
|
||||||
if (MsgIt.Type == 2) {
|
if (MsgIt.Type == 2) {
|
||||||
Msgs.value[Msgs.value.length - 1] = MsgIt
|
Msgs.value[Msgs.value.length - 1] = MsgIt
|
||||||
} else {
|
} else if (MsgIt.Type == 3) {
|
||||||
|
var it = JSON.parse(MsgIt.Body);
|
||||||
|
/**
|
||||||
|
* This function appears to be intended for processing children elements, though the current implementation is incomplete.
|
||||||
|
*
|
||||||
|
* @param {Array} children - The array of child elements to be processed.
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
const f = (item) => {
|
||||||
|
Msgs.value.push({
|
||||||
|
Step: MsgIt.Step,
|
||||||
|
Type: MsgIt.Type,
|
||||||
|
Body: `[${getOpEmoj(item.NextOp)}] ${item.FormatedPath}`
|
||||||
|
})
|
||||||
|
if (item.Children) {
|
||||||
|
item.Children.forEach((e) => {
|
||||||
|
f(e)
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f(it)
|
||||||
|
}
|
||||||
|
else {
|
||||||
Msgs.value.push(MsgIt)
|
Msgs.value.push(MsgIt)
|
||||||
}
|
}
|
||||||
if (MsgIt.Step == 6) {
|
if (MsgIt.Step == 6) {
|
||||||
if (MsgIt.Body == "发布完成!") {
|
if (MsgIt.Body == "发布完成!") {
|
||||||
CStatus.value = 'Success'
|
CStatus.value = 'Success'
|
||||||
|
IsSuccess = true
|
||||||
Pipe.ClosePipe()
|
Pipe.ClosePipe()
|
||||||
dialogShow("正确:发布完成!")
|
dialogShow("正确:发布完成!")
|
||||||
}
|
}
|
||||||
|
@ -154,7 +191,7 @@ onMounted(() => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const dMsg = ref('')
|
const dMsg = ref('')
|
||||||
function dialogClose() {
|
function dialogClose() {
|
||||||
document.getElementById('dialog').close()
|
document.getElementById('dialog').close()
|
||||||
}
|
}
|
||||||
|
@ -162,6 +199,46 @@ function dialogShow(msg) {
|
||||||
dMsg.value = msg
|
dMsg.value = msg
|
||||||
document.getElementById('dialog').showModal()
|
document.getElementById('dialog').showModal()
|
||||||
}
|
}
|
||||||
|
function getColor(msg) {
|
||||||
|
if (msg.Step >= 7) {
|
||||||
|
if (IsSuccess) {
|
||||||
|
return "green"
|
||||||
|
}
|
||||||
|
return "red"
|
||||||
|
} else if (msg.Type == 2) {
|
||||||
|
return "yellow"
|
||||||
|
} else {
|
||||||
|
return "green"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function getTitle(msg) {
|
||||||
|
|
||||||
|
var x = getColor(msg)
|
||||||
|
switch (x) {
|
||||||
|
case "green":
|
||||||
|
return "[成功]"
|
||||||
|
break;
|
||||||
|
case "red":
|
||||||
|
return "[失败]"
|
||||||
|
break;
|
||||||
|
case "yellow":
|
||||||
|
return "[上传进度]"
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
function getStep(msg) {
|
||||||
|
if (msg.Step > 6) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return `(${msg.Step}/6)`
|
||||||
|
}
|
||||||
|
function getBody(msg) {
|
||||||
|
return msg.Body
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -173,13 +250,18 @@ function dialogShow(msg) {
|
||||||
|
|
||||||
<MonacoEditor theme="vs-dark" :options="options" language="javascript" :width="800" :height="700"
|
<MonacoEditor theme="vs-dark" :options="options" language="javascript" :width="800" :height="700"
|
||||||
v-model:value="code"></MonacoEditor>
|
v-model:value="code"></MonacoEditor>
|
||||||
<div style="width: 800px;height: 700px;background-color: #1e1e1e;">
|
<div style="width: 1200px;height: 700px;background-color: #1e1e1e;overflow:auto;">
|
||||||
发布日志
|
发布日志
|
||||||
|
|
||||||
<p style="text-align: left;border: 1px solid gray;margin: 5px;" v-for="msg in Msgs">
|
<p style="text-align: left;border: 1px solid gray;margin: 5px;" v-for="msg in Msgs">
|
||||||
<span :style="{ width: '100px', color: msg.Step > 6 ? 'red' : 'green' }">[{{ msg.Step
|
|
||||||
> 6 ? msg.Step > 7 ? "关闭" : "错误" : `${msg.Step}/${6}`}}]</span>
|
<span :style="{ width: '100px', color: getColor(msg) }">
|
||||||
<span style="margin-left: 5px ;">{{ msg.Body }}</span>
|
{{ getTitle(msg) }}
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
{{ getStep(msg) }}
|
||||||
|
</span>
|
||||||
|
{{ getBody(msg) }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,7 +7,7 @@ class ConnectPipe {
|
||||||
}
|
}
|
||||||
OpenPipe(config, MsgCb) {
|
OpenPipe(config, MsgCb) {
|
||||||
var webSocUrl = `ws://${window.location.host}/websoc?Name=${config.Name}`
|
var webSocUrl = `ws://${window.location.host}/websoc?Name=${config.Name}`
|
||||||
// var webSocUrl = "ws://127.0.0.1:6818/websoc?Name=Test";
|
// var webSocUrl = `ws://127.0.0.1:6818/websoc?Name=${config.Name}`;
|
||||||
this.#websocket = new WebSocket(webSocUrl);
|
this.#websocket = new WebSocket(webSocUrl);
|
||||||
this.#websocket.onopen = (event) => {
|
this.#websocket.onopen = (event) => {
|
||||||
var starter = {
|
var starter = {
|
||||||
|
|
|
@ -59,7 +59,7 @@ button:focus-visible {
|
||||||
}
|
}
|
||||||
|
|
||||||
#app {
|
#app {
|
||||||
max-width: 1280px;
|
/* max-width: 1280px; */
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
Loading…
Reference in a new issue