From 1a69f2f7df6d88b71eae6f9bfb5a961327431e0d Mon Sep 17 00:00:00 2001 From: Simon Annetts Date: Fri, 1 Sep 2023 16:55:30 +0100 Subject: [PATCH 1/7] start with the webapp csproj --- Content/WebApp/WebApp.csproj | 141 +++++++++++++++++------------------ 1 file changed, 70 insertions(+), 71 deletions(-) diff --git a/Content/WebApp/WebApp.csproj b/Content/WebApp/WebApp.csproj index f26afd8..ec9b637 100644 --- a/Content/WebApp/WebApp.csproj +++ b/Content/WebApp/WebApp.csproj @@ -49,19 +49,19 @@ - + - + - + - + - + @@ -76,38 +76,38 @@ - + - + - + - + - + - - + + - + - + - + - + @@ -115,19 +115,19 @@ - + - + - + - + - + @@ -137,19 +137,19 @@ - + - + - + - + - + @@ -166,19 +166,19 @@ - + - + - + - + - + @@ -187,36 +187,35 @@ - + - + - + - + - + - - + - + - + - + @@ -224,22 +223,22 @@ - + - + - + - + - + @@ -250,19 +249,19 @@ - + - + - + - + - + @@ -271,19 +270,19 @@ - + - + - + - + - + @@ -293,19 +292,19 @@ - + - + - + - + - + @@ -314,19 +313,19 @@ - + - + - + - + - + @@ -338,19 +337,19 @@ - + - + - + - + - + From c79930602ae45396bd12561b8063cb777f11009a Mon Sep 17 00:00:00 2001 From: Simon Annetts Date: Fri, 1 Sep 2023 17:09:56 +0100 Subject: [PATCH 2/7] add options to template wizard --- Content/WebApp/.template.config/template.json | 10 +++++++++- cloudscribeTemplate/ProjectOptionsDialog.cs | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Content/WebApp/.template.config/template.json b/Content/WebApp/.template.config/template.json index 339d683..4e9f1ac 100644 --- a/Content/WebApp/.template.config/template.json +++ b/Content/WebApp/.template.config/template.json @@ -275,7 +275,11 @@ { "choice": "MySql", "description": "MySql storage using Entity Framework Core" - } + }, + { + "choice": "AllStorage", + "description": "All database storage types (for developing new cloudscribe modules)" + } ] }, @@ -308,6 +312,10 @@ "type": "computed", "value": "(DataStorage == \"NoDb\")" }, + "AllStorage": { + "type": "computed", + "value": "(DataStorage == \"AllStorage\")" + }, "UtmCampaign": { "type": "generated", "generator": "casing", diff --git a/cloudscribeTemplate/ProjectOptionsDialog.cs b/cloudscribeTemplate/ProjectOptionsDialog.cs index 0011e61..d3cc2c0 100644 --- a/cloudscribeTemplate/ProjectOptionsDialog.cs +++ b/cloudscribeTemplate/ProjectOptionsDialog.cs @@ -28,7 +28,8 @@ private void InitControls() new ComboItem{ Key = "SQLite", Text = "Use SQLite" }, new ComboItem{ Key = "MSSQL", Text = "Use Microsoft SqlServer" }, new ComboItem{ Key = "MySql", Text = "Use MySql" }, - new ComboItem{ Key = "pgsql", Text = "Use PostgreSql" } + new ComboItem{ Key = "pgsql", Text = "Use PostgreSql", + new ComboItem{ Key = "AllStorage", Text = "Use all database types (for developing new cloudscribe modules)" } }; cbDataStorage.ValueMember = "Key"; From 139337172c0c0db3f827269b370856f5f000e450 Mon Sep 17 00:00:00 2001 From: Simon Annetts Date: Fri, 1 Sep 2023 17:47:28 +0100 Subject: [PATCH 3/7] CloudscribeFeatures and appsettings --- Content/WebApp/Config/CloudscribeFeatures.cs | 233 +++++++++++++++++++ Content/WebApp/appsettings.Development.json | 30 ++- Content/WebApp/appsettings.json | 23 ++ 3 files changed, 283 insertions(+), 3 deletions(-) diff --git a/Content/WebApp/Config/CloudscribeFeatures.cs b/Content/WebApp/Config/CloudscribeFeatures.cs index 4d06942..2c076a7 100644 --- a/Content/WebApp/Config/CloudscribeFeatures.cs +++ b/Content/WebApp/Config/CloudscribeFeatures.cs @@ -35,6 +35,8 @@ public static IServiceCollection SetupDataStorage( IWebHostEnvironment env ) { +#region "Single database storage choices" +#if (!AllStorage) #if (!NoDb && !SQLite) var connectionString = config.GetConnectionString("EntityFrameworkConnection"); #endif @@ -281,6 +283,237 @@ IWebHostEnvironment env #endif #endif +#endif +#endregion + +#region "All database storage choice" +#if (AllStorage) + var storage = config["DevOptions:DbPlatform"].ToLowerInvariant(); + var efProvider = config["DevOptions:EFProvider"].ToLowerInvariant(); + + switch (storage) + { + case "efcore": + default: + switch (efProvider) + { + case "mysql": + connectionString = config.GetConnectionString("MySqlEntityFrameworkConnection"); + services.AddCloudscribeCoreEFStorageMySql(connectionString); +#if (KvpCustomRegistration || Newsletter) + services.AddCloudscribeKvpEFStorageMySql(connectionString); +#endif +#if (Logging) + services.AddCloudscribeLoggingEFStorageMySQL(connectionString); +#endif +#if (SimpleContentConfig != "z") + services.AddCloudscribeSimpleContentEFStorageMySQL(connectionString); +#endif +#if (IncludeStripeIntegration) + services.AddStripeIntegrationStorageMySql(connectionString); +#endif +#if (FormBuilder) + services.AddFormsStorageMySql(connectionString); +#endif +#if (DynamicPolicy) + services.AddDynamicPolicyEFStorageMySql(connectionString); +#endif +#if (Paywall) + services.AddMembershipSubscriptionStorageMySql(connectionString); +#endif +#if (IncludeEmailQueue) + services.AddEmailTemplateStorageMySql(connectionString); + services.AddEmailQueueStorageMySql(connectionString); +#endif +#if (Newsletter) + services.AddEmailListStorageMySql(connectionString); +#endif +#if (CommentSystem) + services.AddCommentStorageMySql(connectionString); +#endif +#if (Forum) + services.AddForumStorageMySql(connectionString); +#endif +#if (QueryTool) + services.AddQueryToolEFStorageMySql(connectionString); +#endif + break; + + case "pgsql": + connectionString = config.GetConnectionString("PostgreSqlEntityFrameworkConnection"); + services.AddCloudscribeCorePostgreSqlStorage(connectionString); +#if (KvpCustomRegistration || Newsletter) + services.AddCloudscribeKvpPostgreSqlStorage(connectionString); +#endif +#if (Logging) + services.AddCloudscribeLoggingPostgreSqlStorage(connectionString); +#endif +#if (SimpleContentConfig != "z") + services.AddCloudscribeSimpleContentPostgreSqlStorage(connectionString); +#endif +#if (IncludeStripeIntegration) + services.AddStripeIntegrationPostgreSqlStorage(connectionString); +#endif +#if (FormBuilder) + services.AddFormsStoragePostgreSql(connectionString); +#endif +#if (DynamicPolicy) + services.AddDynamicPolicyPostgreSqlStorage(connectionString); +#endif +#if (Paywall) + services.AddMembershipSubscriptionPostgreSqlStorage(connectionString); +#endif +#if (IncludeEmailQueue) + services.AddEmailTemplatePostgreSqlStorage(connectionString); + services.AddEmailQueuePostgreSqlStorage(connectionString); +#endif +#if (Newsletter) + services.AddEmailListPostgreSqlStorage(connectionString); +#endif +#if (CommentSystem) + services.AddCommentStoragePostgreSql(connectionString); +#endif +#if (Forum) + services.AddForumStoragePostgreSql(connectionString); +#endif +#if (QueryTool) + services.AddQueryToolEFStoragePostgreSql(connectionString); +#endif + break; + + case "sqlite": + var dbName = config.GetConnectionString("SQLiteDbName"); + var dbPath = Path.Combine(env.ContentRootPath, dbName); + connectionString = $"Data Source={dbPath}"; + services.AddCloudscribeCoreEFStorageSQLite(connectionString); +#if (KvpCustomRegistration || Newsletter) + services.AddCloudscribeKvpEFStorageSQLite(connectionString); +#endif +#if (Logging) + services.AddCloudscribeLoggingEFStorageSQLite(connectionString); +#endif +#if (SimpleContentConfig != "z") + services.AddCloudscribeSimpleContentEFStorageSQLite(connectionString); +#endif +#if (IncludeStripeIntegration) + services.AddStripeIntegrationStorageSQLite(connectionString); +#endif +#if (FormBuilder) + services.AddFormsStorageSQLite(connectionString); +#endif +#if (DynamicPolicy) + services.AddDynamicPolicyEFStorageSQLite(connectionString); +#endif +#if (Paywall) + services.AddMembershipSubscriptionStorageSQLite(connectionString); +#endif +#if (IncludeEmailQueue) + services.AddEmailTemplateStorageSQLite(connectionString); + services.AddEmailQueueStorageSQLite(connectionString); +#endif +#if (Newsletter) + services.AddEmailListStorageSQLite(connectionString); +#endif +#if (CommentSystem) + services.AddCommentStorageSQLite(connectionString); +#endif +#if (Forum) + services.AddForumStorageSQLite(connectionString); +#endif +#if (QueryTool) + services.AddQueryToolEFStorageSQLite(connectionString); +#endif + break; + + case "mssql": + default: + var connectionString = config.GetConnectionString("EntityFrameworkConnection"); + services.AddCloudscribeCoreEFStorageMSSQL(connectionString); +#if (KvpCustomRegistration || Newsletter) + services.AddCloudscribeKvpEFStorageMSSQL(connectionString); +#endif +#if (Logging) + services.AddCloudscribeLoggingEFStorageMSSQL(connectionString); +#endif +#if (SimpleContentConfig != "z") + services.AddCloudscribeSimpleContentEFStorageMSSQL(connectionString); +#endif +#if (IncludeStripeIntegration) + services.AddStripeIntegrationStorageMSSQL(connectionString); +#endif +#if (FormBuilder) + services.AddFormsStorageMSSQL(connectionString); +#endif +#if (DynamicPolicy) + services.AddDynamicPolicyEFStorageMSSQL(connectionString); +#endif +#if (Paywall) + services.AddMembershipSubscriptionStorageMSSQL(connectionString); +#endif +#if (IncludeEmailQueue) + services.AddEmailTemplateStorageMSSQL(connectionString); + services.AddEmailQueueStorageMSSQL(connectionString); +#endif +#if (Newsletter) + services.AddEmailListStorageMSSQL(connectionString); +#endif +#if (CommentSystem) + services.AddCommentStorageMSSQL(connectionString); +#endif +#if (Forum) + services.AddForumStorageMSSQL(connectionString); +#endif +#if (QueryTool) + services.AddQueryToolEFStorageMSSQL(connectionString); +#endif + break; + } + break; + + case "nodb": + default: + services.AddCloudscribeCoreNoDbStorage(); +#if (KvpCustomRegistration || Newsletter) + services.AddCloudscribeKvpNoDbStorage(); +#endif +#if (Logging) + services.AddCloudscribeLoggingNoDbStorage(config); +#endif +#if (SimpleContentConfig != "z") + services.AddNoDbStorageForSimpleContent(); +#endif +#if (IncludeStripeIntegration) + services.AddStripeIntegrationStorageNoDb(); +#endif +#if (FormBuilder) + services.AddFormsStorageNoDb(); +#endif +#if (DynamicPolicy) + services.AddNoDbStorageForDynamicPolicies(config); +#endif +#if (Paywall) + services.AddMembershipSubscriptionStorageNoDb(); +#endif +#if (IncludeEmailQueue) + services.AddEmailTemplateStorageNoDb(); + services.AddEmailQueueStorageNoDb(); +#endif +#if (Newsletter) + services.AddEmailListStorageNoDb(); +#endif +#if (CommentSystem) + services.AddTalkAboutStorageNoDb(); +#endif +#if (Forum) + services.AddTalkAboutForumStorageNoDb(); +#endif +#if (QueryTool) + services.AddQueryToolNoDbStorage(); +#endif + break; + } +#endif +#endregion return services; } diff --git a/Content/WebApp/appsettings.Development.json b/Content/WebApp/appsettings.Development.json index d278c6b..c9121a1 100644 --- a/Content/WebApp/appsettings.Development.json +++ b/Content/WebApp/appsettings.Development.json @@ -1,4 +1,5 @@ { + //#if (!AllStorage) //#if (!NoDb) "ConnectionStrings": { //#if (SQLite) @@ -15,14 +16,15 @@ //#endif //#if (QueryTool) + //QueryTool should use a different connection string than the main app for security reasons (possibly readonly and no DDL commands) //#if (SQLite) - "QueryToolConnectionString": "Data Source=appdata.db;Pooling=false;Mode=ReadWrite", + "QueryToolConnectionString": "Data Source=appdata.db;Pooling=false;Mode=ReadWrite" //#endif //#if (MSSQL) - "QueryToolConnectionString": "Server=(localdb)\\mssqllocaldb;Database=WebApp-0353CAB0-205A-4FCD-9626-1282ECF47059;Trusted_Connection=True;MultipleActiveResultSets=true", + "QueryToolConnectionString": "Server=(localdb)\\mssqllocaldb;Database=WebApp-0353CAB0-205A-4FCD-9626-1282ECF47059;Trusted_Connection=True;MultipleActiveResultSets=true" //#endif //#if (MySql) - "QueryToolConnectionString": "Server=localhost;Database=yourdbname;Uid=yourdbuser;Pwd=yourdbpassword;Charset=utf8;", + "QueryToolConnectionString": "Server=localhost;Database=yourdbname;Uid=yourdbuser;Pwd=yourdbpassword;Charset=utf8;" //#endif //#if (pgsql) "QueryToolConnectionString": "Server=yourserver;Port=5432;User Id=youruser;Password=yourpassword;Database=yourdbname;" @@ -31,6 +33,28 @@ }, //#endif + //#endif + //#if (AllStorage) + "DevOptions": { + "DbPlatform": "NoDb", //NoDb or EFCore + "EFProvider": "MSSQL" // SQLite, MSSQL, MySql, pgsql + }, + "ConnectionStrings": { + //EFCore SQLite + "SQLiteDbName": "appdata.db", + //EFCore MSSQL + "EntityFrameworkConnection": "Server=(localdb)\\mssqllocaldb;Database=WebApp-0353CAB0-205A-4FCD-9626-1282ECF47059;Trusted_Connection=True;MultipleActiveResultSets=true", + //EFCore MySql + "MySqlEntityFrameworkConnection": "Server=localhost;Database=yourdbname;Uid=yourdbuser;Pwd=yourdbpassword;Charset=utf8;", + //EFCore pgsql + "PostgreSqlEntityFrameworkConnection": "Server=yourserver;Port=5432;User Id=youruser;Password=yourpassword;Database=yourdbname;Pooling=true;MinPoolSize=0;MaxPoolSize=20;", + //#if (QueryTool) + //QueryTool should use a different connection string than the main app for security reasons (possibly readonly and no DDL commands) + "QueryToolConnectionString": "Data Source=appdata.db;Pooling=false;Mode=ReadWrite" //or one of the above + //#endif + }, + //#endif + "Logging": { "IncludeScopes": false, "LogLevel": { diff --git a/Content/WebApp/appsettings.json b/Content/WebApp/appsettings.json index 87fea3d..6a45aec 100644 --- a/Content/WebApp/appsettings.json +++ b/Content/WebApp/appsettings.json @@ -1,4 +1,5 @@ { + //#if (!AllStorage) //#if (!NoDb) "ConnectionStrings": { //#if (SQLite) @@ -15,6 +16,7 @@ //#endif //#if (QueryTool) + //QueryTool should use a different connection string than the main app for security reasons (possibly readonly and no DDL commands) //#if (SQLite) "QueryToolConnectionString": "Data Source=appdata.db;Pooling=false;Mode=ReadWrite" //#endif @@ -30,6 +32,27 @@ //#endif }, + //#endif + //#endif + //#if (AllStorage) + "DevOptions": { + "DbPlatform": "NoDb", //NoDb or EFCore + "EFProvider": "MSSQL" // SQLite, MSSQL, MySql, pgsql + }, + "ConnectionStrings": { + //EFCore SQLite + "SQLiteDbName": "appdata.db", + //EFCore MSSQL + "EntityFrameworkConnection": "Server=(localdb)\\mssqllocaldb;Database=WebApp-0353CAB0-205A-4FCD-9626-1282ECF47059;Trusted_Connection=True;MultipleActiveResultSets=true", + //EFCore MySql + "MySqlEntityFrameworkConnection": "Server=localhost;Database=yourdbname;Uid=yourdbuser;Pwd=yourdbpassword;Charset=utf8;", + //EFCore pgsql + "PostgreSqlEntityFrameworkConnection": "Server=yourserver;Port=5432;User Id=youruser;Password=yourpassword;Database=yourdbname;Pooling=true;MinPoolSize=0;MaxPoolSize=20;", + //#if (QueryTool) + //QueryTool should use a different connection string than the main app for security reasons (possibly readonly and no DDL commands) + "QueryToolConnectionString": "Data Source=appdata.db;Pooling=false;Mode=ReadWrite" //or one of the above + //#endif + }, //#endif "AppSettings": { From 2164799e7278dd2dc3f8063f58646702dc651e40 Mon Sep 17 00:00:00 2001 From: Simon Annetts Date: Fri, 1 Sep 2023 19:36:24 +0100 Subject: [PATCH 4/7] postgresql connection pooling --- Content/WebApp/appsettings.Development.json | 6 +++--- Content/WebApp/appsettings.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Content/WebApp/appsettings.Development.json b/Content/WebApp/appsettings.Development.json index c9121a1..d9a4d80 100644 --- a/Content/WebApp/appsettings.Development.json +++ b/Content/WebApp/appsettings.Development.json @@ -12,7 +12,7 @@ "EntityFrameworkConnection": "Server=localhost;Database=yourdbname;Uid=yourdbuser;Pwd=yourdbpassword;Charset=utf8;", //#endif //#if (pgsql) - "EntityFrameworkConnection": "Server=yourserver;Port=5432;User Id=youruser;Password=yourpassword;Database=yourdbname;", + "EntityFrameworkConnection": "Server=yourserver;Port=5432;User Id=youruser;Password=yourpassword;Database=yourdbname;Pooling=true;Minimum Pool Size=0;Maximim Pool Size=20;", //#endif //#if (QueryTool) @@ -27,7 +27,7 @@ "QueryToolConnectionString": "Server=localhost;Database=yourdbname;Uid=yourdbuser;Pwd=yourdbpassword;Charset=utf8;" //#endif //#if (pgsql) - "QueryToolConnectionString": "Server=yourserver;Port=5432;User Id=youruser;Password=yourpassword;Database=yourdbname;" + "QueryToolConnectionString": "Server=yourserver;Port=5432;User Id=youruser;Password=yourpassword;Database=yourdbname;Pooling=true;Minimum Pool Size=0;Maximim Pool Size=20;" //#endif //#endif }, @@ -47,7 +47,7 @@ //EFCore MySql "MySqlEntityFrameworkConnection": "Server=localhost;Database=yourdbname;Uid=yourdbuser;Pwd=yourdbpassword;Charset=utf8;", //EFCore pgsql - "PostgreSqlEntityFrameworkConnection": "Server=yourserver;Port=5432;User Id=youruser;Password=yourpassword;Database=yourdbname;Pooling=true;MinPoolSize=0;MaxPoolSize=20;", + "PostgreSqlEntityFrameworkConnection": "Server=yourserver;Port=5432;User Id=youruser;Password=yourpassword;Database=yourdbname;Pooling=true;Minimum Pool Size=0;Maximim Pool Size=20;", //#if (QueryTool) //QueryTool should use a different connection string than the main app for security reasons (possibly readonly and no DDL commands) "QueryToolConnectionString": "Data Source=appdata.db;Pooling=false;Mode=ReadWrite" //or one of the above diff --git a/Content/WebApp/appsettings.json b/Content/WebApp/appsettings.json index 6a45aec..2592dd9 100644 --- a/Content/WebApp/appsettings.json +++ b/Content/WebApp/appsettings.json @@ -12,7 +12,7 @@ "EntityFrameworkConnection": "Server=localhost;Database=yourdbname;Uid=yourdbuser;Pwd=yourdbpassword;Charset=utf8;", //#endif //#if (pgsql) - "EntityFrameworkConnection": "Server=yourserver;Port=5432;User Id=youruser;Password=yourpassword;Database=yourdbname;", + "EntityFrameworkConnection": "Server=yourserver;Port=5432;User Id=youruser;Password=yourpassword;Database=yourdbname;Pooling=true;Minimum Pool Size=0;Maximim Pool Size=20;", //#endif //#if (QueryTool) @@ -27,7 +27,7 @@ "QueryToolConnectionString": "Server=localhost;Database=yourdbname;Uid=yourdbuser;Pwd=yourdbpassword;Charset=utf8;" //#endif //#if (pgsql) - "QueryToolConnectionString": "Server=yourserver;Port=5432;User Id=youruser;Password=yourpassword;Database=yourdbname;" + "QueryToolConnectionString": "Server=yourserver;Port=5432;User Id=youruser;Password=yourpassword;Database=yourdbname;Pooling=true;Minimum Pool Size=0;Maximim Pool Size=20;" //#endif //#endif }, @@ -47,7 +47,7 @@ //EFCore MySql "MySqlEntityFrameworkConnection": "Server=localhost;Database=yourdbname;Uid=yourdbuser;Pwd=yourdbpassword;Charset=utf8;", //EFCore pgsql - "PostgreSqlEntityFrameworkConnection": "Server=yourserver;Port=5432;User Id=youruser;Password=yourpassword;Database=yourdbname;Pooling=true;MinPoolSize=0;MaxPoolSize=20;", + "PostgreSqlEntityFrameworkConnection": "Server=yourserver;Port=5432;User Id=youruser;Password=yourpassword;Database=yourdbname;Pooling=true;Minimum Pool Size=0;Maximim Pool Size=20;", //#if (QueryTool) //QueryTool should use a different connection string than the main app for security reasons (possibly readonly and no DDL commands) "QueryToolConnectionString": "Data Source=appdata.db;Pooling=false;Mode=ReadWrite" //or one of the above From 269a7a235071884881bf9b021dd8690838d9c7c9 Mon Sep 17 00:00:00 2001 From: Simon Annetts Date: Sat, 2 Sep 2023 00:38:51 +0100 Subject: [PATCH 5/7] wip more changes --- .gitignore | 4 +- Content/WebApp/Config/CloudscribeFeatures.cs | 59 ++-- Content/WebApp/WebApp.csproj | 316 +++++++++---------- Content/WebApp/changelog.txt | 10 - Content/WebApp/navigation.xml | 12 + README.md | 2 +- changelog.txt | 38 +++ cloudscribe.templates.nuspec | 4 +- packtemplate.cmd | 2 +- packtemplate.sh | 3 + testtemplate.sh | 14 + 11 files changed, 263 insertions(+), 201 deletions(-) delete mode 100644 Content/WebApp/changelog.txt create mode 100644 changelog.txt create mode 100644 packtemplate.sh create mode 100644 testtemplate.sh diff --git a/.gitignore b/.gitignore index 7c65fa9..7216944 100644 --- a/.gitignore +++ b/.gitignore @@ -289,4 +289,6 @@ __pycache__/ *.xsd.cs **/wwwroot/lib/** -nuget.exe \ No newline at end of file +nuget.exe + +cloudscribe.template.test/ diff --git a/Content/WebApp/Config/CloudscribeFeatures.cs b/Content/WebApp/Config/CloudscribeFeatures.cs index 2c076a7..b64e1ee 100644 --- a/Content/WebApp/Config/CloudscribeFeatures.cs +++ b/Content/WebApp/Config/CloudscribeFeatures.cs @@ -7,16 +7,16 @@ #if (QueryTool && !NoDb) using cloudscribe.QueryTool.Services; -#if (MSSQL) +#if (MSSQL || AllStorage) using cloudscribe.QueryTool.EFCore.MSSQL; #endif -#if (MySql) +#if (MySql || AllStorage) using cloudscribe.QueryTool.EFCore.MySql; #endif -#if (pgsql) +#if (pgsql || AllStorage) using cloudscribe.QueryTool.EFCore.PostgreSql; #endif -#if (SQLite) +#if (SQLite || AllStorage) using cloudscribe.QueryTool.EFCore.SQLite; #endif #endif @@ -35,7 +35,6 @@ public static IServiceCollection SetupDataStorage( IWebHostEnvironment env ) { -#region "Single database storage choices" #if (!AllStorage) #if (!NoDb && !SQLite) var connectionString = config.GetConnectionString("EntityFrameworkConnection"); @@ -284,17 +283,14 @@ IWebHostEnvironment env #endif #endif -#endregion - -#region "All database storage choice" #if (AllStorage) var storage = config["DevOptions:DbPlatform"].ToLowerInvariant(); var efProvider = config["DevOptions:EFProvider"].ToLowerInvariant(); + string connectionString; switch (storage) { case "efcore": - default: switch (efProvider) { case "mysql": @@ -427,7 +423,7 @@ IWebHostEnvironment env case "mssql": default: - var connectionString = config.GetConnectionString("EntityFrameworkConnection"); + connectionString = config.GetConnectionString("EntityFrameworkConnection"); services.AddCloudscribeCoreEFStorageMSSQL(connectionString); #if (KvpCustomRegistration || Newsletter) services.AddCloudscribeKvpEFStorageMSSQL(connectionString); @@ -508,12 +504,11 @@ IWebHostEnvironment env services.AddTalkAboutForumStorageNoDb(); #endif #if (QueryTool) - services.AddQueryToolNoDbStorage(); + //The QueryTool can only work with Entity Framework databases and not with NoDb #endif break; } #endif -#endregion return services; } @@ -532,16 +527,17 @@ IConfiguration config services.Configure(config.GetSection("ProfilePropertySetContainer")); #if (Newsletter) services.AddEmailListKvpIntegration(config); + #endif services.AddCloudscribeKvpUserProperties(); -#endif - +#endif services.AddScoped(); #if (SimpleContentConfig != "z") services.AddScoped(); #endif services.AddCloudscribeCoreMvc(config); + #if (SimpleContentConfig != "z") services.AddCloudscribeCoreIntegrationForSimpleContent(config); services.AddSimpleContentMvc(config); @@ -549,73 +545,84 @@ IConfiguration config services.AddMetaWeblogForSimpleContent(config.GetSection("MetaWeblogApiOptions")); services.AddSimpleContentRssSyndiction(); + #endif #if (ContactForm) services.AddCloudscribeSimpleContactFormCoreIntegration(config); services.AddCloudscribeSimpleContactForm(config); -#endif +#endif #if (FormBuilder) services.AddFormsCloudscribeCoreIntegration(config); services.AddFormsServices(config); + #if (SimpleContentConfig != "z") services.AddFormSurveyContentTemplatesForSimpleContent(config); + #endif // these are examples to show you how to implement custom form submission handlers. // see /Services/SampleFormSubmissionHandlers.cs services.AddScoped(); services.AddScoped(); -#endif +#endif #if (IncludeStripeIntegration) services.AddMembershipStripeIntegration(config); services.AddCloudscribeCoreStripeIntegration(); services.AddStripeIntegrationMvc(config); #endif - #if (Paywall) services.AddMembershipSubscriptionMvcComponents(config); services.AddMembershipBackgroundTasks(config); -#endif +#endif #if (IncludeEmailQueue) services.AddEmailQueueBackgroundTask(config); services.AddEmailQueueWithCloudscribeIntegration(config); services.AddEmailRazorTemplating(config); -#endif +#endif #if (Newsletter) services.AddEmailListWithCloudscribeIntegration(config); -#endif +#endif #if (DynamicPolicy) services.AddCloudscribeDynamicPolicyIntegration(config); services.AddDynamicAuthorizationMvc(config); -#endif -#if (CommentSystem || Forum) - services.AddTalkAboutCloudscribeIntegration(config); #endif +#if (CommentSystem || Forum) + services.AddTalkAboutCloudscribeIntegration(config); +#endif #if (Forum) services.AddTalkAboutForumServices(config) .AddTalkAboutForumNotificationServices(config); -#endif +#endif #if (CommentSystem) services.AddTalkAboutCommentsCloudscribeIntegration(config); services.AddTalkAboutServices(config) .AddTalkAboutNotificationServices(config); -#endif - +#endif +#if(!AllStorage) #if (QueryTool && !NoDb) //The QueryTool can only work with Entity Framework databases and not with NoDb services.AddScoped(); + #endif +#endif +#if(AllStorage) + var storage = config["DevOptions:DbPlatform"].ToLowerInvariant(); + if (storage == "efcore") + { + services.AddScoped(); + } +#endif return services; } diff --git a/Content/WebApp/WebApp.csproj b/Content/WebApp/WebApp.csproj index ec9b637..b98c6bb 100644 --- a/Content/WebApp/WebApp.csproj +++ b/Content/WebApp/WebApp.csproj @@ -3,10 +3,10 @@ net6.0 WebApp-4BC5DF1F-B155-4A69-9719-0AB349B1ACB2 - + true Latest - + @@ -31,12 +31,12 @@ - + - + @@ -49,23 +49,23 @@ - + - - + + - - + + - - + + - - + + - + - + @@ -76,172 +76,171 @@ - + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - - + + - - + + - - - + + - + - - + + - - + + - - + + - + @@ -270,93 +269,90 @@ - + - - + + - - + + - - + + - - + + - - + + - + - + - + - - + + - - + + - - + + - + - + - + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - - + + - - + + - - + + - - + + - - - + + - - - + diff --git a/Content/WebApp/changelog.txt b/Content/WebApp/changelog.txt deleted file mode 100644 index 1953621..0000000 --- a/Content/WebApp/changelog.txt +++ /dev/null @@ -1,10 +0,0 @@ -Cloudscribe Template Change Log -------------------------------- - - -Version 6.6 (not yet built) - -29 Aug 2023 - Added support for KVP properties to be rendered in user listing view -https://github.com/cloudscribe/cloudscribe.UserProperties.Kvp/issues/46 - - diff --git a/Content/WebApp/navigation.xml b/Content/WebApp/navigation.xml index 7a27b19..1072a50 100644 --- a/Content/WebApp/navigation.xml +++ b/Content/WebApp/navigation.xml @@ -877,6 +877,18 @@ + + + + cloudscribe.templates - 6.5.0 + 6.5.1 cloudscribe Project Templates Joe Audette Project template for starting new web application projects with cloudscribe library components @@ -21,6 +21,6 @@ - + diff --git a/packtemplate.cmd b/packtemplate.cmd index d042549..f72b9cd 100644 --- a/packtemplate.cmd +++ b/packtemplate.cmd @@ -1 +1 @@ -nuget pack cloudscribe.templates.nuspec -Version 6.5.0 -OutputDirectory "nupkgs" +nuget pack cloudscribe.templates.nuspec -OutputDirectory "nupkgs" diff --git a/packtemplate.sh b/packtemplate.sh new file mode 100644 index 0000000..1ae1f84 --- /dev/null +++ b/packtemplate.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +nuget pack cloudscribe.templates.nuspec -OutputDirectory "nupkgs" -Properties Configuration=Release \ No newline at end of file diff --git a/testtemplate.sh b/testtemplate.sh new file mode 100644 index 0000000..c85111d --- /dev/null +++ b/testtemplate.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +rm -Rf ./nupkgs 2>/dev/null +dotnet new --uninstall cloudscribe.templates +nuget pack cloudscribe.templates.nuspec -OutputDirectory "nupkgs" +dotnet new --install ./nupkgs/*.nupkg + +rm -Rf ./cloudscribe.templates.test 2>/dev/null +mkdir ./cloudscribe.templates.test 2>/dev/null +cd ./cloudscribe.template.test +dotnet new cloudscribe -Da AllStorage -Q +dotnet restore +dotnet build + From 615781f1f67ae1e053f5ea13f0132de1aa73db70 Mon Sep 17 00:00:00 2001 From: Simon Annetts Date: Sat, 2 Sep 2023 02:36:40 +0100 Subject: [PATCH 6/7] more WIP, experimental! --- .gitignore | 2 +- testtemplate.sh | 14 ------------- testtemplates.sh | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 15 deletions(-) delete mode 100644 testtemplate.sh create mode 100644 testtemplates.sh diff --git a/.gitignore b/.gitignore index 7216944..a5a4ead 100644 --- a/.gitignore +++ b/.gitignore @@ -291,4 +291,4 @@ __pycache__/ **/wwwroot/lib/** nuget.exe -cloudscribe.template.test/ +cloudscribe.templates.test/ diff --git a/testtemplate.sh b/testtemplate.sh deleted file mode 100644 index c85111d..0000000 --- a/testtemplate.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -rm -Rf ./nupkgs 2>/dev/null -dotnet new --uninstall cloudscribe.templates -nuget pack cloudscribe.templates.nuspec -OutputDirectory "nupkgs" -dotnet new --install ./nupkgs/*.nupkg - -rm -Rf ./cloudscribe.templates.test 2>/dev/null -mkdir ./cloudscribe.templates.test 2>/dev/null -cd ./cloudscribe.template.test -dotnet new cloudscribe -Da AllStorage -Q -dotnet restore -dotnet build - diff --git a/testtemplates.sh b/testtemplates.sh new file mode 100644 index 0000000..a19e911 --- /dev/null +++ b/testtemplates.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# the purpose of this script is to try and test the various template options +# to make sure that they produce valid cloudscribe projects that build and run + +TESTPROJECTDIR="cloudscribe.templates.test" + +# this will build a new cloudscribe.templates nuget package and install it locally + +rm -Rf ./nupkgs 2>/dev/null +# create a new nuget package for the template +nuget pack cloudscribe.templates.nuspec -OutputDirectory "nupkgs" +[ $? -ne 0 ] && echo "nuget pack failed" && exit 1 + +#Uninstall any existing local version of the template +dotnet new --uninstall cloudscribe.templates +#Install the new version of the template we've just compiled +dotnet new --install ./nupkgs/*.nupkg + +# now we need to create a new project from the template and try and build it +# we'll use various options to test the different template options + +# this is a list of possibly useful combinations of options that we should test +# But how do I test all combinations because there is so many! +# As a start we'll just test the most common combinations +# some of which are not supported in NoDb or SQLite mode! + +# options for dotnet new cloudscribe -Da +DBOPTIONS = "NoDb MSSQL MySql SQLite pgsql AllStorage" + +# cloudcribe module inclusions +MODULEOPTIONS = "-C -K -I -Q -L -F -P -Ne -Co -Fo -D" + +# but some modules are not supported in NoDb or SQLite mode! + + + + +#remove and recreate the test project directory +rm -Rf ./$TESTPROJECTDIR 2>/dev/null +mkdir ./$TESTPROJECTDIR 2>/dev/null + +#if the test project directory exists, try and create a new project from the template +if [ -d "./$TESTPROJECTDIR" ]; then + cd ./$TESTPROJECTDIR + dotnet new cloudscribe -Da AllStorage -Q + [ $? -ne 0 ] && echo "dotnet new failed" && exit 1 + dotnet restore --force --no-cache --forec-evaluate + [ $? -ne 0 ] && echo "dotnet restore failed" && exit 1 + dotnet build + [ $? -ne 0 ] && echo "dotnet build failed" && exit 1 +fi + + From ec4dceff64c19db5deda0cdeae78bbfa3b376af2 Mon Sep 17 00:00:00 2001 From: Simon Annetts Date: Sat, 2 Sep 2023 20:10:57 +0100 Subject: [PATCH 7/7] add tests and update license --- cloudscribe.templates.nuspec | 2 +- packtemplate.sh | 0 testtemplates.sh | 67 ++++++++++++++++++++++-------------- 3 files changed, 43 insertions(+), 26 deletions(-) mode change 100644 => 100755 packtemplate.sh mode change 100644 => 100755 testtemplates.sh diff --git a/cloudscribe.templates.nuspec b/cloudscribe.templates.nuspec index 4f88847..5a3daf1 100644 --- a/cloudscribe.templates.nuspec +++ b/cloudscribe.templates.nuspec @@ -10,7 +10,7 @@ Copyright © Exegesis Spatial Data Management en-US https://github.com/cloudscribe/cloudscribe.templates - https://licenses.nuget.org/Apache-2.0 + Apache-2.0 false diff --git a/packtemplate.sh b/packtemplate.sh old mode 100644 new mode 100755 diff --git a/testtemplates.sh b/testtemplates.sh old mode 100644 new mode 100755 index a19e911..c0fed10 --- a/testtemplates.sh +++ b/testtemplates.sh @@ -3,6 +3,8 @@ # the purpose of this script is to try and test the various template options # to make sure that they produce valid cloudscribe projects that build and run +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + TESTPROJECTDIR="cloudscribe.templates.test" # this will build a new cloudscribe.templates nuget package and install it locally @@ -26,29 +28,44 @@ dotnet new --install ./nupkgs/*.nupkg # some of which are not supported in NoDb or SQLite mode! # options for dotnet new cloudscribe -Da -DBOPTIONS = "NoDb MSSQL MySql SQLite pgsql AllStorage" - -# cloudcribe module inclusions -MODULEOPTIONS = "-C -K -I -Q -L -F -P -Ne -Co -Fo -D" - -# but some modules are not supported in NoDb or SQLite mode! - - - - -#remove and recreate the test project directory -rm -Rf ./$TESTPROJECTDIR 2>/dev/null -mkdir ./$TESTPROJECTDIR 2>/dev/null - -#if the test project directory exists, try and create a new project from the template -if [ -d "./$TESTPROJECTDIR" ]; then - cd ./$TESTPROJECTDIR - dotnet new cloudscribe -Da AllStorage -Q - [ $? -ne 0 ] && echo "dotnet new failed" && exit 1 - dotnet restore --force --no-cache --forec-evaluate - [ $? -ne 0 ] && echo "dotnet restore failed" && exit 1 - dotnet build - [ $? -ne 0 ] && echo "dotnet build failed" && exit 1 -fi - +DBOPTIONS="NoDb MSSQL MySql SQLite pgsql AllStorage" + +S=0 + +for DB in $DBOPTIONS; do + + echo "Building project with $DB database in $SCRIPT_DIR/$TESTPROJECTDIR ..." + + # cloudcribe module inclusions + MODULEOPTIONS="-C -K -I -Q -L -F -P -Ne -Co -Fo -D" + + # but some modules are not supported in NoDb or SQLite mode! + if [ $DB == "SQLite" ]; then + MODULEOPTIONS="-C -K -I -Q -L -F -Co -Fo -D" + fi + if [ $DB == "NoDb" ]; then + MODULEOPTIONS="-C -K -I -L -F -Co -Fo -D" + fi + + #remove and recreate the test project directory + rm -Rf $SCRIPT_DIR/$TESTPROJECTDIR 2>/dev/null + mkdir $SCRIPT_DIR/$TESTPROJECTDIR 2>/dev/null + + #if the test project directory exists, try and create a new project from the template + if [ -d "$SCRIPT_DIR/$TESTPROJECTDIR" ]; then + cd $SCRIPT_DIR/$TESTPROJECTDIR + dotnet new cloudscribe -Da $DB $MODULEOPTIONS + [ $? -ne 0 ] && echo "dotnet new failed" && break + dotnet restore --force --no-cache --force-evaluate + [ $? -ne 0 ] && echo "dotnet restore failed" && break + dotnet build + [ $? -ne 0 ] && echo "dotnet build failed" && break + cd $SCRIPT_DIR + S=$((S+1)) + fi + +done +rm -Rf $SCRIPT_DIR/$TESTPROJECTDIR 2>/dev/null + +echo "Successfully built $S/6 projects with various options!"