1.工区号是否起作用;

2.增加定期轮询检查以往数据,参数:起始日期偏移:3天、结束日期偏移:1天,轮巡间隔:1h;
3.增加手动检查数据是否上传功能,参数:起始日期偏移:3天、结束日期偏移:1天,使用独立页面显示执行过程、结果;
master
mzhifa 3 months ago
parent a7b843ce94
commit 8997ccec41

@ -3,6 +3,7 @@ using Prism.Regions;
using System.Text.Json; using System.Text.Json;
using System.Windows; using System.Windows;
using Txgy.FilesWatcher.model; using Txgy.FilesWatcher.model;
using Txgy.FilesWatcher.ViewModels;
using Txgy.FilesWatcher.Views; using Txgy.FilesWatcher.Views;
namespace Txgy.FilesWatcher namespace Txgy.FilesWatcher
@ -29,7 +30,8 @@ namespace Txgy.FilesWatcher
ReadCommentHandling = JsonCommentHandling.Skip ReadCommentHandling = JsonCommentHandling.Skip
}); });
}); });
containerRegistry.RegisterDialog<ManualModeDialog>();
containerRegistry.RegisterSingleton<ManualModeDialogViewModel>();
var iregion= Container.Resolve<IRegionManager>(); var iregion= Container.Resolve<IRegionManager>();
iregion.RegisterViewWithRegion("MainContentRegion", typeof(MainView)); iregion.RegisterViewWithRegion("MainContentRegion", typeof(MainView));
} }

