修改测试问题

master
mzhifa 3 months ago
parent f7e8b01149
commit c625991677

@ -30,6 +30,7 @@ using System.Xml.Linq;
using Prism.Services.Dialogs;
using Microsoft.VisualBasic.Logging;
using log4net;
using System.Windows.Documents;
namespace Txgy.FilesWatcher.ViewModels
{
@ -156,6 +157,15 @@ namespace Txgy.FilesWatcher.ViewModels
get { return dataList; }
set { SetProperty(ref dataList, value); }
}
private ObservableCollection<FileModel> autoDataList = new ObservableCollection<FileModel>();
public ObservableCollection<FileModel> AutoDataList
{
get { return autoDataList; }
set { SetProperty(ref autoDataList, value); }
}
private ObservableCollection<FileModel> realTimeDataList = new ObservableCollection<FileModel>();
public ObservableCollection<FileModel> RealTimeDataList
@ -205,7 +215,7 @@ namespace Txgy.FilesWatcher.ViewModels
get { return selectedIndex; }
set { SetProperty(ref selectedIndex, value); }
}
private int proMonInterval = 5;
private int proMonInterval = 10;
public int ProMonInterval
{
get => proMonInterval;
@ -283,6 +293,10 @@ namespace Txgy.FilesWatcher.ViewModels
}));
});
public DelegateCommand ClearLogCommand => new DelegateCommand(() =>
{
if (AutoDataList.Count > 0) { AutoDataList.Clear(); }
});
private void Start()
{
int res = WatchStartOrSopt(true);
@ -504,7 +518,7 @@ namespace Txgy.FilesWatcher.ViewModels
}
private string settingDataPath = "systemconfig.json";
private void timer1_Tick(object? sender, EventArgs e)
private async void timer1_Tick(object? sender, EventArgs e)
{
DateTime currentT= DateTime.Now;
RunTime = DateDiff(currentT, StartTime);
@ -512,11 +526,20 @@ namespace Txgy.FilesWatcher.ViewModels
if ((currentT - mseedFileTime).TotalSeconds >= CycleTime)
{
mseedFileTime = DateTime.Now;
//DateTime end= DateTime.Now.AddDays(-3);
_manualModeDialog.StartHandle(mseedFileTime.AddDays(-4), mseedFileTime);
if (AutoDataList.Count >= 100) { AutoDataList.Remove(AutoDataList.Last()); }
var list = await _manualModeDialog.StartHandle(mseedFileTime.AddDays(-4), mseedFileTime);
foreach (var item in list)
{
AutoDataList.Insert(0, new FileModel
{
CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"),
Data = $"{item}"
});
}
}
else
{
Thread.Sleep(20000);
MseedFileChanged(currentT);
}
}

