A new static method `BuildStaticClient(Action<HttpClient> configureClient)`
was added to the `ReC.Client` namespace in `ReCClient.cs`. This method
configures and builds a static `IServiceProvider` for creating `ReCClient`
instances. It includes XML documentation detailing its purpose, usage,
and parameters, and warns that it should only be called once during
application startup.
The method accepts an `Action<HttpClient>` parameter for `HttpClient`
configuration and throws an `InvalidOperationException` if the static
provider is already built. It is marked `[Obsolete]` to encourage the
use of a local service collection instead of the static provider.
Additionally, the XML documentation for the `ReCClient` creation method
was updated to reference the new `BuildStaticClient` method.
Simplified the HTTP client configuration in the `BuildStaticClient` method of the `ReC.Client` namespace. Replaced the explicit use of `Services.AddHttpClient` with a call to `Services.AddRecClient(apiUri)`. This change improves code readability and reusability by encapsulating the HTTP client setup logic in a dedicated method or extension.
Refactored the `Create` method in the `ReCClient` class to directly resolve a `ReCClient` instance from the dependency injection container using `Provider.GetRequiredService<ReCClient>()`.
Removed the intermediate step of retrieving an `IHttpClientFactory` and manually creating a `ReCClient` object. This change reduces boilerplate code and assumes `ReCClient` is already registered in the container, improving maintainability.
Added `services.AddScoped<ReCClient>()` to both `AddRecClient`
method overloads in `DependencyInjection.cs` to ensure proper
scoped registration of `ReCClient`.
Updated `ReC.Client.csproj` to include necessary package
references for dependency injection and HTTP client support:
- `Microsoft.Extensions.DependencyInjection` (v10.0.0)
- `Microsoft.Extensions.Http` (v8.0.0)
- `System.Net.Http` (v4.3.4)
The `BuildStaticClient` and `Create` methods in the `ReC.Client` namespace have been marked with the `[Obsolete]` attribute. These methods now include a message advising developers to use a local service collection instead of the static provider. This change serves as a warning that these methods are outdated and may be removed in future versions, encouraging a transition to a more modern design.
- Added comprehensive XML documentation for `DependencyInjection`
and `ReCClient` classes to improve code readability.
- Introduced overload for `AddRecClient` to allow flexible
`HttpClient` configuration.
- Added static `BuildStaticClient` and `Create` methods for
simplified client instantiation.
- Marked synchronous `InvokeRecAction` method as obsolete to
encourage asynchronous usage.
- Updated `ReC.Client.csproj`:
- Added `<DocumentationFile>` property for XML doc generation.
- Downgraded `Microsoft.Extensions.Http` to version 8.0.0.
- Removed `System.Text.Json` package reference.
- Removed `System.Text.Json` dependency from `ReCClient.cs`.
- Generated unique `HttpClient` name for `ReCClient` instances.
- Performed general code cleanup and improved method remarks.
Replaced the `ReCClient.Static` property with a `ReCClient.Create()` method to improve clarity and align with best practices. The new method retains the same functionality, including throwing an `InvalidOperationException` if the `Provider` is not built. The logic for retrieving the `IHttpClientFactory` and creating a `ReCClient` instance remains unchanged.
Renamed the static field `ServiceProvider` to `Provider` across
the `ReC.Client` namespace in `ReCClient.cs` for consistency
and clarity. Updated all occurrences, including declarations,
usages, and exception messages. Adjusted conditional compilation
blocks to reflect the new name. Ensured the `BuildStaticClient`
method and `Static` property use the renamed field appropriately.
Updated the `ServiceProvider` field in the `ReC.Client` namespace to use conditional compilation for framework-specific behavior:
- Added `NET8_0_OR_GREATER` directive to define `ServiceProvider` as nullable (`IServiceProvider?`) for .NET 8.0 or greater.
- Retained non-nullable `IServiceProvider` for other frameworks.
- Removed redundant `#if nullable` directives to simplify the code.
- Streamlined initialization logic for better clarity and maintainability.
Introduced dependency injection to the `ReCClient` class by adding `Microsoft.Extensions.DependencyInjection`. Added a static mechanism for creating and managing a `ReCClient` instance, including a `BuildStaticClient` method to configure the HTTP client and a `Static` property to retrieve the client. Implemented error handling to ensure proper initialization of the static service provider.
Added the `[Obsolete]` attribute to the `InvokeRecAction` method
in the `ReC.Client` namespace to discourage its use. The attribute
recommends using the `InvokeRecActionAsync` method instead to
avoid potential deadlocks and improve performance.
Added a synchronous version of the `InvokeRecAction` method to
the `ReC.Client` namespace in `ReCClient.cs`. This method
invokes the `POST api/RecAction/invoke/{profileId}` endpoint
synchronously using `GetAwaiter().GetResult()` and returns a
boolean indicating success.
Also included XML documentation comments for the new method,
detailing its purpose, parameters, and return value.
The method `InvokeRecActionAsync` in the `ReC.Client` namespace was updated to return a `bool` instead of `Task`. This change allows the method to indicate whether the HTTP request was successful.
- Updated the return type from `Task` to `Task<bool>`.
- Modified the `<returns>` XML documentation to reflect the new behavior.
- Replaced `resp.EnsureSuccessStatusCode()` with `resp.IsSuccessStatusCode` to return the success status directly.
Updated the parameter name in the `InvokeRecActionAsync` method
to `cancellationToken` for better readability and alignment
with standard naming conventions. Adjusted the method signature
and internal usage to reflect this change.
Removed the `InvokeRecActionFakeAsync` method, which was used to invoke a fake RecAction via the `api/RecAction/invoke/fake` endpoint. This method is no longer needed or relevant.
The `InvokeRecActionAsync` method remains in place to handle RecActions for specific profile IDs via the `api/RecAction/invoke/{profileId}` endpoint.
Added a `using System.Net.Http;` directive within a `#if NETFRAMEWORK` block in `DependencyInjection.cs` to ensure compatibility with .NET Framework.
Introduced the `AddRecClient` extension method in the `DependencyInjection` class to enable custom configuration of `HttpClient` instances via an `Action<HttpClient>` delegate.
Introduced a `DependencyInjection` class in the `ReC.Client`
namespace to enable dependency injection for `ReCClient`.
Added an `AddRecClient` extension method for `IServiceCollection`
to register an `HttpClient` with a configurable `apiUri` as the
base address.
Included conditional `using System;` for .NET Framework
compatibility and added `Microsoft.Extensions.DependencyInjection`
to support DI services.
- Removed unused `System.Xml.Linq` namespace import.
- Simplified code by removing `#if NETFRAMEWORK` directives.
- Added `ClientName` field to uniquely identify HTTP clients.
- Updated constructor to use named HTTP client with `ClientName`.
- Removed unused `_jsonOptions` field for better code clarity.
Updated ReCClient to use IHttpClientFactory for improved
resource management and testability. Added package
references for `Microsoft.Extensions.Http`, `System.Net.Http`,
and `System.Text.Json` to support HTTP client functionality
and JSON serialization. Included `System.Xml.Linq` for
potential XML-related operations. Updated constructor logic
to create `HttpClient` instances via the factory pattern.
A new asynchronous method `InvokeRecActionFakeAsync` was added to the `ReC.Client` namespace in `ReCClient.cs`. This method sends a POST request to the `api/RecAction/invoke/fake` endpoint. It includes XML documentation comments and accepts an optional `CancellationToken` parameter. The method ensures the response has a successful status code.
Added the `InvokeRecActionAsync` method to the `ReCClient` class in the `ReC.Client` namespace. This method performs an asynchronous HTTP POST request to the `api/RecAction/invoke/{profileId}` endpoint. It accepts a `profileId` parameter to specify the profile ID and an optional `CancellationToken` for task cancellation. The method ensures the HTTP response indicates success by calling `EnsureSuccessStatusCode()`. Included XML documentation comments for clarity and maintainability.
Added `ReCClient` class to handle HTTP requests with JSON
serialization/deserialization support. Updated `ReC.Client.csproj`
to include `System.Net.Http` (v4.3.4) and `System.Text.Json`
(v9.0.11) as package references. Introduced conditional `using`
directives for `NETFRAMEWORK` compatibility.
The `logFileNamePrefix` variable in the `NLog` configuration was updated to use a period (`.`) instead of a hyphen (`-`) as the separator between the date and the application name.
Old format: `${shortdate}-Rec.API.Web`
New format: `${shortdate}.Rec.API`
This change aligns the log file naming convention with a new standard or improves consistency across file naming practices.
- Integrated `NLog` for improved logging capabilities.
- Added a logger instance and initialized logging with `NLog`.
- Wrapped app setup in a `try-catch` block to handle startup exceptions.
- Configured logging to use `NLog` in non-development environments.
- Refactored service registration for better organization.
- Retained key configurations for `AddRecServices` and `AddRecInfrastructure`.
- Reorganized middleware pipeline setup for clarity.
- Added exception logging during startup to improve debugging.
Updated the copyright year to 2025 for "Digital Data GmbH."
Added `NLog` (v5.2.5) and `NLog.Web.AspNetCore` (v5.3.0)
package references to introduce logging capabilities.
No functional changes were made to the `Swashbuckle.AspNetCore`
package reference, though it was reformatted slightly.
Added a new NLog configuration section in `appsettings.json` to enable structured logging. This includes settings for log file storage, log targets for different levels (Info, Warn, Error, Fatal), and retention policies.
Added the `NLog` property to the configuration. Introduced a new `AddedWho` property with the value `ReC.API`.
Removed and re-added the `FakeProfileId` property without changing its value. No changes were made to `LuckyPennySoftwareLicenseKey` or `RecAction` sections.
The `<DesktopBuildPackageLocation>` property in `IISProfile.pubxml`
was updated to remove the hardcoded `net8` subdirectory. The path
now dynamically uses the `$(Version)` variable directly under the
`API` directory, improving flexibility and reducing the need for
manual updates when versions change.
Added an XML declaration and structured the IIS publish profile
with a `<Project>` root element and a `<PropertyGroup>`
containing key properties for web publishing. Configured the
publish method as `Package`, set the build configuration to
`Release`, and specified the IIS deployment path. Included
settings for packaging as a single file and defined the build
package location with a version placeholder.
Enhanced the project file (`ReC.API.csproj`) with metadata
to prepare the package for distribution. Added properties
such as `PackageId`, `Authors`, `Company`, `Product`,
`PackageIcon`, `PackageTags`, `Version`, `AssemblyVersion`,
`FileVersion`, `InformationalVersion`, and `Copyright`.
These changes ensure the package contains detailed
information for consumers and aligns with NuGet standards.
Updated the `Invoke` method in `RecActionController` to use `cmd` as the route parameter instead of `profileId`, modifying the HTTP POST route to `invoke/{cmd}`.
Refactored the `Delete` method to accept a `DeleteRecActionsCommand` object (`cmd`) instead of `profileId`. Removed the hardcoded `ProfileId` assignment and passed the `cmd` object directly to `mediator.Send`.
Made the `ProfileId` property in `DeleteRecActionsCommand` required by removing its default value, enforcing explicit initialization. This improves validation and ensures flexibility for future enhancements.
These changes enhance the API's clarity, flexibility, and maintainability.
Simplified the `Get` method in `RecActionController` by replacing
the `profileId` parameter with a `ReadRecActionQuery` object.
This eliminates the need to manually construct the query object
within the method, improving code readability and reducing
redundancy.
The `Get` method in the `RecActionController` class was updated to use the `[FromQuery]` attribute for the `invoked` parameter. This change ensures that the parameter value is explicitly bound from the query string of the HTTP request, improving clarity and alignment with expected usage.
Updated the Get method in RecActionController to include a
new optional parameter, `invoked`, with a default value of
`false`. Updated XML documentation to reflect this change.
Modified the `ReadRecActionQuery` initialization to pass the
`invoked` parameter. Removed the previous method signature
that only accepted a `CancellationToken`.
Updated `InvokeBatchRecActionsCommandExtensions` to filter actions with `Invoked = false` using a lambda in `ToReadQuery`.
Refactored `ReadRecActionQueryBase` to remove the `Invoked` property and updated `ToReadQuery` to accept a delegate for external query modifications.
Moved the `Invoked` property to `ReadRecActionQuery` and added a parameterless constructor.
These changes improve flexibility and enable dynamic query customization.
Introduced a nullable `Invoked` property in `ReadRecActionQueryBase`
to enable conditional filtering of actions based on `Root.OutRes`.
Added a `ToReadQuery` method for easier query conversion.
Refactored `ReadRecActionQueryHandler` to apply dynamic filtering
based on the `Invoked` property:
- `true`: Filters actions with non-null `Root.OutRes`.
- `false`: Filters actions with null `Root.OutRes`.
- `null`: No additional filtering applied.
Replaced hardcoded filtering logic with the new dynamic approach.
Renamed the `RootAction` property to `Root` in the `RecActionView` class to improve clarity and align with naming conventions. Updated the `ReadRecActionQueryHandler` class to reference the renamed property in its LINQ query, ensuring consistency between the data model and query logic.
Enhanced the `Handle` method in `ReadRecActionQueryHandler`
to include an additional filtering condition when querying
the repository. The query now filters actions where
`RootAction.OutRes` is not null, in addition to matching
the `ProfileId`. This ensures that only relevant actions
with a valid `OutRes` are included in the result set.
Introduced a new `OutRes` navigation property in the `RecAction`
class to establish a one-to-one relationship with the `OutRes`
entity. Updated `RecDbContext` to configure this relationship
using the Fluent API. The `OutRes` entity references its
associated `RecAction` via the `Action` navigation property,
with `ActionId` as the foreign key.
Introduced a new nullable `RootAction` property in the `RecActionView` class. This property is decorated with the `[ForeignKey("Id")]` attribute, establishing a foreign key relationship with the `Id` property. This change enables the `RecActionView` entity to reference an optional `RecAction` entity, enhancing the data model and supporting entity relationships.
Introduced a `Profile` navigation property in the `RecActionView` class, linked to the `ProfileId` column using the `[ForeignKey]` attribute. The `Profile` property is nullable to support cases where no related `Profile` exists.
Added XML documentation to `OutResController` methods for clarity.
Introduced `ResultType` enum to specify result parts (Full, Header, Body).
Enhanced `Get` methods to support fake/test profiles and actions.
Added `[ProducesResponseType(StatusCodes.Status200OK)]` for explicit
response status codes. Updated `Get` overloads for various scenarios.
Utilized `config.GetFakeProfileId()` for dynamic fake profile handling.
Updated `Get` methods in `OutResController` to include a
`CancellationToken` parameter, enabling support for request
cancellation during asynchronous operations. Updated all
`mediator.Send` calls to propagate the `CancellationToken`.
Simplified the "fake/{actionId}" route by removing the explicit
assignment of `HttpContext.Response.ContentType` for non-
`ResultType.Full` cases.
Added new endpoints for invoking, retrieving, creating, and deleting
RecActions, including support for both specific and fake/test profiles.
Endpoints include:
- `Invoke` for batch invocation of RecActions.
- `Get` for retrieving RecActions by profile.
- `CreateAction` for creating new RecActions.
- `CreateFakeAction` for creating test RecActions.
- `Delete` for deleting RecActions by profile.
Enhanced all endpoints with XML documentation for clarity and added
`ProducesResponseType` attributes to specify expected HTTP status codes.
Replaced the `catch` block in the `JsonExtensions` class to suppress exceptions silently instead of returning the original string when JSON deserialization fails. The `return str;` statement was moved outside the `try-catch` block, making it the default return value. This change removes explicit handling of invalid JSON inputs and may impact debugging.
Refactored `ConfigExtensions.cs` to move `ConfigurationExtensions`
to the `ReC.API.Extensions` namespace and re-added the
`GetFakeProfileId` method. Introduced `JsonExtensions.cs` with
a `JsonToDynamic` method for recursive JSON deserialization,
simplifying nested JSON handling. Updated `OutResController.cs`
and `RecActionController.cs` to use the new `JsonToDynamic`
method, improving code readability and reducing duplication.
Overall, modularized and cleaned up code for better maintainability.
Introduced a new `HttpGet` endpoint `fake/{actionId}` in the
`OutResController` to support fetching OutRes data filtered
by `actionId` and an optional `resultType` parameter.
Added logic to handle different `resultType` values (`Full`,
`Header`, `Body`) and return the appropriate part of the
result. Updated response `ContentType` for non-`Full` results
and ensured null-safe handling for `Body` and `Header`.
Included a new `ResultType` enum and added necessary `using`
directives for the new functionality.
Reordered using directives in DtoMappingProfile.cs.
Added AutoMapper mapping for OutRes to OutResDto.
Modified ReadOutResQuery to return IEnumerable<OutResDto>.
Updated ReadOutResHandler to handle collection results:
- Changed Handle method to return IEnumerable<OutResDto>.
- Updated mapper.Map to map to a collection of OutResDto.
Updated `InvokeRecActionsCommandHandler` to use `IServiceScopeFactory` for creating scoped services. Replaced direct `IHttpClientFactory` usage with dynamic resolution of `ISender` within a service scope. Improved dependency injection adherence and ensured proper scoping of services. Added `Microsoft.Extensions.DependencyInjection` to `using` directives.
Replaced hardcoded FakeProfileId with a dynamic value retrieved
from the configuration using a new GetFakeProfileId extension
method. Updated OutResController and RecActionController to
inject IConfiguration and use the new method. Added a new
HttpGet endpoint in OutResController for fake profile queries.
Modified appsettings.json to include a FakeProfileId setting
with a default value of 2. Introduced ConfigurationExtensions
to centralize configuration access logic, improving code
maintainability and flexibility.
The validation rule in the `ReadOutResQueryValidator` class was updated to include a `WithName("Identifier")` call. This assigns a name ("Identifier") to the rule, improving the clarity and usability of validation error messages, especially in scenarios where multiple rules are applied and need to be distinguished.