private void saveAndCloseButton_Click(object sender, EventArgs e) { var button = sender as Button; if (button != null) { if (!ValidateViewModel()) { return; } var actions = new List <Action <CancellationToken, IProgress <ProgressInfo> > > { (token, progress) => SaveDocumentDirectory(token, progress) }; if (saveDocumentDirectoryDocumentsCheckBox.Checked) { actions.Add((token, progress) => SaveDocumentDirectoryDocuments(token, progress)); actions.Add((token, progress) => CleanDocumentDirectory(token, progress)); actions.Add((token, progress) => IndexDocumentDirectory(token, progress)); } ProgressViewer.Display(_cancellationTokenIssuer, log: Log, actions: actions.ToArray()); Log.Information($"SAVING DOCUMENT DIRECTORY \"{ViewModel.Label}\"."); DialogResult = DialogResult.OK; } }
private void IndexDocumentDirectory(Entities.DocumentDirectory documentDirectory) { ProgressViewer.Display(_cancellationTokenIssuer, actions: (token, progress) => { _mediator.CommandAsync(new IndexDocumentDirectoryCommand { DocumentDirectoryID = documentDirectory.DocumentDirectoryID }, token, progress).Wait(); }); }
private void CleanDocumentDirectory(Entities.DocumentDirectory documentDirectory) { var actions = new Action <CancellationToken, IProgress <ProgressInfo> >[] { (token, progress) => { _mediator.CommandAsync(new SaveDocumentDirectoryDocumentsCommand { DocumentDirectoryID = documentDirectory.DocumentDirectoryID }, token, progress).Wait(); }, (token, progress) => { _mediator.CommandAsync(new CleanDocumentDirectoryCommand { DocumentDirectoryID = documentDirectory.DocumentDirectoryID }, token, progress).Wait(); } }; ProgressViewer.Display(_cancellationTokenIssuer, actions: actions); }
private void RemoveDocumentDirectory(Entities.DocumentDirectory documentDirectory) { var confirm = MessageBox.Show($"Deseja realmente remover o diretório de documentos \"{documentDirectory.Label}\"?" , "Remover Diretório de Documentos" , MessageBoxButtons.YesNo , MessageBoxIcon.Question); if (confirm == DialogResult.No) { return; } ProgressViewer.Display(_cancellationTokenIssuer, actions: (token, progress) => { _mediator.CommandAsync(new RemoveDocumentDirectoryCommand { DocumentDirectoryID = documentDirectory.DocumentDirectoryID }, token, progress).Wait(); }); FillDocumentDirectoryDataGridView(); }