|  |  | @ -22,7 +22,9 @@ using System.Text.Unicode; | 
			
		
	
		
		
			
				
					
					|  |  |  | using System.Net.Sockets; |  |  |  | using System.Net.Sockets; | 
			
		
	
		
		
			
				
					
					|  |  |  | using System.Security.Policy; |  |  |  | using System.Security.Policy; | 
			
		
	
		
		
			
				
					
					|  |  |  | using Prism.Events; |  |  |  | using Prism.Events; | 
			
		
	
		
		
			
				
					
					|  |  |  | using System.Windows.Shapes; |  |  |  | using ImTools; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | using static System.Windows.Forms.Design.AxImporter; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | using HandyControl.Controls; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | namespace Txgy.FilesWatcher.ViewModels |  |  |  | namespace Txgy.FilesWatcher.ViewModels | 
			
		
	
		
		
			
				
					
					|  |  |  | { |  |  |  | { | 
			
		
	
	
		
		
			
				
					|  |  | @ -32,41 +34,53 @@ namespace Txgy.FilesWatcher.ViewModels | 
			
		
	
		
		
			
				
					
					|  |  |  |         { |  |  |  |         { | 
			
		
	
		
		
			
				
					
					|  |  |  |             string filter = "*.index"; |  |  |  |             string filter = "*.index"; | 
			
		
	
		
		
			
				
					
					|  |  |  |             string str = File.ReadAllText("systemconfig.json"); |  |  |  |             string str = File.ReadAllText("systemconfig.json"); | 
			
		
	
		
		
			
				
					
					|  |  |  |             systemConfig = JsonSerializer.Deserialize<SystemConfig>(str); |  |  |  |             systemConfig = JsonSerializer.Deserialize<SystemConfig>(str, new JsonSerializerOptions | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             WatcherPath = systemConfig.FilePath; |  |  |  |             { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             WatcherMseedPath= systemConfig.WatcherMseedPath; |  |  |  |                 ReadCommentHandling = JsonCommentHandling.Skip | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             MseedFilePath = systemConfig.MseedFilePath; |  |  |  |             }); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             PostPath = systemConfig.realtimepath; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             RealtimePath= systemConfig.postpath; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             MseedPath = systemConfig.mseedpath; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             MainPath= systemConfig.mainpath; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             DataBaseConnect.DataBaseConfig = systemConfig.dBConfig; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             watcherArray[0] = new FileSystemWatcher(); |  |  |  |             watcherArray[0] = new FileSystemWatcher(); | 
			
		
	
		
		
			
				
					
					|  |  |  |             watcherArray[1] = new FileSystemWatcher(); |  |  |  |             watcherArray[1] = new FileSystemWatcher(); | 
			
		
	
		
		
			
				
					
					|  |  |  |             InitializeParams(filter); |  |  |  |             InitializeParams(filter); | 
			
		
	
		
		
			
				
					
					|  |  |  |             StartTime = DateTime.Now; |  |  |  |             StartTime = DateTime.Now; | 
			
		
	
		
		
			
				
					
					|  |  |  |             this._ea = ea; |  |  |  |             this._ea = ea; | 
			
		
	
		
		
			
				
					
					|  |  |  |           //  this._websocketClient = websocketClient; |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |           //  _websocketClient.WebsocketError = WebSocket_Error; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |           //  _websocketClient.WebSocketMessageReceived = WebSocket4Net_MessageReceived; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |           //  _websocketClient.WebSocketInit(systemConfig.Url); |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |         private string watcherPath; |  |  |  |         private string watcherPath; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         public string WatcherPath |  |  |  |         public string PostPath | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         { |  |  |  |         { | 
			
		
	
		
		
			
				
					
					|  |  |  |             get { return watcherPath; } |  |  |  |             get { return watcherPath; } | 
			
		
	
		
		
			
				
					
					|  |  |  |             set { SetProperty(ref watcherPath, value); } |  |  |  |             set { SetProperty(ref watcherPath, value); } | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |         private string watcherMseedPath; |  |  |  |         private string realtimePath; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         public string WatcherMseedPath |  |  |  |         public string RealtimePath | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         { |  |  |  |         { | 
			
		
	
		
		
			
				
					
					|  |  |  |             get { return watcherMseedPath; } |  |  |  |             get { return realtimePath; } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             set { SetProperty(ref watcherMseedPath, value); } |  |  |  |             set { SetProperty(ref realtimePath, value); } | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         private string mseedFilePath; |  |  |  |         private string mseedPath; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         public string MseedFilePath |  |  |  |         public string MseedPath | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         { |  |  |  |         { | 
			
		
	
		
		
			
				
					
					|  |  |  |             get { return mseedFilePath; } |  |  |  |             get { return mseedPath; } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             set { SetProperty(ref mseedFilePath, value); } |  |  |  |             set { SetProperty(ref mseedPath, value); } | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         private string mainPath; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         public string MainPath | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             get { return mainPath; } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             set { SetProperty(ref mainPath, value); } | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |         private ObservableCollection<WatcherFileModel> dataList = new ObservableCollection<WatcherFileModel>(); |  |  |  |         private ObservableCollection<WatcherFileModel> dataList = new ObservableCollection<WatcherFileModel>(); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -129,83 +143,97 @@ namespace Txgy.FilesWatcher.ViewModels | 
			
		
	
		
		
			
				
					
					|  |  |  |             set { SetProperty(ref workAreaId, value); } |  |  |  |             set { SetProperty(ref workAreaId, value); } | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |          |  |  |  |          | 
			
		
	
		
		
			
				
					
					|  |  |  |         bool isLogin = false; |  |  |  |         private bool isUploadDB = false; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         public DelegateCommand SureCommand => new(() => { |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         }); |  |  |  |         public bool IsUploadDB | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             get { return isUploadDB; } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             set { SetProperty(ref isUploadDB, value); } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         private bool isUploadMQTT = false; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         public bool IsUploadMQTT | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             get { return isUploadMQTT; } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             set { SetProperty(ref isUploadMQTT, value); } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |         public DelegateCommand StartCommand => new(Start); |  |  |  |         public DelegateCommand StartCommand => new(Start); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         public DelegateCommand StopCommand => new(Stop); |  |  |  |         public DelegateCommand StopCommand => new(Stop); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         private void Start() |  |  |  |         private void Start() | 
			
		
	
		
		
			
				
					
					|  |  |  |         { |  |  |  |         { | 
			
		
	
		
		
			
				
					
					|  |  |  |             WatchStartOrSopt(true); |  |  |  |             int res= WatchStartOrSopt(true); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (res == 0) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 StartTime = DateTime.Now; |  |  |  |                 StartTime = DateTime.Now; | 
			
		
	
		
		
			
				
					
					|  |  |  |                 timer1.Interval = TimeSpan.FromSeconds(ProMonInterval); |  |  |  |                 timer1.Interval = TimeSpan.FromSeconds(ProMonInterval); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 timer1.Start(); |  |  |  |                 timer1.Start(); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 timer1.Tick += timer1_Tick; |  |  |  |                 timer1.Tick += timer1_Tick; | 
			
		
	
		
		
			
				
					
					|  |  |  |             IsIndeterminate = true; |  |  |  |             } | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         private void Stop() |  |  |  |         private void Stop() | 
			
		
	
		
		
			
				
					
					|  |  |  |         { |  |  |  |         { | 
			
		
	
		
		
			
				
					
					|  |  |  |             WatchStartOrSopt(false); |  |  |  |             WatchStartOrSopt(false); | 
			
		
	
		
		
			
				
					
					|  |  |  |             timer1.Stop(); |  |  |  |             timer1.Stop(); | 
			
		
	
		
		
			
				
					
					|  |  |  |             IsIndeterminate = false; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         public DelegateCommand<object> FilePathSaveCommand => new((obj) => |  |  |  |         public DelegateCommand<object> FilePathSaveCommand => new((obj) => | 
			
		
	
		
		
			
				
					
					|  |  |  |         {  |  |  |  |         {  | 
			
		
	
		
		
			
				
					
					|  |  |  |             System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog(); |  |  |  |             System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog(); | 
			
		
	
		
		
			
				
					
					|  |  |  |             string para = obj.ToString(); |  |  |  |             string para = obj.ToString(); | 
			
		
	
		
		
			
				
					
					|  |  |  |             fbd.SelectedPath = (para == "WatcherPath") ? WatcherPath : watcherMseedPath; |  |  |  |             fbd.SelectedPath = MainPath;// (para == "PostPath") ? PostPath : RealtimePath; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             fbd.Description = "请选择文件路径"; |  |  |  |             fbd.Description = "请选择文件路径"; | 
			
		
	
		
		
			
				
					
					|  |  |  |              fbd.ShowNewFolderButton = true; |  |  |  |              fbd.ShowNewFolderButton = true; | 
			
		
	
		
		
			
				
					
					|  |  |  |             if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) |  |  |  |             if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) | 
			
		
	
		
		
			
				
					
					|  |  |  |             { |  |  |  |             { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 if (fbd.SelectedPath != WatcherPath) |  |  |  |                 if (fbd.SelectedPath != MainPath) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 { |  |  |  |                 { | 
			
		
	
		
		
			
				
					
					|  |  |  |                     if (para == "WatcherPath") |  |  |  |                     MainPath = fbd.SelectedPath; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     { |  |  |  |                     systemConfig.mainpath = MainPath; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                         WatcherPath = fbd.SelectedPath; |  |  |  |                     UpdateJsonConfig(systemConfig); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                         watcherArray[0].Path = watcherPath; |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 } |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |                     else |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                     { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                         watcherMseedPath = fbd.SelectedPath; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                         watcherArray[1].Path = watcherMseedPath; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |                     systemConfig.FilePath = WatcherPath; |  |  |  |         }); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     systemConfig.WatcherMseedPath = watcherMseedPath; |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     var options = new JsonSerializerOptions |  |  |  |         public DelegateCommand<object> SureCommand => new((obj) => | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         { |  |  |  |         { | 
			
		
	
		
		
			
				
					
					|  |  |  |                         // 整齐打印 |  |  |  |             string para = obj.ToString(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                         WriteIndented = true, |  |  |  |             if (para == "MseedPath") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                         //重新编码,解决中文乱码问题 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                         Encoder = JavaScriptEncoder.Create(UnicodeRanges.All) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                     }; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                     string message = JsonSerializer.Serialize(systemConfig, options); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                     if (File.Exists(settingDataPath)) |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             { |  |  |  |             { | 
			
		
	
		
		
			
				
					
					|  |  |  |                         File.WriteAllText(settingDataPath, message); |  |  |  |                 string path = Path.Combine(MainPath, MseedPath); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (!Directory.Exists(path)) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     MessageBox.Show($"{path} 不存在!"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     return; | 
			
		
	
		
		
			
				
					
					|  |  |  |                 } |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 systemConfig.mseedpath = MseedPath; | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             else if (para == "RealtimePath") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 string path = Path.Combine(MainPath, RealtimePath); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (!Directory.Exists(path)) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     MessageBox.Show($"{path} 不存在!"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     return; | 
			
		
	
		
		
			
				
					
					|  |  |  |                 } |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |         }); |  |  |  |                 watcherArray[0].Path = Path.Combine(MainPath, RealtimePath); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |                 systemConfig.realtimepath = RealtimePath; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         private string settingDataPath = "systemconfig.json"; |  |  |  |             } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         private void timer1_Tick(object? sender, EventArgs e) |  |  |  |             else if (para == "PostPath") | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             { |  |  |  |             { | 
			
		
	
		
		
			
				
					
					|  |  |  |             DateTime currentT=  DateTime.Now; |  |  |  |                 string path = Path.Combine(MainPath, PostPath); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             RunTime = DateDiff(currentT, StartTime); |  |  |  |                 if (!Directory.Exists(path)) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             string path = $"{MseedFilePath}/NET{currentT.Year.ToString("D4")}/{currentT.Month.ToString("D2")}/{currentT.Day.ToString("D2")}/{currentT.Hour.ToString("D2")}/{currentT.AddMinutes(-2).Minute.ToString("D2")}"; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |          //   path = "I:\\DATA/NET2023/06/22/22/56"; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             if (Directory.Exists(path)) |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 { |  |  |  |                 { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 UploadMseedFile.UploadMSeedOnce(path, WorkAreaId); |  |  |  |                     MessageBox.Show($"{path} 不存在!"); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     return; | 
			
		
	
		
		
			
				
					
					|  |  |  |                 } |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 watcherArray[1].Path = Path.Combine(MainPath, PostPath); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 systemConfig.postpath = PostPath; | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             UpdateJsonConfig(systemConfig); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         }); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         private void InitializeParams(string fileFilter) |  |  |  |         private void InitializeParams(string fileFilter) | 
			
		
	
		
		
			
				
					
					|  |  |  |         { |  |  |  |         { | 
			
		
	
	
		
		
			
				
					|  |  | @ -217,18 +245,7 @@ namespace Txgy.FilesWatcher.ViewModels | 
			
		
	
		
		
			
				
					
					|  |  |  |             IntervalTimesSource.Add(30); |  |  |  |             IntervalTimesSource.Add(30); | 
			
		
	
		
		
			
				
					
					|  |  |  |             IntervalTimesSource.Add(60); |  |  |  |             IntervalTimesSource.Add(60); | 
			
		
	
		
		
			
				
					
					|  |  |  |             SelectedIndex = 1; |  |  |  |             SelectedIndex = 1; | 
			
		
	
		
		
			
				
					
					|  |  |  |             //如果设置的目录不存在设置到根目录 |  |  |  |             | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             if (!Directory.Exists(WatcherPath)) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 WatcherPath = AppDomain.CurrentDomain.BaseDirectory; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             if (!Directory.Exists(watcherMseedPath)) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 watcherMseedPath = AppDomain.CurrentDomain.BaseDirectory; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             watcherArray[0].Path = watcherPath; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             watcherArray[1].Path = watcherMseedPath; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             //watcherArray = new FileSystemWatcher(); |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             foreach (var watcher in watcherArray) |  |  |  |             foreach (var watcher in watcherArray) | 
			
		
	
		
		
			
				
					
					|  |  |  |             { |  |  |  |             { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 //初始化监听 |  |  |  |                 //初始化监听 | 
			
		
	
	
		
		
			
				
					|  |  | @ -244,7 +261,7 @@ namespace Txgy.FilesWatcher.ViewModels | 
			
		
	
		
		
			
				
					
					|  |  |  |                                      | NotifyFilters.Security |  |  |  |                                      | NotifyFilters.Security | 
			
		
	
		
		
			
				
					
					|  |  |  |                                      | NotifyFilters.Size; |  |  |  |                                      | NotifyFilters.Size; | 
			
		
	
		
		
			
				
					
					|  |  |  |                 //设置监听的路径 |  |  |  |                 //设置监听的路径 | 
			
		
	
		
		
			
				
					
					|  |  |  |                // watcher.Path = WatcherPath; |  |  |  |                // watcher.Path = PostPath; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 watcher.Changed += new FileSystemEventHandler(Watcher_Changed); |  |  |  |                 watcher.Changed += new FileSystemEventHandler(Watcher_Changed); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 // watcherArray.Created += Watcher_Created; |  |  |  |                 // watcherArray.Created += Watcher_Created; | 
			
		
	
		
		
			
				
					
					|  |  |  |                 watcher.Deleted += new FileSystemEventHandler(Watcher_Deleted); |  |  |  |                 watcher.Deleted += new FileSystemEventHandler(Watcher_Deleted); | 
			
		
	
	
		
		
			
				
					|  |  | @ -259,8 +276,62 @@ namespace Txgy.FilesWatcher.ViewModels | 
			
		
	
		
		
			
				
					
					|  |  |  |                 watcher.EnableRaisingEvents = false; |  |  |  |                 watcher.EnableRaisingEvents = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |                 watcher.EndInit(); |  |  |  |                 watcher.EndInit(); | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |      |  |  |  |      | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |          | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         private void UpdateJsonConfig(SystemConfig systemConfig) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             var options = new JsonSerializerOptions | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 // 整齐打印 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 WriteIndented = true, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 //重新编码,解决中文乱码问题 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 Encoder = JavaScriptEncoder.Create(UnicodeRanges.All) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             }; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             string message = JsonSerializer.Serialize(systemConfig, options); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (File.Exists(settingDataPath)) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 File.WriteAllText(settingDataPath, message); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         private string settingDataPath = "systemconfig.json"; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         private void timer1_Tick(object? sender, EventArgs e) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             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:\\DATA/NET2023/06/22/22/56"; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if (Directory.Exists(path) && IsUploadDB) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 UploadMseedFile.UploadMSeedOnce(path, WorkAreaId); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         /// <summary> | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         /// 启动或者停止监听 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         /// </summary> | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         /// <param name="IsEnableRaising">True:启用监听,False:关闭监听</param> | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         private int WatchStartOrSopt(bool IsEnableRaising) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             int result = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             try | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (IsEnableRaising) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     watcherArray[0].Path = Path.Combine(MainPath, RealtimePath); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     watcherArray[1].Path = Path.Combine(MainPath, PostPath); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 watcherArray[0].EnableRaisingEvents = IsEnableRaising; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 watcherArray[1].EnableRaisingEvents = IsEnableRaising; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 IsIndeterminate = IsEnableRaising; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             catch (Exception ex) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 result = 1; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 MessageBox.Show(ex.ToString()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             return result; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         private string DateDiff(DateTime DateTime1, DateTime DateTime2) |  |  |  |         private string DateDiff(DateTime DateTime1, DateTime DateTime2) | 
			
		
	
		
		
			
				
					
					|  |  |  |         { |  |  |  |         { | 
			
		
	
	
		
		
			
				
					|  |  | @ -299,11 +370,13 @@ namespace Txgy.FilesWatcher.ViewModels | 
			
		
	
		
		
			
				
					
					|  |  |  |             if (watch != null && watch.Path == watcherArray[0].Path) |  |  |  |             if (watch != null && watch.Path == watcherArray[0].Path) | 
			
		
	
		
		
			
				
					
					|  |  |  |             { |  |  |  |             { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 watcherArray[0].EnableRaisingEvents = false; |  |  |  |                 watcherArray[0].EnableRaisingEvents = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |                 UploadRealtimeFile.UploadRealtimeFileOnce(e.FullPath, lastLine, WorkAreaId); |  |  |  |                 if (IsUploadDB) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     UploadRealtimeFile.UploadRealtimeFileOnce(e.FullPath, lastLine, IsUploadMQTT, WorkAreaId); | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |             else if (watch != null && watch.Path == watcherArray[1].Path) |  |  |  |             else if (watch != null && watch.Path == watcherArray[1].Path) | 
			
		
	
		
		
			
				
					
					|  |  |  |             { |  |  |  |             { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 watcherArray[1].EnableRaisingEvents = false; |  |  |  |                 watcherArray[1].EnableRaisingEvents = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (IsUploadDB) | 
			
		
	
		
		
			
				
					
					|  |  |  |                     UploadPostproFile.UploadPostproFileOnce(watcherArray[1].Path, lastLine, WorkAreaId); |  |  |  |                     UploadPostproFile.UploadPostproFileOnce(watcherArray[1].Path, lastLine, WorkAreaId); | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |             var str=  dataList.Where(f => f.Data == lastLine).FirstOrDefault(); |  |  |  |             var str=  dataList.Where(f => f.Data == lastLine).FirstOrDefault(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -385,16 +458,6 @@ namespace Txgy.FilesWatcher.ViewModels | 
			
		
	
		
		
			
				
					
					|  |  |  |             //}); |  |  |  |             //}); | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |      |  |  |  |      | 
			
		
	
		
		
			
				
					
					|  |  |  |         /// <summary> |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         /// 启动或者停止监听 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         /// </summary> |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         /// <param name="IsEnableRaising">True:启用监听,False:关闭监听</param> |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         private void WatchStartOrSopt(bool IsEnableRaising) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             watcherArray[0].EnableRaisingEvents = IsEnableRaising; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             watcherArray[1].EnableRaisingEvents = IsEnableRaising; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |      |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         private FileSystemWatcher[] watcherArray = new FileSystemWatcher[2]; |  |  |  |         private FileSystemWatcher[] watcherArray = new FileSystemWatcher[2]; | 
			
		
	
		
		
			
				
					
					|  |  |  |         private DispatcherTimer timer1 = new DispatcherTimer(); |  |  |  |         private DispatcherTimer timer1 = new DispatcherTimer(); | 
			
		
	
		
		
			
				
					
					|  |  |  |         private SystemConfig  systemConfig = new SystemConfig(); |  |  |  |         private SystemConfig  systemConfig = new SystemConfig(); | 
			
		
	
	
		
		
			
				
					|  |  | 
 |