@ -97,25 +97,36 @@ namespace Txgy.FilesWatcher.ViewModels
//}
StateMes = "执行中";
StartEnable = false;
await StartHandle(StartTime,EndTime);
StateMes = "未开始";
var list= await StartHandle(StartTime,EndTime);
foreach (var item in list)
{
DataList.Insert(0, new FileModel
{
CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"),
Data = $"{item}"
});
}
StateMes = "已完成";
StartEnable = true;
}).ObservesCanExecute(()=>StartEnable);
CancellationTokenSource cts = new CancellationTokenSource();
public async Task StartHandle(DateTime start, DateTime end)
public async Task<List<string>> StartHandle(DateTime start, DateTime end)
{
_log.Log.DebugFormat("ManualModeDialogViewModel.StartHandle() start:{0},end:{1}",start, end);
cts = new CancellationTokenSource();
CancellationToken cancellationToken = cts.Token;
string realtimePath = Path.Combine(mainModel.MainPath, mainModel.RealtimePath);
string postPath = Path.Combine(mainModel.MainPath, mainModel.PostPath);
List<string> logList=new List<string>();
Task task1 = Task.Run(() =>
{
DateTime time = start.AddMinutes(1);
while (!cancellationToken.IsCancellationRequested)
{
time = time.AddMinutes(1);
MseedUpload(time);
logList.AddRange(MseedUpload(time));
if (time >= end)
{
break;
@ -135,7 +146,7 @@ namespace Txgy.FilesWatcher.ViewModels
Console.WriteLine("Cancellation");
break;
}
RealtimeChanged(file.FullName, line);
logList.AddRange(RealtimeChanged(file.FullName, line));
}
}
}, cancellationToken);
@ -152,11 +163,12 @@ namespace Txgy.FilesWatcher.ViewModels
Console.WriteLine("Cancellation");
break;
}
PostChanged(file.FullName, line);
logList.AddRange(PostChanged(file.FullName, line));
}
}
}, cancellationToken);
await Task.WhenAll(task1, task2, task3);
return logList;
}
@ -165,39 +177,47 @@ namespace Txgy.FilesWatcher.ViewModels
cts.Cancel();
});
private void MseedUpload(DateTime currentT)
public DelegateCommand ClearLogCommand => new DelegateCommand(() =>
{
if (DataList.Count > 0) { DataList.Clear(); }
});
private List<string> MseedUpload(DateTime currentT)
{
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}");
List<string> logList = new List<string>();
if (Directory.Exists(path) && mainModel.IsUploadDB && mainModel.IsUploadMseedPath)
{
_log.Log.DebugFormat("ManualModeDialogViewModel.MseedUpload() currentT:{0},path:{1}", currentT, path);
UploadMseedFile.UploadMSeedOnce((a =>
logList= UploadMseedFile.UploadMSeedOnce((a =>
{
timer1.Dispatcher.Invoke(() =>
{
// if (DataList.Count >= 20) { DataList.Remove(dataList.Last()); }
DataList.Insert(0, new FileModel
{
CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"),
Data = $"{currentT.AddMinutes(-2).ToString("yyyy-MM-dd T HH:mm:ss")}{a}"
});
});
//timer1.Dispatcher.Invoke(() =>
//{
// // if (DataList.Count >= 20) { DataList.Remove(dataList.Last()); }
// DataList.Insert(0, new FileModel
// {
// CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"),
// Data = $"{currentT.AddMinutes(-2).ToString("yyyy-MM-dd T HH:mm:ss")}{a}"
// });
//});
}), path, mainModel.WorkAreaId);
}
return logList;
}
private void RealtimeChanged(string filePath, string lastLine)
private List<string> RealtimeChanged(string filePath, string lastLine)
{
// 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}");
filePath = Path.GetDirectoryName(filePath);
_log.Log.DebugFormat("ManualModeDialogViewModel.RealtimeChanged() filePath:{0},path:{1}", filePath, lastLine);
List<string> logList = new List<string>();
if (mainModel.IsUploadDB && mainModel.IsUploadRealtimePath)
{
UploadRealtimeFile.UploadRealtimeFileOnce(filePath, lastLine, mainModel.WorkAreaId, out bool isUpload);
logList= UploadRealtimeFile.UploadRealtimeFileOnce(filePath, lastLine, mainModel.WorkAreaId, out bool isUpload);
timer1.Dispatcher.Invoke(() =>
{
// if (RealTimeDataList.Count >= 20) { RealTimeDataList.Remove(RealTimeDataList.Last()); }
@ -218,19 +238,21 @@ namespace Txgy.FilesWatcher.ViewModels
}, filePath, lastLine);
}
return logList;
}
private void PostChanged(string filePath, string lastLine)
private List<string> PostChanged(string filePath, string lastLine)
{
// 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}");
filePath = Path.GetDirectoryName(filePath);
_log.Log.DebugFormat("ManualModeDialogViewModel.RealtimeChanged() filePath:{0},path:{1}", filePath, lastLine);
List<string> logList = new List<string>();
if (mainModel.IsUploadDB && mainModel.IsUploadPostPath)
{
UploadPostproFile.UploadPostproFileOnce(filePath, lastLine, mainModel.WorkAreaId, out bool isUpload);
logList= UploadPostproFile.UploadPostproFileOnce(filePath, lastLine, mainModel.WorkAreaId, out bool isUpload);
{
timer1.Dispatcher.Invoke(() =>
{
@ -256,6 +278,7 @@ namespace Txgy.FilesWatcher.ViewModels
});
}, filePath, lastLine);
}
return logList;
}
private DispatcherTimer timer1 = new DispatcherTimer();

