diff --git a/Txgy.FilesWatcher/ViewModels/MainViewModel.cs b/Txgy.FilesWatcher/ViewModels/MainViewModel.cs index 611ef28..4fc8101 100644 --- a/Txgy.FilesWatcher/ViewModels/MainViewModel.cs +++ b/Txgy.FilesWatcher/ViewModels/MainViewModel.cs @@ -220,6 +220,7 @@ namespace Txgy.FilesWatcher.ViewModels timer1.Interval = TimeSpan.FromSeconds(ProMonInterval); timer1.Start(); timer1.Tick += timer1_Tick; + StartConnectMQ(); } } @@ -227,6 +228,7 @@ namespace Txgy.FilesWatcher.ViewModels { WatchStartOrSopt(false); timer1.Stop(); + StopMQ(); } public DelegateCommand FilePathSaveCommand => new((obj) => @@ -392,7 +394,7 @@ namespace Txgy.FilesWatcher.ViewModels DateTime currentT= DateTime.Now; RunTime = DateDiff(currentT, StartTime); string path = $"{Path.Combine(MainPath, MseedPath)}/{currentT.Month.ToString("D2")}/{currentT.Day.ToString("D2")}/{currentT.Hour.ToString("D2")}/{currentT.AddMinutes(-2).Minute.ToString("D2")}"; - // path = "I:\\yuwuN3102mseed\\NET2023\\06\\22\\21\\50"; + // path = "I:\\yuwuN3102mseed\\NET2023\\06\\22\\21\\51"; Debug.WriteLine($"**********当前时间:{currentT},监控路径:{path}"); if (Directory.Exists(path) && IsUploadDB&& IsUploadMseedPath) { @@ -472,7 +474,6 @@ namespace Txgy.FilesWatcher.ViewModels Debug.WriteLine($"最后修改时间:{lastWriteTime},文件路径:{watch.Path}"); if (watch != null && watch.Path == watcherArray[0].Path) { - watcherArray[0].EnableRaisingEvents = false; if (IsUploadDB && isUploadRealtimePath) { diff --git a/Txgy.FilesWatcher/Views/MainView.xaml b/Txgy.FilesWatcher/Views/MainView.xaml index af67ff9..a767731 100644 --- a/Txgy.FilesWatcher/Views/MainView.xaml +++ b/Txgy.FilesWatcher/Views/MainView.xaml @@ -102,12 +102,12 @@ - - + + - + @@ -132,12 +132,12 @@ - - + + - + @@ -150,12 +150,12 @@ - - + + - + @@ -165,15 +165,15 @@ - + - - + + - + diff --git a/Txgy.FilesWatcher/model/UploadMseedFile.cs b/Txgy.FilesWatcher/model/UploadMseedFile.cs index 67de379..f9cfd7e 100644 --- a/Txgy.FilesWatcher/model/UploadMseedFile.cs +++ b/Txgy.FilesWatcher/model/UploadMseedFile.cs @@ -26,6 +26,7 @@ namespace Txgy.FilesWatcher.model { var currentTime = DateTime.Now; var Dfiles = new DirectoryInfo(path).GetFiles("*.mseed"); + string mes = string.Empty; foreach (var DFile in Dfiles) { string file = DFile.Name; @@ -42,6 +43,7 @@ namespace Txgy.FilesWatcher.model if (a == 0) { //WorkAreaId = 1,更新 + mes += file.Substring(3, 3); FileStream fs = new FileStream(DFile.FullName, FileMode.Open, FileAccess.Read); BinaryReader mbr = new BinaryReader(fs); Byte[] mseedDatas = mbr.ReadBytes((int)fs.Length); @@ -57,9 +59,9 @@ namespace Txgy.FilesWatcher.model } } } - // if (Dfiles.Length != 0) + if (!string.IsNullOrEmpty(mes)) { - string notifyMes = $"共{Dfiles.Length}个数据上传成功,{string.Join(",", Dfiles.Select(f => f.Name.Substring(3, 3)))}"; + string notifyMes = $"共{Dfiles.Length}个数据上传成功,{mes}";// {string.Join(",", Dfiles.Select(f => f.Name.Substring(3, 3)))}"; mseedAction(notifyMes); } } diff --git a/Txgy.FilesWatcher/model/UploadPostproFile.cs b/Txgy.FilesWatcher/model/UploadPostproFile.cs index f4bcd81..20f52a7 100644 --- a/Txgy.FilesWatcher/model/UploadPostproFile.cs +++ b/Txgy.FilesWatcher/model/UploadPostproFile.cs @@ -69,7 +69,7 @@ namespace Txgy.FilesWatcher.model sqlNumber = $"INSERT INTO {tbname} (EventTime, WorkAreaID, WaveData, JsonFile) VALUES('{EventTime}', '{workAreaId}', @mDatas, @jDatas);"; MySqlCommand mycomm = new MySqlCommand(sqlNumber, conn); res = conn.Execute(sqlNumber, new { mDatas = mseedDatas, jDatas = jsonDatas }); - mqAction($"/watcherdata/post/", JsonSerializer.Serialize(new { jsonFile = jsonString, eventMessage = eventMessage }, options)); + mqAction($"/watcherdata/post", JsonSerializer.Serialize(new { jsonFile = jsonString, eventMessage = eventMessage }, options)); sqlNumber = $"INSERT INTO {uploadedtbname}(filename, uploadtime) VALUES('{file}', '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}')"; res = conn.Execute(sqlNumber); } diff --git a/Txgy.FilesWatcher/model/UploadRealtimeFile.cs b/Txgy.FilesWatcher/model/UploadRealtimeFile.cs index 5e6ba2f..045b208 100644 --- a/Txgy.FilesWatcher/model/UploadRealtimeFile.cs +++ b/Txgy.FilesWatcher/model/UploadRealtimeFile.cs @@ -75,7 +75,7 @@ namespace Txgy.FilesWatcher.model sqlNumber = $"INSERT INTO {tbname} (EventTime, WorkAreaID, WaveData, JsonFile) VALUES('{EventTime}', '{workAreaId}', @mDatas, @jDatas);"; MySqlCommand mycomm = new MySqlCommand(sqlNumber,conn); res = conn.Execute(sqlNumber, new { mDatas = mseedDatas, jDatas = jsonDatas }); - mqAction("$/watcherdata/realtime/", JsonSerializer.Serialize(new { jsonFile = jsonString, eventMessage = eventMessage }, options)); + mqAction($"/watcherdata/realtime", JsonSerializer.Serialize(new { jsonFile = jsonString, eventMessage = eventMessage }, options)); sqlNumber = $"INSERT INTO {uploadedtbname}(filename, uploadtime) VALUES('{file}', '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}')"; res = conn.Execute(sqlNumber); }