Split output file into multiple partitions (#116)

This commit is contained in:
Alexey Golub 2018-11-03 22:53:20 +02:00 committed by GitHub
parent aa53cecd4e
commit a0359b1e43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 133 additions and 19 deletions

View file

@ -19,6 +19,7 @@ namespace DiscordChatExporter.Gui.ViewModels
private ExportFormat _format;
private DateTime? _from;
private DateTime? _to;
private int? _partitionLimit;
public Guild Guild { get; private set; }
@ -63,6 +64,12 @@ namespace DiscordChatExporter.Gui.ViewModels
set => Set(ref _to, value);
}
public int? PartitionLimit
{
get => _partitionLimit;
set => Set(ref _partitionLimit, value);
}
// Commands
public RelayCommand ExportCommand { get; }
@ -83,13 +90,15 @@ namespace DiscordChatExporter.Gui.ViewModels
.Replace(Path.GetInvalidFileNameChars(), '_');
From = null;
To = null;
PartitionLimit = _settingsService.LastPartitionLimit;
});
}
private void Export()
{
// Save format
// Persist preferences
_settingsService.LastExportFormat = SelectedFormat;
_settingsService.LastPartitionLimit = PartitionLimit;
// Clamp 'from' and 'to' values
if (From > To)
@ -98,7 +107,7 @@ namespace DiscordChatExporter.Gui.ViewModels
To = From;
// Start export
MessengerInstance.Send(new StartExportMessage(Channel, FilePath, SelectedFormat, From, To));
MessengerInstance.Send(new StartExportMessage(Channel, FilePath, SelectedFormat, From, To, PartitionLimit));
}
}
}

View file

@ -14,6 +14,7 @@ namespace DiscordChatExporter.Gui.ViewModels
ExportFormat SelectedFormat { get; set; }
DateTime? From { get; set; }
DateTime? To { get; set; }
int? PartitionLimit { get; set; }
RelayCommand ExportCommand { get; }
}

View file

@ -129,7 +129,7 @@ namespace DiscordChatExporter.Gui.ViewModels
// Messages
MessengerInstance.Register<StartExportMessage>(this,
m => Export(m.Channel, m.FilePath, m.Format, m.From, m.To));
m => Export(m.Channel, m.FilePath, m.Format, m.From, m.To, m.PartitionLimit));
}
private async void ViewLoaded()
@ -239,7 +239,8 @@ namespace DiscordChatExporter.Gui.ViewModels
MessengerInstance.Send(new ShowExportSetupMessage(SelectedGuild, channel));
}
private async void Export(Channel channel, string filePath, ExportFormat format, DateTime? from, DateTime? to)
private async void Export(Channel channel, string filePath, ExportFormat format,
DateTime? from, DateTime? to, int? partitionLimit)
{
IsBusy = true;
@ -258,7 +259,7 @@ namespace DiscordChatExporter.Gui.ViewModels
var chatLog = await _dataService.GetChatLogAsync(token, guild, channel, from, to, progressHandler);
// Export
_exportService.ExportChatLog(chatLog, filePath, format);
_exportService.ExportChatLog(chatLog, filePath, format, partitionLimit);
// Notify completion
MessengerInstance.Send(new ShowNotificationMessage("Export complete"));