Compare commits
7 Commits
9a12643eb6
...
b71ea7d346
| Author | SHA1 | Date | |
|---|---|---|---|
| b71ea7d346 | |||
| 3764fdaf01 | |||
| 5e7287bf86 | |||
| 9992086e48 | |||
| 40019bf693 | |||
| 4b9e577d41 | |||
| 4e6cb20dc2 |
@ -1,56 +1,78 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using NLog;
|
||||||
|
using NLog.Web;
|
||||||
using ReC.API.Middleware;
|
using ReC.API.Middleware;
|
||||||
using ReC.Application;
|
using ReC.Application;
|
||||||
using ReC.Infrastructure;
|
using ReC.Infrastructure;
|
||||||
|
using LogLevel = Microsoft.Extensions.Logging.LogLevel;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
|
||||||
|
logger.Info("Logging initialized!");
|
||||||
|
|
||||||
var config = builder.Configuration;
|
try
|
||||||
|
|
||||||
// Add services to the container.
|
|
||||||
builder.Services.AddRecServices(options =>
|
|
||||||
{
|
{
|
||||||
options.LuckyPennySoftwareLicenseKey = builder.Configuration["LuckyPennySoftwareLicenseKey"];
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
options.ConfigureRecActions(config.GetSection("RecAction"));
|
|
||||||
});
|
|
||||||
|
|
||||||
builder.Services.AddRecInfrastructure(options =>
|
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
||||||
{
|
|
||||||
options.ConfigureDbContext((provider, opt) =>
|
if (!builder.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
var cnnStr = builder.Configuration.GetConnectionString("Default")
|
builder.Logging.ClearProviders();
|
||||||
?? throw new InvalidOperationException("Connection string is not found.");
|
builder.Host.UseNLog();
|
||||||
|
}
|
||||||
|
|
||||||
var logger = provider.GetRequiredService<ILogger<RecDbContext>>();
|
var config = builder.Configuration;
|
||||||
opt.UseSqlServer(cnnStr)
|
|
||||||
.LogTo(log => logger.LogInformation("{log}", log), LogLevel.Trace)
|
// Add services to the container.
|
||||||
.EnableSensitiveDataLogging()
|
builder.Services.AddRecServices(options =>
|
||||||
.EnableDetailedErrors();
|
{
|
||||||
|
options.LuckyPennySoftwareLicenseKey = builder.Configuration["LuckyPennySoftwareLicenseKey"];
|
||||||
|
options.ConfigureRecActions(config.GetSection("RecAction"));
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddRecInfrastructure(options =>
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
{
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
options.ConfigureDbContext((provider, opt) =>
|
||||||
builder.Services.AddSwaggerGen();
|
{
|
||||||
|
var cnnStr = builder.Configuration.GetConnectionString("Default")
|
||||||
|
?? throw new InvalidOperationException("Connection string is not found.");
|
||||||
|
|
||||||
var app = builder.Build();
|
var logger = provider.GetRequiredService<ILogger<RecDbContext>>();
|
||||||
|
opt.UseSqlServer(cnnStr)
|
||||||
|
.LogTo(log => logger.LogInformation("{log}", log), LogLevel.Trace)
|
||||||
|
.EnableSensitiveDataLogging()
|
||||||
|
.EnableDetailedErrors();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.Services.AddControllers();
|
||||||
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
builder.Services.AddSwaggerGen();
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
#pragma warning disable CS0618
|
#pragma warning disable CS0618
|
||||||
app.UseMiddleware<ExceptionHandlingMiddleware>();
|
app.UseMiddleware<ExceptionHandlingMiddleware>();
|
||||||
#pragma warning restore CS0618
|
#pragma warning restore CS0618
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI();
|
app.UseSwaggerUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
app.MapControllers();
|
||||||
|
|
||||||
|
app.Run();
|
||||||
}
|
}
|
||||||
|
catch(Exception ex)
|
||||||
app.UseHttpsRedirection();
|
{
|
||||||
|
logger.Error(ex, "Stopped program because of exception");
|
||||||
app.UseAuthorization();
|
throw;
|
||||||
|
}
|
||||||
app.MapControllers();
|
|
||||||
|
|
||||||
app.Run();
|
|
||||||
17
src/ReC.API/Properties/PublishProfiles/IISProfile.pubxml
Normal file
17
src/ReC.API/Properties/PublishProfiles/IISProfile.pubxml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<WebPublishMethod>Package</WebPublishMethod>
|
||||||
|
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||||
|
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||||
|
<SiteUrlToLaunchAfterPublish />
|
||||||
|
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||||
|
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||||
|
<ProjectGuid>420218ad-3c27-4003-9a84-36c92352f175</ProjectGuid>
|
||||||
|
<DesktopBuildPackageLocation>P:\Install .Net\0 DD - Smart UP\ReC\API\$(Version)\Rec.API.zip</DesktopBuildPackageLocation>
|
||||||
|
<PackageAsSingleFile>true</PackageAsSingleFile>
|
||||||
|
<DeployIisAppPath>Rec.API</DeployIisAppPath>
|
||||||
|
<_TargetId>IISWebDeployPackage</_TargetId>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
@ -1,14 +1,27 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<PackageId>ReC.API</PackageId>
|
||||||
|
<Authors>Digital Data GmbH</Authors>
|
||||||
|
<Company>Digital Data GmbH</Company>
|
||||||
|
<Product>ReC.API</Product>
|
||||||
|
<PackageIcon>Assets\icon.ico</PackageIcon>
|
||||||
|
<PackageTags>digital data rest-caller rec api</PackageTags>
|
||||||
|
<Version>1.0.0-beta</Version>
|
||||||
|
<AssemblyVersion>1.0.0.0</AssemblyVersion>
|
||||||
|
<FileVersion>1.0.0.0</FileVersion>
|
||||||
|
<InformationalVersion>1.0.0-beta</InformationalVersion>
|
||||||
|
<Copyright>Copyright © 2025 Digital Data GmbH. All rights reserved.</Copyright>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.11" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.11" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
||||||
|
<PackageReference Include="NLog" Version="5.2.5" />
|
||||||
|
<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -14,5 +14,56 @@
|
|||||||
"MaxConcurrentInvocations": 5
|
"MaxConcurrentInvocations": 5
|
||||||
},
|
},
|
||||||
"AddedWho": "ReC.API",
|
"AddedWho": "ReC.API",
|
||||||
"FakeProfileId": 2
|
"FakeProfileId": 2,
|
||||||
|
"NLog": {
|
||||||
|
"throwConfigExceptions": true,
|
||||||
|
"variables": {
|
||||||
|
"logDirectory": "E:\\LogFiles\\Digital Data\\Rec.API",
|
||||||
|
"logFileNamePrefix": "${shortdate}.Rec.API"
|
||||||
|
},
|
||||||
|
"targets": {
|
||||||
|
"infoLogs": {
|
||||||
|
"type": "File",
|
||||||
|
"fileName": "${logDirectory}\\${logFileNamePrefix}-Info.log",
|
||||||
|
"maxArchiveDays": 30
|
||||||
|
},
|
||||||
|
"warningLogs": {
|
||||||
|
"type": "File",
|
||||||
|
"fileName": "${logDirectory}\\${logFileNamePrefix}-Warning.log",
|
||||||
|
"maxArchiveDays": 30
|
||||||
|
},
|
||||||
|
"errorLogs": {
|
||||||
|
"type": "File",
|
||||||
|
"fileName": "${logDirectory}\\${logFileNamePrefix}-Error.log",
|
||||||
|
"maxArchiveDays": 30
|
||||||
|
},
|
||||||
|
"criticalLogs": {
|
||||||
|
"type": "File",
|
||||||
|
"fileName": "${logDirectory}\\${logFileNamePrefix}-Critical.log",
|
||||||
|
"maxArchiveDays": 30
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"logger": "*",
|
||||||
|
"level": "Info",
|
||||||
|
"writeTo": "infoLogs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"logger": "*",
|
||||||
|
"level": "Warn",
|
||||||
|
"writeTo": "warningLogs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"logger": "*",
|
||||||
|
"level": "Error",
|
||||||
|
"writeTo": "errorLogs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"logger": "*",
|
||||||
|
"level": "Fatal",
|
||||||
|
"writeTo": "criticalLogs"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user