@ -27,12 +27,13 @@ using MQTTnet.Client.Options;
using System.Windows.Markup; using System.Windows.Markup;
using System.Windows.Forms.VisualStyles; using System.Windows.Forms.VisualStyles;
using System.Xml.Linq; using System.Xml.Linq;
using Prism.Services.Dialogs;
namespace Txgy.FilesWatcher.ViewModels namespace Txgy.FilesWatcher.ViewModels
{ {
internal class MainViewModel : BindableBase internal class MainViewModel : BindableBase
{ {
public MainViewModel(WebsocketClient websocketClient, SystemConfig systemConfig, IEventAggregator ea) public MainViewModel(WebsocketClient websocketClient, SystemConfig systemConfig, IEventAggregator ea, IDialogService dialogService, ManualModeDialogViewModel manualModeDialog)
{ {
StartCommand = new DelegateCommand(Start, StartCanExecute).ObservesProperty(() => StartEnable); StartCommand = new DelegateCommand(Start, StartCanExecute).ObservesProperty(() => StartEnable);
StopCommand= new DelegateCommand(Stop, StopCanExecute).ObservesProperty(() => StopEnable); StopCommand= new DelegateCommand(Stop, StopCanExecute).ObservesProperty(() => StopEnable);
@ -52,8 +53,10 @@ namespace Txgy.FilesWatcher.ViewModels
InitializeParams(filter); InitializeParams(filter);
StartTime = DateTime.Now; StartTime = DateTime.Now;
this._ea = ea; this._ea = ea;
this._dialogService = dialogService;
this._manualModeDialog = manualModeDialog;
} }
private string watcherPath; private string watcherPath;
public string PostPath public string PostPath
@ -92,16 +95,16 @@ namespace Txgy.FilesWatcher.ViewModels
get { return toolPath; } get { return toolPath; }
set { SetProperty(ref toolPath, value); } set { SetProperty(ref toolPath, value); }
} }
private bool isUploadMseedPath; private bool isUploadMseedPath = true;
public bool IsUploadMseedPath public bool IsUploadMseedPath
{ {
get { return isUploadMseedPath; } get { return isUploadMseedPath; }
set { SetProperty(ref isUploadMseedPath, value); } set { SetProperty(ref isUploadMseedPath, value); }
} }
private bool isUploadRealtimePath; private bool isUploadRealtimePath = true;
public bool IsUploadRealtimePath public bool IsUploadRealtimePath
{ {
@ -109,7 +112,7 @@ namespace Txgy.FilesWatcher.ViewModels
set { SetProperty(ref isUploadRealtimePath, value); } set { SetProperty(ref isUploadRealtimePath, value); }
} }
private bool isUploadPostPath; private bool isUploadPostPath = true;
public bool IsUploadPostPath public bool IsUploadPostPath
{ {
@ -223,6 +226,14 @@ namespace Txgy.FilesWatcher.ViewModels
get { return workAreaId; } get { return workAreaId; }
set { SetProperty(ref workAreaId, value); } set { SetProperty(ref workAreaId, value); }
} }
private int cycleTime = 1;
public int CycleTime
{
get { return cycleTime; }
set { SetProperty(ref cycleTime, value); }
}
private bool startEnable=true; private bool startEnable=true;
public bool StartEnable public bool StartEnable
@ -253,6 +264,18 @@ namespace Txgy.FilesWatcher.ViewModels
public DelegateCommand StopCommand { get; private set; } public DelegateCommand StopCommand { get; private set; }
public DelegateCommand ManualCommand => new DelegateCommand(() =>
{
DialogParameters param = new DialogParameters
{
{ "main", this }
};
_dialogService.ShowDialog("ManualModeDialog", param, ((a) =>
{
}));
});
private void Start() private void Start()
{ {
int res= WatchStartOrSopt(true); int res= WatchStartOrSopt(true);
@ -265,7 +288,7 @@ namespace Txgy.FilesWatcher.ViewModels
timer1.Start(); timer1.Start();
timerTool.Start(); timerTool.Start();
StartConnectMQ(); StartConnectMQ();
mseedFileTime = DateTime.Now;
} }
} }
@ -475,16 +498,31 @@ namespace Txgy.FilesWatcher.ViewModels
{ {
DateTime currentT= DateTime.Now; DateTime currentT= DateTime.Now;
RunTime = DateDiff(currentT, StartTime); RunTime = DateDiff(currentT, StartTime);
// path = "I:\\yuwuN3102mseed\\NET2023\\06\\22\\21\\51";
if ((currentT - mseedFileTime).TotalHours >= CycleTime)
{
mseedFileTime = DateTime.Now;
DateTime start= DateTime.Now.AddDays(-3);
_manualModeDialog.StartHandle(start, start.AddDays(-4));
}
else
{
MseedFileChanged(currentT);
}
}
DateTime mseedFileTime = DateTime.Now;
private void MseedFileChanged(DateTime 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")}"; 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\\51";
Debug.WriteLine($"**********当前时间:{currentT},监控路径:{path}"); Debug.WriteLine($"**********当前时间:{currentT},监控路径:{path}");
if (Directory.Exists(path) && IsUploadDB&& IsUploadMseedPath) if (Directory.Exists(path) && IsUploadDB && IsUploadMseedPath)
{ {
UploadMseedFile.UploadMSeedOnce((a=> UploadMseedFile.UploadMSeedOnce((a =>
{ {
timer1.Dispatcher.Invoke(() => timer1.Dispatcher.Invoke(() =>
{ {
if(DataList.Count >= 20) { DataList.Remove(dataList.Last()); } if (DataList.Count >= 20) { DataList.Remove(dataList.Last()); }
DataList.Insert(0, new FileModel DataList.Insert(0, new FileModel
{ {
CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"), CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"),
@ -494,6 +532,8 @@ namespace Txgy.FilesWatcher.ViewModels
}), path, WorkAreaId); }), path, WorkAreaId);
} }
} }
/// <summary> /// <summary>
/// 启动或者停止监听 /// 启动或者停止监听
/// </summary> /// </summary>
@ -557,7 +597,7 @@ namespace Txgy.FilesWatcher.ViewModels
{ {
} }
private void Watcher_Changed(object sender, System.IO.FileSystemEventArgs e) private void Watcher_Changed(object sender, System.IO.FileSystemEventArgs e)
{ {
Thread.Sleep(100); Thread.Sleep(100);
// string tmp = dt.Hour.ToString() + "时" + dt.Minute.ToString() + "分" + dt.Second.ToString() + "秒" + dt.Millisecond.ToString() + "毫秒,目录发生变化\r\n"; // string tmp = dt.Hour.ToString() + "时" + dt.Minute.ToString() + "分" + dt.Second.ToString() + "秒" + dt.Millisecond.ToString() + "毫秒,目录发生变化\r\n";
@ -571,16 +611,19 @@ namespace Txgy.FilesWatcher.ViewModels
watcherArray[0].EnableRaisingEvents = false; watcherArray[0].EnableRaisingEvents = false;
if (IsUploadDB && isUploadRealtimePath) if (IsUploadDB && isUploadRealtimePath)
{ {
UploadRealtimeFile.UploadRealtimeFileOnce(filePath, lastLine, WorkAreaId); UploadRealtimeFile.UploadRealtimeFileOnce(filePath, lastLine, WorkAreaId, out bool isUpload);
timer1.Dispatcher.Invoke(() => if (isUpload)
{ {
if (RealTimeDataList.Count >= 20) { RealTimeDataList.Remove(RealTimeDataList.Last()); } timer1.Dispatcher.Invoke(() =>
RealTimeDataList.Insert(0, new FileModel
{ {
CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"), if (RealTimeDataList.Count >= 20) { RealTimeDataList.Remove(RealTimeDataList.Last()); }
Data = $"{lastLine},事件上传成功。" RealTimeDataList.Insert(0, new FileModel
{
CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"),
Data = $"{lastLine},事件上传成功。"
});
}); });
}); }
} }
if (IsUploadMQTT && isUploadRealtimePath) if (IsUploadMQTT && isUploadRealtimePath)
{ {
@ -605,17 +648,20 @@ namespace Txgy.FilesWatcher.ViewModels
watcherArray[1].EnableRaisingEvents = false; watcherArray[1].EnableRaisingEvents = false;
if (IsUploadDB && IsUploadPostPath) if (IsUploadDB && IsUploadPostPath)
{ {
UploadPostproFile.UploadPostproFileOnce(filePath, lastLine, WorkAreaId); UploadPostproFile.UploadPostproFileOnce(filePath, lastLine, WorkAreaId , out bool isUpload );
{ {
timer1.Dispatcher.Invoke(() => if (isUpload)
{ {
if (PostDataList.Count >= 20) { PostDataList.Remove(PostDataList.Last()); } timer1.Dispatcher.Invoke(() =>
PostDataList.Insert(0,new FileModel
{ {
CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"), if (PostDataList.Count >= 20) { PostDataList.Remove(PostDataList.Last()); }
Data = $"{lastLine},事件上传成功。" PostDataList.Insert(0, new FileModel
{
CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"),
Data = $"{lastLine},事件上传成功。"
});
}); });
}); }
} }
} }
if (IsUploadMQTT && IsUploadPostPath) if (IsUploadMQTT && IsUploadPostPath)
@ -745,6 +791,8 @@ namespace Txgy.FilesWatcher.ViewModels
private IManagedMqttClient mqttClient; private IManagedMqttClient mqttClient;
// private readonly WebsocketClient _websocketClient; // private readonly WebsocketClient _websocketClient;
private readonly IEventAggregator _ea; private readonly IEventAggregator _ea;
private readonly IDialogService _dialogService;
private readonly ManualModeDialogViewModel _manualModeDialog;
protected void ShowLoading(string tip = "正在加载....") protected void ShowLoading(string tip = "正在加载....")
{ {

@ -0,0 +1,311 @@
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Unicode;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media.Animation;
using System.Windows.Threading;
using Txgy.FilesWatcher.model;
namespace Txgy.FilesWatcher.ViewModels
{
public class ManualModeDialogViewModel : BindableBase, IDialogAware
{
public ManualModeDialogViewModel(IEventAggregator ea)
{
}
public string Title => "手动模式";
public event Action<IDialogResult> RequestClose;
public bool CanCloseDialog() => true;
public void OnDialogClosed()
{
cts.Cancel();
}
MainViewModel mainModel;
public void OnDialogOpened(IDialogParameters parameters)
{
StartTime = DateTime.Now.AddDays(-3);
EndTime = StartTime.AddDays(4);
mainModel = parameters.GetValue<MainViewModel>("main");
if (DataList.Count > 0) { DataList.Clear(); }
if (RealTimeDataList.Count >= 0) { RealTimeDataList.Clear(); }
if (PostDataList.Count >= 0) { PostDataList.Clear(); }
}
public ICommand SelectFileCommand { get; set; }
public ICommand UploadCommand { get; set; }
private ObservableCollection<FileModel> dataList = new ObservableCollection<FileModel>();
public ObservableCollection<FileModel> DataList
{
get { return dataList; }
set { SetProperty(ref dataList, value); }
}
private ObservableCollection<FileModel> realTimeDataList = new ObservableCollection<FileModel>();
public ObservableCollection<FileModel> RealTimeDataList
{
get { return realTimeDataList; }
set { SetProperty(ref realTimeDataList, value); }
}
private ObservableCollection<FileModel> postDataList = new ObservableCollection<FileModel>();
public ObservableCollection<FileModel> PostDataList
{
get { return postDataList; }
set { SetProperty(ref postDataList, value); }
}
private DateTime startTime;
public DateTime StartTime { get => startTime; set => SetProperty(ref startTime, value); }
private DateTime endTime;
public DateTime EndTime { get => endTime; set => SetProperty(ref endTime, value); }
private string stateMes="未开始";
public string StateMes { get => stateMes; set => SetProperty(ref stateMes, value); }
private bool startEnable = true;
public bool StartEnable { get => startEnable; set => SetProperty(ref startEnable, value); }
public DelegateCommand StartCommand => new DelegateCommand(async () =>
{
if ((EndTime - StartTime).TotalDays > 4)
{
MessageBox.Show("时间区间超范围!");
}
StateMes = "执行中";
StartEnable = false;
await StartHandle(StartTime,EndTime);
StateMes = "未开始";
StartEnable = true;
}).ObservesCanExecute(()=>StartEnable);
CancellationTokenSource cts = new CancellationTokenSource();
public async Task StartHandle(DateTime start, DateTime end)
{
CancellationToken cancellationToken = cts.Token;
string realtimePath = Path.Combine(mainModel.MainPath, mainModel.RealtimePath);
string postPath = Path.Combine(mainModel.MainPath, mainModel.PostPath);
Task task1 = Task.Run(() =>
{
DateTime time = start.AddMinutes(1);
while (!cancellationToken.IsCancellationRequested)
{
time = time.AddMinutes(1);
MseedUpload(time);
if (time >= end)
{
break;
}
}
}, cancellationToken);
Task task2 = Task.Run(() =>
{
var files = new DirectoryInfo(realtimePath).GetFiles("*.index");
foreach (var file in files)
{
var lines = File.ReadAllLines(file.FullName);
foreach (var line in lines)
{
if (cancellationToken.IsCancellationRequested)
{
Console.WriteLine("Cancellation");
break;
}
RealtimeChanged(file.FullName, line);
}
}
}, cancellationToken);
Task task3 = Task.Run(() =>
{
var postFiles = new DirectoryInfo(postPath).GetFiles("*.index");
foreach (var file in postFiles)
{
var lines = File.ReadAllLines(file.FullName);
foreach (var line in lines)
{
if (cancellationToken.IsCancellationRequested)
{
Console.WriteLine("Cancellation");
break;
}
PostChanged(file.FullName, line);
}
}
}, cancellationToken);
await Task.WhenAll(task1, task2, task3);
}
public DelegateCommand ManualCommand => new DelegateCommand(() =>
{
cts.Cancel();
});
private void 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}");
if (Directory.Exists(path) && mainModel.IsUploadDB && mainModel.IsUploadMseedPath)
{
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}"
});
});
}), path, mainModel.WorkAreaId);
}
}
private void 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);
if (mainModel.IsUploadDB && mainModel.IsUploadRealtimePath)
{
UploadRealtimeFile.UploadRealtimeFileOnce(filePath, lastLine, mainModel.WorkAreaId, out bool isUpload);
timer1.Dispatcher.Invoke(() =>
{
// if (RealTimeDataList.Count >= 20) { RealTimeDataList.Remove(RealTimeDataList.Last()); }
if (isUpload)
{
RealTimeDataList.Insert(0, new FileModel
{
CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"),
Data = $"{lastLine},事件上传成功。"
});
}
});
}
if (mainModel.IsUploadMQTT && mainModel.IsUploadRealtimePath)
{
UploadRealtimeFile.UploadRealtimeFileMQ((a, b) =>
{
}, filePath, lastLine);
}
}
private void 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);
if (mainModel.IsUploadDB && mainModel.IsUploadPostPath)
{
UploadPostproFile.UploadPostproFileOnce(filePath, lastLine, mainModel.WorkAreaId, out bool isUpload);
{
timer1.Dispatcher.Invoke(() =>
{
// if (PostDataList.Count >= 20) { PostDataList.Remove(PostDataList.Last()); }
if (isUpload)
{
PostDataList.Insert(0, new FileModel
{
CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"),
Data = $"{lastLine},事件上传成功。"
});
}
});
}
}
if (mainModel.IsUploadMQTT && mainModel.IsUploadPostPath)
{
UploadPostproFile.UploadPostproFileMQ((a, b) =>
{
timer1.Dispatcher.Invoke(() =>
{
});
}, filePath, lastLine);
}
}
private DispatcherTimer timer1 = new DispatcherTimer();
private System.Timers.Timer timerTool = new System.Timers.Timer();
private readonly SystemConfig _systemConfig;
private readonly IEventAggregator _ea;
private readonly IDialogService _dialogService;
#region
private void TimerTool_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
DateTime currentT = DateTime.Now;
string path = $"{mainModel.ToolPath}/{currentT.Month.ToString("D2")}/{currentT.Day.ToString("D2")}/{currentT.Hour.ToString("D2")}/{currentT.AddMinutes(-2).Minute.ToString("D2")}";
// path = "H:/mzhifa/txgy/FileWatchProject/NET2023/11/29/00/06";
Debug.WriteLine($"**********apmTools{currentT},结果路径:{path}");
if (Directory.Exists(path) && mainModel.IsEnableToolPath)
{
CMDStartProcess(_systemConfig.proTools, path);
}
}
private bool CMDStartProcess(ProcessInfo proInfo, string path)
{
Process process = new Process();
process.Exited += Process_Exited;
process.EnableRaisingEvents = true;
process.StartInfo.FileName = Path.GetFullPath(proInfo.ProPath + proInfo.ProName + ".exe");
process.StartInfo.UseShellExecute = false;
process.StartInfo.WorkingDirectory = Path.GetFullPath(proInfo.ProPath);
process.StartInfo.Arguments = proInfo.ProParams + path;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
//* Set your output and error (asynchronous) handlers
process.OutputDataReceived += new DataReceivedEventHandler(OutputHandler);
process.ErrorDataReceived += new DataReceivedEventHandler(OutputHandler);
bool res = process.Start();
return res;
}
private void Process_Exited(object? sender, EventArgs e)
{
}
void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
{
Debug.WriteLine("output*************:{0},{1}", sendingProcess.ToString(), outLine.Data);
if (string.IsNullOrEmpty(outLine.Data)) return;
}
#endregion
}
}

