修改测试相关问题

master
mzhifa 12 months ago
parent 5e544144a1
commit 60dda83726

@ -220,6 +220,7 @@ namespace Txgy.FilesWatcher.ViewModels
timer1.Interval = TimeSpan.FromSeconds(ProMonInterval); timer1.Interval = TimeSpan.FromSeconds(ProMonInterval);
timer1.Start(); timer1.Start();
timer1.Tick += timer1_Tick; timer1.Tick += timer1_Tick;
StartConnectMQ();
} }
} }
@ -227,6 +228,7 @@ namespace Txgy.FilesWatcher.ViewModels
{ {
WatchStartOrSopt(false); WatchStartOrSopt(false);
timer1.Stop(); timer1.Stop();
StopMQ();
} }
public DelegateCommand<object> FilePathSaveCommand => new((obj) => public DelegateCommand<object> FilePathSaveCommand => new((obj) =>
@ -392,7 +394,7 @@ namespace Txgy.FilesWatcher.ViewModels
DateTime currentT= DateTime.Now; DateTime currentT= DateTime.Now;
RunTime = DateDiff(currentT, StartTime); 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")}"; 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}"); Debug.WriteLine($"**********当前时间:{currentT},监控路径:{path}");
if (Directory.Exists(path) && IsUploadDB&& IsUploadMseedPath) if (Directory.Exists(path) && IsUploadDB&& IsUploadMseedPath)
{ {
@ -472,7 +474,6 @@ namespace Txgy.FilesWatcher.ViewModels
Debug.WriteLine($"最后修改时间:{lastWriteTime},文件路径:{watch.Path}"); Debug.WriteLine($"最后修改时间:{lastWriteTime},文件路径:{watch.Path}");
if (watch != null && watch.Path == watcherArray[0].Path) if (watch != null && watch.Path == watcherArray[0].Path)
{ {
watcherArray[0].EnableRaisingEvents = false; watcherArray[0].EnableRaisingEvents = false;
if (IsUploadDB && isUploadRealtimePath) if (IsUploadDB && isUploadRealtimePath)
{ {

@ -102,12 +102,12 @@
<ListView ItemsSource="{Binding DataList}" > <ListView ItemsSource="{Binding DataList}" >
<ListView.View> <ListView.View>
<GridView> <GridView>
<GridViewColumn Header="时间" DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" /> <GridViewColumn DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" />
<GridViewColumn Header="内容" Width="300" > <GridViewColumn >
<!--模板化单元格内容--> <!--模板化单元格内容-->
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<TextBox Foreground="CornflowerBlue" MinWidth="200" Cursor="Hand" Text="{Binding Data}" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap"></TextBox> <TextBox Foreground="CornflowerBlue" MinWidth="300" Cursor="Hand" Text="{Binding Data}" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap"></TextBox>
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
@ -132,12 +132,12 @@
<ListView ItemsSource="{Binding RealTimeDataList}" > <ListView ItemsSource="{Binding RealTimeDataList}" >
<ListView.View> <ListView.View>
<GridView> <GridView>
<GridViewColumn Header="时间" DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" /> <GridViewColumn DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" />
<GridViewColumn Header="内容" Width="300" > <GridViewColumn >
<!--模板化单元格内容--> <!--模板化单元格内容-->
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<TextBox Foreground="CornflowerBlue" MinWidth="200" Cursor="Hand" Text="{Binding Data}" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap"></TextBox> <TextBox Foreground="CornflowerBlue" MinWidth="300" Cursor="Hand" Text="{Binding Data}" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap"></TextBox>
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
@ -150,12 +150,12 @@
<ListView ItemsSource="{Binding PostDataList}" > <ListView ItemsSource="{Binding PostDataList}" >
<ListView.View> <ListView.View>
<GridView> <GridView>
<GridViewColumn Header="时间" DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" /> <GridViewColumn DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" />
<GridViewColumn Header="内容" Width="300" > <GridViewColumn >
<!--模板化单元格内容--> <!--模板化单元格内容-->
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<TextBox Foreground="CornflowerBlue" MinWidth="200" Cursor="Hand" Text="{Binding Data}" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap"></TextBox> <TextBox Foreground="CornflowerBlue" MinWidth="300" Cursor="Hand" Text="{Binding Data}" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap"></TextBox>
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
@ -165,15 +165,15 @@
</DockPanel> </DockPanel>
<DockPanel> <DockPanel>
<TextBlock Text="MQTT转发监控" DockPanel.Dock="Top"/> <TextBlock Text="MQTT转发监控" DockPanel.Dock="Top"/>
<ListView ItemsSource="{Binding MQTTDataList}" > <ListView ItemsSource="{Binding MQTTDataList}" >
<ListView.View> <ListView.View>
<GridView> <GridView>
<GridViewColumn Header="时间" DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" /> <GridViewColumn DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" />
<GridViewColumn Header="内容" Width="300" > <GridViewColumn >
<!--模板化单元格内容--> <!--模板化单元格内容-->
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<TextBox Foreground="CornflowerBlue" MinWidth="200" Cursor="Hand" Text="{Binding Data}" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap"></TextBox> <TextBox Foreground="CornflowerBlue" MinWidth="300" Cursor="Hand" Text="{Binding Data}" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap"></TextBox>
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>

@ -26,6 +26,7 @@ namespace Txgy.FilesWatcher.model
{ {
var currentTime = DateTime.Now; var currentTime = DateTime.Now;
var Dfiles = new DirectoryInfo(path).GetFiles("*.mseed"); var Dfiles = new DirectoryInfo(path).GetFiles("*.mseed");
string mes = string.Empty;
foreach (var DFile in Dfiles) foreach (var DFile in Dfiles)
{ {
string file = DFile.Name; string file = DFile.Name;
@ -42,6 +43,7 @@ namespace Txgy.FilesWatcher.model
if (a == 0) if (a == 0)
{ {
//WorkAreaId = 1,更新 //WorkAreaId = 1,更新
mes += file.Substring(3, 3);
FileStream fs = new FileStream(DFile.FullName, FileMode.Open, FileAccess.Read); FileStream fs = new FileStream(DFile.FullName, FileMode.Open, FileAccess.Read);
BinaryReader mbr = new BinaryReader(fs); BinaryReader mbr = new BinaryReader(fs);
Byte[] mseedDatas = mbr.ReadBytes((int)fs.Length); 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); mseedAction(notifyMes);
} }
} }

@ -69,7 +69,7 @@ namespace Txgy.FilesWatcher.model
sqlNumber = $"INSERT INTO {tbname} (EventTime, WorkAreaID, WaveData, JsonFile) VALUES('{EventTime}', '{workAreaId}', @mDatas, @jDatas);"; sqlNumber = $"INSERT INTO {tbname} (EventTime, WorkAreaID, WaveData, JsonFile) VALUES('{EventTime}', '{workAreaId}', @mDatas, @jDatas);";
MySqlCommand mycomm = new MySqlCommand(sqlNumber, conn); MySqlCommand mycomm = new MySqlCommand(sqlNumber, conn);
res = conn.Execute(sqlNumber, new { mDatas = mseedDatas, jDatas = jsonDatas }); 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")}')"; sqlNumber = $"INSERT INTO {uploadedtbname}(filename, uploadtime) VALUES('{file}', '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}')";
res = conn.Execute(sqlNumber); res = conn.Execute(sqlNumber);
} }

@ -75,7 +75,7 @@ namespace Txgy.FilesWatcher.model
sqlNumber = $"INSERT INTO {tbname} (EventTime, WorkAreaID, WaveData, JsonFile) VALUES('{EventTime}', '{workAreaId}', @mDatas, @jDatas);"; sqlNumber = $"INSERT INTO {tbname} (EventTime, WorkAreaID, WaveData, JsonFile) VALUES('{EventTime}', '{workAreaId}', @mDatas, @jDatas);";
MySqlCommand mycomm = new MySqlCommand(sqlNumber,conn); MySqlCommand mycomm = new MySqlCommand(sqlNumber,conn);
res = conn.Execute(sqlNumber, new { mDatas = mseedDatas, jDatas = jsonDatas }); 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")}')"; sqlNumber = $"INSERT INTO {uploadedtbname}(filename, uploadtime) VALUES('{file}', '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}')";
res = conn.Execute(sqlNumber); res = conn.Execute(sqlNumber);
} }

Loading…
Cancel
Save