@ -141,92 +141,123 @@
Value="0" />
</Grid>
</GroupBox>
<UniformGrid Columns="1" Grid.Column="1">
<DockPanel>
<TextBlock Text="原始数据监控" DockPanel.Dock="Top"/>
<ListView ItemsSource="{Binding DataList}" >
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" />
<GridViewColumn >
<!--模板化单元格内容-->
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Foreground="CornflowerBlue" MinWidth="300" Cursor="Hand" Text="{Binding Data}" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap"></TextBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<!--<GridViewColumn Header="文件名" Width="80" DisplayMemberBinding="{Binding Name}" />
<TabControl Grid.Column="1">
<TabItem Header="监控记录">
<UniformGrid Columns="1" Grid.Column="1">
<DockPanel>
<TextBlock Text="原始数据监控" DockPanel.Dock="Top"/>
<ListView ItemsSource="{Binding DataList}" >
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" />
<GridViewColumn >
<!--模板化单元格内容-->
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Foreground="CornflowerBlue" MinWidth="300" Cursor="Hand" Text="{Binding Data}" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap"></TextBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<!--<GridViewColumn Header="文件名" Width="80" DisplayMemberBinding="{Binding Name}" />
<GridViewColumn Header="修改类型" Width="80" DisplayMemberBinding="{Binding ChangeType}" />
<GridViewColumn Header="是否发送" >
-->
<!--模板化单元格内容-->
<!--
<!--模板化单元格内容-->
<!--
<GridViewColumn.CellTemplate>
<DataTemplate>
<ToggleButton IsEnabled="False" IsChecked="{Binding IsSend}" HorizontalAlignment="Center" Margin="5,4" Style="{StaticResource ToggleButtonSwitch}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>-->
</GridView>
</ListView.View>
</ListView>
</DockPanel>
<DockPanel>
<TextBlock Text="实时结果监控" DockPanel.Dock="Top"/>
<ListView ItemsSource="{Binding RealTimeDataList}" >
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" />
<GridViewColumn >
<!--模板化单元格内容-->
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Foreground="CornflowerBlue" MinWidth="300" Cursor="Hand" Text="{Binding Data}" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap"></TextBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</DockPanel>
<DockPanel>
<TextBlock Text="后处理结果监控" DockPanel.Dock="Top"/>
<ListView ItemsSource="{Binding PostDataList}" >
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" />
<GridViewColumn >
<!--模板化单元格内容-->
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Foreground="CornflowerBlue" MinWidth="300" Cursor="Hand" Text="{Binding Data}" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap"></TextBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</DockPanel>
<DockPanel>
<TextBlock Text="MQTT转发监控" DockPanel.Dock="Top"/>
<ListView ItemsSource="{Binding MQTTDataList}" >
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" />
<GridViewColumn >
<!--模板化单元格内容-->
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Foreground="CornflowerBlue" MinWidth="300" Cursor="Hand" Text="{Binding Data}" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap"></TextBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</DockPanel>
</GridView>
</ListView.View>
</ListView>
</DockPanel>
<DockPanel>
<TextBlock Text="实时结果监控" DockPanel.Dock="Top"/>
<ListView ItemsSource="{Binding RealTimeDataList}" >
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" />
<GridViewColumn >
<!--模板化单元格内容-->
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Foreground="CornflowerBlue" MinWidth="300" Cursor="Hand" Text="{Binding Data}" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap"></TextBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</DockPanel>
<DockPanel>
<TextBlock Text="后处理结果监控" DockPanel.Dock="Top"/>
<ListView ItemsSource="{Binding PostDataList}" >
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" />
<GridViewColumn >
<!--模板化单元格内容-->
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Foreground="CornflowerBlue" MinWidth="300" Cursor="Hand" Text="{Binding Data}" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap"></TextBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</DockPanel>
<DockPanel>
<TextBlock Text="MQTT转发监控" DockPanel.Dock="Top"/>
<ListView ItemsSource="{Binding MQTTDataList}" >
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" />
<GridViewColumn >
<!--模板化单元格内容-->
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Foreground="CornflowerBlue" MinWidth="300" Cursor="Hand" Text="{Binding Data}" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap"></TextBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</DockPanel>
</UniformGrid>
</TabItem>
<TabItem Header="自动上传记录">
<UniformGrid Columns="1" Grid.Column="2">
<DockPanel>
<DockPanel DockPanel.Dock="Top">
<TextBlock Text="自动上传数据" VerticalAlignment="Center"/>
<Button Content="清除" Command="{Binding ClearLogCommand}" HorizontalAlignment="Right" Height="30" Margin="0,0,20,0"/>
</DockPanel>
<ListView ItemsSource="{Binding AutoDataList}" >
<ListView.View>
<GridView>
<!--<GridViewColumn DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" />-->
<GridViewColumn>
<!--模板化单元格内容-->
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Foreground="CornflowerBlue" MinWidth="300" Cursor="Hand" Text="{Binding Data}" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap"></TextBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</DockPanel>
</UniformGrid>
</UniformGrid>
</TabItem>
</TabControl>
</Grid>
</UserControl>