@ -65,7 +65,7 @@
</RadioButton>--> </RadioButton>-->
<DockPanel Grid.Row="1" IsEnabled="{Binding StartEnable}"> <DockPanel Grid.Row="1" IsEnabled="{Binding StartEnable}">
<TextBlock Text="工区编号:" VerticalAlignment="Center"/> <TextBlock Text="工区编号:" VerticalAlignment="Center"/>
<hc:NumericUpDown Value="{Binding WorkAreaId}"/> <hc:NumericUpDown Value="{Binding WorkAreaId, UpdateSourceTrigger=PropertyChanged}"/>
</DockPanel> </DockPanel>
<TextBlock Grid.Row="2" VerticalAlignment="Center" Grid.ColumnSpan="3"> <TextBlock Grid.Row="2" VerticalAlignment="Center" Grid.ColumnSpan="3">
<Run Text="启动时间:"/> <Run Text="启动时间:"/>
@ -126,6 +126,12 @@
FontSize="10" /> FontSize="10" />
</DockPanel> </DockPanel>
</GroupBox> </GroupBox>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<TextBlock Text="自动处理时间间隔(小时)" VerticalAlignment="Center"/>
<hc:NumericUpDown Value="{Binding CycleTime}"/>
</StackPanel>
<Button Content="手动处理" Command="{Binding ManualCommand}" Margin="0,20,0,0"/>
</StackPanel> </StackPanel>
<ProgressBar Grid.Row="7" <ProgressBar Grid.Row="7"
Grid.ColumnSpan="3" Grid.ColumnSpan="3"

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

