diff --git a/StartServerWPF.Modules.Main/ViewModels/DataProcessViewModel.cs b/StartServerWPF.Modules.Main/ViewModels/DataProcessViewModel.cs index a9643b6..1324bb9 100644 --- a/StartServerWPF.Modules.Main/ViewModels/DataProcessViewModel.cs +++ b/StartServerWPF.Modules.Main/ViewModels/DataProcessViewModel.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Drawing.Drawing2D; +using System.Globalization; using System.IO; using System.Linq; using System.Text; @@ -194,6 +195,17 @@ namespace StartServerWPF.Modules.Main.ViewModels DataSelectedIndex = 0; }; }); + public DelegateCommand CleanDataCommand => new(() => + { + //清除临时文件 + string temPath = Path.GetPathRoot(SavePath) + "temPath"; + if (Directory.Exists(temPath)) + { + Directory.Delete(temPath, true); + } + MessageBox.Show("清除成功!"); + + }); public DelegateCommand SaveCommand => new(() => { var item = NameSource[DataSelectedIndex]; @@ -232,7 +244,6 @@ namespace StartServerWPF.Modules.Main.ViewModels { DataPath = path; } - } }); @@ -255,13 +266,32 @@ namespace StartServerWPF.Modules.Main.ViewModels return; } DateTime dateTime = StartSelectedDate; - string temPath = Path.GetPathRoot(_workareaModel.savepath) + "temPath"; - //清除临时文件 - if (Directory.Exists(temPath)) + string temPath = Path.GetPathRoot(SavePath) + "temPath"; + + if (!Directory.Exists(temPath)) + { + Directory.CreateDirectory(temPath); + } + if (ApmsEventSource.Count > 0) { - Directory.Delete(temPath, true); + ApmsEventSource.Clear(); } - Directory.CreateDirectory(temPath); + var fileName = Directory.GetFiles(SavePath, "*.index", SearchOption.AllDirectories); + + foreach (var file in fileName) + { + bool flag= DateTime.TryParseExact(Path.GetFileNameWithoutExtension(file), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture, + DateTimeStyles.None, out DateTime da); + if (flag && StartSelectedDate.Date <= da && EndSelectedDate.Date >= da) + { + if (File.Exists(file)) + { + File.Delete(file); + } + } + + } + Task.Run(() => { IsBusy = false; diff --git a/StartServerWPF.Modules.Main/Views/DataProcessView.xaml b/StartServerWPF.Modules.Main/Views/DataProcessView.xaml index 1b800f8..9daeed3 100644 --- a/StartServerWPF.Modules.Main/Views/DataProcessView.xaml +++ b/StartServerWPF.Modules.Main/Views/DataProcessView.xaml @@ -110,6 +110,7 @@ +