static void Main(string[] args)
        {
            Console.Title = "cloudscribe Email Queue/Email List Processor task";

            var hostBuilder = GetHostBuilder(args);
            var host        = hostBuilder.Build();

            using (var scope = host.Services.CreateScope())
            {
                var scopedServices = scope.ServiceProvider;
                try
                {
                    EmailQueueDatabase.InitializeDatabaseAsync(scopedServices).Wait();
                    EmailListDatabase.InitializeDatabaseAsync(scopedServices).Wait();
                }
                catch (Exception ex)
                {
                    var logger = scopedServices.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred while migrating the database.");
                }
            }

            var job = host.Services.GetRequiredService <IEmailQueueProcessor>();

            job.StartProcessing().Wait();
        }
 private static void EnsureDataStorageIsReady(IServiceProvider scopedServices)
 {
     LoggingEFStartup.InitializeDatabaseAsync(scopedServices).Wait();
     CoreEFStartup.InitializeDatabaseAsync(scopedServices).Wait();
     SimpleContentEFStartup.InitializeDatabaseAsync(scopedServices).Wait();
     KvpEFCoreStartup.InitializeDatabaseAsync(scopedServices).Wait();
     EmailQueueDatabase.InitializeDatabaseAsync(scopedServices).Wait();
     EmailListDatabase.InitializeDatabaseAsync(scopedServices).Wait();
     EmailTemplateDatabase.InitializeDatabaseAsync(scopedServices).Wait();
 }
 private static void EnsureDataStorageIsReady(IServiceProvider scopedServices)
 {
     #if (Logging)
     #if (!NoDb)
     var deleteLogsOlderThanDays = 90;
     LoggingEFStartup.InitializeDatabaseAsync(scopedServices, deleteLogsOlderThanDays).Wait();
     #endif
     #endif
     #if (NoDb)
     CoreNoDbStartup.InitializeDataAsync(scopedServices).Wait();
     #else
     CoreEFStartup.InitializeDatabaseAsync(scopedServices).Wait();
     #endif
     #if (SimpleContentConfig != "z")
     #if (!NoDb)
     SimpleContentEFStartup.InitializeDatabaseAsync(scopedServices).Wait();
     #endif
     #endif
     #if (KvpCustomRegistration || Newsletter)
     #if (!NoDb)
     KvpEFCoreStartup.InitializeDatabaseAsync(scopedServices).Wait();
     #endif
     #endif
     #if (IdentityServer)
     #if (NoDb)
     CloudscribeIdentityServerIntegrationNoDbStorage.InitializeDatabaseAsync(scopedServices).Wait();
     #else
     CloudscribeIdentityServerIntegrationEFCoreStorage.InitializeDatabaseAsync(scopedServices).Wait();
     #endif
     #endif
     #if (FormBuilder)
     #if (!NoDb)
     FormsDatabase.InitializeDatabaseAsync(scopedServices).Wait();
     #endif
     #endif
     #if (Paywall)
     #if (!NoDb)
     MembershipDatabase.InitializeDatabaseAsync(scopedServices).Wait();
     #endif
     #endif
      #if (IncludeEmailQueue)
     #if (!NoDb)
     EmailQueueDatabase.InitializeDatabaseAsync(scopedServices).Wait();
     EmailTemplateDatabase.InitializeDatabaseAsync(scopedServices).Wait();
     #endif
     #endif
     #if (Newsletter)
     #if (!NoDb)
     EmailListDatabase.InitializeDatabaseAsync(scopedServices).Wait();
     #endif
     #endif
     #if (IncludeStripeIntegration)
     #if (!NoDb)
     StripeDatabase.InitializeDatabaseAsync(scopedServices).Wait();
     #endif
     #endif
     #if (DynamicPolicy)
     #if (!NoDb)
     DynamicPolicyEFCore.InitializeDatabaseAsync(scopedServices).Wait();
     #endif
     #endif
     #if (CommentSystem)
     #if (!NoDb)
     CommentsDatabase.InitializeDatabaseAsync(scopedServices).Wait();
     #endif
     #endif
     #if (Forum)
     #if (!NoDb)
     ForumDatabase.InitializeDatabaseAsync(scopedServices).Wait();
     #endif
     #endif
 }