@ -0,0 +1,101 @@
<UserControl x:Class="Txgy.FilesWatcher.Views.ManualModeDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Txgy.FilesWatcher.Views"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<prism:Dialog.WindowStyle>
<Style TargetType="Window">
<Setter Property="Width" Value="600"/>
<Setter Property="Height" Value="650"/>
</Style>
</prism:Dialog.WindowStyle>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="31*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<Label Content="开始时间"/>
<DatePicker SelectedDate="{Binding StartTime}" Margin="10,0,0,0" IsEnabled="False"/>
<Label Content="结束时间" Margin="10,0,0,0" Visibility="Collapsed"/>
<DatePicker SelectedDate="{Binding EndTime}" IsEnabled="False" Visibility="Collapsed"/>
<Button Content="开始" Command="{Binding StartCommand}"/>
<TextBlock Text="{Binding StateMes}" VerticalAlignment="Center" Margin="20,0,20,0"/>
<Button Content="停止" Command="{Binding ManualCommand}"/>
</StackPanel>
<UniformGrid Columns="1" Grid.Row="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>
</UniformGrid>
</Grid>
</UserControl>

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Txgy.FilesWatcher.Views
{
/// <summary>
/// ManualModeView.xaml 的交互逻辑
/// </summary>
public partial class ManualModeDialog : UserControl
{
public ManualModeDialog()
{
InitializeComponent();
}
}
}

