From f7e8b01149e06aedeae52e3d50ff94afdc081d45 Mon Sep 17 00:00:00 2001 From: mzhifa Date: Sun, 16 Jun 2024 23:19:24 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=81=9C=E6=AD=A2=E6=97=B6=EF=BC=8C=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E6=96=87=E4=BB=B6=E7=9B=91=E6=8E=A7=EF=BC=9B=202.?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E9=80=BB=E8=BE=91;=203.=E5=8E=BB=E6=8E=89?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E5=BC=B9=E7=AA=97;=204=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=B7=A5=E5=8C=BA=E9=85=8D=E7=BD=AE=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Txgy.FilesWatcher/ViewModels/MainViewModel.cs | 17 ++++---- .../ViewModels/ManualModeDialogViewModel.cs | 9 ----- Txgy.FilesWatcher/Views/MainView.xaml | 2 +- Txgy.FilesWatcher/log4net.config | 2 +- Txgy.FilesWatcher/model/SystemConfig.cs | 2 + Txgy.FilesWatcher/model/UploadMseedFile.cs | 3 -- Txgy.FilesWatcher/model/UploadPostproFile.cs | 35 ++++++++++------ Txgy.FilesWatcher/model/UploadRealtimeFile.cs | 40 ++++++++++--------- Txgy.FilesWatcher/systemconfig.json | 3 ++ 9 files changed, 60 insertions(+), 53 deletions(-) diff --git a/Txgy.FilesWatcher/ViewModels/MainViewModel.cs b/Txgy.FilesWatcher/ViewModels/MainViewModel.cs index 6034fdf..bf1f979 100644 --- a/Txgy.FilesWatcher/ViewModels/MainViewModel.cs +++ b/Txgy.FilesWatcher/ViewModels/MainViewModel.cs @@ -48,6 +48,8 @@ namespace Txgy.FilesWatcher.ViewModels MseedPath = systemConfig.mseedpath; MainPath= systemConfig.mainpath; ToolPath = systemConfig.toolpath; + WorkAreaId = systemConfig.workAreaId; + CycleTime = systemConfig.cycleTime; DataBaseConnect.GetInstance.DataBaseConfig = systemConfig.dBConfig; @@ -124,7 +126,7 @@ namespace Txgy.FilesWatcher.ViewModels set { SetProperty(ref isUploadPostPath, value); } } - private bool isUploadDB = false; + private bool isUploadDB = true; public bool IsUploadDB { @@ -294,6 +296,9 @@ namespace Txgy.FilesWatcher.ViewModels timerTool.Start(); StartConnectMQ(); mseedFileTime = DateTime.Now; + _systemConfig.cycleTime = CycleTime; + _systemConfig.workAreaId = WorkAreaId; + UpdateJsonConfig(_systemConfig); } } @@ -504,7 +509,7 @@ namespace Txgy.FilesWatcher.ViewModels DateTime currentT= DateTime.Now; RunTime = DateDiff(currentT, StartTime); // path = "I:\\yuwuN3102mseed\\NET2023\\06\\22\\21\\51"; - if ((currentT - mseedFileTime).TotalSeconds >= 15) + if ((currentT - mseedFileTime).TotalSeconds >= CycleTime) { mseedFileTime = DateTime.Now; //DateTime end= DateTime.Now.AddDays(-3); @@ -519,8 +524,6 @@ namespace Txgy.FilesWatcher.ViewModels private void MseedFileChanged(DateTime currentT) { - _log.Log.Debug("MainViewModel.MseedFileChanged() > enter...."); - _log.Log.DebugFormat("MainViewModel.MseedFileChanged() currentT:{0}", currentT); string path = $"{Path.Combine(MainPath, MseedPath)}/{currentT.Month.ToString("D2")}/{currentT.Day.ToString("D2")}/{currentT.Hour.ToString("D2")}/{currentT.AddMinutes(-2).Minute.ToString("D2")}"; Debug.WriteLine($"**********当前时间:{currentT},监控路径:{path}"); if (Directory.Exists(path) && IsUploadDB && IsUploadMseedPath) @@ -538,8 +541,6 @@ namespace Txgy.FilesWatcher.ViewModels }); }), path, WorkAreaId); } - _log.Log.Debug("MainViewModel.MseedFileChanged() < exit...."); - } @@ -567,8 +568,8 @@ namespace Txgy.FilesWatcher.ViewModels } } } - watcherArray[0].EnableRaisingEvents =IsUploadRealtimePath; - watcherArray[1].EnableRaisingEvents = IsUploadPostPath; + watcherArray[0].EnableRaisingEvents = IsUploadRealtimePath && IsEnableRaising; + watcherArray[1].EnableRaisingEvents = IsUploadPostPath && IsEnableRaising; IsIndeterminate = IsEnableRaising; } catch (Exception ex) diff --git a/Txgy.FilesWatcher/ViewModels/ManualModeDialogViewModel.cs b/Txgy.FilesWatcher/ViewModels/ManualModeDialogViewModel.cs index bace928..809c87e 100644 --- a/Txgy.FilesWatcher/ViewModels/ManualModeDialogViewModel.cs +++ b/Txgy.FilesWatcher/ViewModels/ManualModeDialogViewModel.cs @@ -105,7 +105,6 @@ namespace Txgy.FilesWatcher.ViewModels CancellationTokenSource cts = new CancellationTokenSource(); public async Task StartHandle(DateTime start, DateTime end) { - _log.Log.Debug("ManualModeDialogViewModel.StartHandle() > enter..."); _log.Log.DebugFormat("ManualModeDialogViewModel.StartHandle() start:{0},end:{1}",start, end); CancellationToken cancellationToken = cts.Token; string realtimePath = Path.Combine(mainModel.MainPath, mainModel.RealtimePath); @@ -158,7 +157,6 @@ namespace Txgy.FilesWatcher.ViewModels } }, cancellationToken); await Task.WhenAll(task1, task2, task3); - _log.Log.Debug("ManualModeDialogViewModel.StartHandle() < exit..."); } @@ -169,7 +167,6 @@ namespace Txgy.FilesWatcher.ViewModels private void MseedUpload(DateTime currentT) { - _log.Log.Debug("ManualModeDialogViewModel.MseedUpload() > enter..."); string path = $"{Path.Combine(mainModel.MainPath, mainModel.MseedPath)}/{currentT.Month.ToString("D2")}/{currentT.Day.ToString("D2")}/{currentT.Hour.ToString("D2")}/{currentT.Minute.ToString("D2")}"; // path = "I:\\yuwuN3102mseed\\NET2023\\06\\22\\21\\51"; Debug.WriteLine($"**********当前时间:{currentT},监控路径:{path}"); @@ -189,13 +186,10 @@ namespace Txgy.FilesWatcher.ViewModels }); }), path, mainModel.WorkAreaId); } - _log.Log.Debug("ManualModeDialogViewModel.MseedUpload() < exit..."); - } private void RealtimeChanged(string filePath, string lastLine) { - _log.Log.Debug("ManualModeDialogViewModel.RealtimeChanged() > enter..."); // string tmp = dt.Hour.ToString() + "时" + dt.Minute.ToString() + "分" + dt.Second.ToString() + "秒" + dt.Millisecond.ToString() + "毫秒,目录发生变化\r\n"; DateTime lastWriteTime = DateTime.Now; //File.GetLastWriteTime(e.FullPath); Debug.WriteLine($"最后修改时间:{lastWriteTime},文件路径:{filePath}"); @@ -224,13 +218,11 @@ namespace Txgy.FilesWatcher.ViewModels }, filePath, lastLine); } - _log.Log.Debug("ManualModeDialogViewModel.RealtimeChanged() < exit..."); } private void PostChanged(string filePath, string lastLine) { - _log.Log.Debug("ManualModeDialogViewModel.PostChanged() > enter..."); // string tmp = dt.Hour.ToString() + "时" + dt.Minute.ToString() + "分" + dt.Second.ToString() + "秒" + dt.Millisecond.ToString() + "毫秒,目录发生变化\r\n"; DateTime lastWriteTime = DateTime.Now; //File.GetLastWriteTime(e.FullPath); Debug.WriteLine($"最后修改时间:{lastWriteTime},文件路径:{filePath}"); @@ -264,7 +256,6 @@ namespace Txgy.FilesWatcher.ViewModels }); }, filePath, lastLine); } - _log.Log.Debug("ManualModeDialogViewModel.PostChanged() < exit..."); } private DispatcherTimer timer1 = new DispatcherTimer(); diff --git a/Txgy.FilesWatcher/Views/MainView.xaml b/Txgy.FilesWatcher/Views/MainView.xaml index 55a2e10..700cac7 100644 --- a/Txgy.FilesWatcher/Views/MainView.xaml +++ b/Txgy.FilesWatcher/Views/MainView.xaml @@ -128,7 +128,7 @@ - +