/// <summary> /// Executes a loop catching server exceptions till the function had not excecuted up to the end. /// </summary> /// <param name="errors">The <see cref="VServerErrors"/> handling the <see cref="VServerError"/>.</param> /// <param name="message">The message, that should be shown in the error.</param> /// <param name="function">The function, that should be invoked.</param> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> internal static async Task NpgsqlWhileNullLoopAsync(this VServerErrors errors, string message, Func <Task> function) { while (true) { try { await function.ThrowExceptionIfNull(nameof(function)).Invoke().ConfigureAwait(false); break; } catch (Exception exception) when(exception is PostgresException || exception is NpgsqlException || exception is NpgsqlOperationInProgressException || exception is InvalidOperationException || exception is NullReferenceException || exception is IndexOutOfRangeException) { errors.AddError(new VServerError(message, exception)); } } }
/// <inheritdoc/> protected override void OnStart() { ServerErrors = new VServerErrors(); ServerConnections = new VServerConnections(new VServerConnectionArguments("sql.minmer.nazwa.pl", 5432, "minmer_mainverbum", "minmer_mainverbum", "VerbumCaroFactumEst0"), ServerErrors); QuerySchedule = new VQuerySchedule(ServerConnections, ServerErrors); }
private void OnStartup(object sender, StartupEventArgs eventArgs) { ServerErrors = new VServerErrors(); ServerConnections = new VServerConnections(new VServerConnectionArguments("sql.minmer.nazwa.pl", 5432, "minmer_mainverbum", "minmer_mainverbum", "VerbumCaroFactumEst0"), ServerErrors); QuerySchedule = new VQuerySchedule(ServerConnections, ServerErrors); }