修改列表按时间倒序显示

master
mzhifa 6 months ago
parent 6e8430d51b
commit 6cc01d6e22

@ -484,7 +484,8 @@ namespace Txgy.FilesWatcher.ViewModels
{ {
timer1.Dispatcher.Invoke(() => timer1.Dispatcher.Invoke(() =>
{ {
DataList.Add(new FileModel if(DataList.Count >= 20) { DataList.Remove(dataList.Last()); }
DataList.Insert(0, new FileModel
{ {
CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"), CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"),
Data = $"{currentT.AddMinutes(-2).ToString("yyyy-MM-dd T HH:mm:ss")}{a}" Data = $"{currentT.AddMinutes(-2).ToString("yyyy-MM-dd T HH:mm:ss")}{a}"
@ -573,10 +574,11 @@ namespace Txgy.FilesWatcher.ViewModels
UploadRealtimeFile.UploadRealtimeFileOnce(filePath, lastLine, WorkAreaId); UploadRealtimeFile.UploadRealtimeFileOnce(filePath, lastLine, WorkAreaId);
timer1.Dispatcher.Invoke(() => timer1.Dispatcher.Invoke(() =>
{ {
RealTimeDataList.Add(new FileModel if (RealTimeDataList.Count >= 20) { RealTimeDataList.Remove(RealTimeDataList.Last()); }
RealTimeDataList.Insert(0, new FileModel
{ {
CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"), CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"),
Data = $"{DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss")}事件上传成功。" Data = $"{lastLine},事件上传成功。"
}); });
}); });
} }
@ -587,7 +589,8 @@ namespace Txgy.FilesWatcher.ViewModels
MQPublish(a, b); MQPublish(a, b);
timer1.Dispatcher.Invoke(() => timer1.Dispatcher.Invoke(() =>
{ {
MQTTDataList.Add(new FileModel if (MQTTDataList.Count >= 20) { MQTTDataList.Remove(MQTTDataList.Last()); }
MQTTDataList.Insert(0, new FileModel
{ {
CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"), CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"),
Data = $"{DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss")}事件上传成功。" Data = $"{DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss")}事件上传成功。"
@ -606,10 +609,11 @@ namespace Txgy.FilesWatcher.ViewModels
{ {
timer1.Dispatcher.Invoke(() => timer1.Dispatcher.Invoke(() =>
{ {
PostDataList.Add(new FileModel if (PostDataList.Count >= 20) { PostDataList.Remove(PostDataList.Last()); }
PostDataList.Insert(0,new FileModel
{ {
CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"), CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"),
Data = $"{DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss")}事件上传成功。" Data = $"{lastLine},事件上传成功。"
}); });
}); });
} }
@ -621,7 +625,8 @@ namespace Txgy.FilesWatcher.ViewModels
MQPublish(a, b); MQPublish(a, b);
timer1.Dispatcher.Invoke(() => timer1.Dispatcher.Invoke(() =>
{ {
MQTTDataList.Add(new FileModel if (MQTTDataList.Count >= 20) { MQTTDataList.Remove(MQTTDataList.Last()); }
MQTTDataList.Insert(0, new FileModel
{ {
CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"), CreateTime = DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss"),
Data = $"{DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss")}事件上传成功。" Data = $"{DateTime.Now.ToString("yyyy-MM-dd T HH:mm:ss")}事件上传成功。"

Loading…
Cancel
Save