Example #1
0
 public UnhandledExceptionWindow(Exception ex, bool showDetails, Func <Task>?sendReportFunc = null)
 {
     _CanShowDetails     = showDetails;
     this.ex             = ex;
     this.sendReportFunc = sendReportFunc;
     // Create commands
     IgnoreCommand             = new GenericCommand(() => Close(), () => Buttons.HasFlag(UnhandledExceptionWindowButtons.CloseWindow));
     CloseConsoleCommand       = new GenericCommand(() => Application.Current.Shutdown(), () => Buttons.HasFlag(UnhandledExceptionWindowButtons.CloseWindow));
     RestartApplicationCommand = new GenericCommand(() =>
     {
         Process.Start(Application.ResourceAssembly.Location);
         Application.Current.Shutdown();
     }, () => Buttons.HasFlag(UnhandledExceptionWindowButtons.RestartApplication));
     ShowDetailsCommand = new GenericCommand(() => ShowDetails = !ShowDetails, () => CanShowDetails);
     SendReportCommand  = new GenericCommand(async() =>
     {
         try
         {
             SendingReport = true;
             if (sendReportFunc != null)
             {
                 await sendReportFunc();
             }
             sendReportFunc = null;
             SendReportCommand?.RaiseCanExecuteChanged();
         }
         catch (Exception ex2)
         {
             MessageBox.Show(this, ex2.Message, "Error al enviar el mensaje", MessageBoxButton.OK, MessageBoxImage.Error);
             Debug.WriteLine("");
         }
         finally
         {
             SendingReport = false;
         }
     }, () => sendReportFunc != null);
     // Inicializar interfaz
     InitializeComponent();
     // Populate Document
     Document.Blocks.AddRange(ex.ToBlocks());
 }
Example #2
0
 public App(
     ILogger <App> logger,
     IVkApi bot,
     IConfigurationRoot configuration,
     IAntiplagiatService antiplagiatService,
     MireaAntiplagiatDataContext context,
     SendReportCommand sendReportCommand)
 {
     logger.LogInformation(nameof(App));
     this.logger             = logger;
     this.bot                = bot;
     this.groupId            = configuration.GetSection("ConnectionStrings").GetValue <ulong>("GroupId");
     this.antiplagiatService = antiplagiatService;
     workers = new List <IBackgroundWorker>
     {
         sendReportCommand
     };
     this.commands = new List <BaseCommand>
     {
         new CheckDocument(antiplagiatService, context),
         new StartCommand()
     };
 }