From 6eaacf0e4bd7a91f265427389066f9b1a42102fe Mon Sep 17 00:00:00 2001 From: Danny Logsdon Date: Sat, 24 Aug 2024 09:45:55 -0400 Subject: [PATCH] v1.1.0-b prerelease BREAKING CHANGES Code cleanup --- ...ricks.Logging.AzureDataTables.Debug.csproj | 2 +- .../Domain/WebRequestMessage.cs | 10 +-- .../Rule/LogMessageCreateRule.cs | 4 +- .../Rule/WebRequestMessageCreateRule.cs | 4 +- ...rviceBricks.Logging.AzureDataTables.csproj | 8 +- .../ServiceBricks.Logging.Cosmos.Debug.csproj | 15 ++-- .../Domain/LogMessage.cs | 5 ++ .../Domain/WebRequestMessage.cs | 15 ++-- .../ApplicationBuilderExtensions.cs | 4 +- .../Extensions/ServiceCollectionExtensions.cs | 22 +++--- .../Mapping/LogMessageMappingProfile.cs | 1 + .../WebRequestMessageMessageMappingProfile.cs | 1 + .../Model/LoggingCosmosConstants.cs | 12 ++- .../Model/LoggingCosmosContext.cs | 11 +-- .../Rule/LogMessageCreateRule.cs | 76 +++++++++++++++++++ .../Rule/WebRequestMessageCreateRule.cs | 76 +++++++++++++++++++ .../ServiceBricks.Logging.Cosmos.csproj | 17 ++--- ...erviceBricks - Backup.Logging.Debug.csproj | 56 -------------- .../ServiceBricks.Logging.Debug.csproj | 4 +- ...p.Logging.EntityFrameworkCore.Debug.csproj | 44 ----------- ...s.Logging.EntityFrameworkCore.Debug.csproj | 2 +- .../Domain/WebRequestMessage.cs | 10 +-- ... Backup.Logging.EntityFrameworkCore.csproj | 37 --------- ...eBricks.Logging.EntityFrameworkCore.csproj | 8 +- ...cks - Backup.Logging.InMemory.Debug.csproj | 47 ------------ ...erviceBricks.Logging.InMemory.Debug.csproj | 15 +--- .../Model/LoggingInMemoryContext.cs | 2 + ...ricks - Backup (1).Logging.InMemory.csproj | 46 ----------- ...iceBricks - Backup.Logging.InMemory.csproj | 46 ----------- .../ServiceBricks.Logging.InMemory.csproj | 22 ++---- ...icks - Backup.Logging.MongoDb.Debug.csproj | 44 ----------- ...ServiceBricks.Logging.MongoDb.Debug.csproj | 2 +- .../Domain/WebRequestMessage.cs | 10 +-- ...viceBricks - Backup.Logging.MongoDb.csproj | 36 --------- .../ServiceBricks.Logging.MongoDb.csproj | 8 +- ...cks - Backup.Logging.Postgres.Debug.csproj | 49 ------------ ...erviceBricks.Logging.Postgres.Debug.csproj | 12 +-- .../Model/LoggingPostgresContext.cs | 26 +++---- ...ricks - Backup (1).Logging.Postgres.csproj | 47 ------------ ...iceBricks - Backup.Logging.Postgres.csproj | 47 ------------ .../ServiceBricks.Logging.Postgres.csproj | 19 ++--- ...ks - Backup.Logging.SqlServer.Debug.csproj | 48 ------------ ...rviceBricks.Logging.SqlServer.Debug.csproj | 11 +-- .../Model/LoggingSqlServerContext.cs | 8 +- ...icks - Backup (1).Logging.SqlServer.csproj | 47 ------------ ...ceBricks - Backup.Logging.SqlServer.csproj | 47 ------------ .../ServiceBricks.Logging.SqlServer.csproj | 18 ++--- ...ricks - Backup.Logging.Sqlite.Debug.csproj | 49 ------------ .../ServiceBricks.Logging.Sqlite.Debug.csproj | 12 +-- .../Model/LoggingSqliteContext.cs | 17 +++-- ...eBricks - Backup (1).Logging.Sqlite.csproj | 47 ------------ ...rviceBricks - Backup.Logging.Sqlite.csproj | 47 ------------ .../ServiceBricks.Logging.Sqlite.csproj | 18 ++--- .../Api/WebRequestMessageDto.cs | 10 +-- ...rMiddleware.cs => LogMessageMiddleware.cs} | 6 +- .../Middleware/WebRequestMessageMiddleware.cs | 14 ++-- .../Model/WebRequestMessageOptions.cs | 20 ++--- .../Rule/CreateApplicationLogRule.cs | 8 +- .../ServiceBricks.Logging.csproj | 6 +- .../MigrationsHost/MigrationsHost.csproj | 10 +-- .../Tests/MigrationsHost/StartupMigrations.cs | 16 +++- src/V1/Tests/MigrationsHost/SystemManager.cs | 50 ++++++------ ...s.Logging.AzureDataTables.XunitNet6.csproj | 2 +- ...s.Logging.AzureDataTables.XunitNet8.csproj | 2 +- ...viceBricks.Logging.Client.XunitNet6.csproj | 2 +- ...viceBricks.Logging.Client.XunitNet8.csproj | 2 +- ...viceBricks.Logging.Cosmos.XunitNet6.csproj | 2 +- ...viceBricks.Logging.Cosmos.XunitNet8.csproj | 2 +- ...ceBricks.Logging.InMemory.XunitNet6.csproj | 2 +- ...ceBricks.Logging.InMemory.XunitNet8.csproj | 2 +- ...iceBricks.Logging.MongoDb.XunitNet6.csproj | 2 +- ...iceBricks.Logging.MongoDb.XunitNet8.csproj | 2 +- ...ceBricks.Logging.Postgres.XunitNet6.csproj | 2 +- ...ceBricks.Logging.Postgres.XunitNet8.csproj | 2 +- ...eBricks.Logging.SqlServer.XunitNet6.csproj | 2 +- ...eBricks.Logging.SqlServer.XunitNet8.csproj | 2 +- ...viceBricks.Logging.Sqlite.XunitNet6.csproj | 2 +- ...viceBricks.Logging.Sqlite.XunitNet8.csproj | 2 +- .../ServiceBricks.Logging.XunitNet6.csproj | 10 ++- .../ServiceBricks.Logging.XunitNet7.csproj | 6 +- .../ServiceBricks.Logging.XunitNet8.csproj | 6 +- .../TestFiles/LogMessageApiControllerTest.cs | 41 ++++++++++ ...MessageApiControllerTestAzureDataTables.cs | 35 +-------- .../LogMessageApiControllerTestCosmos.cs | 35 +-------- .../LogMessageApiControllerTestInMemory.cs | 35 +-------- .../LogMessageApiControllerTestMongoDb.cs | 35 +-------- .../LogMessageApiControllerTestPostgres.cs | 32 +------- .../LogMessageApiControllerTestSqlServer.cs | 35 +-------- .../LogMessageApiControllerTestSqlite.cs | 35 +-------- .../WebRequestMessageApiControllerTest.cs | 41 ++++++++++ ...ebRequestMessageApiControllerTestCosmos.cs | 32 +------- ...RequestMessageApiControllerTestInMemory.cs | 32 +------- ...bRequestMessageApiControllerTestMongoDb.cs | 32 +------- ...RequestMessageApiControllerTestPostgres.cs | 32 +------- ...equestMessageApiControllerTestSqlServer.cs | 32 +------- ...ebRequestMessageApiControllerTestSqlite.cs | 32 +------- .../TestFiles/WebRequestMessageTestManager.cs | 22 +++++- .../WebRequestMessageTestManagerPostgres.cs | 2 +- src/V1/Tests/TestFiles/appsettings.json | 8 +- .../Tests/TestFiles/webapp/appsettings.json | 12 +-- .../ApplicationBuilderExtensions.cs | 2 +- src/V1/Tests/WebAppNet6/WebAppNet6.csproj | 4 +- .../ApplicationBuilderExtensions.cs | 2 +- src/V1/Tests/WebAppNet7/WebAppNet7.csproj | 2 +- .../ApplicationBuilderExtensions.cs | 2 +- src/V1/Tests/WebAppNet8/WebAppNet8.csproj | 4 +- 106 files changed, 559 insertions(+), 1502 deletions(-) create mode 100644 src/V1/ServiceBricks.Logging.Cosmos/Rule/LogMessageCreateRule.cs create mode 100644 src/V1/ServiceBricks.Logging.Cosmos/Rule/WebRequestMessageCreateRule.cs delete mode 100644 src/V1/ServiceBricks.Logging.Debug/ServiceBricks - Backup.Logging.Debug.csproj delete mode 100644 src/V1/ServiceBricks.Logging.EntityFrameworkCore.Debug/ServiceBricks - Backup.Logging.EntityFrameworkCore.Debug.csproj delete mode 100644 src/V1/ServiceBricks.Logging.EntityFrameworkCore/ServiceBricks - Backup.Logging.EntityFrameworkCore.csproj delete mode 100644 src/V1/ServiceBricks.Logging.InMemory.Debug/ServiceBricks - Backup.Logging.InMemory.Debug.csproj delete mode 100644 src/V1/ServiceBricks.Logging.InMemory/ServiceBricks - Backup (1).Logging.InMemory.csproj delete mode 100644 src/V1/ServiceBricks.Logging.InMemory/ServiceBricks - Backup.Logging.InMemory.csproj delete mode 100644 src/V1/ServiceBricks.Logging.MongoDb.Debug/ServiceBricks - Backup.Logging.MongoDb.Debug.csproj delete mode 100644 src/V1/ServiceBricks.Logging.MongoDb/ServiceBricks - Backup.Logging.MongoDb.csproj delete mode 100644 src/V1/ServiceBricks.Logging.Postgres.Debug/ServiceBricks - Backup.Logging.Postgres.Debug.csproj delete mode 100644 src/V1/ServiceBricks.Logging.Postgres/ServiceBricks - Backup (1).Logging.Postgres.csproj delete mode 100644 src/V1/ServiceBricks.Logging.Postgres/ServiceBricks - Backup.Logging.Postgres.csproj delete mode 100644 src/V1/ServiceBricks.Logging.SqlServer.Debug/ServiceBricks - Backup.Logging.SqlServer.Debug.csproj delete mode 100644 src/V1/ServiceBricks.Logging.SqlServer/ServiceBricks - Backup (1).Logging.SqlServer.csproj delete mode 100644 src/V1/ServiceBricks.Logging.SqlServer/ServiceBricks - Backup.Logging.SqlServer.csproj delete mode 100644 src/V1/ServiceBricks.Logging.Sqlite.Debug/ServiceBricks - Backup.Logging.Sqlite.Debug.csproj delete mode 100644 src/V1/ServiceBricks.Logging.Sqlite/ServiceBricks - Backup (1).Logging.Sqlite.csproj delete mode 100644 src/V1/ServiceBricks.Logging.Sqlite/ServiceBricks - Backup.Logging.Sqlite.csproj rename src/V1/ServiceBricks.Logging/Middleware/{CustomLoggerMiddleware.cs => LogMessageMiddleware.cs} (96%) create mode 100644 src/V1/Tests/TestFiles/LogMessageApiControllerTest.cs create mode 100644 src/V1/Tests/TestFiles/WebRequestMessageApiControllerTest.cs diff --git a/src/V1/ServiceBricks.Logging.AzureDataTables.Debug/ServiceBricks.Logging.AzureDataTables.Debug.csproj b/src/V1/ServiceBricks.Logging.AzureDataTables.Debug/ServiceBricks.Logging.AzureDataTables.Debug.csproj index 32d7b2b..5780589 100644 --- a/src/V1/ServiceBricks.Logging.AzureDataTables.Debug/ServiceBricks.Logging.AzureDataTables.Debug.csproj +++ b/src/V1/ServiceBricks.Logging.AzureDataTables.Debug/ServiceBricks.Logging.AzureDataTables.Debug.csproj @@ -25,7 +25,7 @@ - + diff --git a/src/V1/ServiceBricks.Logging.AzureDataTables/Domain/WebRequestMessage.cs b/src/V1/ServiceBricks.Logging.AzureDataTables/Domain/WebRequestMessage.cs index 81740a6..b7e66ad 100644 --- a/src/V1/ServiceBricks.Logging.AzureDataTables/Domain/WebRequestMessage.cs +++ b/src/V1/ServiceBricks.Logging.AzureDataTables/Domain/WebRequestMessage.cs @@ -27,6 +27,11 @@ public partial class WebRequestMessage : AzureDataTablesDomainObject public virtual string Server { get; set; } + /// + /// The User storage key associated with the Request. + /// + public string UserStorageKey { get; set; } + /// /// The Request IP Address. /// @@ -112,11 +117,6 @@ public partial class WebRequestMessage : AzureDataTablesDomainObject public bool? RequestIsHttps { get; set; } - /// - /// The User storage key associated with the Request. - /// - public string RequestUserStorageKey { get; set; } - /// /// The status code of the response. /// diff --git a/src/V1/ServiceBricks.Logging.AzureDataTables/Rule/LogMessageCreateRule.cs b/src/V1/ServiceBricks.Logging.AzureDataTables/Rule/LogMessageCreateRule.cs index 1e57456..521a0a5 100644 --- a/src/V1/ServiceBricks.Logging.AzureDataTables/Rule/LogMessageCreateRule.cs +++ b/src/V1/ServiceBricks.Logging.AzureDataTables/Rule/LogMessageCreateRule.cs @@ -49,8 +49,8 @@ public override IResponse ExecuteRule(IBusinessRuleContext context) var item = e.DomainObject; item.Key = Guid.NewGuid(); - // AI: Set the PartitionKey to be the year and month so that the data is partitioned - item.PartitionKey = item.CreateDate.ToString("yyyyMM"); + // AI: Set the PartitionKey to be the year, month and day so that the data is partitioned + item.PartitionKey = item.CreateDate.ToString("yyyyMMdd"); // AI: Set the RowKey to be the reverse date and time so that the newest items are at the top when querying var reverseDate = DateTimeOffset.MaxValue.Ticks - item.CreateDate.Ticks; diff --git a/src/V1/ServiceBricks.Logging.AzureDataTables/Rule/WebRequestMessageCreateRule.cs b/src/V1/ServiceBricks.Logging.AzureDataTables/Rule/WebRequestMessageCreateRule.cs index e934bb1..35c3554 100644 --- a/src/V1/ServiceBricks.Logging.AzureDataTables/Rule/WebRequestMessageCreateRule.cs +++ b/src/V1/ServiceBricks.Logging.AzureDataTables/Rule/WebRequestMessageCreateRule.cs @@ -49,8 +49,8 @@ public override IResponse ExecuteRule(IBusinessRuleContext context) var item = ei.DomainObject; item.Key = Guid.NewGuid(); - // AI: Set the PartitionKey to be the year and month so that the data is partitioned - item.PartitionKey = item.CreateDate.ToString("yyyyMM"); + // AI: Set the PartitionKey to be the year, month and day so that the data is partitioned + item.PartitionKey = item.CreateDate.ToString("yyyyMMdd"); // AI: Set the RowKey to be the reverse date and time so that the newest items are at the top when querying var reverseDate = DateTimeOffset.MaxValue.Ticks - item.CreateDate.Ticks; diff --git a/src/V1/ServiceBricks.Logging.AzureDataTables/ServiceBricks.Logging.AzureDataTables.csproj b/src/V1/ServiceBricks.Logging.AzureDataTables/ServiceBricks.Logging.AzureDataTables.csproj index 55033be..b1a8992 100644 --- a/src/V1/ServiceBricks.Logging.AzureDataTables/ServiceBricks.Logging.AzureDataTables.csproj +++ b/src/V1/ServiceBricks.Logging.AzureDataTables/ServiceBricks.Logging.AzureDataTables.csproj @@ -1,7 +1,7 @@ - 1.1.0-a + 1.1.0-b ServiceBricks - The open source microservices foundation. Visit https://ServiceBricks.com to learn more. ServiceBricks.Logging.AzureDataTables holomodular @@ -19,7 +19,7 @@ False git https://github.com/holomodular/ServiceBricks - False + True @@ -29,7 +29,7 @@ - - + + diff --git a/src/V1/ServiceBricks.Logging.Cosmos.Debug/ServiceBricks.Logging.Cosmos.Debug.csproj b/src/V1/ServiceBricks.Logging.Cosmos.Debug/ServiceBricks.Logging.Cosmos.Debug.csproj index 6104ccb..5956e9f 100644 --- a/src/V1/ServiceBricks.Logging.Cosmos.Debug/ServiceBricks.Logging.Cosmos.Debug.csproj +++ b/src/V1/ServiceBricks.Logging.Cosmos.Debug/ServiceBricks.Logging.Cosmos.Debug.csproj @@ -16,6 +16,8 @@ + + @@ -25,15 +27,8 @@ - - - - - - - - - - + + + diff --git a/src/V1/ServiceBricks.Logging.Cosmos/Domain/LogMessage.cs b/src/V1/ServiceBricks.Logging.Cosmos/Domain/LogMessage.cs index 1ec91bc..3dc3635 100644 --- a/src/V1/ServiceBricks.Logging.Cosmos/Domain/LogMessage.cs +++ b/src/V1/ServiceBricks.Logging.Cosmos/Domain/LogMessage.cs @@ -13,6 +13,11 @@ public partial class LogMessage : EntityFrameworkCoreDomainObject, I /// public Guid Key { get; set; } + /// + /// Internal Partition Key + /// + public string PartitionKey { get; set; } + /// /// The date and time the log message was created in UTC. /// diff --git a/src/V1/ServiceBricks.Logging.Cosmos/Domain/WebRequestMessage.cs b/src/V1/ServiceBricks.Logging.Cosmos/Domain/WebRequestMessage.cs index 4cebb25..35876a0 100644 --- a/src/V1/ServiceBricks.Logging.Cosmos/Domain/WebRequestMessage.cs +++ b/src/V1/ServiceBricks.Logging.Cosmos/Domain/WebRequestMessage.cs @@ -13,6 +13,11 @@ public partial class WebRequestMessage : EntityFrameworkCoreDomainObject public Guid Key { get; set; } + /// + /// Internal Partition Key + /// + public string PartitionKey { get; set; } + /// /// The date and time the message was created in UTC. /// @@ -28,6 +33,11 @@ public partial class WebRequestMessage : EntityFrameworkCoreDomainObject public virtual string Server { get; set; } + /// + /// The User storage key associated with the Request. + /// + public string UserStorageKey { get; set; } + /// /// The Request IP Address. /// @@ -113,11 +123,6 @@ public partial class WebRequestMessage : EntityFrameworkCoreDomainObject public bool? RequestIsHttps { get; set; } - /// - /// The User storage key associated with the Request. - /// - public string RequestUserStorageKey { get; set; } - /// /// The status code of the response. /// diff --git a/src/V1/ServiceBricks.Logging.Cosmos/Extensions/ApplicationBuilderExtensions.cs b/src/V1/ServiceBricks.Logging.Cosmos/Extensions/ApplicationBuilderExtensions.cs index e54b5d5..364ca9d 100644 --- a/src/V1/ServiceBricks.Logging.Cosmos/Extensions/ApplicationBuilderExtensions.cs +++ b/src/V1/ServiceBricks.Logging.Cosmos/Extensions/ApplicationBuilderExtensions.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; +using ServiceBricks.Logging.EntityFrameworkCore; namespace ServiceBricks.Logging.Cosmos { @@ -31,8 +32,7 @@ public static IApplicationBuilder StartServiceBricksLoggingCosmos(this IApplicat ModuleStarted = true; // AI: Start the parent module. - // AI: If the primary keys of the Cosmos models do not match the EFC module, we can't use it rules, so skip EFC and call start on the core module instead. - applicationBuilder.StartServiceBricksLogging(); // Skip EFC + applicationBuilder.StartServiceBricksLoggingEntityFrameworkCore(); return applicationBuilder; } diff --git a/src/V1/ServiceBricks.Logging.Cosmos/Extensions/ServiceCollectionExtensions.cs b/src/V1/ServiceBricks.Logging.Cosmos/Extensions/ServiceCollectionExtensions.cs index 17bbace..a22a280 100644 --- a/src/V1/ServiceBricks.Logging.Cosmos/Extensions/ServiceCollectionExtensions.cs +++ b/src/V1/ServiceBricks.Logging.Cosmos/Extensions/ServiceCollectionExtensions.cs @@ -1,6 +1,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using ServiceBricks.Logging.EntityFrameworkCore; using ServiceBricks.Storage.EntityFrameworkCore; namespace ServiceBricks.Logging.Cosmos @@ -22,8 +23,7 @@ public static IServiceCollection AddServiceBricksLoggingCosmos(this IServiceColl ModuleRegistry.Instance.RegisterItem(typeof(LoggingCosmosModule), new LoggingCosmosModule()); // AI: Add the parent module - // AI: If the primary keys of the Cosmos models do not match the EFC module, we can't use EFC rules, so skip EFC and call start on the core module instead. - services.AddServiceBricksLogging(configuration); // Skip EFC + services.AddServiceBricksLoggingEntityFrameworkCore(configuration); // AI: Register the database for the module var builder = new DbContextOptionsBuilder(); @@ -40,22 +40,22 @@ public static IServiceCollection AddServiceBricksLoggingCosmos(this IServiceColl services.AddScoped, LoggingStorageRepository>(); services.AddScoped, LoggingStorageRepository>(); - // AI: Register business rules for the module - // AI: If the primary keys of the Cosmos models match the EFC module, we can use the EFC rules - DomainCreateDateRule.RegisterRule(BusinessRuleRegistry.Instance); - DomainQueryPropertyRenameRule.RegisterRule(BusinessRuleRegistry.Instance, "StorageKey", "Key"); - - DomainCreateDateRule.RegisterRule(BusinessRuleRegistry.Instance); - DomainQueryPropertyRenameRule.RegisterRule(BusinessRuleRegistry.Instance, "StorageKey", "Key"); - // AI: Add API services for the module. Each DTO should have two registrations, one for the generic IApiService<> and one for the named interface - // AI: If the primary keys of the Cosmos models match the EFC module, we can use the EFC rules services.AddScoped, LogMessageApiService>(); services.AddScoped(); services.AddScoped, WebRequestMessageApiService>(); services.AddScoped(); + // AI: Register business rules for the module + DomainCreateDateRule.RegisterRule(BusinessRuleRegistry.Instance); + DomainQueryPropertyRenameRule.RegisterRule(BusinessRuleRegistry.Instance, "StorageKey", "Key"); + LogMessageCreateRule.RegisterRule(BusinessRuleRegistry.Instance); + + DomainCreateDateRule.RegisterRule(BusinessRuleRegistry.Instance); + DomainQueryPropertyRenameRule.RegisterRule(BusinessRuleRegistry.Instance, "StorageKey", "Key"); + WebRequestMessageCreateRule.RegisterRule(BusinessRuleRegistry.Instance); + return services; } } diff --git a/src/V1/ServiceBricks.Logging.Cosmos/Mapping/LogMessageMappingProfile.cs b/src/V1/ServiceBricks.Logging.Cosmos/Mapping/LogMessageMappingProfile.cs index c789e1a..7f713f4 100644 --- a/src/V1/ServiceBricks.Logging.Cosmos/Mapping/LogMessageMappingProfile.cs +++ b/src/V1/ServiceBricks.Logging.Cosmos/Mapping/LogMessageMappingProfile.cs @@ -15,6 +15,7 @@ public LogMessageMappingProfile() // AI: Add mappings for LogMessageDto and LogMessage CreateMap() .ForMember(x => x.CreateDate, y => y.Ignore()) + .ForMember(x => x.PartitionKey, y => y.Ignore()) .ForMember(x => x.Key, y => y.MapFrom()); CreateMap() diff --git a/src/V1/ServiceBricks.Logging.Cosmos/Mapping/WebRequestMessageMessageMappingProfile.cs b/src/V1/ServiceBricks.Logging.Cosmos/Mapping/WebRequestMessageMessageMappingProfile.cs index cbe52d7..9fcd6cf 100644 --- a/src/V1/ServiceBricks.Logging.Cosmos/Mapping/WebRequestMessageMessageMappingProfile.cs +++ b/src/V1/ServiceBricks.Logging.Cosmos/Mapping/WebRequestMessageMessageMappingProfile.cs @@ -15,6 +15,7 @@ public WebRequestMessageMappingProfile() // AI: Add mappings for WebRequestMessageDto and WebRequestMessage CreateMap() .ForMember(x => x.CreateDate, y => y.Ignore()) + .ForMember(x => x.PartitionKey, y => y.Ignore()) .ForMember(x => x.Key, y => y.MapFrom()); CreateMap() diff --git a/src/V1/ServiceBricks.Logging.Cosmos/Model/LoggingCosmosConstants.cs b/src/V1/ServiceBricks.Logging.Cosmos/Model/LoggingCosmosConstants.cs index ba75719..5fb4393 100644 --- a/src/V1/ServiceBricks.Logging.Cosmos/Model/LoggingCosmosConstants.cs +++ b/src/V1/ServiceBricks.Logging.Cosmos/Model/LoggingCosmosConstants.cs @@ -18,6 +18,16 @@ public static partial class LoggingCosmosConstants /// /// Default Container Name. /// - public const string DEFAULT_CONTAINER_NAME = "Logging"; + public const string CONTAINER_PREFIX = "Logging"; + + /// + /// Get the container name for the given table name. + /// + /// + /// + public static string GetContainerName(string tableName) + { + return CONTAINER_PREFIX + tableName; + } } } \ No newline at end of file diff --git a/src/V1/ServiceBricks.Logging.Cosmos/Model/LoggingCosmosContext.cs b/src/V1/ServiceBricks.Logging.Cosmos/Model/LoggingCosmosContext.cs index 72be5b8..98c3d05 100644 --- a/src/V1/ServiceBricks.Logging.Cosmos/Model/LoggingCosmosContext.cs +++ b/src/V1/ServiceBricks.Logging.Cosmos/Model/LoggingCosmosContext.cs @@ -55,15 +55,16 @@ protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); - // AI: Set the default container name - builder.Model.SetDefaultContainer(LoggingCosmosConstants.DEFAULT_CONTAINER_NAME); - // AI: Create the model for each table builder.Entity().HasKey(p => p.Key); - builder.Entity().Property(p => p.Key).ValueGeneratedOnAdd(); + builder.Entity().HasPartitionKey(p => p.PartitionKey); + builder.Entity().HasIndex(key => new { key.Application, key.Level, key.CreateDate }); + builder.Entity().ToContainer(LoggingCosmosConstants.GetContainerName(nameof(LogMessage))); builder.Entity().HasKey(p => p.Key); - builder.Entity().Property(p => p.Key).ValueGeneratedOnAdd(); + builder.Entity().HasPartitionKey(p => p.PartitionKey); + builder.Entity().HasIndex(key => new { key.Application, key.UserStorageKey, key.CreateDate }); + builder.Entity().ToContainer(LoggingCosmosConstants.GetContainerName(nameof(WebRequestMessage))); } /// diff --git a/src/V1/ServiceBricks.Logging.Cosmos/Rule/LogMessageCreateRule.cs b/src/V1/ServiceBricks.Logging.Cosmos/Rule/LogMessageCreateRule.cs new file mode 100644 index 0000000..6d4cb70 --- /dev/null +++ b/src/V1/ServiceBricks.Logging.Cosmos/Rule/LogMessageCreateRule.cs @@ -0,0 +1,76 @@ +using Microsoft.Extensions.Logging; +using ServiceBricks.Storage.EntityFrameworkCore; + +namespace ServiceBricks.Logging.Cosmos +{ + /// + /// This is a business rule for creating a LogMessage domain object. It will set the Key and PartitionKey. + /// + public sealed class LogMessageCreateRule : BusinessRule + { + private readonly ILogger _logger; + + /// + /// Constructor. + /// + /// + public LogMessageCreateRule(ILoggerFactory loggerFactory) + { + _logger = loggerFactory.CreateLogger(); + Priority = PRIORITY_LOW; + } + + /// + /// Register the business rule to the DomainCreateBeforeEvent. + /// + /// + public static void RegisterRule(IBusinessRuleRegistry registry) + { + registry.RegisterItem( + typeof(DomainCreateBeforeEvent), + typeof(LogMessageCreateRule)); + } + + /// + /// Execute the business rule. + /// + /// + /// + public override IResponse ExecuteRule(IBusinessRuleContext context) + { + var response = new Response(); + + try + { + // AI: Make sure the context object is the correct type + if (context.Object is DomainCreateBeforeEvent e) + { + // AI: Set the Key and PartitionKey + var item = e.DomainObject; + item.Key = Guid.NewGuid(); + + // AI: Set the PartitionKey to be the year, month and day so that the data is partitioned + item.PartitionKey = item.CreateDate.ToString("yyyyMMdd"); + } + } + catch (Exception ex) + { + _logger.LogError(ex, ex.Message); + response.AddMessage(ResponseMessage.CreateError(LocalizationResource.ERROR_BUSINESS_RULE)); + } + + return response; + } + + /// + /// Execute the business rule. + /// + /// + /// + public override Task ExecuteRuleAsync(IBusinessRuleContext context) + { + // AI: There is no async work, so just call the sync method + return Task.FromResult(ExecuteRule(context)); + } + } +} \ No newline at end of file diff --git a/src/V1/ServiceBricks.Logging.Cosmos/Rule/WebRequestMessageCreateRule.cs b/src/V1/ServiceBricks.Logging.Cosmos/Rule/WebRequestMessageCreateRule.cs new file mode 100644 index 0000000..4087745 --- /dev/null +++ b/src/V1/ServiceBricks.Logging.Cosmos/Rule/WebRequestMessageCreateRule.cs @@ -0,0 +1,76 @@ +using Microsoft.Extensions.Logging; +using ServiceBricks.Storage.EntityFrameworkCore; + +namespace ServiceBricks.Logging.Cosmos +{ + /// + /// This is a business rule for creating a WebRequestMessage domain object. It will set the Key and PartitionKey. + /// + public sealed class WebRequestMessageCreateRule : BusinessRule + { + private readonly ILogger _logger; + + /// + /// Constructor. + /// + /// + public WebRequestMessageCreateRule(ILoggerFactory loggerFactory) + { + _logger = loggerFactory.CreateLogger(); + Priority = PRIORITY_LOW; + } + + /// + /// Register the business rule to the DomainCreateBeforeEvent. + /// + /// + public static void RegisterRule(IBusinessRuleRegistry registry) + { + registry.RegisterItem( + typeof(DomainCreateBeforeEvent), + typeof(WebRequestMessageCreateRule)); + } + + /// + /// Execute the business rule. + /// + /// + /// + public override IResponse ExecuteRule(IBusinessRuleContext context) + { + var response = new Response(); + + try + { + // AI: Make sure the context object is the correct type + if (context.Object is DomainCreateBeforeEvent e) + { + // AI: Set the Key and PartitionKey + var item = e.DomainObject; + item.Key = Guid.NewGuid(); + + // AI: Set the PartitionKey to be the year, month and day so that the data is partitioned + item.PartitionKey = item.CreateDate.ToString("yyyyMMdd"); + } + } + catch (Exception ex) + { + _logger.LogError(ex, ex.Message); + response.AddMessage(ResponseMessage.CreateError(LocalizationResource.ERROR_BUSINESS_RULE)); + } + + return response; + } + + /// + /// Execute the business rule. + /// + /// + /// + public override Task ExecuteRuleAsync(IBusinessRuleContext context) + { + // AI: There is no async work, so just call the sync method + return Task.FromResult(ExecuteRule(context)); + } + } +} \ No newline at end of file diff --git a/src/V1/ServiceBricks.Logging.Cosmos/ServiceBricks.Logging.Cosmos.csproj b/src/V1/ServiceBricks.Logging.Cosmos/ServiceBricks.Logging.Cosmos.csproj index 5ce840d..55edc8b 100644 --- a/src/V1/ServiceBricks.Logging.Cosmos/ServiceBricks.Logging.Cosmos.csproj +++ b/src/V1/ServiceBricks.Logging.Cosmos/ServiceBricks.Logging.Cosmos.csproj @@ -1,7 +1,7 @@ - 1.1.0-a + 1.1.0-b ServiceBricks - The open source microservices foundation. Visit https://ServiceBricks.com to learn more. ServiceBricks.Logging.Cosmos holomodular @@ -19,7 +19,7 @@ False git https://github.com/holomodular/ServiceBricks - False + True @@ -29,18 +29,11 @@ - + - - - - - - + + - - - diff --git a/src/V1/ServiceBricks.Logging.Debug/ServiceBricks - Backup.Logging.Debug.csproj b/src/V1/ServiceBricks.Logging.Debug/ServiceBricks - Backup.Logging.Debug.csproj deleted file mode 100644 index f887d50..0000000 --- a/src/V1/ServiceBricks.Logging.Debug/ServiceBricks - Backup.Logging.Debug.csproj +++ /dev/null @@ -1,56 +0,0 @@ - - - - 1.0.4 - ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more. - ServiceBricks.Logging - holomodular - net6.0;net7.0;net8.0 - disable - Copyright © 2023 HoloModular LLC. All Rights Reserved. Visit http://HoloModular.com to learn more. - http://ServiceBricks.com - logo.png - service;bricks;logging - MIT - True - ServiceBricks.Logging.snk - readme.md - enable - False - git - https://github.com/holomodular/ServiceBricks - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/V1/ServiceBricks.Logging.Debug/ServiceBricks.Logging.Debug.csproj b/src/V1/ServiceBricks.Logging.Debug/ServiceBricks.Logging.Debug.csproj index b62b5d1..ede006d 100644 --- a/src/V1/ServiceBricks.Logging.Debug/ServiceBricks.Logging.Debug.csproj +++ b/src/V1/ServiceBricks.Logging.Debug/ServiceBricks.Logging.Debug.csproj @@ -23,7 +23,7 @@ - + @@ -37,7 +37,7 @@ - + diff --git a/src/V1/ServiceBricks.Logging.EntityFrameworkCore.Debug/ServiceBricks - Backup.Logging.EntityFrameworkCore.Debug.csproj b/src/V1/ServiceBricks.Logging.EntityFrameworkCore.Debug/ServiceBricks - Backup.Logging.EntityFrameworkCore.Debug.csproj deleted file mode 100644 index a697635..0000000 --- a/src/V1/ServiceBricks.Logging.EntityFrameworkCore.Debug/ServiceBricks - Backup.Logging.EntityFrameworkCore.Debug.csproj +++ /dev/null @@ -1,44 +0,0 @@ - - - - 1.0.4 - ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more. - ServiceBricks.Logging.EntityFrameworkCore - holomodular - net6.0;net7.0;net8.0 - disable - Copyright © 2023 HoloModular LLC. All Rights Reserved. Visit http://HoloModular.com to learn more. - http://ServiceBricks.com - logo.png - service;bricks;logging;entityframeworkcore;efc - MIT - True - ServiceBricks.Logging.EntityFrameworkCore.snk - readme.md - enable - False - git - https://github.com/holomodular/ServiceBricks - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/V1/ServiceBricks.Logging.EntityFrameworkCore.Debug/ServiceBricks.Logging.EntityFrameworkCore.Debug.csproj b/src/V1/ServiceBricks.Logging.EntityFrameworkCore.Debug/ServiceBricks.Logging.EntityFrameworkCore.Debug.csproj index 48bac77..3f027bd 100644 --- a/src/V1/ServiceBricks.Logging.EntityFrameworkCore.Debug/ServiceBricks.Logging.EntityFrameworkCore.Debug.csproj +++ b/src/V1/ServiceBricks.Logging.EntityFrameworkCore.Debug/ServiceBricks.Logging.EntityFrameworkCore.Debug.csproj @@ -23,7 +23,7 @@ - + diff --git a/src/V1/ServiceBricks.Logging.EntityFrameworkCore/Domain/WebRequestMessage.cs b/src/V1/ServiceBricks.Logging.EntityFrameworkCore/Domain/WebRequestMessage.cs index 9e40b6c..c0b66b8 100644 --- a/src/V1/ServiceBricks.Logging.EntityFrameworkCore/Domain/WebRequestMessage.cs +++ b/src/V1/ServiceBricks.Logging.EntityFrameworkCore/Domain/WebRequestMessage.cs @@ -25,6 +25,11 @@ public partial class WebRequestMessage : EntityFrameworkCoreDomainObject public virtual string Server { get; set; } + /// + /// The User storage key associated with the Request. + /// + public string UserStorageKey { get; set; } + /// /// The Request IP Address. /// @@ -110,11 +115,6 @@ public partial class WebRequestMessage : EntityFrameworkCoreDomainObject public bool? RequestIsHttps { get; set; } - /// - /// The User storage key associated with the Request. - /// - public string RequestUserStorageKey { get; set; } - /// /// The status code of the response. /// diff --git a/src/V1/ServiceBricks.Logging.EntityFrameworkCore/ServiceBricks - Backup.Logging.EntityFrameworkCore.csproj b/src/V1/ServiceBricks.Logging.EntityFrameworkCore/ServiceBricks - Backup.Logging.EntityFrameworkCore.csproj deleted file mode 100644 index 3680455..0000000 --- a/src/V1/ServiceBricks.Logging.EntityFrameworkCore/ServiceBricks - Backup.Logging.EntityFrameworkCore.csproj +++ /dev/null @@ -1,37 +0,0 @@ - - - - 1.0.4 - ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more. - ServiceBricks.Logging.EntityFrameworkCore - holomodular - net6.0;net7.0;net8.0 - disable - Copyright © 2023 HoloModular LLC. All Rights Reserved. Visit http://HoloModular.com to learn more. - http://ServiceBricks.com - logo.png - service;bricks;logging;entityframeworkcore;efc - MIT - True - ServiceBricks.Logging.EntityFrameworkCore.snk - readme.md - enable - False - git - https://github.com/holomodular/ServiceBricks - - - - - True - \ - - - - - - - - - - diff --git a/src/V1/ServiceBricks.Logging.EntityFrameworkCore/ServiceBricks.Logging.EntityFrameworkCore.csproj b/src/V1/ServiceBricks.Logging.EntityFrameworkCore/ServiceBricks.Logging.EntityFrameworkCore.csproj index ce3b717..a5ab5a8 100644 --- a/src/V1/ServiceBricks.Logging.EntityFrameworkCore/ServiceBricks.Logging.EntityFrameworkCore.csproj +++ b/src/V1/ServiceBricks.Logging.EntityFrameworkCore/ServiceBricks.Logging.EntityFrameworkCore.csproj @@ -1,7 +1,7 @@ - 1.1.0-a + 1.1.0-b ServiceBricks - The open source microservices foundation. Visit https://ServiceBricks.com to learn more. ServiceBricks.Logging.EntityFrameworkCore holomodular @@ -19,7 +19,7 @@ False git https://github.com/holomodular/ServiceBricks - False + True @@ -29,10 +29,10 @@ - + - + diff --git a/src/V1/ServiceBricks.Logging.InMemory.Debug/ServiceBricks - Backup.Logging.InMemory.Debug.csproj b/src/V1/ServiceBricks.Logging.InMemory.Debug/ServiceBricks - Backup.Logging.InMemory.Debug.csproj deleted file mode 100644 index 49a7e41..0000000 --- a/src/V1/ServiceBricks.Logging.InMemory.Debug/ServiceBricks - Backup.Logging.InMemory.Debug.csproj +++ /dev/null @@ -1,47 +0,0 @@ - - - - 1.0.4 - ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more. - ServiceBricks.Logging.InMemory - holomodular - net6.0;net7.0;net8.0 - disable - Copyright © 2023 HoloModular LLC. All Rights Reserved. Visit http://HoloModular.com to learn more. - http://ServiceBricks.com - logo.png - service;bricks;logging;inmemory - MIT - True - ServiceBricks.Logging.InMemory.snk - readme.md - enable - False - git - https://github.com/holomodular/ServiceBricks - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/V1/ServiceBricks.Logging.InMemory.Debug/ServiceBricks.Logging.InMemory.Debug.csproj b/src/V1/ServiceBricks.Logging.InMemory.Debug/ServiceBricks.Logging.InMemory.Debug.csproj index 8ba88ff..1d4051e 100644 --- a/src/V1/ServiceBricks.Logging.InMemory.Debug/ServiceBricks.Logging.InMemory.Debug.csproj +++ b/src/V1/ServiceBricks.Logging.InMemory.Debug/ServiceBricks.Logging.InMemory.Debug.csproj @@ -17,16 +17,9 @@ - - - - - - - - - - - + + + + diff --git a/src/V1/ServiceBricks.Logging.InMemory/Model/LoggingInMemoryContext.cs b/src/V1/ServiceBricks.Logging.InMemory/Model/LoggingInMemoryContext.cs index e745dee..ee3af05 100644 --- a/src/V1/ServiceBricks.Logging.InMemory/Model/LoggingInMemoryContext.cs +++ b/src/V1/ServiceBricks.Logging.InMemory/Model/LoggingInMemoryContext.cs @@ -54,8 +54,10 @@ protected override void OnModelCreating(ModelBuilder builder) // AI: Setup the entities to the model builder.Entity().HasKey(key => key.Key); + builder.Entity().HasIndex(key => new { key.Application, key.Level, key.CreateDate }); builder.Entity().HasKey(key => key.Key); + builder.Entity().HasIndex(key => new { key.Application, key.UserStorageKey, key.CreateDate }); } /// diff --git a/src/V1/ServiceBricks.Logging.InMemory/ServiceBricks - Backup (1).Logging.InMemory.csproj b/src/V1/ServiceBricks.Logging.InMemory/ServiceBricks - Backup (1).Logging.InMemory.csproj deleted file mode 100644 index 32b8da6..0000000 --- a/src/V1/ServiceBricks.Logging.InMemory/ServiceBricks - Backup (1).Logging.InMemory.csproj +++ /dev/null @@ -1,46 +0,0 @@ - - - - 1.0.6 - ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more. - ServiceBricks.Logging.InMemory - holomodular - net6.0;net7.0;net8.0 - disable - Copyright © 2023 HoloModular LLC. All Rights Reserved. Visit http://HoloModular.com to learn more. - http://ServiceBricks.com - logo.png - service;bricks;logging;inmemory - MIT - True - ServiceBricks.Logging.InMemory.snk - readme.md - enable - False - git - https://github.com/holomodular/ServiceBricks - - - - - True - \ - - - - - - - - - - - - - - - - - - - diff --git a/src/V1/ServiceBricks.Logging.InMemory/ServiceBricks - Backup.Logging.InMemory.csproj b/src/V1/ServiceBricks.Logging.InMemory/ServiceBricks - Backup.Logging.InMemory.csproj deleted file mode 100644 index b8a9a66..0000000 --- a/src/V1/ServiceBricks.Logging.InMemory/ServiceBricks - Backup.Logging.InMemory.csproj +++ /dev/null @@ -1,46 +0,0 @@ - - - - 1.0.4 - ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more. - ServiceBricks.Logging.InMemory - holomodular - net6.0;net7.0;net8.0 - disable - Copyright © 2023 HoloModular LLC. All Rights Reserved. Visit http://HoloModular.com to learn more. - http://ServiceBricks.com - logo.png - service;bricks;logging;inmemory - MIT - True - ServiceBricks.Logging.InMemory.snk - readme.md - enable - False - git - https://github.com/holomodular/ServiceBricks - - - - - True - \ - - - - - - - - - - - - - - - - - - - diff --git a/src/V1/ServiceBricks.Logging.InMemory/ServiceBricks.Logging.InMemory.csproj b/src/V1/ServiceBricks.Logging.InMemory/ServiceBricks.Logging.InMemory.csproj index 56e217f..9c8002c 100644 --- a/src/V1/ServiceBricks.Logging.InMemory/ServiceBricks.Logging.InMemory.csproj +++ b/src/V1/ServiceBricks.Logging.InMemory/ServiceBricks.Logging.InMemory.csproj @@ -1,7 +1,7 @@ - 1.1.0-a + 1.1.0-b ServiceBricks - The open source microservices foundation. Visit https://ServiceBricks.com to learn more. ServiceBricks.Logging.InMemory holomodular @@ -19,7 +19,7 @@ False git https://github.com/holomodular/ServiceBricks - False + True @@ -28,20 +28,14 @@ \ - - - - - - + + + - - + + - - - - + diff --git a/src/V1/ServiceBricks.Logging.MongoDb.Debug/ServiceBricks - Backup.Logging.MongoDb.Debug.csproj b/src/V1/ServiceBricks.Logging.MongoDb.Debug/ServiceBricks - Backup.Logging.MongoDb.Debug.csproj deleted file mode 100644 index f31c778..0000000 --- a/src/V1/ServiceBricks.Logging.MongoDb.Debug/ServiceBricks - Backup.Logging.MongoDb.Debug.csproj +++ /dev/null @@ -1,44 +0,0 @@ - - - - 1.0.4 - ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more. - ServiceBricks.Logging.MongoDb - holomodular - net6.0;net7.0;net8.0 - disable - Copyright © 2023 HoloModular LLC. All Rights Reserved. Visit http://HoloModular.com to learn more. - http://ServiceBricks.com - logo.png - service;bricks;logging;mongo;mongodb - MIT - True - ServiceBricks.Logging.MongoDb.snk - readme.md - enable - False - git - https://github.com/holomodular/ServiceBricks - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/V1/ServiceBricks.Logging.MongoDb.Debug/ServiceBricks.Logging.MongoDb.Debug.csproj b/src/V1/ServiceBricks.Logging.MongoDb.Debug/ServiceBricks.Logging.MongoDb.Debug.csproj index ac6523a..a19fbbe 100644 --- a/src/V1/ServiceBricks.Logging.MongoDb.Debug/ServiceBricks.Logging.MongoDb.Debug.csproj +++ b/src/V1/ServiceBricks.Logging.MongoDb.Debug/ServiceBricks.Logging.MongoDb.Debug.csproj @@ -21,7 +21,7 @@ - + diff --git a/src/V1/ServiceBricks.Logging.MongoDb/Domain/WebRequestMessage.cs b/src/V1/ServiceBricks.Logging.MongoDb/Domain/WebRequestMessage.cs index dfd10f5..b4c0fe0 100644 --- a/src/V1/ServiceBricks.Logging.MongoDb/Domain/WebRequestMessage.cs +++ b/src/V1/ServiceBricks.Logging.MongoDb/Domain/WebRequestMessage.cs @@ -32,6 +32,11 @@ public partial class WebRequestMessage : MongoDbDomainObject, /// public virtual string Server { get; set; } + /// + /// The User storage key associated with the Request. + /// + public string UserStorageKey { get; set; } + /// /// The Request IP Address. /// @@ -117,11 +122,6 @@ public partial class WebRequestMessage : MongoDbDomainObject, /// public bool? RequestIsHttps { get; set; } - /// - /// The User storage key associated with the Request. - /// - public string RequestUserStorageKey { get; set; } - /// /// The status code of the response. /// diff --git a/src/V1/ServiceBricks.Logging.MongoDb/ServiceBricks - Backup.Logging.MongoDb.csproj b/src/V1/ServiceBricks.Logging.MongoDb/ServiceBricks - Backup.Logging.MongoDb.csproj deleted file mode 100644 index 30fa14d..0000000 --- a/src/V1/ServiceBricks.Logging.MongoDb/ServiceBricks - Backup.Logging.MongoDb.csproj +++ /dev/null @@ -1,36 +0,0 @@ - - - - 1.0.4 - ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more. - ServiceBricks.Logging.MongoDb - holomodular - net6.0;net7.0;net8.0 - disable - Copyright © 2023 HoloModular LLC. All Rights Reserved. Visit http://HoloModular.com to learn more. - http://ServiceBricks.com - logo.png - service;bricks;logging;mongo;mongodb - MIT - True - ServiceBricks.Logging.MongoDb.snk - readme.md - enable - False - git - https://github.com/holomodular/ServiceBricks - - - - - True - \ - - - - - - - - - diff --git a/src/V1/ServiceBricks.Logging.MongoDb/ServiceBricks.Logging.MongoDb.csproj b/src/V1/ServiceBricks.Logging.MongoDb/ServiceBricks.Logging.MongoDb.csproj index e5e6d43..c160cd4 100644 --- a/src/V1/ServiceBricks.Logging.MongoDb/ServiceBricks.Logging.MongoDb.csproj +++ b/src/V1/ServiceBricks.Logging.MongoDb/ServiceBricks.Logging.MongoDb.csproj @@ -1,7 +1,7 @@ - 1.1.0-a + 1.1.0-b ServiceBricks - The open source microservices foundation. Visit https://ServiceBricks.com to learn more. ServiceBricks.Logging.MongoDb holomodular @@ -19,7 +19,7 @@ False git https://github.com/holomodular/ServiceBricks - False + True @@ -29,7 +29,7 @@ - - + + diff --git a/src/V1/ServiceBricks.Logging.Postgres.Debug/ServiceBricks - Backup.Logging.Postgres.Debug.csproj b/src/V1/ServiceBricks.Logging.Postgres.Debug/ServiceBricks - Backup.Logging.Postgres.Debug.csproj deleted file mode 100644 index b8c53e5..0000000 --- a/src/V1/ServiceBricks.Logging.Postgres.Debug/ServiceBricks - Backup.Logging.Postgres.Debug.csproj +++ /dev/null @@ -1,49 +0,0 @@ - - - - 1.0.4 - ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more. - ServiceBricks.Logging.Postgres - holomodular - net6.0;net7.0;net8.0 - disable - Copyright © 2023 HoloModular LLC. All Rights Reserved. Visit http://HoloModular.com to learn more. - http://ServiceBricks.com - logo.png - service;bricks;logging;postgres;postgresql - MIT - True - ServiceBricks.Logging.Postgres.snk - readme.md - enable - False - git - https://github.com/holomodular/ServiceBricks - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/V1/ServiceBricks.Logging.Postgres.Debug/ServiceBricks.Logging.Postgres.Debug.csproj b/src/V1/ServiceBricks.Logging.Postgres.Debug/ServiceBricks.Logging.Postgres.Debug.csproj index 3f18148..9ed2222 100644 --- a/src/V1/ServiceBricks.Logging.Postgres.Debug/ServiceBricks.Logging.Postgres.Debug.csproj +++ b/src/V1/ServiceBricks.Logging.Postgres.Debug/ServiceBricks.Logging.Postgres.Debug.csproj @@ -20,15 +20,7 @@ - - - - - - - - - - + + diff --git a/src/V1/ServiceBricks.Logging.Postgres/Model/LoggingPostgresContext.cs b/src/V1/ServiceBricks.Logging.Postgres/Model/LoggingPostgresContext.cs index b9e8558..6fdf6ed 100644 --- a/src/V1/ServiceBricks.Logging.Postgres/Model/LoggingPostgresContext.cs +++ b/src/V1/ServiceBricks.Logging.Postgres/Model/LoggingPostgresContext.cs @@ -5,7 +5,7 @@ namespace ServiceBricks.Logging.Postgres { - // dotnet ef migrations add LoggingV1 --context LoggingPostgresContext --startup-project ../Test/MigrationsHost + // dotnet ef migrations add LoggingV1 --context LoggingPostgresContext --startup-project ../Tests/MigrationsHost /// /// The database context for the ServiceBricks Logging Postgres module. @@ -63,27 +63,21 @@ protected override void OnModelCreating(ModelBuilder builder) builder.HasDefaultSchema(LoggingPostgresConstants.DATABASE_SCHEMA_NAME); // AI: Set up the table definitions - builder.Entity().ToTable("LogMessage").HasKey(key => key.Key); + builder.Entity().HasKey(key => key.Key); + builder.Entity().HasIndex(key => new { key.Application, key.Level, key.CreateDate }); - builder.Entity().ToTable("WebRequestMessage").HasKey(key => key.Key); + builder.Entity().HasKey(key => key.Key); + builder.Entity().HasIndex(key => new { key.Application, key.UserStorageKey, key.CreateDate }); } /// - /// OnConfiguring. + /// Create context. /// - /// - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + /// + /// + public virtual LoggingPostgresContext CreateDbContext(string[] args) { - if (!optionsBuilder.IsConfigured) - { - IConfigurationRoot configuration = new ConfigurationBuilder().AddAppSettingsConfig().Build(); - string connectionString = configuration.GetPostgresConnectionString(LoggingPostgresConstants.APPSETTING_CONNECTION_STRING); - optionsBuilder.UseNpgsql(connectionString, x => - { - x.MigrationsAssembly(typeof(LoggingPostgresContext).Assembly.GetName().Name); - x.EnableRetryOnFailure(); - }); - } + return new LoggingPostgresContext(_options); } } } \ No newline at end of file diff --git a/src/V1/ServiceBricks.Logging.Postgres/ServiceBricks - Backup (1).Logging.Postgres.csproj b/src/V1/ServiceBricks.Logging.Postgres/ServiceBricks - Backup (1).Logging.Postgres.csproj deleted file mode 100644 index 7c38674..0000000 --- a/src/V1/ServiceBricks.Logging.Postgres/ServiceBricks - Backup (1).Logging.Postgres.csproj +++ /dev/null @@ -1,47 +0,0 @@ - - - - 1.0.6 - ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more. - ServiceBricks.Logging.Postgres - holomodular - net6.0;net7.0;net8.0 - disable - Copyright © 2023 HoloModular LLC. All Rights Reserved. Visit http://HoloModular.com to learn more. - http://ServiceBricks.com - logo.png - service;bricks;logging;postgres;postgresql - MIT - True - ServiceBricks.Logging.Postgres.snk - readme.md - enable - False - git - https://github.com/holomodular/ServiceBricks - - - - - - True - \ - - - - - - - - - - - - - - - - - - - diff --git a/src/V1/ServiceBricks.Logging.Postgres/ServiceBricks - Backup.Logging.Postgres.csproj b/src/V1/ServiceBricks.Logging.Postgres/ServiceBricks - Backup.Logging.Postgres.csproj deleted file mode 100644 index 645107f..0000000 --- a/src/V1/ServiceBricks.Logging.Postgres/ServiceBricks - Backup.Logging.Postgres.csproj +++ /dev/null @@ -1,47 +0,0 @@ - - - - 1.0.4 - ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more. - ServiceBricks.Logging.Postgres - holomodular - net6.0;net7.0;net8.0 - disable - Copyright © 2023 HoloModular LLC. All Rights Reserved. Visit http://HoloModular.com to learn more. - http://ServiceBricks.com - logo.png - service;bricks;logging;postgres;postgresql - MIT - True - ServiceBricks.Logging.Postgres.snk - readme.md - enable - False - git - https://github.com/holomodular/ServiceBricks - - - - - - True - \ - - - - - - - - - - - - - - - - - - - diff --git a/src/V1/ServiceBricks.Logging.Postgres/ServiceBricks.Logging.Postgres.csproj b/src/V1/ServiceBricks.Logging.Postgres/ServiceBricks.Logging.Postgres.csproj index 32bb54c..ef86537 100644 --- a/src/V1/ServiceBricks.Logging.Postgres/ServiceBricks.Logging.Postgres.csproj +++ b/src/V1/ServiceBricks.Logging.Postgres/ServiceBricks.Logging.Postgres.csproj @@ -1,7 +1,7 @@ - 1.1.0-a + 1.1.0-b ServiceBricks - The open source microservices foundation. Visit https://ServiceBricks.com to learn more. ServiceBricks.Logging.Postgres holomodular @@ -19,7 +19,7 @@ False git https://github.com/holomodular/ServiceBricks - False + True @@ -31,18 +31,11 @@ - + - - - - - - - - - - + + + diff --git a/src/V1/ServiceBricks.Logging.SqlServer.Debug/ServiceBricks - Backup.Logging.SqlServer.Debug.csproj b/src/V1/ServiceBricks.Logging.SqlServer.Debug/ServiceBricks - Backup.Logging.SqlServer.Debug.csproj deleted file mode 100644 index 658ca70..0000000 --- a/src/V1/ServiceBricks.Logging.SqlServer.Debug/ServiceBricks - Backup.Logging.SqlServer.Debug.csproj +++ /dev/null @@ -1,48 +0,0 @@ - - - - 1.0.4 - ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more. - ServiceBricks.Logging.SqlServer - holomodular - net6.0;net7.0;net8.0 - disable - Copyright © 2023 HoloModular LLC. All Rights Reserved. Visit http://HoloModular.com to learn more. - http://ServiceBricks.com - logo.png - service;bricks;logging;sql;sqlserver - MIT - True - ServiceBricks.Logging.SqlServer.snk - readme.md - enable - False - git - https://github.com/holomodular/ServiceBricks - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/V1/ServiceBricks.Logging.SqlServer.Debug/ServiceBricks.Logging.SqlServer.Debug.csproj b/src/V1/ServiceBricks.Logging.SqlServer.Debug/ServiceBricks.Logging.SqlServer.Debug.csproj index c549bc8..3f90163 100644 --- a/src/V1/ServiceBricks.Logging.SqlServer.Debug/ServiceBricks.Logging.SqlServer.Debug.csproj +++ b/src/V1/ServiceBricks.Logging.SqlServer.Debug/ServiceBricks.Logging.SqlServer.Debug.csproj @@ -19,15 +19,8 @@ - - - - - - + + - - - diff --git a/src/V1/ServiceBricks.Logging.SqlServer/Model/LoggingSqlServerContext.cs b/src/V1/ServiceBricks.Logging.SqlServer/Model/LoggingSqlServerContext.cs index afa4320..d3b77db 100644 --- a/src/V1/ServiceBricks.Logging.SqlServer/Model/LoggingSqlServerContext.cs +++ b/src/V1/ServiceBricks.Logging.SqlServer/Model/LoggingSqlServerContext.cs @@ -5,7 +5,7 @@ namespace ServiceBricks.Logging.SqlServer { - // dotnet ef migrations add LoggingV1 --context LoggingSqlServerContext --startup-project ../Test/MigrationsHost + // dotnet ef migrations add LoggingV1 --context LoggingSqlServerContext --startup-project ../Tests/MigrationsHost /// /// The database context for the ServiceBricks.Logging.SqlServer module. @@ -65,9 +65,11 @@ protected override void OnModelCreating(ModelBuilder builder) builder.HasDefaultSchema(LoggingSqlServerConstants.DATABASE_SCHEMA_NAME); // AI: Setup the entities to the model - builder.Entity().ToTable("LogMessage").HasKey(key => key.Key); + builder.Entity().HasKey(key => key.Key); + builder.Entity().HasIndex(key => new { key.Application, key.Level, key.CreateDate }); - builder.Entity().ToTable("WebRequestMessage").HasKey(key => key.Key); + builder.Entity().HasKey(key => key.Key); + builder.Entity().HasIndex(key => new { key.Application, key.UserStorageKey, key.CreateDate }); } /// diff --git a/src/V1/ServiceBricks.Logging.SqlServer/ServiceBricks - Backup (1).Logging.SqlServer.csproj b/src/V1/ServiceBricks.Logging.SqlServer/ServiceBricks - Backup (1).Logging.SqlServer.csproj deleted file mode 100644 index 88de1ab..0000000 --- a/src/V1/ServiceBricks.Logging.SqlServer/ServiceBricks - Backup (1).Logging.SqlServer.csproj +++ /dev/null @@ -1,47 +0,0 @@ - - - - 1.0.6 - ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more. - ServiceBricks.Logging.SqlServer - holomodular - net6.0;net7.0;net8.0 - disable - Copyright © 2023 HoloModular LLC. All Rights Reserved. Visit http://HoloModular.com to learn more. - http://ServiceBricks.com - logo.png - service;bricks;logging;sql;sqlserver - MIT - True - ServiceBricks.Logging.SqlServer.snk - readme.md - enable - False - git - https://github.com/holomodular/ServiceBricks - - - - - True - \ - - - - - - - - - - - - - - - - - - - - diff --git a/src/V1/ServiceBricks.Logging.SqlServer/ServiceBricks - Backup.Logging.SqlServer.csproj b/src/V1/ServiceBricks.Logging.SqlServer/ServiceBricks - Backup.Logging.SqlServer.csproj deleted file mode 100644 index 31a3011..0000000 --- a/src/V1/ServiceBricks.Logging.SqlServer/ServiceBricks - Backup.Logging.SqlServer.csproj +++ /dev/null @@ -1,47 +0,0 @@ - - - - 1.0.4 - ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more. - ServiceBricks.Logging.SqlServer - holomodular - net6.0;net7.0;net8.0 - disable - Copyright © 2023 HoloModular LLC. All Rights Reserved. Visit http://HoloModular.com to learn more. - http://ServiceBricks.com - logo.png - service;bricks;logging;sql;sqlserver - MIT - True - ServiceBricks.Logging.SqlServer.snk - readme.md - enable - False - git - https://github.com/holomodular/ServiceBricks - - - - - True - \ - - - - - - - - - - - - - - - - - - - - diff --git a/src/V1/ServiceBricks.Logging.SqlServer/ServiceBricks.Logging.SqlServer.csproj b/src/V1/ServiceBricks.Logging.SqlServer/ServiceBricks.Logging.SqlServer.csproj index 7c94ff2..26e1ff9 100644 --- a/src/V1/ServiceBricks.Logging.SqlServer/ServiceBricks.Logging.SqlServer.csproj +++ b/src/V1/ServiceBricks.Logging.SqlServer/ServiceBricks.Logging.SqlServer.csproj @@ -1,7 +1,7 @@ - 1.1.0-a + 1.1.0-b ServiceBricks - The open source microservices foundation. Visit https://ServiceBricks.com to learn more. ServiceBricks.Logging.SqlServer holomodular @@ -19,7 +19,7 @@ False git https://github.com/holomodular/ServiceBricks - False + True @@ -30,19 +30,11 @@ - + - - - - - - - - - - + + diff --git a/src/V1/ServiceBricks.Logging.Sqlite.Debug/ServiceBricks - Backup.Logging.Sqlite.Debug.csproj b/src/V1/ServiceBricks.Logging.Sqlite.Debug/ServiceBricks - Backup.Logging.Sqlite.Debug.csproj deleted file mode 100644 index 1db45ab..0000000 --- a/src/V1/ServiceBricks.Logging.Sqlite.Debug/ServiceBricks - Backup.Logging.Sqlite.Debug.csproj +++ /dev/null @@ -1,49 +0,0 @@ - - - - 1.0.4 - ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more. - ServiceBricks.Logging.Sqlite - holomodular - net6.0;net7.0;net8.0 - disable - Copyright © 2023 HoloModular LLC. All Rights Reserved. Visit http://HoloModular.com to learn more. - http://ServiceBricks.com - logo.png - service;bricks;logging;sqlite - MIT - True - ServiceBricks.Logging.Sqlite.snk - readme.md - enable - False - git - https://github.com/holomodular/ServiceBricks - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/V1/ServiceBricks.Logging.Sqlite.Debug/ServiceBricks.Logging.Sqlite.Debug.csproj b/src/V1/ServiceBricks.Logging.Sqlite.Debug/ServiceBricks.Logging.Sqlite.Debug.csproj index b7516b7..140c2a5 100644 --- a/src/V1/ServiceBricks.Logging.Sqlite.Debug/ServiceBricks.Logging.Sqlite.Debug.csproj +++ b/src/V1/ServiceBricks.Logging.Sqlite.Debug/ServiceBricks.Logging.Sqlite.Debug.csproj @@ -19,16 +19,8 @@ - - - - - - - - - - + + diff --git a/src/V1/ServiceBricks.Logging.Sqlite/Model/LoggingSqliteContext.cs b/src/V1/ServiceBricks.Logging.Sqlite/Model/LoggingSqliteContext.cs index 154db8b..f5dc04f 100644 --- a/src/V1/ServiceBricks.Logging.Sqlite/Model/LoggingSqliteContext.cs +++ b/src/V1/ServiceBricks.Logging.Sqlite/Model/LoggingSqliteContext.cs @@ -6,7 +6,7 @@ namespace ServiceBricks.Logging.Sqlite { - // dotnet ef migrations add LoggingV1 --context LoggingSqliteContext --startup-project ../Test/MigrationsHost + // dotnet ef migrations add LoggingV1 --context LoggingSqliteContext --startup-project ../Tests/MigrationsHost /// /// The database context for the ServiceBricks.Logging.Sqlite module. @@ -59,12 +59,17 @@ public LoggingSqliteContext(DbContextOptions options) : ba /// protected override void OnModelCreating(ModelBuilder builder) { - //Set default schema - builder.HasDefaultSchema(LoggingSqliteConstants.DATABASE_SCHEMA_NAME); + base.OnModelCreating(builder); - builder.Entity().ToTable("LogMessage").HasKey(key => key.Key); + // AI: Set the default schema (SQLite does not support schemas) + //builder.HasDefaultSchema(LoggingSqliteConstants.DATABASE_SCHEMA_NAME); - builder.Entity().ToTable("WebRequestMessage").HasKey(key => key.Key); + // AI: Setup the entities to the model + builder.Entity().HasKey(key => key.Key); + builder.Entity().HasIndex(key => new { key.Application, key.Level, key.CreateDate }); + + builder.Entity().HasKey(key => key.Key); + builder.Entity().HasIndex(key => new { key.Application, key.UserStorageKey, key.CreateDate }); } /// @@ -73,8 +78,6 @@ protected override void OnModelCreating(ModelBuilder builder) /// protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder) { - base.ConfigureConventions(configurationBuilder); - configurationBuilder .Properties() .HaveConversion(); diff --git a/src/V1/ServiceBricks.Logging.Sqlite/ServiceBricks - Backup (1).Logging.Sqlite.csproj b/src/V1/ServiceBricks.Logging.Sqlite/ServiceBricks - Backup (1).Logging.Sqlite.csproj deleted file mode 100644 index 6b870ae..0000000 --- a/src/V1/ServiceBricks.Logging.Sqlite/ServiceBricks - Backup (1).Logging.Sqlite.csproj +++ /dev/null @@ -1,47 +0,0 @@ - - - - 1.0.6 - ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more. - ServiceBricks.Logging.Sqlite - holomodular - net6.0;net7.0;net8.0 - disable - Copyright © 2023 HoloModular LLC. All Rights Reserved. Visit http://HoloModular.com to learn more. - http://ServiceBricks.com - logo.png - service;bricks;logging;sqlite - MIT - True - ServiceBricks.Logging.Sqlite.snk - readme.md - enable - False - git - https://github.com/holomodular/ServiceBricks - - - - - True - \ - - - - - - - - - - - - - - - - - - - - diff --git a/src/V1/ServiceBricks.Logging.Sqlite/ServiceBricks - Backup.Logging.Sqlite.csproj b/src/V1/ServiceBricks.Logging.Sqlite/ServiceBricks - Backup.Logging.Sqlite.csproj deleted file mode 100644 index 9961654..0000000 --- a/src/V1/ServiceBricks.Logging.Sqlite/ServiceBricks - Backup.Logging.Sqlite.csproj +++ /dev/null @@ -1,47 +0,0 @@ - - - - 1.0.4 - ServiceBricks is the cornerstone for building a microservices foundation. Visit http://ServiceBricks.com to learn more. - ServiceBricks.Logging.Sqlite - holomodular - net6.0;net7.0;net8.0 - disable - Copyright © 2023 HoloModular LLC. All Rights Reserved. Visit http://HoloModular.com to learn more. - http://ServiceBricks.com - logo.png - service;bricks;logging;sqlite - MIT - True - ServiceBricks.Logging.Sqlite.snk - readme.md - enable - False - git - https://github.com/holomodular/ServiceBricks - - - - - True - \ - - - - - - - - - - - - - - - - - - - - diff --git a/src/V1/ServiceBricks.Logging.Sqlite/ServiceBricks.Logging.Sqlite.csproj b/src/V1/ServiceBricks.Logging.Sqlite/ServiceBricks.Logging.Sqlite.csproj index 445f486..84b2d56 100644 --- a/src/V1/ServiceBricks.Logging.Sqlite/ServiceBricks.Logging.Sqlite.csproj +++ b/src/V1/ServiceBricks.Logging.Sqlite/ServiceBricks.Logging.Sqlite.csproj @@ -1,7 +1,7 @@ - 1.1.0-a + 1.1.0-b ServiceBricks - The open source microservices foundation. Visit https://ServiceBricks.com to learn more. ServiceBricks.Logging.Sqlite holomodular @@ -19,7 +19,7 @@ False git https://github.com/holomodular/ServiceBricks - False + True @@ -30,19 +30,11 @@ - + - - - - - - - - - - + + diff --git a/src/V1/ServiceBricks.Logging/Api/WebRequestMessageDto.cs b/src/V1/ServiceBricks.Logging/Api/WebRequestMessageDto.cs index 0fe1a6d..dd512da 100644 --- a/src/V1/ServiceBricks.Logging/Api/WebRequestMessageDto.cs +++ b/src/V1/ServiceBricks.Logging/Api/WebRequestMessageDto.cs @@ -20,6 +20,11 @@ public partial class WebRequestMessageDto : DataTransferObject /// public virtual string Server { get; set; } + /// + /// The User storage key associated with the Request. + /// + public virtual string UserStorageKey { get; set; } + /// /// The Request IP Address. /// @@ -105,11 +110,6 @@ public partial class WebRequestMessageDto : DataTransferObject /// public virtual bool? RequestIsHttps { get; set; } - /// - /// The User storage key associated with the Request. - /// - public virtual string RequestUserStorageKey { get; set; } - /// /// The status code of the response. /// diff --git a/src/V1/ServiceBricks.Logging/Middleware/CustomLoggerMiddleware.cs b/src/V1/ServiceBricks.Logging/Middleware/LogMessageMiddleware.cs similarity index 96% rename from src/V1/ServiceBricks.Logging/Middleware/CustomLoggerMiddleware.cs rename to src/V1/ServiceBricks.Logging/Middleware/LogMessageMiddleware.cs index 05d2db0..c6db69c 100644 --- a/src/V1/ServiceBricks.Logging/Middleware/CustomLoggerMiddleware.cs +++ b/src/V1/ServiceBricks.Logging/Middleware/LogMessageMiddleware.cs @@ -7,17 +7,17 @@ namespace ServiceBricks.Logging /// /// This is a custom logger middleware component used to add http request properties to the request pipeline. /// - public sealed class CustomLoggerMiddleware + public sealed class LogMessageMiddleware { private readonly RequestDelegate _next; - private readonly ILogger _logger; + private readonly ILogger _logger; /// /// Constructor. /// /// /// - public CustomLoggerMiddleware(RequestDelegate next, ILogger logger) + public LogMessageMiddleware(RequestDelegate next, ILogger logger) { _logger = logger; _next = next; diff --git a/src/V1/ServiceBricks.Logging/Middleware/WebRequestMessageMiddleware.cs b/src/V1/ServiceBricks.Logging/Middleware/WebRequestMessageMiddleware.cs index 645693e..118ff6d 100644 --- a/src/V1/ServiceBricks.Logging/Middleware/WebRequestMessageMiddleware.cs +++ b/src/V1/ServiceBricks.Logging/Middleware/WebRequestMessageMiddleware.cs @@ -110,7 +110,7 @@ private async Task WriteMessage(HttpContext context, Exception exception) // AI: Get IP Address string ipaddress = null; - if (context.Connection != null) + if (context.Connection != null && context.Connection.RemoteIpAddress != null) { ipaddress = context.Connection.RemoteIpAddress.ToString(); if (ipaddress == LoggingConstants.IPADDRESS_LOCAL_SHORT) @@ -121,13 +121,9 @@ private async Task WriteMessage(HttpContext context, Exception exception) if (!_webRequestOptions.EnableLocalIpRequests && ipaddress == LoggingConstants.IPADDRESS_LOCAL_FULL) return; - // AI: Check options if we should log the request IP address - if (!_webRequestOptions.EnableRequestIPAddress) - ipaddress = null; - // AI: Check options if we should log the user associated with the request string userId = null; - if (_webRequestOptions.EnableRequestUserId && context.User != null && context.User.Claims != null) + if (_webRequestOptions.EnableUserStorageKey && context.User != null && context.User.Claims != null) { var claim = context.User.Claims.Where(x => x.Type == System.Security.Claims.ClaimTypes.NameIdentifier).FirstOrDefault(); if (claim != null) @@ -147,7 +143,8 @@ await _webRequestMessageApiService.CreateAsync(new WebRequestMessageDto() CreateDate = DateTimeOffset.UtcNow, Application = _applicationOptions.Name, Server = System.Net.Dns.GetHostName(), - RequestIPAddress = ipaddress, + UserStorageKey = _webRequestOptions.EnableUserStorageKey ? userId : null, + RequestIPAddress = _webRequestOptions.EnableRequestIPAddress ? ipaddress : null, RequestBody = _webRequestOptions.EnableRequestBody || (_webRequestOptions.EnableRequestBodyOnError && exception != null) ? _requestBody : null, RequestContentLength = _webRequestOptions.EnableRequestContentLength ? context.Request.ContentLength : null, RequestContentType = _webRequestOptions.EnableRequestContentType ? context.Request.ContentType : null, @@ -155,7 +152,7 @@ await _webRequestMessageApiService.CreateAsync(new WebRequestMessageDto() RequestHasFormContentType = _webRequestOptions.EnableRequestHasFormContentType ? context.Request.HasFormContentType : new Nullable(), RequestHeaders = _webRequestOptions.EnableRequestHeaders && context.Request.Headers != null ? JsonConvert.SerializeObject(context.Request.Headers) : null, RequestHost = _webRequestOptions.EnableRequestHost ? JsonConvert.SerializeObject(context.Request.Host) : null, - RequestIsHttps = _webRequestOptions.EnableRequestIsHttps ? context.Request.IsHttps : new Nullable(), + RequestIsHttps = _webRequestOptions.EnableRequestIsHttps ? context.Request.IsHttps : null, RequestMethod = _webRequestOptions.EnableRequestMethod ? context.Request.Method : null, RequestPath = _webRequestOptions.EnableRequestPath && context.Request.Path.HasValue ? context.Request.Path.Value : null, RequestPathBase = _webRequestOptions.EnableRequestPathBase && context.Request.PathBase.HasValue ? context.Request.PathBase.Value : null, @@ -164,7 +161,6 @@ await _webRequestMessageApiService.CreateAsync(new WebRequestMessageDto() RequestQueryString = _webRequestOptions.EnableRequestQueryString && context.Request.QueryString.HasValue ? context.Request.QueryString.Value : null, RequestRouteValues = _webRequestOptions.EnableRequestRouteValues && context.Request.RouteValues != null ? JsonConvert.SerializeObject(context.Request.RouteValues) : null, RequestScheme = _webRequestOptions.EnableRequestScheme ? context.Request.Scheme : null, - RequestUserStorageKey = _webRequestOptions.EnableRequestUserId ? userId : null, ResponseBody = _webRequestOptions.EnableResponseBody ? _responseBody : null, ResponseContentLength = responseContentLength, ResponseContentType = _webRequestOptions.EnableResponseContentType ? context.Response.ContentType : null, diff --git a/src/V1/ServiceBricks.Logging/Model/WebRequestMessageOptions.cs b/src/V1/ServiceBricks.Logging/Model/WebRequestMessageOptions.cs index c8243d0..797354d 100644 --- a/src/V1/ServiceBricks.Logging/Model/WebRequestMessageOptions.cs +++ b/src/V1/ServiceBricks.Logging/Model/WebRequestMessageOptions.cs @@ -18,11 +18,21 @@ public WebRequestMessageOptions() /// public bool EnableLogging { get; set; } + /// + /// Determine if exceptions will be logged. If false, the exception will not be logged. + /// + public bool EnableExceptions { get; set; } + /// /// Determines if logging is enabled for local IP addresses. If false, no logging will occur for local IP addresses requests. /// public bool EnableLocalIpRequests { get; set; } + /// + /// Determines if logging is enabled for the request user storage key. If false, the user storage key will not be stored. + /// + public bool EnableUserStorageKey { get; set; } + /// /// Determines if logging is enabled for remote IP addresses. If false, the IP Address will not be stored. /// @@ -113,11 +123,6 @@ public WebRequestMessageOptions() /// public bool EnableRequestIsHttps { get; set; } - /// - /// Determines if logging is enabled for the request user storage key. If false, the user storage key will not be stored. - /// - public bool EnableRequestUserId { get; set; } - /// /// Determines if logging is enabled for the response status code. If false, the status code will not be stored. /// @@ -167,10 +172,5 @@ public WebRequestMessageOptions() /// The list of excluded request paths. /// public List ExcludeRequestPaths { get; set; } - - /// - /// Determine if exceptions will be logged. If false, the exception will not be logged. - /// - public bool EnableExceptions { get; set; } } } \ No newline at end of file diff --git a/src/V1/ServiceBricks.Logging/Rule/CreateApplicationLogRule.cs b/src/V1/ServiceBricks.Logging/Rule/CreateApplicationLogRule.cs index 7563619..4852550 100644 --- a/src/V1/ServiceBricks.Logging/Rule/CreateApplicationLogRule.cs +++ b/src/V1/ServiceBricks.Logging/Rule/CreateApplicationLogRule.cs @@ -85,14 +85,20 @@ public override async Task ExecuteRuleAsync(IBusinessRuleContext cont try { + // AI: Make sure the context object is the correct type var e = context.Object as CreateApplicationLogBroadcast; if (e == null || e.DomainObject == null) return response; - // AI: Map the CreateApplicationLogBroadcast to a LogMessageDto and call the LogMessageApiService.CreateAsync method. + // AI: Map the ApplicationLogBroadcast to a LogMessageDto var message = _mapper.Map(e.DomainObject); + + // AI: Call the API service to create the log message var respCreate = await _logMessageApiService.CreateAsync(message); + + // AI: Copy the API response to the business rule response response.CopyFrom(respCreate); + return response; } catch (Exception ex) diff --git a/src/V1/ServiceBricks.Logging/ServiceBricks.Logging.csproj b/src/V1/ServiceBricks.Logging/ServiceBricks.Logging.csproj index 2967f96..c0cf2d6 100644 --- a/src/V1/ServiceBricks.Logging/ServiceBricks.Logging.csproj +++ b/src/V1/ServiceBricks.Logging/ServiceBricks.Logging.csproj @@ -1,7 +1,7 @@ - 1.1.0-a + 1.1.0-b ServiceBricks - The open source microservices foundation. Visit https://ServiceBricks.com to learn more. ServiceBricks.Logging holomodular @@ -19,7 +19,7 @@ False git https://github.com/holomodular/ServiceBricks - False + True @@ -29,7 +29,7 @@ - + diff --git a/src/V1/Tests/MigrationsHost/MigrationsHost.csproj b/src/V1/Tests/MigrationsHost/MigrationsHost.csproj index c7fb9f9..811a6ff 100644 --- a/src/V1/Tests/MigrationsHost/MigrationsHost.csproj +++ b/src/V1/Tests/MigrationsHost/MigrationsHost.csproj @@ -14,19 +14,19 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + - + diff --git a/src/V1/Tests/MigrationsHost/StartupMigrations.cs b/src/V1/Tests/MigrationsHost/StartupMigrations.cs index ab37854..58290b0 100644 --- a/src/V1/Tests/MigrationsHost/StartupMigrations.cs +++ b/src/V1/Tests/MigrationsHost/StartupMigrations.cs @@ -3,6 +3,8 @@ using Microsoft.Extensions.DependencyInjection; using ServiceBricks.Logging; using ServiceBricks.Logging.Postgres; +using ServiceBricks.Logging.Sqlite; +using ServiceBricks.Logging.SqlServer; namespace ServiceBricks.Xunit { @@ -18,8 +20,11 @@ public virtual void ConfigureDevelopmentServices(IServiceCollection services) services.AddSingleton(Configuration); services.AddServiceBricks(Configuration); - services.AddServiceBricksLoggingPostgres(Configuration); - //services.AddServiceBricksLoggingSqlServer(Configuration); + //************************** + //UNCOMMENT THE ONE YOU NEED + //************************** + //services.AddServiceBricksLoggingPostgres(Configuration); + services.AddServiceBricksLoggingSqlServer(Configuration); //services.AddServiceBricksLoggingSqlite(Configuration); // Remove all background tasks/timers for unit testing @@ -35,8 +40,11 @@ public virtual void Configure(IApplicationBuilder app) base.CustomConfigure(app); app.StartServiceBricks(); - app.StartServiceBricksLoggingPostgres(); - //app.StartServiceBricksLoggingSqlServer(); + //************************** + //UNCOMMENT THE ONE YOU NEED + //************************** + //app.StartServiceBricksLoggingPostgres(); + app.StartServiceBricksLoggingSqlServer(); //app.StartServiceBricksLoggingSqlite(); } } diff --git a/src/V1/Tests/MigrationsHost/SystemManager.cs b/src/V1/Tests/MigrationsHost/SystemManager.cs index 935eee3..943686f 100644 --- a/src/V1/Tests/MigrationsHost/SystemManager.cs +++ b/src/V1/Tests/MigrationsHost/SystemManager.cs @@ -48,23 +48,26 @@ public static ISystemManager GetSystemManager(Type startupType) private CancellationTokenSource CancellationTokenSource; private SemaphoreSlim _signal = new SemaphoreSlim(0); - public virtual IWebHostBuilder CreateWebHostBuilder(Type startupType) + public virtual IHostBuilder CreateWebHostBuilder(Type startupType) { - return new WebHostBuilder() - .UseContentRoot(Directory.GetCurrentDirectory()) - .ConfigureAppConfiguration(config => - { - config.AddAppSettingsConfig(); - }) - .ConfigureLogging((hostingContext, logging) => - { - logging.ClearProviders(); - logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); - logging.AddConsole(); - logging.AddDebug(); - }) - .UseEnvironment("Development") - .UseStartup(startupType); + return Host.CreateDefaultBuilder() + .ConfigureWebHostDefaults(builder => + { + builder.UseContentRoot(Directory.GetCurrentDirectory()) + .ConfigureAppConfiguration(config => + { + config.AddAppSettingsConfig(); + }) + .ConfigureLogging((hostingContext, logging) => + { + logging.ClearProviders(); + logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); + logging.AddConsole(); + logging.AddDebug(); + }) + .UseEnvironment("Development") + .UseStartup(startupType); + }); } public virtual void StopSystem() @@ -78,15 +81,16 @@ public virtual void StartSystem(Type startupType) ServiceBrickStartup.ConfigureCompleteEvent += Startup_ConfigureCompleteEvent; // Create host builder - var webHostBuilder = CreateWebHostBuilder(startupType); + var hostBuilder = CreateWebHostBuilder(startupType); - //var build = webHostBuilder.Build(); - //ServiceProvider = build.Services; - //Configuration = (IConfiguration)build.Services.GetService(typeof(IConfiguration)); + var build = hostBuilder.Build(); + ServiceProvider = build.Services; + Configuration = (IConfiguration)build.Services.GetService(typeof(IConfiguration)); + build.Start(); - TestServer = new Microsoft.AspNetCore.TestHost.TestServer(webHostBuilder); - ServiceProvider = TestServer.Services; - Configuration = (IConfiguration)TestServer.Host.Services.GetService(typeof(IConfiguration)); + //TestServer = new Microsoft.AspNetCore.TestHost.TestServer(webHostBuilder); + //ServiceProvider = TestServer.Services; + //Configuration = (IConfiguration)TestServer.Host.Services.GetService(typeof(IConfiguration)); CancellationTokenSource = new CancellationTokenSource(); diff --git a/src/V1/Tests/ServiceBricks.Logging.AzureDataTables.XunitNet6/ServiceBricks.Logging.AzureDataTables.XunitNet6.csproj b/src/V1/Tests/ServiceBricks.Logging.AzureDataTables.XunitNet6/ServiceBricks.Logging.AzureDataTables.XunitNet6.csproj index 6878420..4399ca9 100644 --- a/src/V1/Tests/ServiceBricks.Logging.AzureDataTables.XunitNet6/ServiceBricks.Logging.AzureDataTables.XunitNet6.csproj +++ b/src/V1/Tests/ServiceBricks.Logging.AzureDataTables.XunitNet6/ServiceBricks.Logging.AzureDataTables.XunitNet6.csproj @@ -29,7 +29,7 @@ - + diff --git a/src/V1/Tests/ServiceBricks.Logging.AzureDataTables.XunitNet8/ServiceBricks.Logging.AzureDataTables.XunitNet8.csproj b/src/V1/Tests/ServiceBricks.Logging.AzureDataTables.XunitNet8/ServiceBricks.Logging.AzureDataTables.XunitNet8.csproj index 67ce854..b8af6e1 100644 --- a/src/V1/Tests/ServiceBricks.Logging.AzureDataTables.XunitNet8/ServiceBricks.Logging.AzureDataTables.XunitNet8.csproj +++ b/src/V1/Tests/ServiceBricks.Logging.AzureDataTables.XunitNet8/ServiceBricks.Logging.AzureDataTables.XunitNet8.csproj @@ -29,7 +29,7 @@ - + diff --git a/src/V1/Tests/ServiceBricks.Logging.Client.XunitNet6/ServiceBricks.Logging.Client.XunitNet6.csproj b/src/V1/Tests/ServiceBricks.Logging.Client.XunitNet6/ServiceBricks.Logging.Client.XunitNet6.csproj index 2b3b57f..f41e7fe 100644 --- a/src/V1/Tests/ServiceBricks.Logging.Client.XunitNet6/ServiceBricks.Logging.Client.XunitNet6.csproj +++ b/src/V1/Tests/ServiceBricks.Logging.Client.XunitNet6/ServiceBricks.Logging.Client.XunitNet6.csproj @@ -24,7 +24,7 @@ - + diff --git a/src/V1/Tests/ServiceBricks.Logging.Client.XunitNet8/ServiceBricks.Logging.Client.XunitNet8.csproj b/src/V1/Tests/ServiceBricks.Logging.Client.XunitNet8/ServiceBricks.Logging.Client.XunitNet8.csproj index c89994a..0e72e20 100644 --- a/src/V1/Tests/ServiceBricks.Logging.Client.XunitNet8/ServiceBricks.Logging.Client.XunitNet8.csproj +++ b/src/V1/Tests/ServiceBricks.Logging.Client.XunitNet8/ServiceBricks.Logging.Client.XunitNet8.csproj @@ -24,7 +24,7 @@ - + diff --git a/src/V1/Tests/ServiceBricks.Logging.Cosmos.XunitNet6/ServiceBricks.Logging.Cosmos.XunitNet6.csproj b/src/V1/Tests/ServiceBricks.Logging.Cosmos.XunitNet6/ServiceBricks.Logging.Cosmos.XunitNet6.csproj index fc0b43f..932ab23 100644 --- a/src/V1/Tests/ServiceBricks.Logging.Cosmos.XunitNet6/ServiceBricks.Logging.Cosmos.XunitNet6.csproj +++ b/src/V1/Tests/ServiceBricks.Logging.Cosmos.XunitNet6/ServiceBricks.Logging.Cosmos.XunitNet6.csproj @@ -29,7 +29,7 @@ - + diff --git a/src/V1/Tests/ServiceBricks.Logging.Cosmos.XunitNet8/ServiceBricks.Logging.Cosmos.XunitNet8.csproj b/src/V1/Tests/ServiceBricks.Logging.Cosmos.XunitNet8/ServiceBricks.Logging.Cosmos.XunitNet8.csproj index 1b2f1dd..8b154d8 100644 --- a/src/V1/Tests/ServiceBricks.Logging.Cosmos.XunitNet8/ServiceBricks.Logging.Cosmos.XunitNet8.csproj +++ b/src/V1/Tests/ServiceBricks.Logging.Cosmos.XunitNet8/ServiceBricks.Logging.Cosmos.XunitNet8.csproj @@ -30,7 +30,7 @@ - + diff --git a/src/V1/Tests/ServiceBricks.Logging.InMemory.XunitNet6/ServiceBricks.Logging.InMemory.XunitNet6.csproj b/src/V1/Tests/ServiceBricks.Logging.InMemory.XunitNet6/ServiceBricks.Logging.InMemory.XunitNet6.csproj index cc02dd9..cfc4cee 100644 --- a/src/V1/Tests/ServiceBricks.Logging.InMemory.XunitNet6/ServiceBricks.Logging.InMemory.XunitNet6.csproj +++ b/src/V1/Tests/ServiceBricks.Logging.InMemory.XunitNet6/ServiceBricks.Logging.InMemory.XunitNet6.csproj @@ -29,7 +29,7 @@ - + diff --git a/src/V1/Tests/ServiceBricks.Logging.InMemory.XunitNet8/ServiceBricks.Logging.InMemory.XunitNet8.csproj b/src/V1/Tests/ServiceBricks.Logging.InMemory.XunitNet8/ServiceBricks.Logging.InMemory.XunitNet8.csproj index b8055c3..f1d598f 100644 --- a/src/V1/Tests/ServiceBricks.Logging.InMemory.XunitNet8/ServiceBricks.Logging.InMemory.XunitNet8.csproj +++ b/src/V1/Tests/ServiceBricks.Logging.InMemory.XunitNet8/ServiceBricks.Logging.InMemory.XunitNet8.csproj @@ -30,7 +30,7 @@ - + diff --git a/src/V1/Tests/ServiceBricks.Logging.MongoDb.XunitNet6/ServiceBricks.Logging.MongoDb.XunitNet6.csproj b/src/V1/Tests/ServiceBricks.Logging.MongoDb.XunitNet6/ServiceBricks.Logging.MongoDb.XunitNet6.csproj index 4448e5d..0b2f7da 100644 --- a/src/V1/Tests/ServiceBricks.Logging.MongoDb.XunitNet6/ServiceBricks.Logging.MongoDb.XunitNet6.csproj +++ b/src/V1/Tests/ServiceBricks.Logging.MongoDb.XunitNet6/ServiceBricks.Logging.MongoDb.XunitNet6.csproj @@ -31,7 +31,7 @@ - + diff --git a/src/V1/Tests/ServiceBricks.Logging.MongoDb.XunitNet8/ServiceBricks.Logging.MongoDb.XunitNet8.csproj b/src/V1/Tests/ServiceBricks.Logging.MongoDb.XunitNet8/ServiceBricks.Logging.MongoDb.XunitNet8.csproj index 242d1b9..10b6c73 100644 --- a/src/V1/Tests/ServiceBricks.Logging.MongoDb.XunitNet8/ServiceBricks.Logging.MongoDb.XunitNet8.csproj +++ b/src/V1/Tests/ServiceBricks.Logging.MongoDb.XunitNet8/ServiceBricks.Logging.MongoDb.XunitNet8.csproj @@ -32,7 +32,7 @@ - + diff --git a/src/V1/Tests/ServiceBricks.Logging.Postgres.XunitNet6/ServiceBricks.Logging.Postgres.XunitNet6.csproj b/src/V1/Tests/ServiceBricks.Logging.Postgres.XunitNet6/ServiceBricks.Logging.Postgres.XunitNet6.csproj index cf9ce6f..d083dab 100644 --- a/src/V1/Tests/ServiceBricks.Logging.Postgres.XunitNet6/ServiceBricks.Logging.Postgres.XunitNet6.csproj +++ b/src/V1/Tests/ServiceBricks.Logging.Postgres.XunitNet6/ServiceBricks.Logging.Postgres.XunitNet6.csproj @@ -31,7 +31,7 @@ - + diff --git a/src/V1/Tests/ServiceBricks.Logging.Postgres.XunitNet8/ServiceBricks.Logging.Postgres.XunitNet8.csproj b/src/V1/Tests/ServiceBricks.Logging.Postgres.XunitNet8/ServiceBricks.Logging.Postgres.XunitNet8.csproj index 5fb1112..ffcd566 100644 --- a/src/V1/Tests/ServiceBricks.Logging.Postgres.XunitNet8/ServiceBricks.Logging.Postgres.XunitNet8.csproj +++ b/src/V1/Tests/ServiceBricks.Logging.Postgres.XunitNet8/ServiceBricks.Logging.Postgres.XunitNet8.csproj @@ -32,7 +32,7 @@ - + diff --git a/src/V1/Tests/ServiceBricks.Logging.SqlServer.XunitNet6/ServiceBricks.Logging.SqlServer.XunitNet6.csproj b/src/V1/Tests/ServiceBricks.Logging.SqlServer.XunitNet6/ServiceBricks.Logging.SqlServer.XunitNet6.csproj index 63dad2b..a6b9b1b 100644 --- a/src/V1/Tests/ServiceBricks.Logging.SqlServer.XunitNet6/ServiceBricks.Logging.SqlServer.XunitNet6.csproj +++ b/src/V1/Tests/ServiceBricks.Logging.SqlServer.XunitNet6/ServiceBricks.Logging.SqlServer.XunitNet6.csproj @@ -28,7 +28,7 @@ - + diff --git a/src/V1/Tests/ServiceBricks.Logging.SqlServer.XunitNet8/ServiceBricks.Logging.SqlServer.XunitNet8.csproj b/src/V1/Tests/ServiceBricks.Logging.SqlServer.XunitNet8/ServiceBricks.Logging.SqlServer.XunitNet8.csproj index b096b8d..0ede492 100644 --- a/src/V1/Tests/ServiceBricks.Logging.SqlServer.XunitNet8/ServiceBricks.Logging.SqlServer.XunitNet8.csproj +++ b/src/V1/Tests/ServiceBricks.Logging.SqlServer.XunitNet8/ServiceBricks.Logging.SqlServer.XunitNet8.csproj @@ -29,7 +29,7 @@ - + diff --git a/src/V1/Tests/ServiceBricks.Logging.Sqlite.XunitNet6/ServiceBricks.Logging.Sqlite.XunitNet6.csproj b/src/V1/Tests/ServiceBricks.Logging.Sqlite.XunitNet6/ServiceBricks.Logging.Sqlite.XunitNet6.csproj index 4701911..2494faf 100644 --- a/src/V1/Tests/ServiceBricks.Logging.Sqlite.XunitNet6/ServiceBricks.Logging.Sqlite.XunitNet6.csproj +++ b/src/V1/Tests/ServiceBricks.Logging.Sqlite.XunitNet6/ServiceBricks.Logging.Sqlite.XunitNet6.csproj @@ -29,7 +29,7 @@ - + diff --git a/src/V1/Tests/ServiceBricks.Logging.Sqlite.XunitNet8/ServiceBricks.Logging.Sqlite.XunitNet8.csproj b/src/V1/Tests/ServiceBricks.Logging.Sqlite.XunitNet8/ServiceBricks.Logging.Sqlite.XunitNet8.csproj index 274d419..c8bb65c 100644 --- a/src/V1/Tests/ServiceBricks.Logging.Sqlite.XunitNet8/ServiceBricks.Logging.Sqlite.XunitNet8.csproj +++ b/src/V1/Tests/ServiceBricks.Logging.Sqlite.XunitNet8/ServiceBricks.Logging.Sqlite.XunitNet8.csproj @@ -30,7 +30,7 @@ - + diff --git a/src/V1/Tests/ServiceBricks.Logging.XunitNet6/ServiceBricks.Logging.XunitNet6.csproj b/src/V1/Tests/ServiceBricks.Logging.XunitNet6/ServiceBricks.Logging.XunitNet6.csproj index 0f886f9..67d7342 100644 --- a/src/V1/Tests/ServiceBricks.Logging.XunitNet6/ServiceBricks.Logging.XunitNet6.csproj +++ b/src/V1/Tests/ServiceBricks.Logging.XunitNet6/ServiceBricks.Logging.XunitNet6.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -10,12 +10,14 @@ - + + + - + @@ -23,7 +25,7 @@ - + diff --git a/src/V1/Tests/ServiceBricks.Logging.XunitNet7/ServiceBricks.Logging.XunitNet7.csproj b/src/V1/Tests/ServiceBricks.Logging.XunitNet7/ServiceBricks.Logging.XunitNet7.csproj index 68aef0f..febcb94 100644 --- a/src/V1/Tests/ServiceBricks.Logging.XunitNet7/ServiceBricks.Logging.XunitNet7.csproj +++ b/src/V1/Tests/ServiceBricks.Logging.XunitNet7/ServiceBricks.Logging.XunitNet7.csproj @@ -1,4 +1,4 @@ - + net7.0 @@ -10,12 +10,14 @@ + + - + diff --git a/src/V1/Tests/ServiceBricks.Logging.XunitNet8/ServiceBricks.Logging.XunitNet8.csproj b/src/V1/Tests/ServiceBricks.Logging.XunitNet8/ServiceBricks.Logging.XunitNet8.csproj index 64dc531..ed4e12b 100644 --- a/src/V1/Tests/ServiceBricks.Logging.XunitNet8/ServiceBricks.Logging.XunitNet8.csproj +++ b/src/V1/Tests/ServiceBricks.Logging.XunitNet8/ServiceBricks.Logging.XunitNet8.csproj @@ -10,12 +10,14 @@ + + - + @@ -23,7 +25,7 @@ - + diff --git a/src/V1/Tests/TestFiles/LogMessageApiControllerTest.cs b/src/V1/Tests/TestFiles/LogMessageApiControllerTest.cs new file mode 100644 index 0000000..bfb2a72 --- /dev/null +++ b/src/V1/Tests/TestFiles/LogMessageApiControllerTest.cs @@ -0,0 +1,41 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.DependencyInjection; +using ServiceBricks.Logging; + +namespace ServiceBricks.Xunit +{ + [Collection(Constants.SERVICEBRICKS_COLLECTION_NAME)] + public abstract class LogMessageApiControllerTest : ApiControllerTest + { + [Fact] + public virtual async Task Update_CreateDateAsync() + { + var model = TestManager.GetMinimumDataObject(); + var dto = await CreateBaseAsync(model); + + DateTimeOffset startingCreateDate = dto.CreateDate; + + //Update the CreateDate property + dto.CreateDate = DateTime.UtcNow; + + //Call Update + var controller = TestManager.GetController(SystemManager.ServiceProvider); + var respUpdate = await controller.UpdateAsync(dto); + if (respUpdate is OkObjectResult okResult) + { + Assert.True(okResult.Value != null); + if (okResult.Value is LogMessageDto obj) + { + Assert.True(obj.CreateDate == startingCreateDate); + } + else + Assert.Fail(""); + } + else + Assert.Fail(""); + + // Cleanup + await DeleteBaseAsync(dto); + } + } +} \ No newline at end of file diff --git a/src/V1/Tests/TestFiles/LogMessageApiControllerTestAzureDataTables.cs b/src/V1/Tests/TestFiles/LogMessageApiControllerTestAzureDataTables.cs index 830ff7a..1f20711 100644 --- a/src/V1/Tests/TestFiles/LogMessageApiControllerTestAzureDataTables.cs +++ b/src/V1/Tests/TestFiles/LogMessageApiControllerTestAzureDataTables.cs @@ -5,43 +5,12 @@ namespace ServiceBricks.Xunit.Integration { [Collection(Constants.SERVICEBRICKS_COLLECTION_NAME)] - public class LogMessageApiControllerTest : ApiControllerTest + public class LogMessageApiControllerTestAzureDataTables : LogMessageApiControllerTest { - public LogMessageApiControllerTest() + public LogMessageApiControllerTestAzureDataTables() { SystemManager = ServiceBricksSystemManager.GetSystemManager(typeof(StartupAzureDataTables)); TestManager = SystemManager.ServiceProvider.GetRequiredService>(); } - - [Fact] - public virtual async Task Update_CreateDateAsync() - { - var model = TestManager.GetMinimumDataObject(); - var dto = await CreateBaseAsync(model); - - DateTimeOffset startingCreateDate = dto.CreateDate; - - //Update the CreateDate property - dto.CreateDate = DateTime.UtcNow; - - //Call Update - var controller = TestManager.GetController(SystemManager.ServiceProvider); - var respUpdate = await controller.UpdateAsync(dto); - if (respUpdate is OkObjectResult okResult) - { - Assert.True(okResult.Value != null); - if (okResult.Value is LogMessageDto obj) - { - Assert.True(obj.CreateDate == startingCreateDate); - } - else - Assert.Fail(""); - } - else - Assert.Fail(""); - - // Cleanup - DeleteBase(dto); - } } } \ No newline at end of file diff --git a/src/V1/Tests/TestFiles/LogMessageApiControllerTestCosmos.cs b/src/V1/Tests/TestFiles/LogMessageApiControllerTestCosmos.cs index 340553e..2c29624 100644 --- a/src/V1/Tests/TestFiles/LogMessageApiControllerTestCosmos.cs +++ b/src/V1/Tests/TestFiles/LogMessageApiControllerTestCosmos.cs @@ -5,43 +5,12 @@ namespace ServiceBricks.Xunit.Integration { [Collection(Constants.SERVICEBRICKS_COLLECTION_NAME)] - public class LogMessageApiControllerTest : ApiControllerTest + public class LogMessageApiControllerTestCosmos : LogMessageApiControllerTest { - public LogMessageApiControllerTest() + public LogMessageApiControllerTestCosmos() { SystemManager = ServiceBricksSystemManager.GetSystemManager(typeof(StartupCosmos)); TestManager = SystemManager.ServiceProvider.GetRequiredService>(); } - - [Fact] - public virtual async Task Update_CreateDateAsync() - { - var model = TestManager.GetMinimumDataObject(); - var dto = await CreateBaseAsync(model); - - DateTimeOffset startingCreateDate = dto.CreateDate; - - //Update the CreateDate property - dto.CreateDate = DateTime.UtcNow; - - //Call Update - var controller = TestManager.GetController(SystemManager.ServiceProvider); - var respUpdate = await controller.UpdateAsync(dto); - if (respUpdate is OkObjectResult okResult) - { - Assert.True(okResult.Value != null); - if (okResult.Value is LogMessageDto obj) - { - Assert.True(obj.CreateDate == startingCreateDate); - } - else - Assert.Fail(""); - } - else - Assert.Fail(""); - - // Cleanup - DeleteBase(dto); - } } } \ No newline at end of file diff --git a/src/V1/Tests/TestFiles/LogMessageApiControllerTestInMemory.cs b/src/V1/Tests/TestFiles/LogMessageApiControllerTestInMemory.cs index bdd6c6c..4bd1d60 100644 --- a/src/V1/Tests/TestFiles/LogMessageApiControllerTestInMemory.cs +++ b/src/V1/Tests/TestFiles/LogMessageApiControllerTestInMemory.cs @@ -5,43 +5,12 @@ namespace ServiceBricks.Xunit { [Collection(Constants.SERVICEBRICKS_COLLECTION_NAME)] - public class LogMessageApiControllerTest : ApiControllerTest + public class LogMessageApiControllerTestInMemory : LogMessageApiControllerTest { - public LogMessageApiControllerTest() + public LogMessageApiControllerTestInMemory() { SystemManager = ServiceBricksSystemManager.GetSystemManager(typeof(StartupInMemory)); TestManager = SystemManager.ServiceProvider.GetRequiredService>(); } - - [Fact] - public virtual async Task Update_CreateDateAsync() - { - var model = TestManager.GetMinimumDataObject(); - var dto = await CreateBaseAsync(model); - - DateTimeOffset startingCreateDate = dto.CreateDate; - - //Update the CreateDate property - dto.CreateDate = DateTime.UtcNow; - - //Call Update - var controller = TestManager.GetController(SystemManager.ServiceProvider); - var respUpdate = await controller.UpdateAsync(dto); - if (respUpdate is OkObjectResult okResult) - { - Assert.True(okResult.Value != null); - if (okResult.Value is LogMessageDto obj) - { - Assert.True(obj.CreateDate == startingCreateDate); - } - else - Assert.Fail(""); - } - else - Assert.Fail(""); - - // Cleanup - DeleteBase(dto); - } } } \ No newline at end of file diff --git a/src/V1/Tests/TestFiles/LogMessageApiControllerTestMongoDb.cs b/src/V1/Tests/TestFiles/LogMessageApiControllerTestMongoDb.cs index 9ccec58..abdc8c7 100644 --- a/src/V1/Tests/TestFiles/LogMessageApiControllerTestMongoDb.cs +++ b/src/V1/Tests/TestFiles/LogMessageApiControllerTestMongoDb.cs @@ -5,43 +5,12 @@ namespace ServiceBricks.Xunit.Integration { [Collection(Constants.SERVICEBRICKS_COLLECTION_NAME)] - public class LogMessageApiControllerTest : ApiControllerTest + public class LogMessageApiControllerTestMongoDb : LogMessageApiControllerTest { - public LogMessageApiControllerTest() + public LogMessageApiControllerTestMongoDb() { SystemManager = ServiceBricksSystemManager.GetSystemManager(typeof(StartupMongoDb)); TestManager = SystemManager.ServiceProvider.GetRequiredService>(); } - - [Fact] - public virtual async Task Update_CreateDateAsync() - { - var model = TestManager.GetMinimumDataObject(); - var dto = await CreateBaseAsync(model); - - DateTimeOffset startingCreateDate = dto.CreateDate; - - //Update the CreateDate property - dto.CreateDate = DateTime.UtcNow; - - //Call Update - var controller = TestManager.GetController(SystemManager.ServiceProvider); - var respUpdate = await controller.UpdateAsync(dto); - if (respUpdate is OkObjectResult okResult) - { - Assert.True(okResult.Value != null); - if (okResult.Value is LogMessageDto obj) - { - Assert.True(obj.CreateDate == startingCreateDate); - } - else - Assert.Fail(""); - } - else - Assert.Fail(""); - - // Cleanup - DeleteBase(dto); - } } } \ No newline at end of file diff --git a/src/V1/Tests/TestFiles/LogMessageApiControllerTestPostgres.cs b/src/V1/Tests/TestFiles/LogMessageApiControllerTestPostgres.cs index c15358b..edf7a77 100644 --- a/src/V1/Tests/TestFiles/LogMessageApiControllerTestPostgres.cs +++ b/src/V1/Tests/TestFiles/LogMessageApiControllerTestPostgres.cs @@ -5,40 +5,12 @@ namespace ServiceBricks.Xunit.Integration { [Collection(Constants.SERVICEBRICKS_COLLECTION_NAME)] - public class LogMessageApiControllerTest : ApiControllerTest + public class LogMessageApiControllerTestPostgres : LogMessageApiControllerTest { - public LogMessageApiControllerTest() + public LogMessageApiControllerTestPostgres() { SystemManager = ServiceBricksSystemManager.GetSystemManager(typeof(StartupPostgres)); TestManager = SystemManager.ServiceProvider.GetRequiredService>(); } - - [Fact] - public virtual async Task Update_CreateDateAsync() - { - var model = TestManager.GetMinimumDataObject(); - var dto = await CreateBaseAsync(model); - - DateTimeOffset startingCreateDate = dto.CreateDate; - - //Update the CreateDate property - dto.CreateDate = DateTime.UtcNow; - - //Call Update - var controller = TestManager.GetController(SystemManager.ServiceProvider); - var respUpdate = await controller.UpdateAsync(dto); - if (respUpdate is OkObjectResult okResult) - { - Assert.True(okResult.Value != null); - if (okResult.Value is LogMessageDto obj) - { - Assert.True(obj.CreateDate == startingCreateDate); - } - else - Assert.Fail(""); - } - else - Assert.Fail(""); - } } } \ No newline at end of file diff --git a/src/V1/Tests/TestFiles/LogMessageApiControllerTestSqlServer.cs b/src/V1/Tests/TestFiles/LogMessageApiControllerTestSqlServer.cs index 5e59985..3a81a37 100644 --- a/src/V1/Tests/TestFiles/LogMessageApiControllerTestSqlServer.cs +++ b/src/V1/Tests/TestFiles/LogMessageApiControllerTestSqlServer.cs @@ -5,43 +5,12 @@ namespace ServiceBricks.Xunit.Integration { [Collection(Constants.SERVICEBRICKS_COLLECTION_NAME)] - public class LogMessageApiControllerTest : ApiControllerTest + public class LogMessageApiControllerTestSqlServer : LogMessageApiControllerTest { - public LogMessageApiControllerTest() + public LogMessageApiControllerTestSqlServer() { SystemManager = ServiceBricksSystemManager.GetSystemManager(typeof(StartupSqlServer)); TestManager = SystemManager.ServiceProvider.GetRequiredService>(); } - - [Fact] - public virtual async Task Update_CreateDateAsync() - { - var model = TestManager.GetMinimumDataObject(); - var dto = await CreateBaseAsync(model); - - DateTimeOffset startingCreateDate = dto.CreateDate; - - //Update the CreateDate property - dto.CreateDate = DateTime.UtcNow; - - //Call Update - var controller = TestManager.GetController(SystemManager.ServiceProvider); - var respUpdate = await controller.UpdateAsync(dto); - if (respUpdate is OkObjectResult okResult) - { - Assert.True(okResult.Value != null); - if (okResult.Value is LogMessageDto obj) - { - Assert.True(obj.CreateDate == startingCreateDate); - } - else - Assert.Fail(""); - } - else - Assert.Fail(""); - - // Cleanup - DeleteBase(dto); - } } } \ No newline at end of file diff --git a/src/V1/Tests/TestFiles/LogMessageApiControllerTestSqlite.cs b/src/V1/Tests/TestFiles/LogMessageApiControllerTestSqlite.cs index 775a2f6..1c9d882 100644 --- a/src/V1/Tests/TestFiles/LogMessageApiControllerTestSqlite.cs +++ b/src/V1/Tests/TestFiles/LogMessageApiControllerTestSqlite.cs @@ -5,43 +5,12 @@ namespace ServiceBricks.Xunit.Integration { [Collection(Constants.SERVICEBRICKS_COLLECTION_NAME)] - public class LogMessageApiControllerTest : ApiControllerTest + public class LogMessageApiControllerTestSqlite : LogMessageApiControllerTest { - public LogMessageApiControllerTest() + public LogMessageApiControllerTestSqlite() { SystemManager = ServiceBricksSystemManager.GetSystemManager(typeof(StartupSqlite)); TestManager = SystemManager.ServiceProvider.GetRequiredService>(); } - - [Fact] - public virtual async Task Update_CreateDateAsync() - { - var model = TestManager.GetMinimumDataObject(); - var dto = await CreateBaseAsync(model); - - DateTimeOffset startingCreateDate = dto.CreateDate; - - //Update the CreateDate property - dto.CreateDate = DateTime.UtcNow; - - //Call Update - var controller = TestManager.GetController(SystemManager.ServiceProvider); - var respUpdate = await controller.UpdateAsync(dto); - if (respUpdate is OkObjectResult okResult) - { - Assert.True(okResult.Value != null); - if (okResult.Value is LogMessageDto obj) - { - Assert.True(obj.CreateDate == startingCreateDate); - } - else - Assert.Fail(""); - } - else - Assert.Fail(""); - - // Cleanup - DeleteBase(dto); - } } } \ No newline at end of file diff --git a/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTest.cs b/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTest.cs new file mode 100644 index 0000000..725912f --- /dev/null +++ b/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTest.cs @@ -0,0 +1,41 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.DependencyInjection; +using ServiceBricks.Logging; + +namespace ServiceBricks.Xunit +{ + [Collection(Constants.SERVICEBRICKS_COLLECTION_NAME)] + public abstract class WebRequestMessageApiControllerTest : ApiControllerTest + { + [Fact] + public virtual async Task Update_CreateDateAsync() + { + var model = TestManager.GetMinimumDataObject(); + var dto = await CreateBaseAsync(model); + + DateTimeOffset startingCreateDate = dto.CreateDate; + + //Update the CreateDate property + dto.CreateDate = DateTime.UtcNow; + + //Call Update + var controller = TestManager.GetController(SystemManager.ServiceProvider); + var respUpdate = await controller.UpdateAsync(dto); + if (respUpdate is OkObjectResult okResult) + { + Assert.True(okResult.Value != null); + if (okResult.Value is WebRequestMessageDto obj) + { + Assert.True(obj.CreateDate == startingCreateDate); + } + else + Assert.Fail(""); + } + else + Assert.Fail(""); + + // Do cleanup + await DeleteBaseAsync(dto); + } + } +} \ No newline at end of file diff --git a/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestCosmos.cs b/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestCosmos.cs index e45bbfc..c3ad9fa 100644 --- a/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestCosmos.cs +++ b/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestCosmos.cs @@ -5,40 +5,12 @@ namespace ServiceBricks.Xunit.Integration { [Collection(Constants.SERVICEBRICKS_COLLECTION_NAME)] - public class WebRequestMessageApiControllerTest : ApiControllerTest + public class WebRequestMessageApiControllerTestCosmos : WebRequestMessageApiControllerTest { - public WebRequestMessageApiControllerTest() + public WebRequestMessageApiControllerTestCosmos() { SystemManager = ServiceBricksSystemManager.GetSystemManager(typeof(StartupCosmos)); TestManager = SystemManager.ServiceProvider.GetRequiredService>(); } - - [Fact] - public virtual async Task Update_CreateDateAsync() - { - var model = TestManager.GetMinimumDataObject(); - var dto = await CreateBaseAsync(model); - - DateTimeOffset startingCreateDate = dto.CreateDate; - - //Update the CreateDate property - dto.CreateDate = DateTime.UtcNow; - - //Call Update - var controller = TestManager.GetController(SystemManager.ServiceProvider); - var respUpdate = await controller.UpdateAsync(dto); - if (respUpdate is OkObjectResult okResult) - { - Assert.True(okResult.Value != null); - if (okResult.Value is WebRequestMessageDto obj) - { - Assert.True(obj.CreateDate == startingCreateDate); - } - else - Assert.Fail(""); - } - else - Assert.Fail(""); - } } } \ No newline at end of file diff --git a/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestInMemory.cs b/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestInMemory.cs index 5ffe058..d1358b3 100644 --- a/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestInMemory.cs +++ b/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestInMemory.cs @@ -5,40 +5,12 @@ namespace ServiceBricks.Xunit { [Collection(Constants.SERVICEBRICKS_COLLECTION_NAME)] - public class WebRequestMessageApiControllerTest : ApiControllerTest + public class WebRequestMessageApiControllerTestInMemory : WebRequestMessageApiControllerTest { - public WebRequestMessageApiControllerTest() + public WebRequestMessageApiControllerTestInMemory() { SystemManager = ServiceBricksSystemManager.GetSystemManager(typeof(StartupInMemory)); TestManager = SystemManager.ServiceProvider.GetRequiredService>(); } - - [Fact] - public virtual async Task Update_CreateDateAsync() - { - var model = TestManager.GetMinimumDataObject(); - var dto = await CreateBaseAsync(model); - - DateTimeOffset startingCreateDate = dto.CreateDate; - - //Update the CreateDate property - dto.CreateDate = DateTime.UtcNow; - - //Call Update - var controller = TestManager.GetController(SystemManager.ServiceProvider); - var respUpdate = await controller.UpdateAsync(dto); - if (respUpdate is OkObjectResult okResult) - { - Assert.True(okResult.Value != null); - if (okResult.Value is WebRequestMessageDto obj) - { - Assert.True(obj.CreateDate == startingCreateDate); - } - else - Assert.Fail(""); - } - else - Assert.Fail(""); - } } } \ No newline at end of file diff --git a/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestMongoDb.cs b/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestMongoDb.cs index 72e6f62..6a98cfb 100644 --- a/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestMongoDb.cs +++ b/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestMongoDb.cs @@ -5,40 +5,12 @@ namespace ServiceBricks.Xunit.Integration { [Collection(Constants.SERVICEBRICKS_COLLECTION_NAME)] - public class WebRequestMessageApiControllerTest : ApiControllerTest + public class WebRequestMessageApiControllerTestMongoDb : WebRequestMessageApiControllerTest { - public WebRequestMessageApiControllerTest() + public WebRequestMessageApiControllerTestMongoDb() { SystemManager = ServiceBricksSystemManager.GetSystemManager(typeof(StartupMongoDb)); TestManager = SystemManager.ServiceProvider.GetRequiredService>(); } - - [Fact] - public virtual async Task Update_CreateDateAsync() - { - var model = TestManager.GetMinimumDataObject(); - var dto = await CreateBaseAsync(model); - - DateTimeOffset startingCreateDate = dto.CreateDate; - - //Update the CreateDate property - dto.CreateDate = DateTime.UtcNow; - - //Call Update - var controller = TestManager.GetController(SystemManager.ServiceProvider); - var respUpdate = await controller.UpdateAsync(dto); - if (respUpdate is OkObjectResult okResult) - { - Assert.True(okResult.Value != null); - if (okResult.Value is WebRequestMessageDto obj) - { - Assert.True(obj.CreateDate == startingCreateDate); - } - else - Assert.Fail(""); - } - else - Assert.Fail(""); - } } } \ No newline at end of file diff --git a/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestPostgres.cs b/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestPostgres.cs index 1f29062..77c74f8 100644 --- a/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestPostgres.cs +++ b/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestPostgres.cs @@ -5,40 +5,12 @@ namespace ServiceBricks.Xunit.Integration { [Collection(Constants.SERVICEBRICKS_COLLECTION_NAME)] - public class WebRequestMessageApiControllerTest : ApiControllerTest + public class WebRequestMessageApiControllerTestPostgres : WebRequestMessageApiControllerTest { - public WebRequestMessageApiControllerTest() + public WebRequestMessageApiControllerTestPostgres() { SystemManager = ServiceBricksSystemManager.GetSystemManager(typeof(StartupPostgres)); TestManager = SystemManager.ServiceProvider.GetRequiredService>(); } - - [Fact] - public virtual async Task Update_CreateDateAsync() - { - var model = TestManager.GetMinimumDataObject(); - var dto = await CreateBaseAsync(model); - - DateTimeOffset startingCreateDate = dto.CreateDate; - - //Update the CreateDate property - dto.CreateDate = DateTime.UtcNow; - - //Call Update - var controller = TestManager.GetController(SystemManager.ServiceProvider); - var respUpdate = await controller.UpdateAsync(dto); - if (respUpdate is OkObjectResult okResult) - { - Assert.True(okResult.Value != null); - if (okResult.Value is WebRequestMessageDto obj) - { - Assert.True(obj.CreateDate == startingCreateDate); - } - else - Assert.Fail(""); - } - else - Assert.Fail(""); - } } } \ No newline at end of file diff --git a/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestSqlServer.cs b/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestSqlServer.cs index 319371e..c371809 100644 --- a/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestSqlServer.cs +++ b/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestSqlServer.cs @@ -5,40 +5,12 @@ namespace ServiceBricks.Xunit.Integration { [Collection(Constants.SERVICEBRICKS_COLLECTION_NAME)] - public class WebRequestMessageApiControllerTest : ApiControllerTest + public class WebRequestMessageApiControllerTestSqlServer : WebRequestMessageApiControllerTest { - public WebRequestMessageApiControllerTest() + public WebRequestMessageApiControllerTestSqlServer() { SystemManager = ServiceBricksSystemManager.GetSystemManager(typeof(StartupSqlServer)); TestManager = SystemManager.ServiceProvider.GetRequiredService>(); } - - [Fact] - public virtual async Task Update_CreateDateAsync() - { - var model = TestManager.GetMinimumDataObject(); - var dto = await CreateBaseAsync(model); - - DateTimeOffset startingCreateDate = dto.CreateDate; - - //Update the CreateDate property - dto.CreateDate = DateTime.UtcNow; - - //Call Update - var controller = TestManager.GetController(SystemManager.ServiceProvider); - var respUpdate = await controller.UpdateAsync(dto); - if (respUpdate is OkObjectResult okResult) - { - Assert.True(okResult.Value != null); - if (okResult.Value is WebRequestMessageDto obj) - { - Assert.True(obj.CreateDate == startingCreateDate); - } - else - Assert.Fail(""); - } - else - Assert.Fail(""); - } } } \ No newline at end of file diff --git a/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestSqlite.cs b/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestSqlite.cs index 8ae1b47..2ed043f 100644 --- a/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestSqlite.cs +++ b/src/V1/Tests/TestFiles/WebRequestMessageApiControllerTestSqlite.cs @@ -5,40 +5,12 @@ namespace ServiceBricks.Xunit.Integration { [Collection(Constants.SERVICEBRICKS_COLLECTION_NAME)] - public class WebRequestMessageApiControllerTest : ApiControllerTest + public class WebRequestMessageApiControllerTestSqlite : WebRequestMessageApiControllerTest { - public WebRequestMessageApiControllerTest() + public WebRequestMessageApiControllerTestSqlite() { SystemManager = ServiceBricksSystemManager.GetSystemManager(typeof(StartupSqlite)); TestManager = SystemManager.ServiceProvider.GetRequiredService>(); } - - [Fact] - public virtual async Task Update_CreateDateAsync() - { - var model = TestManager.GetMinimumDataObject(); - var dto = await CreateBaseAsync(model); - - DateTimeOffset startingCreateDate = dto.CreateDate; - - //Update the CreateDate property - dto.CreateDate = DateTime.UtcNow; - - //Call Update - var controller = TestManager.GetController(SystemManager.ServiceProvider); - var respUpdate = await controller.UpdateAsync(dto); - if (respUpdate is OkObjectResult okResult) - { - Assert.True(okResult.Value != null); - if (okResult.Value is WebRequestMessageDto obj) - { - Assert.True(obj.CreateDate == startingCreateDate); - } - else - Assert.Fail(""); - } - else - Assert.Fail(""); - } } } \ No newline at end of file diff --git a/src/V1/Tests/TestFiles/WebRequestMessageTestManager.cs b/src/V1/Tests/TestFiles/WebRequestMessageTestManager.cs index 9d2a903..2706d2e 100644 --- a/src/V1/Tests/TestFiles/WebRequestMessageTestManager.cs +++ b/src/V1/Tests/TestFiles/WebRequestMessageTestManager.cs @@ -14,6 +14,8 @@ public override WebRequestMessageDto GetMaximumDataObject() var model = new WebRequestMessageDto() { CreateDate = DateTimeOffset.UtcNow, + Application = Guid.NewGuid().ToString(), + Server = Guid.NewGuid().ToString(), Exception = Guid.NewGuid().ToString(), RequestBody = Guid.NewGuid().ToString(), RequestContentLength = 1, @@ -32,7 +34,7 @@ public override WebRequestMessageDto GetMaximumDataObject() RequestQueryString = Guid.NewGuid().ToString(), RequestRouteValues = Guid.NewGuid().ToString(), RequestScheme = Guid.NewGuid().ToString(), - RequestUserStorageKey = Guid.NewGuid().ToString(), + UserStorageKey = Guid.NewGuid().ToString(), ResponseBody = Guid.NewGuid().ToString(), ResponseContentType = Guid.NewGuid().ToString(), ResponseCookies = Guid.NewGuid().ToString(), @@ -80,6 +82,8 @@ public override IApiService GetService(IServiceProvider se public override void UpdateObject(WebRequestMessageDto dto) { //dto.CreateDate = DateTimeOffset.UtcNow; + dto.Application = Guid.NewGuid().ToString(); + dto.Server = Guid.NewGuid().ToString(); dto.Exception = Guid.NewGuid().ToString(); dto.RequestBody = Guid.NewGuid().ToString(); dto.RequestContentLength = 2; @@ -98,7 +102,7 @@ public override void UpdateObject(WebRequestMessageDto dto) dto.RequestQueryString = Guid.NewGuid().ToString(); dto.RequestRouteValues = Guid.NewGuid().ToString(); dto.RequestScheme = Guid.NewGuid().ToString(); - dto.RequestUserStorageKey = Guid.NewGuid().ToString(); + dto.UserStorageKey = Guid.NewGuid().ToString(); dto.ResponseBody = Guid.NewGuid().ToString(); dto.ResponseContentType = Guid.NewGuid().ToString(); dto.ResponseCookies = Guid.NewGuid().ToString(); @@ -116,6 +120,8 @@ public override void ValidateObjects(WebRequestMessageDto clientDto, WebRequestM else Assert.True(serviceDto.CreateDate == clientDto.CreateDate); + Assert.True(serviceDto.Application == clientDto.Application); + Assert.True(serviceDto.Server == clientDto.Server); Assert.True(serviceDto.Exception == clientDto.Exception); Assert.True(serviceDto.RequestBody == clientDto.RequestBody); Assert.True(serviceDto.RequestContentLength == clientDto.RequestContentLength); @@ -134,7 +140,7 @@ public override void ValidateObjects(WebRequestMessageDto clientDto, WebRequestM Assert.True(serviceDto.RequestQueryString == clientDto.RequestQueryString); Assert.True(serviceDto.RequestRouteValues == clientDto.RequestRouteValues); Assert.True(serviceDto.RequestScheme == clientDto.RequestScheme); - Assert.True(serviceDto.RequestUserStorageKey == clientDto.RequestUserStorageKey); + Assert.True(serviceDto.UserStorageKey == clientDto.UserStorageKey); Assert.True(serviceDto.ResponseBody == clientDto.ResponseBody); Assert.True(serviceDto.ResponseContentType == clientDto.ResponseContentType); Assert.True(serviceDto.ResponseCookies == clientDto.ResponseCookies); @@ -158,6 +164,14 @@ public override List GetQueriesForObject(WebRequestMessageD IsEqual(nameof(WebRequestMessageDto.CreateDate), dto.CreateDate.ToString("o")); queries.Add(qb.Build()); + qb = ServiceQueryRequestBuilder.New(). + IsEqual(nameof(WebRequestMessageDto.Application), dto.Application); + queries.Add(qb.Build()); + + qb = ServiceQueryRequestBuilder.New(). + IsEqual(nameof(WebRequestMessageDto.Server), dto.Server); + queries.Add(qb.Build()); + qb = ServiceQueryRequestBuilder.New(). IsEqual(nameof(WebRequestMessageDto.Exception), dto.Exception); queries.Add(qb.Build()); @@ -231,7 +245,7 @@ public override List GetQueriesForObject(WebRequestMessageD queries.Add(qb.Build()); qb = ServiceQueryRequestBuilder.New(). - IsEqual(nameof(WebRequestMessageDto.RequestUserStorageKey), dto.RequestUserStorageKey); + IsEqual(nameof(WebRequestMessageDto.UserStorageKey), dto.UserStorageKey); queries.Add(qb.Build()); qb = ServiceQueryRequestBuilder.New(). diff --git a/src/V1/Tests/TestFiles/WebRequestMessageTestManagerPostgres.cs b/src/V1/Tests/TestFiles/WebRequestMessageTestManagerPostgres.cs index 55bb88b..6230496 100644 --- a/src/V1/Tests/TestFiles/WebRequestMessageTestManagerPostgres.cs +++ b/src/V1/Tests/TestFiles/WebRequestMessageTestManagerPostgres.cs @@ -36,7 +36,7 @@ public override void ValidateObjects(WebRequestMessageDto clientDto, WebRequestM Assert.True(serviceDto.RequestQueryString == clientDto.RequestQueryString); Assert.True(serviceDto.RequestRouteValues == clientDto.RequestRouteValues); Assert.True(serviceDto.RequestScheme == clientDto.RequestScheme); - Assert.True(serviceDto.RequestUserStorageKey == clientDto.RequestUserStorageKey); + Assert.True(serviceDto.UserStorageKey == clientDto.UserStorageKey); Assert.True(serviceDto.ResponseBody == clientDto.ResponseBody); Assert.True(serviceDto.ResponseContentType == clientDto.ResponseContentType); Assert.True(serviceDto.ResponseCookies == clientDto.ResponseCookies); diff --git a/src/V1/Tests/TestFiles/appsettings.json b/src/V1/Tests/TestFiles/appsettings.json index 15eee26..12ae3a7 100644 --- a/src/V1/Tests/TestFiles/appsettings.json +++ b/src/V1/Tests/TestFiles/appsettings.json @@ -21,21 +21,21 @@ "ConnectionString": "DefaultEndpointsProtocol=" }, "SqlServer": { - "ConnectionString": "Data Source=localhost;Database=ServiceBricks;Trusted_Connection=yes;Encrypt=false;" + "ConnectionString": "Data Source=localhost;Database=ServiceBricksLogging;Trusted_Connection=yes;Encrypt=false;" }, "Sqlite": { "ConnectionString": "Data Source=c:\\temp\\ServiceBricksLogging.sqlite" }, "Postgres": { - "ConnectionString": "Server=localhost;Port=5432;Database=servicebricks;User Id=postgres;Password=MyPassword" + "ConnectionString": "Server=localhost;Port=5432;Database=ServiceBricksLogging;User Id=postgres;Password=MyPassword" }, "Cosmos": { "ConnectionString": "AccountEndpoint=", - "Database": "ServiceBricks" + "Database": "ServiceBricksLogging" }, "MongoDb": { "ConnectionString": "mongodb://localhost:27017", - "Database": "ServiceBricks" + "Database": "ServiceBricksLogging" } } } diff --git a/src/V1/Tests/TestFiles/webapp/appsettings.json b/src/V1/Tests/TestFiles/webapp/appsettings.json index 9c2d522..6c6e739 100644 --- a/src/V1/Tests/TestFiles/webapp/appsettings.json +++ b/src/V1/Tests/TestFiles/webapp/appsettings.json @@ -19,7 +19,9 @@ "Logging": { "WebRequestMessage": { "EnableLogging": false, // This messes with client unit tests + "EnableExceptions": true, "EnableLocalIpRequests": true, + "EnableUserStorageKey": true, "EnableRequestIPAddress": true, "EnableRequestBody": false, "EnableRequestBodyOnError": true, @@ -38,7 +40,6 @@ "EnableRequestContentLength": true, "EnableRequestHeaders": false, "EnableRequestIsHttps": true, - "EnableRequestUserId": true, "EnableResponseStatusCode": true, "EnableResponseHeaders": false, "EnableResponseCookies": false, @@ -47,6 +48,7 @@ "EnableResponseTotalMilliseconds": true, "EnableResponseBody": false, "EnableExcludeRequestPaths": true, + "EnableExcludeRegExExpressions": false, "ExcludeRequestPaths": [ "/css/", "/img/", @@ -68,21 +70,21 @@ "ConnectionString": "DefaultEndpointsProtocol=" }, "SqlServer": { - "ConnectionString": "Data Source=localhost;Database=ServiceBricks;Trusted_Connection=yes;Encrypt=false;" + "ConnectionString": "Data Source=localhost;Database=ServiceBricksLogging;Trusted_Connection=yes;Encrypt=false;" }, "Sqlite": { "ConnectionString": "Data Source=c:\\temp\\ServiceBricksLogging.sqlite" }, "Postgres": { - "ConnectionString": "Server=localhost;Port=5432;Database=servicebricks;User Id=postgres;Password=MyPassword" + "ConnectionString": "Server=localhost;Port=5432;Database=ServiceBricksLogging;User Id=postgres;Password=MyPassword" }, "Cosmos": { "ConnectionString": "AccountEndpoint=", - "Database": "ServiceBricks" + "Database": "ServiceBricksLogging" }, "MongoDb": { "ConnectionString": "mongodb://localhost:27017", - "Database": "ServiceBricks" + "Database": "ServiceBricksLogging" } } } diff --git a/src/V1/Tests/WebAppNet6/Extensions/ApplicationBuilderExtensions.cs b/src/V1/Tests/WebAppNet6/Extensions/ApplicationBuilderExtensions.cs index 8080281..e7f39a3 100644 --- a/src/V1/Tests/WebAppNet6/Extensions/ApplicationBuilderExtensions.cs +++ b/src/V1/Tests/WebAppNet6/Extensions/ApplicationBuilderExtensions.cs @@ -7,7 +7,7 @@ public static class ApplicationBuilderExtensions { private static IApplicationBuilder RegisterMiddleware(this IApplicationBuilder app) { - app.UseMiddleware(); + app.UseMiddleware(); app.UseMiddleware(); diff --git a/src/V1/Tests/WebAppNet6/WebAppNet6.csproj b/src/V1/Tests/WebAppNet6/WebAppNet6.csproj index 614d225..96eb34a 100644 --- a/src/V1/Tests/WebAppNet6/WebAppNet6.csproj +++ b/src/V1/Tests/WebAppNet6/WebAppNet6.csproj @@ -15,8 +15,8 @@ - - + + diff --git a/src/V1/Tests/WebAppNet7/Extensions/ApplicationBuilderExtensions.cs b/src/V1/Tests/WebAppNet7/Extensions/ApplicationBuilderExtensions.cs index 8080281..e7f39a3 100644 --- a/src/V1/Tests/WebAppNet7/Extensions/ApplicationBuilderExtensions.cs +++ b/src/V1/Tests/WebAppNet7/Extensions/ApplicationBuilderExtensions.cs @@ -7,7 +7,7 @@ public static class ApplicationBuilderExtensions { private static IApplicationBuilder RegisterMiddleware(this IApplicationBuilder app) { - app.UseMiddleware(); + app.UseMiddleware(); app.UseMiddleware(); diff --git a/src/V1/Tests/WebAppNet7/WebAppNet7.csproj b/src/V1/Tests/WebAppNet7/WebAppNet7.csproj index 4f39218..56073fa 100644 --- a/src/V1/Tests/WebAppNet7/WebAppNet7.csproj +++ b/src/V1/Tests/WebAppNet7/WebAppNet7.csproj @@ -16,7 +16,7 @@ - + diff --git a/src/V1/Tests/WebAppNet8/Extensions/ApplicationBuilderExtensions.cs b/src/V1/Tests/WebAppNet8/Extensions/ApplicationBuilderExtensions.cs index 8080281..e7f39a3 100644 --- a/src/V1/Tests/WebAppNet8/Extensions/ApplicationBuilderExtensions.cs +++ b/src/V1/Tests/WebAppNet8/Extensions/ApplicationBuilderExtensions.cs @@ -7,7 +7,7 @@ public static class ApplicationBuilderExtensions { private static IApplicationBuilder RegisterMiddleware(this IApplicationBuilder app) { - app.UseMiddleware(); + app.UseMiddleware(); app.UseMiddleware(); diff --git a/src/V1/Tests/WebAppNet8/WebAppNet8.csproj b/src/V1/Tests/WebAppNet8/WebAppNet8.csproj index 25f1d83..c303aca 100644 --- a/src/V1/Tests/WebAppNet8/WebAppNet8.csproj +++ b/src/V1/Tests/WebAppNet8/WebAppNet8.csproj @@ -15,8 +15,8 @@ - - + +