@ -4,7 +4,7 @@
xmlns:prism="http://prismlibrary.com/"
xmlns:local="clr-namespace:Txgy.FilesWatcher.Views"
prism:ViewModelLocator.AutoWireViewModel="True"
Title="{Binding Title}" Height="550" Width="960"
Title="{Binding Title}" Height="600" Width="960"
Icon="/Views/Upload Database.png">
<Grid>
<ContentControl prism:RegionManager.RegionName="MainContentRegion" />

@ -29,6 +29,7 @@
<Button Content="开始" Command="{Binding StartCommand}"/>
<TextBlock Text="{Binding StateMes}" VerticalAlignment="Center" Margin="20,0,20,0"/>
<Button Content="停止" Command="{Binding ManualCommand}"/>
<Button Content="清除" Command="{Binding ClearLogCommand}" Margin="100,0,0,0"/>
</StackPanel>
<UniformGrid Columns="1" Grid.Row="1">
<DockPanel>
@ -36,7 +37,7 @@
<ListView ItemsSource="{Binding DataList}" >
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" />
<!--<GridViewColumn DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" />-->
<GridViewColumn >
<!--模板化单元格内容-->
<GridViewColumn.CellTemplate>
@ -61,14 +62,14 @@
</ListView.View>
</ListView>
</DockPanel>
<DockPanel>
<!--<DockPanel>
<TextBlock Text="实时结果监控" DockPanel.Dock="Top"/>
<ListView ItemsSource="{Binding RealTimeDataList}" >
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" />
<GridViewColumn >
<!--模板化单元格内容-->
--><!--模板化单元格内容--><!--
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Foreground="CornflowerBlue" MinWidth="300" Cursor="Hand" Text="{Binding Data}" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap"></TextBox>
@ -86,7 +87,7 @@
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" />
<GridViewColumn >
<!--模板化单元格内容-->
--><!--模板化单元格内容--><!--
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Foreground="CornflowerBlue" MinWidth="300" Cursor="Hand" Text="{Binding Data}" IsReadOnly="True" BorderBrush="Transparent" Background="Transparent" TextWrapping="Wrap"></TextBox>
@ -96,7 +97,7 @@
</GridView>
</ListView.View>
</ListView>
</DockPanel>
</DockPanel>-->
</UniformGrid>
</Grid>

