mirror of
https://github.com/chylex/Backup-Essentials.git
synced 2025-05-25 10:34:02 +02:00
Fixed inconsistencies with report data using constants
This commit is contained in:
parent
f80a9eb23b
commit
e9de3f93fa
BackupEssentials
@ -23,7 +23,7 @@ namespace BackupEssentials.Backup{
|
||||
else if (line[0] == 'I')build.Append(line.Substring(1)).Append(Environment.NewLine);
|
||||
else if (line[0] == 'V'){
|
||||
string[] split = line.Substring(1).Split(new char[]{ '=' },2);
|
||||
if (split.Length == 2)build.Append(split[0]).Append(": ").Append(split[1]).Append(Environment.NewLine);
|
||||
if (split.Length == 2)build.Append(Constants.Translate(split[0])).Append(": ").Append(split[1]).Append(Environment.NewLine);
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,5 +110,26 @@ namespace BackupEssentials.Backup{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Constants{
|
||||
public const string Source = "SRC";
|
||||
public const string Destination = "DEST";
|
||||
public const string Date = "DT";
|
||||
public const string EntriesAdded = "ENA";
|
||||
public const string EntriesUpdated = "ENU";
|
||||
public const string EntriesDeleted = "END";
|
||||
|
||||
public static string Translate(string constant){
|
||||
switch(constant){
|
||||
case Source: return "Source";
|
||||
case Destination: return "Destination";
|
||||
case Date: return "Date";
|
||||
case EntriesAdded: return "Added";
|
||||
case EntriesUpdated: return "Updated";
|
||||
case EntriesDeleted: return "Deleted";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -150,14 +150,14 @@ namespace BackupEssentials.Backup{
|
||||
}
|
||||
|
||||
reportBuilder.Add("= Preparing backup =");
|
||||
reportBuilder.Add("Source",fullSrc);
|
||||
reportBuilder.Add("Destination",destFolder);
|
||||
reportBuilder.Add("Date",DateTime.Now.ToString("d",CultureInfo.CurrentCulture)+" "+DateTime.Now.ToString("t",CultureInfo.CurrentCulture));
|
||||
reportBuilder.Add(BackupReport.Constants.Source,fullSrc);
|
||||
reportBuilder.Add(BackupReport.Constants.Destination,destFolder);
|
||||
reportBuilder.Add(BackupReport.Constants.Date,DateTime.Now.ToString("d",CultureInfo.CurrentCulture)+" "+DateTime.Now.ToString("t",CultureInfo.CurrentCulture));
|
||||
reportBuilder.Add("");
|
||||
reportBuilder.Add("= Files and folders =");
|
||||
reportBuilder.Add("Added",actions.Count((entry) => entry.Action == IOAction.Create).ToString());
|
||||
reportBuilder.Add("Updated",actions.Count((entry) => entry.Action == IOAction.Replace).ToString());
|
||||
reportBuilder.Add("Deleted",actions.Count((entry) => entry.Action == IOAction.Delete).ToString());
|
||||
reportBuilder.Add(BackupReport.Constants.EntriesAdded,actions.Count((entry) => entry.Action == IOAction.Create).ToString());
|
||||
reportBuilder.Add(BackupReport.Constants.EntriesUpdated,actions.Count((entry) => entry.Action == IOAction.Replace).ToString());
|
||||
reportBuilder.Add(BackupReport.Constants.EntriesDeleted,actions.Count((entry) => entry.Action == IOAction.Delete).ToString());
|
||||
reportBuilder.Add("");
|
||||
reportBuilder.Add("= Starting backup =");
|
||||
|
||||
|
@ -9,13 +9,13 @@ namespace BackupEssentials.Backup.History{
|
||||
public DateTime BackupTime { get; set; }
|
||||
public int EntriesAdded { get; set; }
|
||||
public int EntriesUpdated { get; set; }
|
||||
public int EntriesRemoved { get; set; }
|
||||
public int EntriesDeleted { get; set; }
|
||||
public string Filename = "";
|
||||
|
||||
public HistoryEntry(){
|
||||
LocationName = "";
|
||||
BackupTime = DateTime.MinValue;
|
||||
EntriesAdded = EntriesUpdated = EntriesRemoved = 0;
|
||||
EntriesAdded = EntriesUpdated = EntriesDeleted = 0;
|
||||
}
|
||||
|
||||
void StringDictionarySerializer.IObjectToDictionary.ToDictionary(SafeDictionary<string,string> dict){
|
||||
@ -23,7 +23,7 @@ namespace BackupEssentials.Backup.History{
|
||||
dict["Time"] = NumberSerialization.WriteLong(BackupTime.ToBinary());
|
||||
dict["EnA"] = EntriesAdded.ToString();
|
||||
dict["EnU"] = EntriesUpdated.ToString();
|
||||
dict["EnR"] = EntriesRemoved.ToString();
|
||||
dict["EnR"] = EntriesDeleted.ToString();
|
||||
dict["File"] = Filename;
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ namespace BackupEssentials.Backup.History{
|
||||
int.TryParse(dict["EnR"] ?? "0",out enRem);
|
||||
EntriesAdded = enAdd;
|
||||
EntriesUpdated = enUpd;
|
||||
EntriesRemoved = enRem;
|
||||
EntriesDeleted = enRem;
|
||||
|
||||
Filename = dict["File"] ?? "";
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ namespace BackupEssentials.Backup.History{
|
||||
HistoryEntry entry = new HistoryEntry(){
|
||||
LocationName = data.Item1.Name,
|
||||
BackupTime = DateTime.Now,
|
||||
EntriesAdded = data.Item2.TryFindValue("Added",0),
|
||||
EntriesUpdated = data.Item2.TryFindValue("Updated",0),
|
||||
EntriesRemoved = data.Item2.TryFindValue("Removed",0)
|
||||
EntriesAdded = data.Item2.TryFindValue(BackupReport.Constants.EntriesAdded,0),
|
||||
EntriesUpdated = data.Item2.TryFindValue(BackupReport.Constants.EntriesUpdated,0),
|
||||
EntriesDeleted = data.Item2.TryFindValue(BackupReport.Constants.EntriesDeleted,0)
|
||||
};
|
||||
|
||||
DataStorage.HistoryEntryList.Insert(0,entry);
|
||||
|
@ -63,13 +63,13 @@
|
||||
<StackPanel Grid.Column="1" Orientation="Vertical" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,8,0">
|
||||
<TextBlock Text="Added:" Foreground="#FFDDDDDD" FontSize="11" HorizontalAlignment="Right"/>
|
||||
<TextBlock Text="Updated:" Foreground="#FFDDDDDD" FontSize="11" HorizontalAlignment="Right"/>
|
||||
<TextBlock Text="Removed:" Foreground="#FFDDDDDD" FontSize="11" HorizontalAlignment="Right"/>
|
||||
<TextBlock Text="Deleted:" Foreground="#FFDDDDDD" FontSize="11" HorizontalAlignment="Right"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Column="2" Orientation="Vertical" HorizontalAlignment="Right" VerticalAlignment="Center">
|
||||
<TextBlock Text="{Binding EntriesAdded}" Foreground="#FFDDDDDD" FontSize="11"/>
|
||||
<TextBlock Text="{Binding EntriesUpdated}" Foreground="#FFDDDDDD" FontSize="11"/>
|
||||
<TextBlock Text="{Binding EntriesRemoved}" Foreground="#FFDDDDDD" FontSize="11"/>
|
||||
<TextBlock Text="{Binding EntriesDeleted}" Foreground="#FFDDDDDD" FontSize="11"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
@ -80,7 +80,7 @@
|
||||
</ListView.Resources>
|
||||
|
||||
<ListView.Items>
|
||||
<history:HistoryEntry LocationName="Dropbox" BackupTime="2015-4-17 17:26:00" EntriesAdded="2600" EntriesRemoved="125"/>
|
||||
<history:HistoryEntry LocationName="Dropbox" BackupTime="2015-4-17 17:26:00" EntriesAdded="2600" EntriesDeleted="125"/>
|
||||
</ListView.Items>
|
||||
</ListView>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user