|
|
@ -24,9 +24,9 @@ using System.Text.Unicode;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Txgy.FilesWatcher.ViewModels
|
|
|
|
namespace Txgy.FilesWatcher.ViewModels
|
|
|
|
{
|
|
|
|
{
|
|
|
|
internal class MainViewModel:BindableBase
|
|
|
|
internal class MainViewModel : BindableBase
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public MainViewModel(WebsocketClient websocketClient )
|
|
|
|
public MainViewModel(WebsocketClient websocketClient)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string filter = "*.txt";
|
|
|
|
string filter = "*.txt";
|
|
|
|
string str = File.ReadAllText("systemconfig.json");
|
|
|
|
string str = File.ReadAllText("systemconfig.json");
|
|
|
@ -42,6 +42,10 @@ namespace Txgy.FilesWatcher.ViewModels
|
|
|
|
private void WebSocket4Net_MessageReceived(string message)
|
|
|
|
private void WebSocket4Net_MessageReceived(string message)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Debug.WriteLine($"服务端回复数据:{message}!");
|
|
|
|
Debug.WriteLine($"服务端回复数据:{message}!");
|
|
|
|
|
|
|
|
if(message == "sigin")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MessageBox.Show("登录成功");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void WebSocket_Error(SuperSocket.ClientEngine.ErrorEventArgs e)
|
|
|
|
void WebSocket_Error(SuperSocket.ClientEngine.ErrorEventArgs e)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -52,15 +56,16 @@ namespace Txgy.FilesWatcher.ViewModels
|
|
|
|
public string WatcherPath
|
|
|
|
public string WatcherPath
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get { return watcherPath; }
|
|
|
|
get { return watcherPath; }
|
|
|
|
set { SetProperty(ref watcherPath , value); }
|
|
|
|
set { SetProperty(ref watcherPath, value); }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ObservableCollection<WatcherFileModel> dataList = new ObservableCollection<WatcherFileModel>();
|
|
|
|
private ObservableCollection<WatcherFileModel> dataList = new ObservableCollection<WatcherFileModel>();
|
|
|
|
|
|
|
|
|
|
|
|
public ObservableCollection<WatcherFileModel> DataList
|
|
|
|
public ObservableCollection<WatcherFileModel> DataList
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get { return dataList; }
|
|
|
|
get { return dataList; }
|
|
|
|
set { SetProperty(ref dataList , value); }
|
|
|
|
set { SetProperty(ref dataList, value); }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private DateTime startTime;
|
|
|
|
private DateTime startTime;
|
|
|
@ -100,7 +105,20 @@ namespace Txgy.FilesWatcher.ViewModels
|
|
|
|
get { return isIndeterminate; }
|
|
|
|
get { return isIndeterminate; }
|
|
|
|
set { SetProperty(ref isIndeterminate, value); }
|
|
|
|
set { SetProperty(ref isIndeterminate, value); }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private string account;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string Account
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
get { return account; }
|
|
|
|
|
|
|
|
set { SetProperty(ref account, value); }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private string password;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string Password
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
get { return password; }
|
|
|
|
|
|
|
|
set { SetProperty(ref password, value); }
|
|
|
|
|
|
|
|
}
|
|
|
|
public void InitializeParams(string fileFilter)
|
|
|
|
public void InitializeParams(string fileFilter)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
timer1.Interval = TimeSpan.FromSeconds(ProMonInterval);
|
|
|
|
timer1.Interval = TimeSpan.FromSeconds(ProMonInterval);
|
|
|
@ -112,7 +130,7 @@ namespace Txgy.FilesWatcher.ViewModels
|
|
|
|
IntervalTimesSource.Add(60);
|
|
|
|
IntervalTimesSource.Add(60);
|
|
|
|
SelectedIndex = 1;
|
|
|
|
SelectedIndex = 1;
|
|
|
|
//如果设置的目录不存在设置到根目录
|
|
|
|
//如果设置的目录不存在设置到根目录
|
|
|
|
if(!File.Exists(WatcherPath))
|
|
|
|
if (!File.Exists(WatcherPath))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WatcherPath = AppDomain.CurrentDomain.BaseDirectory;
|
|
|
|
WatcherPath = AppDomain.CurrentDomain.BaseDirectory;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -138,7 +156,7 @@ namespace Txgy.FilesWatcher.ViewModels
|
|
|
|
watcher.Error += OnError;
|
|
|
|
watcher.Error += OnError;
|
|
|
|
|
|
|
|
|
|
|
|
//设置监听文件类型
|
|
|
|
//设置监听文件类型
|
|
|
|
watcher.Filter =fileFilter;
|
|
|
|
watcher.Filter = fileFilter;
|
|
|
|
//设置是否监听子目录
|
|
|
|
//设置是否监听子目录
|
|
|
|
watcher.IncludeSubdirectories = true;
|
|
|
|
watcher.IncludeSubdirectories = true;
|
|
|
|
//设置是否启用监听
|
|
|
|
//设置是否启用监听
|
|
|
@ -147,6 +165,13 @@ namespace Txgy.FilesWatcher.ViewModels
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DelegateCommand LoginCommand => new(() => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_websocketClient.SiginServer(Account, Password);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DelegateCommand StartCommand => new(Start);
|
|
|
|
public DelegateCommand StartCommand => new(Start);
|
|
|
|
|
|
|
|
|
|
|
|
public DelegateCommand StopCommand => new(Stop);
|
|
|
|
public DelegateCommand StopCommand => new(Stop);
|
|
|
@ -246,7 +271,14 @@ namespace Txgy.FilesWatcher.ViewModels
|
|
|
|
Data = lastLine,
|
|
|
|
Data = lastLine,
|
|
|
|
IsSend = false
|
|
|
|
IsSend = false
|
|
|
|
}) ;
|
|
|
|
}) ;
|
|
|
|
_websocketClient.SendMes(lastLine);
|
|
|
|
|
|
|
|
|
|
|
|
CSDevicePublish cSDevicePublish = new CSDevicePublish()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
type = CSMessage.publish,
|
|
|
|
|
|
|
|
message = lastLine,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
string jsonStr = JsonSerializer.Serialize(cSDevicePublish);
|
|
|
|
|
|
|
|
_websocketClient.SendMes(jsonStr);
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|