@ -20,8 +20,9 @@ namespace Txgy.FilesWatcher.model
public string FileName { get; set; }
public static void UploadMSeedOnce(Action<string> mseedAction, string path, int workAreaId)
public static List<string> UploadMSeedOnce(Action<string> mseedAction, string path, int workAreaId)
{
List<string> logList =new List<string>();
GetLogger _log = new GetLogger("UploadMseedFile");
_log.Log.DebugFormat("UploadMseedFile.UploadMSeedOnce() path:{0},workAreaId:{1}", path, workAreaId);
try
@ -56,10 +57,11 @@ namespace Txgy.FilesWatcher.model
sqlNumber = $"INSERT INTO {tbname} (WaveTime, WorkAreaID, WaveData) VALUES('{WaveTime}', '{workAreaId}', @mseedD)";
var res = conn.Execute(sqlNumber, new { mseedD = mseedDatas });
_log.Log.DebugFormat("UploadMseedFile.UploadMSeedOnce() 上传数据表:{0},WaveTime:{1}", tbname, WaveTime);
logList.Add($"{DateTime.Now},表名:{tbname},原始mseedwavesdata:{WaveTime}");
//更新上传文件记录
sqlNumber = $"INSERT INTO {uploadedtbname}(filename, uploadtime) VALUES('{file}', '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}')";
res = conn.Execute(sqlNumber);
logList.Add($"{DateTime.Now},表名:{uploadedtbname},文件名:{file}");
_log.Log.DebugFormat("UploadMseedFile.UploadMSeedOnce() 上传数据表:{0},文件:{1}", uploadedtbname, file);
}
}
@ -74,7 +76,7 @@ namespace Txgy.FilesWatcher.model
{
_log.Log.ErrorFormat("UploadMseedFile.UploadMSeedOnce()() error:{0}", ex);
}
return logList;
}
}
}

