Skip to content

Commit

Permalink
fix(export): progress reporting + parallelization
Browse files Browse the repository at this point in the history
+ Fix erroneous progress reporting for exporting since the actual number
of replays was being used instead of the percentage.
+ Disable `Export` button while exporting is going on
  • Loading branch information
CrispyDrone committed Nov 10, 2019
1 parent e709f9a commit 50a29a2
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
7 changes: 5 additions & 2 deletions Main/ReplayParser.ReplaySorter.UI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1693,6 +1693,7 @@ private void CancelExportingButton_Click(object sender, RoutedEventArgs e)

private async void ExecuteExportingButton_Click(object sender, RoutedEventArgs e)
{
executeExportingButton.IsEnabled = false;
if (exportReplaysAsComboBox.SelectedIndex == -1)
{
MessageBox.Show("Please select an output format!", "Export error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
Expand Down Expand Up @@ -1733,10 +1734,11 @@ private async void ExecuteExportingButton_Click(object sender, RoutedEventArgs e

_cancelExport = new CancellationTokenSource();
var exporter = new ReplayExporter(replays);
var replaysCount = replays.Count;

var progress = new Progress<int>(percent =>
var progress = new Progress<int>(counter =>
{
progressBarExportingReplays.Value = percent;
progressBarExportingReplays.Value = Math.Round((double)counter / replaysCount * 100);
}
);

Expand Down Expand Up @@ -1770,6 +1772,7 @@ private async void ExecuteExportingButton_Click(object sender, RoutedEventArgs e
{
MessageBox.Show(result.Result.Message, "Exporting failed", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
}
executeExportingButton.IsEnabled = true;
}

private void ExportOutputPathSelectButton_Click(object sender, RoutedEventArgs e)
Expand Down
6 changes: 5 additions & 1 deletion Main/ReplayParser.ReplaySorter.UI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Currently there are 3 ways to get the program:
2. Use the non-setup based .exe from the .RAR archive labelled as such
3. Compile from source

You can find the latest release here: <https://github.com/CrispyDrone/BWSort/releases/tag/v1.1.0>
You can find the latest release here: <https://github.com/CrispyDrone/BWSort/releases/tag/v1.1.1>

## User guide
After an optional installation, run the .exe file.
Expand Down Expand Up @@ -336,6 +336,10 @@ Due to the possible presence of some bugs and it being hard to verify edge case
At the end of 2017 I had just started to learn how to program and was still playing some Starcraft here and there. I was severely annoyed at the lack of support from Blizzard in regards to managing replays. I thought this could be the ideal way to gain some experience as a new developer and at the same time help out the Starcraft community. As it was my first real project ever, and many of the important design decisions were made during this period when I had absolutely no experience, the code base is very badly designed and a pain to work with.

### Change history
#### v1.1.1
+ Disable `Export` button while exporting is going on to prevent exceptions
+ Fix progress reporting to actually show percentage instead of the number of replays that have been processed

#### v1.1.0
+ Added export to csv functionality

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>C:\Users\Bart\Documents\Projects\BWSort\Published\v1.0.1\</PublishUrl>
<PublishUrl>C:\Users\Bart\Documents\Projects\BWSort\Published\v1.1.0\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
Expand All @@ -45,7 +45,7 @@
<ErrorReportUrl>https://github.com/CrispyDrone/BWSort/issues</ErrorReportUrl>
<TargetCulture>en</TargetCulture>
<ProductName>BWSort</ProductName>
<ApplicationRevision>8</ApplicationRevision>
<ApplicationRevision>9</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void Save()

public string RepositoryUrl => "https://github.com/crispydrone/bwsort";
public string GithubAPIRepoUrl => "https://api.github.com/repos/crispydrone/bwsort";
public string Version => "1.1.0";
public string Version => "1.1.1";
public Regex VersionRegex => new Regex("\"tag_name\"\\s*:\\s*\"v(.*?)\"", RegexOptions.IgnoreCase);
public string LogDirectory
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ public async Task<ServiceResult<ServiceResultSummary>> ExecuteAsync(Stream outpu
message = $"Exported {replayCount} replays with {errors.Count} errors in {stopwatch.Elapsed.TotalSeconds} seconds.";
}

if (progress != null)
progress.Report(100);

return new ServiceResult<ServiceResultSummary>(
new ServiceResultSummary(
null,
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Currently there are 3 ways to get the program:
2. Use the non-setup based .exe from the .RAR archive labelled as such
3. Compile from source

You can find the latest release here: <https://github.com/CrispyDrone/BWSort/releases/tag/v1.1.0>
You can find the latest release here: <https://github.com/CrispyDrone/BWSort/releases/tag/v1.1.1>

## User guide
After an optional installation, run the .exe file.
Expand Down Expand Up @@ -336,6 +336,10 @@ Due to the possible presence of some bugs and it being hard to verify edge case
At the end of 2017 I had just started to learn how to program and was still playing some Starcraft here and there. I was severely annoyed at the lack of support from Blizzard in regards to managing replays. I thought this could be the ideal way to gain some experience as a new developer and at the same time help out the Starcraft community. As it was my first real project ever, and many of the important design decisions were made during this period when I had absolutely no experience, the code base is very badly designed and a pain to work with.

### Change history
#### v1.1.1
+ Disable `Export` button while exporting is going on to prevent exceptions
+ Fix progress reporting to actually show percentage instead of the number of replays that have been processed

#### v1.1.0
+ Added export to csv functionality

Expand Down

0 comments on commit 50a29a2

Please # to comment.