排除空内容和相同数据通过websocket上传

master
gekoukate 1 year ago
parent b65f5476c6
commit e293e6024a

@ -334,7 +334,11 @@ namespace Txgy.FilesWatcher.ViewModels
DateTime lastWriteTime = File.GetLastWriteTime(e.FullPath); DateTime lastWriteTime = File.GetLastWriteTime(e.FullPath);
watcher.EnableRaisingEvents = false; watcher.EnableRaisingEvents = false;
Debug.WriteLine($"最后修改时间:{lastWriteTime}"); Debug.WriteLine($"最后修改时间:{lastWriteTime}");
string lastLine = File.ReadAllLines(e.FullPath).Last(); string lastLine = File.ReadAllLines(e.FullPath).Last().Trim();
var str= dataList.Where(f => f.Data == lastLine).FirstOrDefault();
if (!string.IsNullOrWhiteSpace(lastLine)
&& str==null)
{
System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{ {
DataList.Add(new WatcherFileModel DataList.Add(new WatcherFileModel
@ -356,6 +360,7 @@ namespace Txgy.FilesWatcher.ViewModels
string jsonStr = JsonSerializer.Serialize(cSDevicePublish); string jsonStr = JsonSerializer.Serialize(cSDevicePublish);
_websocketClient.SendMes(jsonStr); _websocketClient.SendMes(jsonStr);
})); }));
}
watcher.EnableRaisingEvents = true; watcher.EnableRaisingEvents = true;
} }

Loading…
Cancel
Save