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 { MembershipDatabase.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 <IRoleRemovalTask>(); job.RemoveExpiredMembersFromGrantedRoles().Wait(); }
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(); MembershipDatabase.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."); } } // note this sample uses email queue for membership reminder emails // if you have other things pushing messages into the queue such as // cloudscribe.EmailList, you should only have one task processing the queue // therefore you would add any other IEmailRecipientProvider implementations so that one and only one scheduled task can // handle processing the queue 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(); EmailQueueDatabase.InitializeDatabaseAsync(scopedServices).Wait(); EmailTemplateDatabase.InitializeDatabaseAsync(scopedServices).Wait(); MembershipDatabase.InitializeDatabaseAsync(scopedServices).Wait(); DynamicPolicyEFCore.InitializeDatabaseAsync(scopedServices).Wait(); StripeDatabase.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 }