| 
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -25,6 +25,10 @@ using Prism.Events;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using ImTools;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using static System.Windows.Forms.Design.AxImporter;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using HandyControl.Controls;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using MQTTnet.Extensions.ManagedClient;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using MQTTnet;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using MQTTnet.Client.Options;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using System.Windows.Markup;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				{
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -118,15 +122,39 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            get { return isUploadMQTT; }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            set { SetProperty(ref isUploadMQTT, value); }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private ObservableCollection<WatcherFileModel> dataList = new ObservableCollection<WatcherFileModel>();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private ObservableCollection<FileModel> dataList = new ObservableCollection<FileModel>();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        public ObservableCollection<WatcherFileModel> DataList
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        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 ObservableCollection<FileModel> mqttDataList = new ObservableCollection<FileModel>();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        public ObservableCollection<FileModel> MQTTDataList
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            get { return mqttDataList; }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            set { SetProperty(ref mqttDataList, value); }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private DateTime startTime;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        public DateTime StartTime { get => startTime; set => SetProperty(ref startTime, value); }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private string runTime;
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -230,37 +258,42 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            else if (para == "MseedPath")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                var name = Path.GetDirectoryName(filePath); 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                //替换主目录;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                var name = filePath.Replace(MainPath+"\\", "");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                string path = Path.Combine(MainPath, name);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                if (!Directory.Exists(path))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    MessageBox.Show($"{path} 不存在!");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    return;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                MseedPath = name;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                _systemConfig.mseedpath = name;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            else if (para == "RealtimePath")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                string path = Path.Combine(MainPath, RealtimePath);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                var name = filePath.Replace(MainPath + "\\", "");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                string path = Path.Combine(MainPath, name);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                if (!Directory.Exists(path))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    MessageBox.Show($"{path} 不存在!");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    return;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcherArray[0].Path = Path.Combine(MainPath, RealtimePath);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                RealtimePath=name;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                _systemConfig.realtimepath = RealtimePath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcherArray[0].Path = path;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            else if (para == "PostPath")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                string path = Path.Combine(MainPath, PostPath);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                var name = filePath.Replace(MainPath + "\\", "");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                string path = Path.Combine(MainPath, name);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                if (!Directory.Exists(path))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    MessageBox.Show($"{path} 不存在!");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    return;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcherArray[1].Path = Path.Combine(MainPath, PostPath);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                PostPath=name;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                _systemConfig.postpath = PostPath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcherArray[1].Path = path;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            UpdateJsonConfig(_systemConfig);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -275,7 +308,7 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            IntervalTimesSource.Add(30);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            IntervalTimesSource.Add(60);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            SelectedIndex = 1;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				           
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				         
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            foreach (var watcher in watcherArray)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                //初始化监听
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -306,9 +339,37 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcher.EnableRaisingEvents = false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcher.EndInit();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            //初始化mqtt
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            mqttClient = new MqttFactory().CreateManagedMqttClient();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            mqttClient.UseDisconnectedHandler(ee =>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                Debug.WriteLine($">>> 服务器断开连接,{ee}");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            mqttClient.UseApplicationMessageReceivedHandler(ee =>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                try
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                //    ResolveDatas(ee.ApplicationMessage.Topic, ee.ApplicationMessage.Payload);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                catch (Exception ex)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    MessageBox.Show($">>>数据解析出错,{ex}");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            mqttClient.UseConnectedHandler(ee =>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                Debug.WriteLine(">>> MQTT 连接到服务!");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            //    mqttClient.SubscribeAsync(CmdData.STREMACTRL + "#", MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				             //   mqttClient.SubscribeAsync(CmdData.STREMARES + "#", MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				              //  Debug.WriteLine($">>>订阅:{CmdData.STREMARES} #");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                //   mqttClient.SubscribeAsync(CmdData.STREMAUP + "vpn45", MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                //   WriteLog($">>>成功订阅:{CmdData.STREMAUP} #");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				             //   mqttClient.SubscribeAsync(CmdData.STREMAROUTERRES + "#", MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				         
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private void UpdateJsonConfig(SystemConfig systemConfig)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -335,7 +396,17 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            Debug.WriteLine($"**********当前时间:{currentT},监控路径:{path}");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if (Directory.Exists(path) && IsUploadDB&& IsUploadMseedPath)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                UploadMseedFile.UploadMSeedOnce(path, WorkAreaId);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                UploadMseedFile.UploadMSeedOnce((a=>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    timer1.Dispatcher.Invoke(() =>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        DataList.Add(new FileModel
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            Data = $"{DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss")}{a}"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                }), path, WorkAreaId);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <summary>
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -364,7 +435,6 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            return result;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private string DateDiff(DateTime DateTime1, DateTime DateTime2)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            string dateDiff = null;
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -402,32 +472,64 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            Debug.WriteLine($"最后修改时间:{lastWriteTime},文件路径:{watch.Path}");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if (watch != null && watch.Path == watcherArray[0].Path)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcherArray[0].EnableRaisingEvents = false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                if (IsUploadDB&& isUploadRealtimePath)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    UploadRealtimeFile.UploadRealtimeFileOnce(watcherArray[0].Path, lastLine, IsUploadMQTT, WorkAreaId);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                if (IsUploadDB && isUploadRealtimePath)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    UploadRealtimeFile.UploadRealtimeFileOnce((a, b) =>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        timer1.Dispatcher.Invoke(() =>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            RealTimeDataList.Add(new FileModel
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                Data = $"{DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss")}事件上传成功。"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        if (IsUploadMQTT)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            MQPublish(a, b);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            timer1.Dispatcher.Invoke(() =>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                MQTTDataList.Add(new FileModel
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                    CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                    Data = $"{DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss")}事件上传成功。"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    }, watcherArray[0].Path, lastLine, WorkAreaId);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            else if (watch != null && watch.Path == watcherArray[1].Path)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcherArray[1].EnableRaisingEvents = false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                if (IsUploadDB&& IsUploadPostPath)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    UploadPostproFile.UploadPostproFileOnce(watcherArray[1].Path, lastLine, WorkAreaId);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            var str=  dataList.Where(f => f.Data == lastLine).FirstOrDefault();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if (!string.IsNullOrWhiteSpace(lastLine)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                && str==null)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                if (IsUploadDB && IsUploadPostPath)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    DataList.Add(new WatcherFileModel
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    UploadPostproFile.UploadPostproFileOnce((a, b) =>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        CreateTime = DateTime.Now.ToString(),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        ChangeType = e.ChangeType,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        Name = e.Name,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        FullPath = e.FullPath,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        Data = lastLine,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        IsSend = false
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                }));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        timer1.Dispatcher.Invoke(() =>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            PostDataList.Add(new FileModel
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                Data = $"{DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss")}事件上传成功。"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        if (IsUploadMQTT)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            MQPublish(a, b);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            timer1.Dispatcher.Invoke(() =>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                MQTTDataList.Add(new FileModel
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                    CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                    Data = $"{DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss")}事件上传成功。"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    }, watcherArray[1].Path, lastLine, WorkAreaId);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if (watch != null && watch.Path == watcherArray[0].Path)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -438,7 +540,6 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcherArray[1].EnableRaisingEvents = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private void Watcher_Renamed(object sender, RenamedEventArgs e)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => {
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -490,11 +591,54 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            //     Data=tmp
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            //});
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private void StartConnectMQ()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            // 向服务端开放的端口进行服务请求
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        //    string clientID = Guid.NewGuid().ToString();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            var mqttClientOptions = new MqttClientOptionsBuilder()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                             .WithClientId(_systemConfig.mQTTConfig.clientID)// 传入ClientID参数
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                             .WithTcpServer(_systemConfig.mQTTConfig.serverIP, _systemConfig.mQTTConfig.port)//指定TCP连接的IP和Port
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                             .WithCredentials(_systemConfig.mQTTConfig.userName, _systemConfig.mQTTConfig.password);//指定连接的用户名和密码
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            var options = new ManagedMqttClientOptionsBuilder()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        .WithAutoReconnectDelay(TimeSpan.FromSeconds(60))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        .WithClientOptions(mqttClientOptions.Build())
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        .Build();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            mqttClient.StartAsync(options);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            startTime = DateTime.Now;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private void StopMQ()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            mqttClient?.StopAsync();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private void MQPublish(string topic, string openCmd)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				         //   byte[] cmdByte = Convert.FromHexString(openCmd.Replace(" ", ""));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            MqttApplicationMessage message = new MqttApplicationMessageBuilder()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                .WithTopic(topic)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                .WithPayload(openCmd)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                .WithRetainFlag(false)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                .Build();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            var res = mqttClient.PublishAsync(message);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            string mes = string.Empty;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if (!res.IsFaulted)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                mes = $">>>数据发送成功:{topic},{openCmd}";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            else
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                mes = $">>>数据发送失败:{topic},{openCmd}";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            Debug.WriteLine(mes);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private FileSystemWatcher[] watcherArray = new FileSystemWatcher[2];
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private DispatcherTimer timer1 = new DispatcherTimer();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private readonly SystemConfig _systemConfig;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      //  private readonly WebsocketClient _websocketClient;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private IManagedMqttClient mqttClient;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        //  private readonly WebsocketClient _websocketClient;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private readonly IEventAggregator _ea;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        protected void ShowLoading(string tip = "正在加载....")
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
			
			 | 
			 | 
			
				
 
 |