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 @@ - +