@ -14,6 +14,8 @@ namespace Txgy.FilesWatcher.model
public string mseedpath { get; set; } public string mseedpath { get; set; }
public string toolpath { get; set; } public string toolpath { get; set; }
public int cycleTime { get; set; }
public MQTTConfig mQTTConfig { get; set; } public MQTTConfig mQTTConfig { get; set; }
public DBConfig dBConfig { get; set; } public DBConfig dBConfig { get; set; }

@ -20,7 +20,7 @@ namespace Txgy.FilesWatcher.model
public string FileName { get; set; } public string FileName { get; set; }
public static void UploadMSeedOnce(Action<string> mseedAction, string path, int workAreaId=1) public static void UploadMSeedOnce(Action<string> mseedAction, string path, int workAreaId)
{ {
try try
{ {

@ -17,8 +17,9 @@ namespace Txgy.FilesWatcher.model
public class UploadPostproFile public class UploadPostproFile
{ {
public static void UploadPostproFileOnce(string path, string eventMessage, int workAreaId = 1) public static void UploadPostproFileOnce(string path, string eventMessage, int workAreaId , out bool isUpload)
{ {
isUpload = false;
try try
{ {
var currentTime = DateTime.Now; var currentTime = DateTime.Now;
@ -50,6 +51,7 @@ namespace Txgy.FilesWatcher.model
//WorkAreaId = 1,更新realtimeeventresult //WorkAreaId = 1,更新realtimeeventresult
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]}')"; 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); var res = conn.Execute(sqlNumber);
isUpload = true;
// .mseed文件 // .mseed文件
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);

@ -23,8 +23,9 @@ namespace Txgy.FilesWatcher.model
{ {
public class UploadRealtimeFile public class UploadRealtimeFile
{ {
public static void UploadRealtimeFileOnce(string path, string eventMessage, int workAreaId= 1) public static void UploadRealtimeFileOnce(string path, string eventMessage, int workAreaId, out bool isUpload)
{ {
isUpload = false;
try try
{ {
var currentTime = DateTime.Now; var currentTime = DateTime.Now;
@ -57,6 +58,7 @@ namespace Txgy.FilesWatcher.model
//WorkAreaId = 1,更新realtimeeventresult //WorkAreaId = 1,更新realtimeeventresult
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]}')"; 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); var res = conn.Execute(sqlNumber);
isUpload = true;
// .mseed文件 // .mseed文件
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);

Loading…
Cancel
Save