diff --git a/Server/Common/Message.cs b/Server/Common/Message.cs index 9c0c93b..6c3d73c 100644 --- a/Server/Common/Message.cs +++ b/Server/Common/Message.cs @@ -4,8 +4,12 @@ public enum SyncMsgType { Error = 0, General = 1, + + //进度消息 Process = 2, - // DirFilePack = 3 + + //文件展示消息 + DirFileDiff = 3 } public enum SyncProcessStep diff --git a/Server/Common/ProgressStreamContent.cs b/Server/Common/ProgressStreamContent.cs index 4130261..7361c8a 100644 --- a/Server/Common/ProgressStreamContent.cs +++ b/Server/Common/ProgressStreamContent.cs @@ -8,10 +8,10 @@ using System.Threading; namespace Common; public class ProgressStreamContent(Stream stream_, IProgress progress) - : StreamContent(stream_, 1024 * 1024) + : StreamContent(stream_, 5 * 1024 * 1024) { private readonly Stream FileStream = stream_; - private readonly int BufferSize = 1024 * 1024; + private readonly int BufferSize = 5 * 1024 * 1024; private readonly IProgress Progress = progress; protected override async Task SerializeToStreamAsync( diff --git a/Server/LocalServer/StateHelper.cs b/Server/LocalServer/StateHelper.cs index 0bc1f49..4a85eec 100644 --- a/Server/LocalServer/StateHelper.cs +++ b/Server/LocalServer/StateHelper.cs @@ -286,6 +286,11 @@ public class DiffFileAndPackHelper(LocalSyncServer context) Context.NotNullSyncConfig.LocalRootPath ); e.DiffDirInfo.WriteByThisInfo(PackOp); + Context + .LocalPipe.SendMsg( + CreateMsg(JsonSerializer.Serialize(e.DiffDirInfo), SyncMsgType.DirFileDiff) + ) + .Wait(); } }); Context.LocalPipe.SendMsg(CreateMsg("鏂囦欢宸紓姣旇緝鎴愬姛锛")).Wait(); @@ -318,6 +323,7 @@ public class DeployMSSqlHelper(LocalSyncServer context) } else { + Context.LocalPipe.SendMsg(CreateMsg("姝e湪鎵撳寘鏁版嵁搴...")).Wait(); var arguments = $" /Action:Extract /TargetFile:{LocalSyncServer.TempRootFile}/{Context.NotNullSyncConfig.Id.ToString()}/{Context.NotNullSyncConfig.Id.ToString()}.dacpac" // 涓嶈log file 浜 @@ -387,7 +393,7 @@ public class UploadPackedHelper(LocalSyncServer context) $"{LocalSyncServer.TempRootFile}/{Context.NotNullSyncConfig.Id}.zip", (double current) => { - //杩欓噷鍙兘闇瑕侀檷浣庤幏鍙栦笂浼犺繘搴︾殑棰戠巼 + // 姣忎笂浼1Mb 鏇存柊涓涓嬭繘搴 Context .LocalPipe.SendMsg(CreateMsg(current.ToString(), SyncMsgType.Process)) .Wait(); diff --git a/Tool/JsScript/release.js b/Tool/JsScript/release.js index 2ce4a76..1feb3f0 100644 --- a/Tool/JsScript/release.js +++ b/Tool/JsScript/release.js @@ -6,21 +6,21 @@ import WebSocket from "ws"; const LocalHost = "127.0.0.1"; const config = { //鍙戝竷鐨勫悕绉帮紝姣忎釜椤圭洰鍏锋湁鍞竴鐨勪竴涓悕绉 - Name: "FYMF", - RemotePwd: "FYMF", + Name: "Test", + RemotePwd: "t123", //杩滅▼鏈嶅姟鍣ㄥ湴鍧锛屼篃灏辨槸鍙戝竷鐨勭洰鐨勫湴锛屽畠鏄寮忕幆澧 - RemoteUrl: "127.0.0.1:8007", + RemoteUrl: "127.0.0.1:6819", //鏄惁鍙戝竷鏁版嵁搴 sqlserver IsDeployDb: true, //鏄惁鍙戝竷鍓嶉噸鏂版瀯寤洪」鐩 - IsDeployProject: false, + IsDeployProject: true, //椤圭洰鍦板潃 LocalProjectAbsolutePath: "D:/git/HMES-H7-HNFY/HMES-H7-HNFYMF/HMES-H7-HNFYMF.WEB", //婧愭枃浠剁洰褰曞湴鍧锛屾槸瑕佸彂甯冪殑鏂囦欢鏍圭洰褰曪紝瀹冩槸缁濆璺緞锛!鎵ц鍙戝竷鏃跺皢鍙戝竷鍒拌繖涓洰褰! LocalRootPath: "D:/FileSyncTest/src", //鐩爣鏂囦欢鐩綍鍦板潃锛屼篃灏辨槸閮ㄧ讲鏈嶅姟鐨勬満鍣ㄤ笂鐨勯」鐩枃浠舵牴鐩綍锛屽畠鏄粷瀵硅矾寰 - RemoteRootPath: "D:/FYMF", + RemoteRootPath: "D:/FileSyncTest/dst", //婧愭暟鎹簱閰嶇疆 SqlServer,灏嗕細鍚屾鏁版嵁搴撶殑缁撴瀯 SrcDb: { //Host @@ -44,7 +44,7 @@ const config = { ServerName: "127.0.0.1", DatabaseName: "HMES_H7_HNFYMF", User: "sa", - Password: "Yuanmo520...", + Password: "0", TrustServerCertificate: "True", }, //瀛愮洰褰曢厤缃紝姣忎釜瀛愮洰褰曢兘鏈夎嚜宸变笉鍚岀殑鍙戝竷绛栫暐锛屽畠鏄浉瀵硅矾寰勶紝鍗崇浉瀵逛簬LocalRootPath鍜孯emoteRootPath(娉ㄦ剰 '/'锛岃繖灏嗘嫾鎴愪竴涓畬鏁寸殑璺緞)锛屾枃浠舵暟鎹緷姝よ繘琛, @@ -82,20 +82,20 @@ let IsSuccess = false; * 鍦ㄦ柊琛屾墦鍗伴敊璇俊鎭 */ function PrintErrInNewLine(str) { - process.stdout.write("\n"); var chunk = chalk["red"]("[閿欒]: "); process.stdout.write(chunk); process.stdout.write(str); + process.stdout.write("\n"); } /** * 鍦ㄦ柊琛屾墦鍗版垚鍔熶俊鎭 */ function PrintSuccessInNewLine(str) { - process.stdout.write("\n"); var chunk = chalk["green"]("[鎴愬姛]: "); process.stdout.write(chunk); process.stdout.write(str); + process.stdout.write("\n"); } /** @@ -111,8 +111,11 @@ function PrintCloseNewLine(str) { /** * 鍦ㄥ綋鍓嶈鎵撳嵃涓鑸俊鎭紝鎵撳嵃姝よ淇℃伅涔嬪墠浼氭竻闄ゅ綋鍓嶈 */ -function PrintGeneralInCurrentLine(str) { - process.stdout.write(`\r${str}`); +function PrintProcessLine(str) { + var chunk = chalk["yellow"]("[涓婁紶杩涘害]: "); + process.stdout.write(chunk); + process.stdout.write(`${str}`); + process.stdout.write("\n"); } //#endregion @@ -122,26 +125,52 @@ function PrintGeneralInCurrentLine(str) { /** * 1-n. localServer 宸ヤ綔锛屾澶勫彧灞曠ず淇℃伅 */ -let ws = null; -function MsgCb(MsgIt) { - if (MsgIt.Type == 2) { - PrintGeneralInCurrentLine(MsgIt.Body); - } else { - if (MsgIt.Step <= 6) { - PrintSuccessInNewLine(`(${MsgIt.Step}/6) ${MsgIt.Body}`); - if (MsgIt.Step == 6) { - if (MsgIt.Body == "鍙戝竷瀹屾垚锛") { - IsSuccess = true; - ws.close(); - } - } - } else if (MsgIt == 7) { - PrintErrInNewLine(MsgIt.Body); - } else { - PrintCloseNewLine("(鍏抽棴)" + MsgIt.Body); - } + +function getOpEmoj(Op) { + switch (Op) { + case 0: + return "鉃"; + case 1: + return "鈸傦笍"; + case 2: + return "鉂"; + default: + return "馃殌"; } } +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); + it.Children.forEach((e) => { + PrintSuccessInNewLine( + `(${MsgIt.Step}/6) [${getOpEmoj(e.NextOp)}] ${e.FormatedPath}` + ); + }); + } 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 async function connectWebSocket() { return new Promise((resolve, reject) => { @@ -183,6 +212,10 @@ async function connectWebSocket() { } (async function main() { try { + // for(var i = 0;i<10;++i) { + // PrintGeneralInCurrentLine(`${i}`) + // } + // PrintSuccessInNewLine("11") await connectWebSocket(); // console.log('WebSocket has closed'); // The script will wait here until the WebSocket connection is closed diff --git a/Tool/webtool/src/App.vue b/Tool/webtool/src/App.vue index e3e4764..b057daa 100644 --- a/Tool/webtool/src/App.vue +++ b/Tool/webtool/src/App.vue @@ -12,26 +12,27 @@ const options = ref({ tabSize: 2, }) +let IsSuccess = false let Pipe = null const Msgs = ref([]) const code = ref(` config = { //鍙戝竷鐨勫悕绉帮紝姣忎釜椤圭洰鍏锋湁鍞竴鐨勪竴涓悕绉 - Name: "FYMF", - RemotePwd: "FYMF", + Name: "Test", + RemotePwd: "t123", //杩滅▼鏈嶅姟鍣ㄥ湴鍧锛屼篃灏辨槸鍙戝竷鐨勭洰鐨勫湴锛屽畠鏄寮忕幆澧 - RemoteUrl: "127.0.0.1:8007", + RemoteUrl: "127.0.0.1:6819", //鏄惁鍙戝竷鏁版嵁搴 sqlserver IsDeployDb: true, //鏄惁鍙戝竷鍓嶉噸鏂版瀯寤洪」鐩 - IsDeployProject: false, + IsDeployProject: true, //椤圭洰鍦板潃 LocalProjectAbsolutePath: "D:/git/HMES-H7-HNFY/HMES-H7-HNFYMF/HMES-H7-HNFYMF.WEB", //婧愭枃浠剁洰褰曞湴鍧锛屾槸瑕佸彂甯冪殑鏂囦欢鏍圭洰褰曪紝瀹冩槸缁濆璺緞锛!鎵ц鍙戝竷鏃跺皢鍙戝竷鍒拌繖涓洰褰! LocalRootPath: "D:/FileSyncTest/src", //鐩爣鏂囦欢鐩綍鍦板潃锛屼篃灏辨槸閮ㄧ讲鏈嶅姟鐨勬満鍣ㄤ笂鐨勯」鐩枃浠舵牴鐩綍锛屽畠鏄粷瀵硅矾寰 - RemoteRootPath: "D:/FYMF", + RemoteRootPath: "D:/FileSyncTest/dst", //婧愭暟鎹簱閰嶇疆 SqlServer,灏嗕細鍚屾鏁版嵁搴撶殑缁撴瀯 SrcDb: { //Host @@ -55,7 +56,7 @@ config = { ServerName: "127.0.0.1", DatabaseName: "HMES_H7_HNFYMF", User: "sa", - Password: "Yuanmo520...", + Password: "0", TrustServerCertificate: "True", }, //瀛愮洰褰曢厤缃紝姣忎釜瀛愮洰褰曢兘鏈夎嚜宸变笉鍚岀殑鍙戝竷绛栫暐锛屽畠鏄浉瀵硅矾寰勶紝鍗崇浉瀵逛簬LocalRootPath鍜孯emoteRootPath(娉ㄦ剰 '/'锛岃繖灏嗘嫾鎴愪竴涓畬鏁寸殑璺緞)锛屾枃浠舵暟鎹緷姝よ繘琛, @@ -86,16 +87,40 @@ config = { }; `) var CStatus = ref('None') +function getOpEmoj(Op) { + switch (Op) { + case 0: + return "鉃"; + case 1: + return "鈸傦笍"; + case 2: + return "鉂"; + default: + return "馃殌"; + } +} function publishCB(MsgIt) { - + console.log(MsgIt) if (MsgIt.Type == 2) { Msgs.value[Msgs.value.length - 1] = MsgIt - } else { + } else if (MsgIt.Type == 3) { + var it = JSON.parse(MsgIt.Body); + it.Children.forEach((e) => { + Msgs.value.push({ + Step: MsgIt.Step, + Type: MsgIt.Type, + Body: `[${getOpEmoj(e.NextOp)}] ${e.FormatedPath}` + }) + + }); + } + else { Msgs.value.push(MsgIt) } if (MsgIt.Step == 6) { if (MsgIt.Body == "鍙戝竷瀹屾垚锛") { CStatus.value = 'Success' + IsSuccess = true Pipe.ClosePipe() dialogShow("姝g‘锛氬彂甯冨畬鎴愶紒") } @@ -154,7 +179,7 @@ onMounted(() => { } }) -const dMsg = ref('') +const dMsg = ref('') function dialogClose() { document.getElementById('dialog').close() } @@ -162,6 +187,46 @@ function dialogShow(msg) { dMsg.value = msg 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 +}