1修改数据处理问题;

2 增加清除缓存功能;
master
mzhifa 7 months ago
parent 92776e6a97
commit 4f686ff5d0

@ -10,6 +10,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -194,6 +195,17 @@ namespace StartServerWPF.Modules.Main.ViewModels
DataSelectedIndex = 0; 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(() => public DelegateCommand SaveCommand => new(() =>
{ {
var item = NameSource[DataSelectedIndex]; var item = NameSource[DataSelectedIndex];
@ -232,7 +244,6 @@ namespace StartServerWPF.Modules.Main.ViewModels
{ {
DataPath = path; DataPath = path;
} }
} }
}); });
@ -255,13 +266,32 @@ namespace StartServerWPF.Modules.Main.ViewModels
return; return;
} }
DateTime dateTime = StartSelectedDate; DateTime dateTime = StartSelectedDate;
string temPath = Path.GetPathRoot(_workareaModel.savepath) + "temPath"; string temPath = Path.GetPathRoot(SavePath) + "temPath";
//清除临时文件
if (Directory.Exists(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(() => Task.Run(() =>
{ {
IsBusy = false; IsBusy = false;

@ -110,6 +110,7 @@
</ListBox> </ListBox>
</Border> </Border>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" > <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" >
<Button Content="清除缓存" Background="#FF0ABEFF" Foreground="White" Command="{Binding CleanDataCommand}" VerticalAlignment="Bottom" Margin="0,0,30,0"/>
<Button Content="保存" Background="#FF0ABEFF" Foreground="White" Command="{Binding SaveCommand}" IsEnabled="{Binding ElementName=cBoxWorkarea,Path=SelectedValue, Converter={StaticResource Object2BooleanConverter}}" VerticalAlignment="Bottom" Margin="0,0,30,0"/> <Button Content="保存" Background="#FF0ABEFF" Foreground="White" Command="{Binding SaveCommand}" IsEnabled="{Binding ElementName=cBoxWorkarea,Path=SelectedValue, Converter={StaticResource Object2BooleanConverter}}" VerticalAlignment="Bottom" Margin="0,0,30,0"/>
<Button Content="开始" Background="#FF0ABEFF" Foreground="White" Command="{Binding StartCommand}" VerticalAlignment="Bottom" IsEnabled="{Binding IsBusy}"/> <Button Content="开始" Background="#FF0ABEFF" Foreground="White" Command="{Binding StartCommand}" VerticalAlignment="Bottom" IsEnabled="{Binding IsBusy}"/>
<hc:LoadingCircle Height="30" Visibility="{Binding IsBusy, Converter={StaticResource Boolean2VisibilityReConverter}}"/> <hc:LoadingCircle Height="30" Visibility="{Binding IsBusy, Converter={StaticResource Boolean2VisibilityReConverter}}"/>

Loading…
Cancel
Save