| 
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -22,6 +22,7 @@ using System.Text.Unicode;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using System.Net.Sockets;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using System.Security.Policy;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using Prism.Events;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using System.Windows.Shapes;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				{
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -29,82 +30,21 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        public MainViewModel(WebsocketClient websocketClient, IEventAggregator ea)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            string filter = "*.txt";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            string filter = "*.index";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            string str = File.ReadAllText("systemconfig.json");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            systemConfig = JsonSerializer.Deserialize<SystemConfig>(str);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            WatcherPath = systemConfig.FilePath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            WatcherMseedPath= systemConfig.WatcherMseedPath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            MseedFilePath = systemConfig.MseedFilePath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            watcherArray[0] = new FileSystemWatcher();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            watcherArray[1] = new FileSystemWatcher();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            InitializeParams(filter);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            StartTime = DateTime.Now;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            this._websocketClient = websocketClient;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            this._ea = ea;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            _websocketClient.WebsocketError = WebSocket_Error;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            _websocketClient.WebSocketMessageReceived = WebSocket4Net_MessageReceived;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            _websocketClient.WebSocketInit(systemConfig.Url);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private void WebSocket4Net_MessageReceived(string message)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            Debug.WriteLine($"服务端回复数据:{message}!");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            using (JsonDocument document = JsonDocument.Parse(message))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                JsonElement root = document.RootElement;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                if (root.TryGetProperty("type", out JsonElement dataElement))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    string type = dataElement.ToString();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    switch (type)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        case CSMessage.sigin:
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        var user= JsonSerializer.Deserialize<SCUserSigin>(message, new JsonSerializerOptions
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                // 整齐打印
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                WriteIndented = true,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                //重新编码,解决中文乱码问题
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            if(user.code==200)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                isLogin = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                LoginContent = "登 出";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            App.Current.Dispatcher.Invoke(() =>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                HandyControl.Controls.MessageBox.Show(user.message, "warning");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            this.HideLoading();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            break;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        case CSMessage.subscribe:
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                           var sub= JsonSerializer.Deserialize<SCUserSubscribeMessage>(message, new JsonSerializerOptions
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                // 整齐打印
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                WriteIndented = true,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                //重新编码,解决中文乱码问题
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            break;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        case CSMessage.publish:
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            var publish = JsonSerializer.Deserialize<SCDevicePublish>(message, new JsonSerializerOptions
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                // 整齐打印
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                WriteIndented = true,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                //重新编码,解决中文乱码问题
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            if (publish.serialNumber >= 0)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                dataList[publish.serialNumber - 1].IsSend = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            break;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            default:
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            break;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        void WebSocket_Error(SuperSocket.ClientEngine.ErrorEventArgs e)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            //出错后隐藏加载窗口
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            this.HideLoading();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            Debug.WriteLine("websocket_Error:" + e.Exception.ToString());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          //  this._websocketClient = websocketClient;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          //  _websocketClient.WebsocketError = WebSocket_Error;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          //  _websocketClient.WebSocketMessageReceived = WebSocket4Net_MessageReceived;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          //  _websocketClient.WebSocketInit(systemConfig.Url);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private string watcherPath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -113,7 +53,21 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            get { return watcherPath; }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            set { SetProperty(ref watcherPath, value); }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private string watcherMseedPath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        public string WatcherMseedPath
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            get { return watcherMseedPath; }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            set { SetProperty(ref watcherMseedPath, value); }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private string mseedFilePath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        public string MseedFilePath
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            get { return mseedFilePath; }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            set { SetProperty(ref mseedFilePath, value); }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private ObservableCollection<WatcherFileModel> dataList = new ObservableCollection<WatcherFileModel>();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        public ObservableCollection<WatcherFileModel> DataList
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -187,13 +141,13 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if (!isLogin)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                this.ShowLoading();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                _websocketClient.SiginServer(Account, Password);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				               // _websocketClient.SiginServer(Account, Password);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            else
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                isLogin = false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                LoginContent = "登 录";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                _websocketClient.Closed();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				               // _websocketClient.Closed();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -209,7 +163,6 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            timer1.Start();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            timer1.Tick += timer1_Tick;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            IsIndeterminate = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            _websocketClient.SendMes(JsonSerializer.Serialize(new CSUserSubscribeMessage { type = CSMessage.subscribe }));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private void Stop()
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -217,23 +170,33 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            WatchStartOrSopt(false);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            timer1.Stop();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            IsIndeterminate = false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            _websocketClient.SendMes(JsonSerializer.Serialize(new CSUserSubscribeMessage { type = CSMessage.unsubscribe }));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        public DelegateCommand FilePathSaveCommand => new(() =>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        public DelegateCommand<object> FilePathSaveCommand => new((obj) =>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        { 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            fbd.SelectedPath = WatcherPath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            string para = obj.ToString();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            fbd.SelectedPath = (para == "WatcherPath") ? WatcherPath : watcherMseedPath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            fbd.Description = "请选择文件路径";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				             fbd.ShowNewFolderButton = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                if (fbd.SelectedPath != WatcherPath)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    if (para == "WatcherPath")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        WatcherPath = fbd.SelectedPath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        watcherArray[0].Path = watcherPath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    else
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        watcherMseedPath = fbd.SelectedPath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        watcherArray[1].Path = watcherMseedPath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    systemConfig.FilePath = WatcherPath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    var options = new JsonSerializerOptions {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    systemConfig.WatcherMseedPath = watcherMseedPath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    var options = new JsonSerializerOptions
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        // 整齐打印
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        WriteIndented = true,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        //重新编码,解决中文乱码问题
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -251,7 +214,14 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private string settingDataPath = "systemconfig.json";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private void timer1_Tick(object? sender, EventArgs e)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            RunTime = DateDiff(DateTime.Now, StartTime);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            DateTime currentT=  DateTime.Now;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            RunTime = DateDiff(currentT, StartTime);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            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);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private void InitializeParams(string fileFilter)
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -265,11 +235,19 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            IntervalTimesSource.Add(60);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            SelectedIndex = 1;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            //如果设置的目录不存在设置到根目录
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if (!File.Exists(WatcherPath))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if (!Directory.Exists(WatcherPath))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                WatcherPath = AppDomain.CurrentDomain.BaseDirectory;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            watcher = new FileSystemWatcher();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if (!Directory.Exists(watcherMseedPath))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcherMseedPath = AppDomain.CurrentDomain.BaseDirectory;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            watcherArray[0].Path = watcherPath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            watcherArray[1].Path = watcherMseedPath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            //watcherArray = new FileSystemWatcher();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            foreach (var watcher in watcherArray)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                //初始化监听
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcher.BeginInit();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -283,9 +261,9 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                     | NotifyFilters.Security
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                     | NotifyFilters.Size;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                //设置监听的路径
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            watcher.Path = WatcherPath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				               // watcher.Path = WatcherPath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcher.Changed += new FileSystemEventHandler(Watcher_Changed);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				           // watcher.Created += Watcher_Created;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                // watcherArray.Created += Watcher_Created;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcher.Deleted += new FileSystemEventHandler(Watcher_Deleted);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcher.Renamed += new RenamedEventHandler(Watcher_Renamed);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcher.Error += OnError;
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -297,6 +275,7 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                //设置是否启用监听
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcher.EnableRaisingEvents = false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcher.EndInit();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -329,12 +308,21 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private void Watcher_Changed(object sender, System.IO.FileSystemEventArgs e)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            //    DateTime dt = DateTime.Now;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            // string tmp = dt.Hour.ToString() + "时" + dt.Minute.ToString() + "分" + dt.Second.ToString() + "秒" + dt.Millisecond.ToString() + "毫秒,目录发生变化\r\n";         
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            DateTime lastWriteTime = File.GetLastWriteTime(e.FullPath);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            watcher.EnableRaisingEvents = false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            Debug.WriteLine($"最后修改时间:{lastWriteTime}");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            var watch= sender as FileSystemWatcher;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            string lastLine = File.ReadAllLines(e.FullPath).Last().Trim();            
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            Debug.WriteLine($"最后修改时间:{lastWriteTime},文件路径:{watch.Path}");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if (watch != null && watch.Path == watcherArray[0].Path)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcherArray[0].EnableRaisingEvents = false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                UploadRealtimeFile.UploadRealtimeFileOnce(e.FullPath, lastLine);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            else if (watch != null && watch.Path == watcherArray[1].Path)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcherArray[1].EnableRaisingEvents = false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                UploadPostproFile.UploadPostproFileOnce(watcherArray[1].Path, lastLine);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            var str=  dataList.Where(f => f.Data == lastLine).FirstOrDefault();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if (!string.IsNullOrWhiteSpace(lastLine)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                && str==null)
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -350,18 +338,16 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        Data = lastLine,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        IsSend = false
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    CSDevicePublish cSDevicePublish = new CSDevicePublish()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        type = CSMessage.publish,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        message = lastLine,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        serialNumber = DataList.Count,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    };
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    string jsonStr = JsonSerializer.Serialize(cSDevicePublish);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    _websocketClient.SendMes(jsonStr);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                }));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            watcher.EnableRaisingEvents = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if (watch != null && watch.Path == watcherArray[0].Path)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcherArray[0].EnableRaisingEvents = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            else if (watch != null && watch.Path == watcherArray[1].Path)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                watcherArray[1].EnableRaisingEvents = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private void Watcher_Renamed(object sender, RenamedEventArgs e)
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -422,13 +408,14 @@ namespace Txgy.FilesWatcher.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <param name="IsEnableRaising">True:启用监听,False:关闭监听</param>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private void WatchStartOrSopt(bool IsEnableRaising)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            watcher.EnableRaisingEvents = IsEnableRaising;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            watcherArray[0].EnableRaisingEvents = IsEnableRaising;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            watcherArray[1].EnableRaisingEvents = IsEnableRaising;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private FileSystemWatcher watcher = new FileSystemWatcher();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private FileSystemWatcher[] watcherArray = new FileSystemWatcher[2];
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private DispatcherTimer timer1 = new DispatcherTimer();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private SystemConfig  systemConfig = new SystemConfig();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private readonly WebsocketClient _websocketClient;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      //  private readonly WebsocketClient _websocketClient;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private readonly IEventAggregator _ea;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        protected void ShowLoading(string tip = "正在加载....")
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
			
			 | 
			 | 
			
				
 
 |