@ -17,8 +17,9 @@ namespace Txgy.FilesWatcher.model
public class UploadPostproFile
{
public static void UploadPostproFileOnce(string path, string eventMessage, int workAreaId , out bool isUpload)
public static List<string> UploadPostproFileOnce(string path, string eventMessage, int workAreaId , out bool isUpload)
{
List<string> logList = new List<string>();
GetLogger _log = new GetLogger("UploadPostproFile");
_log.Log.DebugFormat("UploadPostproFile.UploadPostproFileOnce() path:{0},eventMessage:{1},workAreaId:{2}", path, eventMessage, workAreaId);
isUpload = false;
@ -47,10 +48,11 @@ namespace Txgy.FilesWatcher.model
{
index_file_line[5] = "-4";
}
string letter = index_file_line.Last();
string EventTime = index_file_line[0].Substring(0, 23);
string OriginTime = EventTime;
//.json文件
string JPath = dFile.FullName.Replace(".mseed", "A.json");
string JPath = dFile.FullName.Replace(".mseed", letter+".json");
if (File.Exists(JPath))
{
string mes = File.ReadAllText(JPath);
@ -69,6 +71,7 @@ namespace Txgy.FilesWatcher.model
sqlNumber = $"INSERT INTO {tbrealtimeresult}(WorkAreaId, EventTime, OriginTime, X, Y, Z, ML, LocSta, MLSta, RMS) VALUES('{workAreaId}', '{EventTime}', '{OriginTime}', '{index_file_line[1]}', '{index_file_line[2]}', '{index_file_line[3]}', '{index_file_line[5]}', '{index_file_line[7]}', '{index_file_line[8]}', '{index_file_line[6]}')";
var res = conn.Execute(sqlNumber);
_log.Log.DebugFormat("UploadPostproFileOnce() 上传数据表:{0},eventMessage:{1}", tbrealtimeresult, eventMessage);
logList.Add($"{DateTime.Now},表名:{tbrealtimeresult},事件记录EventTime:{EventTime}, 事件波形文件resultdata:{dFile.FullName}");
}
isUpload = true;
// .mseed文件
@ -100,11 +103,15 @@ namespace Txgy.FilesWatcher.model
MySqlCommand mycomm = new MySqlCommand(sqlNumber, conn);
conn.Execute(sqlNumber, new { mDatas = mseedDatas, jDatas = jsonDatas });
_log.Log.DebugFormat("UploadPostproFileOnce() 上传数据表:{0}", tbname);
logList.Add($"{DateTime.Now},表名:{tbname},事件记录EventTime:{EventTime}, 事件波形文件resultdata:{file}");
}
sqlNumber = $"INSERT INTO {uploadedtbname}(filename, uploadtime) VALUES('{file}', '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}')";
sqlNumber = $"INSERT INTO {uploadedtbname}(filename, uploadtime, WorkAreaID) VALUES('{file}', '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}', '{workAreaId}')";
conn.Execute(sqlNumber);
_log.Log.DebugFormat("UploadPostproFileOnce() 上传数据表:{0},文件:{1}", uploadedtbname, file);
logList.Add($"{DateTime.Now},表名:{uploadedtbname},事件记录:文件名:{file}");
}
}
}
@ -113,6 +120,8 @@ namespace Txgy.FilesWatcher.model
{
_log.Log.ErrorFormat("UploadPostproFile.UploadPostproFileOnce() error:{0}", ex);
}
return logList;
}
public static void UploadPostproFileMQ(Action<string, string> mqAction, string path, string eventMessage)
{

@ -23,8 +23,9 @@ namespace Txgy.FilesWatcher.model
{
public class UploadRealtimeFile
{
public static void UploadRealtimeFileOnce(string path, string eventMessage, int workAreaId, out bool isUpload)
public static List<string> UploadRealtimeFileOnce(string path, string eventMessage, int workAreaId, out bool isUpload)
{
List<string> logList = new List<string>();
GetLogger _log = new GetLogger("UploadRealtimeFile");
_log.Log.DebugFormat("UploadRealtimeFile.UploadRealtimeFileOnce() path:{0},eventMessage:{1},workAreaId:{2}", path, eventMessage, workAreaId);
isUpload = false;
@ -53,11 +54,11 @@ namespace Txgy.FilesWatcher.model
{
index_file_line[5] = "-4";
}
string letter = index_file_line.Last();
string EventTime = index_file_line[0].Substring(0, 23);
string OriginTime = EventTime;
//.json文件
string JPath = dFile.FullName.Replace(".mseed", "A.json");
string JPath = dFile.FullName.Replace(".mseed", letter+".json");
if(File.Exists(JPath))
{
string mes= File.ReadAllText(JPath);
@ -77,7 +78,9 @@ namespace Txgy.FilesWatcher.model
sqlNumber = $"INSERT INTO {tbrealtimeresult}(WorkAreaId, EventTime, OriginTime, X, Y, Z, ML, LocSta, MLSta, RMS) VALUES('{workAreaId}', '{EventTime}', '{OriginTime}', '{index_file_line[1]}', '{index_file_line[2]}', '{index_file_line[3]}', '{index_file_line[5]}', '{index_file_line[7]}', '{index_file_line[8]}', '{index_file_line[6]}')";
conn.Execute(sqlNumber);
_log.Log.DebugFormat("UploadRealtimeFileOnce() 上传数据表:{0},eventMessage:{1}", tbrealtimeresult, eventMessage);
}
logList.Add($"{DateTime.Now},表名:{tbrealtimeresult},事件记录EventTime:{EventTime}, 事件波形文件resultdata:{file}");
}
isUpload = true;
// .mseed文件
FileStream fs = new FileStream(dFile.FullName, FileMode.Open, FileAccess.Read);
@ -107,11 +110,13 @@ namespace Txgy.FilesWatcher.model
MySqlCommand mycomm = new MySqlCommand(sqlNumber, conn);
conn.Execute(sqlNumber, new { mDatas = mseedDatas, jDatas = jsonDatas });
_log.Log.DebugFormat("UploadRealtimeFileOnce() 上传数据表:{0}", tbname);
logList.Add($"{DateTime.Now},表名:{tbname},事件记录EventTime:{EventTime}, 事件波形文件resultdata:{file}");
}
sqlNumber = $"INSERT INTO {uploadedtbname}(filename, uploadtime) VALUES('{file}', '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}')";
sqlNumber = $"INSERT INTO {uploadedtbname}(filename, uploadtime, WorkAreaID) VALUES('{file}', '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}', '{workAreaId}')";
int res = conn.Execute(sqlNumber);
_log.Log.DebugFormat("UploadRealtimeFileOnce() 上传数据表:{0},文传:{1}", uploadedtbname, file);
logList.Add($"{DateTime.Now},表名:{uploadedtbname},事件记录:文件名:{file}");
}
}
}
@ -120,6 +125,7 @@ namespace Txgy.FilesWatcher.model
{
_log.Log.ErrorFormat("UploadRealtimeFile.UploadRealtimeFileOnce() error:{0}", ex);
}
return logList;
}
public static void UploadRealtimeFileMQ(Action<string, string> mqAction, string path, string eventMessage)

Loading…
Cancel
Save