Further improvements to messaging

This commit is contained in:
Dean Herbert 2018-03-19 20:30:45 +09:00
parent 18368d2446
commit 994c7bfabd
1 changed files with 6 additions and 6 deletions

View File

@ -79,7 +79,6 @@ public void Import(params string[] paths)
var notification = new ProgressNotification
{
Text = "Import is initialising...",
CompletionText = "Import successful!",
Progress = 0,
State = ProgressNotificationState.Active,
};
@ -88,7 +87,7 @@ public void Import(params string[] paths)
List<TModel> imported = new List<TModel>();
int success = 0;
int current = 0;
int errors = 0;
foreach (string path in paths)
{
@ -98,11 +97,11 @@ public void Import(params string[] paths)
try
{
notification.Text = $"Importing ({success} of {paths.Length})\n{Path.GetFileName(path)}";
notification.Text = $"Importing ({++current} of {paths.Length})\n{Path.GetFileName(path)}";
using (ArchiveReader reader = getReaderFrom(path))
imported.Add(Import(reader));
notification.Progress = (float)++success / paths.Length;
notification.Progress = (float)(current - 1) / paths.Length;
// We may or may not want to delete the file depending on where it is stored.
// e.g. reconstructing/repairing database with items from default storage.
@ -126,7 +125,8 @@ public void Import(params string[] paths)
}
}
notification.State = errors == 0 ? ProgressNotificationState.Completed : ProgressNotificationState.Cancelled;
notification.Text = errors > 0 ? $"Import complete with {errors} errors" : "Import successful!";
notification.State = ProgressNotificationState.Completed;
}
/// <summary>
@ -333,7 +333,7 @@ private ArchiveReader getReaderFrom(string path)
{
if (ZipFile.IsZipFile(path))
return new ZipArchiveReader(Files.Storage.GetStream(path), Path.GetFileName(path));
return new LegacyFilesystemReader(path);
return new LegacyFilesystemReader(path);
}
}
}