Skip to content

Commit

Permalink
Error out when glossary read error occurs.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswendt1 committed Oct 26, 2021
1 parent a33f214 commit 8d346da
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion DocumentTranslation.GUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,16 +319,39 @@ private void DocumentsTranslateButton_Click(object sender, RoutedEventArgs e)
documentTranslationBusiness.OnContainerCreationFailure += DocumentTranslationBusiness_OnContainerCreationFailure;
documentTranslationBusiness.OnFinalResults += DocumentTranslationBusiness_OnFinalResults;
documentTranslationBusiness.OnThereWereErrors += DocumentTranslationBusiness_OnThereWereErrors;
documentTranslationBusiness.OnFileReadError += DocumentTranslationBusiness_OnFileReadError;
List<string> filestotranslate = new();
foreach (var document in ViewModel.FilesToTranslate) filestotranslate.Add(document);
List<string> glossariestouse = new();
foreach (var glossary in ViewModel.GlossariesToUse) glossariestouse.Add(glossary);
documentTranslationBusiness.OnContainerCreationFailure += DocumentTranslationBusiness_OnContainerCreationFailure;
_ = documentTranslationBusiness.RunAsync(filestotranslate, fromLanguageBoxDocuments.SelectedValue as string, toLanguageBoxDocuments.SelectedValue as string, glossariestouse, ViewModel.TargetFolder);
try
{
_ = documentTranslationBusiness.RunAsync(filestotranslate, fromLanguageBoxDocuments.SelectedValue as string, toLanguageBoxDocuments.SelectedValue as string, glossariestouse, ViewModel.TargetFolder);
}
catch (System.IO.IOException ex)
{
StatusBarText1.Text = Properties.Resources.msg_Error;
StatusBarText2.Text = ex.Message;
ProgressBar.Value = 0;
return;
}
ProgressBar.IsIndeterminate = false;
ProgressBar.Value = 3;
}

private void DocumentTranslationBusiness_OnFileReadError(object sender, string e)
{
ProgressBar.Value = 0;
StatusBarText1.Text = Properties.Resources.msg_Error;
StatusBarText2.Text = e;
CancelButton.Background = Brushes.Gray;
CancelButton.Visibility = Visibility.Hidden;
translateDocumentsButton.Visibility = Visibility.Visible;
SetTranslateDocumentsButtonStatus();

}

private void DocumentTranslationBusiness_OnUploadStart(object sender, EventArgs e)
{
ProgressBar.Value += 2;
Expand Down

0 comments on commit 8d346da

Please sign in to comment.