Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3abaf417a9 | ||
|
|
31540dbfe6 | ||
|
|
380dd7d577 | ||
|
|
b2c0c7517a | ||
|
|
505487a345 | ||
|
|
f8c6316d4e | ||
|
|
e9d30aad16 | ||
|
|
66f8d19f67 | ||
|
|
fdc816624e | ||
|
|
c384e3bdca | ||
|
|
a28799273b | ||
|
|
b7f04522ce | ||
|
|
3b5ae86ce5 | ||
|
|
2de05c3856 |
36
.vscode/launch.json
vendored
Normal file
36
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": ".NET Core Launch (web)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
// If you have changed target frameworks, make sure to update the program path.
|
||||
"program": "${workspaceFolder}/SearchWebApi/bin/Debug/net6.0/SearchWebApi.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}/SearchWebApi",
|
||||
"stopAtEntry": false,
|
||||
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
|
||||
"serverReadyAction": {
|
||||
"action": "openExternally",
|
||||
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
|
||||
},
|
||||
"env": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"ASPNETCORE_URLS": "http://localhost:5000"
|
||||
},
|
||||
"sourceFileMap": {
|
||||
"/Views": "${workspaceFolder}/Views"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach"
|
||||
}
|
||||
]
|
||||
}
|
||||
44
.vscode/tasks.json
vendored
Normal file
44
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"command": "dotnet",
|
||||
"type": "shell",
|
||||
"args": [
|
||||
"build",
|
||||
"${workspaceFolder}/SearchWebApi/SearchWebApi.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "publish",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"publish",
|
||||
"${workspaceFolder}/SearchWebApi/SearchWebApi.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "watch",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"watch",
|
||||
"run",
|
||||
"${workspaceFolder}/SearchWebApi/SearchWebApi.csproj",
|
||||
"/property:GenerateFullPaths=true",
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -27,6 +27,7 @@ namespace BusinessLogic.LookupLogic
|
||||
public async Task<DataResult<List<LookupCategory>>> GetAllLookups()
|
||||
{
|
||||
var result = await _lookupRepo.GetAllLookups();
|
||||
_logger.LogInformation($"Call to GetAllLookups ended with {result.GeneralResult.ToString()}");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.16" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.16" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Datamodels\Datamodels.csproj" />
|
||||
<ProjectReference Include="..\..\Repositories\Repositories.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace SearchApi.Exceptions
|
||||
{
|
||||
public class FieldAliasMissingException : Exception
|
||||
{
|
||||
public FieldAliasMissingException(string message) : base(message: message) {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace SearchApi.Exceptions
|
||||
{
|
||||
public class TableAliasMissingException : Exception
|
||||
{
|
||||
public TableAliasMissingException(string message) : base(message: message) {}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using Datamodels.BusinessModels;
|
||||
using Datamodels.DatabaseModels;
|
||||
using Datamodels.SearchModels;
|
||||
|
||||
namespace SearchLogic
|
||||
namespace SearchApi.SearchLogic
|
||||
{
|
||||
public interface ISearchLogic
|
||||
{
|
||||
|
||||
@@ -9,14 +9,22 @@ using Datamodels.SearchModels;
|
||||
using Newtonsoft.Json;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using SearchApi.Exceptions;
|
||||
using Datamodels.Enums;
|
||||
|
||||
namespace SearchLogic
|
||||
namespace SearchApi.SearchLogic
|
||||
{
|
||||
public class SearchLogic : ISearchLogic
|
||||
{
|
||||
private readonly ILogger<SearchLogic> _logger;
|
||||
private readonly IFwMariaSearchRepo _searchRepo;
|
||||
|
||||
private List<string> _tableNames = new List<string>();
|
||||
private List<string> _joinConditions = new List<string>();
|
||||
private List<string> _fieldNames = new List<string>();
|
||||
private List<string> _whereConditions = new List<string>();
|
||||
private List<string> _sortFields = new List<string>();
|
||||
|
||||
public SearchLogic(ILogger<SearchLogic> logger, IFwMariaSearchRepo searchRepo)
|
||||
{
|
||||
_logger = logger;
|
||||
@@ -34,8 +42,143 @@ namespace SearchLogic
|
||||
var result = new DataResult<ResultModel>();
|
||||
result.Data = new ResultModel();
|
||||
result.Data.SearchModel = filter;
|
||||
|
||||
var sql = await Task.Run(() => { return AssembleSqlQuery(filter); } );
|
||||
return result;
|
||||
}
|
||||
|
||||
// Extract Table
|
||||
private void GetTables(FilterModel filter)
|
||||
{
|
||||
bool hasTableList = filter.TableDescriptions.Count > 0;
|
||||
_tableNames = new List<string>();
|
||||
foreach(var table in filter.TableDescriptions)
|
||||
{
|
||||
if (hasTableList && string.IsNullOrEmpty(table.TableAlias))
|
||||
{
|
||||
throw new TableAliasMissingException($"No Alias defined for Table {table.TableName}");
|
||||
}
|
||||
_tableNames.Add($"{table.TableName} {(string.IsNullOrEmpty(table.TableAlias) ? string.Empty : table.TableAlias)}");
|
||||
}
|
||||
}
|
||||
|
||||
// Extract Fieldlist
|
||||
private void GetFields(FilterModel filter)
|
||||
{
|
||||
var tables = filter.TableDescriptions;
|
||||
foreach (var table in tables)
|
||||
{
|
||||
bool hasMultipleFields = table.Fields.Count > 0;
|
||||
foreach (var field in table.Fields) {
|
||||
if (hasMultipleFields && string.IsNullOrEmpty(field.FieldAlias))
|
||||
{
|
||||
throw new FieldAliasMissingException($"No Alias defined for Field {field.FieldName} in Table {table.TableName}");
|
||||
}
|
||||
_fieldNames.Add($"{table.TableAlias}.{field.FieldName} {field.FieldAlias}");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Extract Join Path if more than one table
|
||||
private void GetTableJoinConditions(FilterModel filter)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Extract Where Conditions
|
||||
// ToDo: wenn es mehrere Values gibt, werden die generell mit OR verknüpft? Oder nehmen wir lieber AND?
|
||||
private void GetWhereConditions(string tableName, FieldModel field)
|
||||
{
|
||||
if (field.SearchDescriptions.Count > 0)
|
||||
{
|
||||
foreach (var condition in field.SearchDescriptions)
|
||||
{
|
||||
var op = Operator(condition.SearchData.PhraseOperator);
|
||||
if (op != "NOTHING")
|
||||
{
|
||||
var usedField = $"{tableName}.{field.FieldName}{op}{condition.SearchData.Values[0]}";
|
||||
_whereConditions.Add(usedField);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (condition.SearchData.PhraseOperator == PhraseOperators.Contains)
|
||||
{
|
||||
var usedField = $"{tableName}.{field.FieldName} like '%{condition.SearchData.Values[0]}%'";
|
||||
_whereConditions.Add(usedField);
|
||||
}
|
||||
if (condition.SearchData.PhraseOperator == PhraseOperators.StartsWith)
|
||||
{
|
||||
var usedField = $"{tableName}.{field.FieldName} like '%{condition.SearchData.Values[0]}'";
|
||||
_whereConditions.Add(usedField);
|
||||
}
|
||||
if (condition.SearchData.PhraseOperator == PhraseOperators.EndsWith)
|
||||
{
|
||||
var usedField = $"{tableName}.{field.FieldName} like '{condition.SearchData.Values[0]} + %'";
|
||||
_whereConditions.Add(usedField);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public string Operator(PhraseOperators ops)
|
||||
{
|
||||
switch (ops)
|
||||
{
|
||||
case PhraseOperators.Equal:
|
||||
return "=";
|
||||
case PhraseOperators.NotEqual:
|
||||
return "!=";
|
||||
case PhraseOperators.GreaterThan:
|
||||
return ">";
|
||||
case PhraseOperators.GreaterThanOrEqual:
|
||||
return ">=";
|
||||
case PhraseOperators.LowerThan:
|
||||
return "<";
|
||||
case PhraseOperators.LowerThanOrEqual:
|
||||
return "<=";
|
||||
default:
|
||||
return "NOTHING";
|
||||
}
|
||||
}
|
||||
|
||||
// Extract Sort Items
|
||||
private void GetSortFields(FilterModel filter)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Assemble SQL Query
|
||||
private string AssembleSqlQuery(FilterModel filter)
|
||||
{
|
||||
GetTables(filter);
|
||||
GetFields(filter);
|
||||
var result = BuildSql();
|
||||
return result;
|
||||
}
|
||||
|
||||
//Build SQL String itself
|
||||
private string BuildSql()
|
||||
{
|
||||
var sql = "SELECT ";
|
||||
foreach (var field in _fieldNames)
|
||||
{
|
||||
sql += field.ToUpper();
|
||||
if (_fieldNames.IndexOf(field) < _fieldNames.Count - 1) sql += ",";
|
||||
}
|
||||
|
||||
sql += " FROM ";
|
||||
foreach (var table in _tableNames)
|
||||
{
|
||||
sql += table.ToUpper();
|
||||
if (_tableNames.IndexOf(table) < _tableNames.Count - 1)
|
||||
{
|
||||
sql += ",";
|
||||
}
|
||||
}
|
||||
|
||||
return sql;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ namespace Repositories
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
|
||||
optionsBuilder.UseMySql(_connectionString);
|
||||
var version = new MariaDbServerVersion(new Version(10,5));
|
||||
optionsBuilder.UseMySql(_connectionString, version);
|
||||
}
|
||||
|
||||
public DbSet<LookupCategory> LookupCategories { get; set; }
|
||||
|
||||
@@ -8,6 +8,7 @@ using Repositories.Interfaces;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.Configuration;
|
||||
|
||||
namespace Repositories
|
||||
{
|
||||
@@ -26,11 +27,11 @@ namespace Repositories
|
||||
{
|
||||
if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development")
|
||||
{
|
||||
_dbContext._connectionString = "SERVER=127.0.0.1;DATABASE=testdb;PORT=3306;USER=root;PASSWORD=example";
|
||||
_dbContext._connectionString = "SERVER=192.168.178.44;DATABASE=fwTest;PORT=3330;USER=root;PASSWORD=$64,Rf1209";
|
||||
}
|
||||
else
|
||||
{
|
||||
string usedDb = configuration.GetSection("GeneralSettings").GetSection("DbToUse").Get<string>();
|
||||
string usedDb = configuration.GetSection("GeneralSettings").GetSection("DbToUse").Value;
|
||||
string connectionString = configuration.GetConnectionString(usedDb);
|
||||
_dbContext._connectionString = connectionString;
|
||||
}
|
||||
@@ -55,7 +56,7 @@ namespace Repositories
|
||||
_logger.LogError(ex, "Error reading Lookup Data");
|
||||
return new DataResult<List<LookupCategory>>
|
||||
{
|
||||
UserMessage = "Daten f<>r Lookups konnten nicht gelesen werden.",
|
||||
UserMessage = "Daten f<>r Lookups konnten nicht gelesen werden.",
|
||||
ServerMessage = ex.Message,
|
||||
GeneralResult = GeneralResults.DatabaseError,
|
||||
StackTrace = ex.StackTrace
|
||||
@@ -79,7 +80,7 @@ namespace Repositories
|
||||
_logger.LogError(ex, $"Error reading Lookup Category with Id: {id}");
|
||||
return new DataResult<LookupCategory>
|
||||
{
|
||||
UserMessage = $"Daten f<>r Lookup Kategorie mit Id {id} konnten nicht gelesen werden.",
|
||||
UserMessage = $"Daten f<>r Lookup Kategorie mit Id {id} konnten nicht gelesen werden.",
|
||||
ServerMessage = ex.Message,
|
||||
GeneralResult = GeneralResults.DatabaseError,
|
||||
StackTrace = ex.StackTrace
|
||||
@@ -103,7 +104,7 @@ namespace Repositories
|
||||
_logger.LogError(ex, $"Error reading Lookup Category with Name: {categoryName}");
|
||||
return new DataResult<List<LookupCategory>>
|
||||
{
|
||||
UserMessage = $"Daten f<>r Lookup Kategorie mit Namen {categoryName} konnten nicht gelesen werden.",
|
||||
UserMessage = $"Daten f<>r Lookup Kategorie mit Namen {categoryName} konnten nicht gelesen werden.",
|
||||
ServerMessage = ex.Message,
|
||||
GeneralResult = GeneralResults.DatabaseError,
|
||||
StackTrace = ex.StackTrace
|
||||
@@ -127,7 +128,7 @@ namespace Repositories
|
||||
_logger.LogError(ex, "Error reading active Lookup Data");
|
||||
return new DataResult<List<LookupCategory>>
|
||||
{
|
||||
UserMessage = "Daten f<>r aktive Lookups konnten nicht gelesen werden.",
|
||||
UserMessage = "Daten f<>r aktive Lookups konnten nicht gelesen werden.",
|
||||
ServerMessage = ex.Message,
|
||||
GeneralResult = GeneralResults.DatabaseError,
|
||||
StackTrace = ex.StackTrace
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Repositories
|
||||
}
|
||||
else
|
||||
{
|
||||
string usedDb = configuration.GetSection("GeneralSettings").GetSection("DbToUse").Get<string>();
|
||||
string usedDb = configuration.GetSection("GeneralSettings").GetSection("DbToUse").Value;
|
||||
string connectionString = configuration.GetConnectionString(usedDb);
|
||||
_dbContext._connectionString = connectionString;
|
||||
}
|
||||
|
||||
@@ -1,22 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Datamodels\Datamodels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.16" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.16">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.2.6" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.16" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.16" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -26,7 +26,10 @@ namespace FwSearchApi.Controllers
|
||||
public async Task<JsonResult> GetAllLookups()
|
||||
{
|
||||
var result = await _lookupLogic.GetAllLookups();
|
||||
_logger.LogInformation($"Lookups zur Verf<72>gung gestellt von {nameof(GetAllLookups)}");
|
||||
if (result.GeneralResult != Datamodels.BusinessModels.GeneralResults.Success) {
|
||||
throw new System.Exception("das war wohl nix");
|
||||
}
|
||||
_logger.LogInformation($"Lookups zur Verfügung gestellt von {nameof(GetAllLookups)}");
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Threading.Tasks;
|
||||
using SearchLogic;
|
||||
using SearchApi.SearchLogic;
|
||||
using Datamodels.SearchModels;
|
||||
using System.Collections.Generic;
|
||||
using Datamodels.DatabaseModels;
|
||||
|
||||
17
SearchWebApi/NuGet.Config
Normal file
17
SearchWebApi/NuGet.Config
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||
</packageSources>
|
||||
<packageSourceCredentials>
|
||||
<Gtue.Framework>
|
||||
<add key="Username" value="not_needed" />
|
||||
<add key="ClearTextPassword" value="%NUGET_PAT%" />
|
||||
</Gtue.Framework>
|
||||
<Gtue.Welt>
|
||||
<add key="Username" value="not_needed" />
|
||||
<add key="ClearTextPassword" value="%NUGET_PAT%" />
|
||||
</Gtue.Welt>
|
||||
</packageSourceCredentials>
|
||||
</configuration>
|
||||
@@ -1,3 +1,5 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Buffers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -7,6 +9,7 @@ using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OpenTelemetry.Logs;
|
||||
using Serilog;
|
||||
|
||||
namespace FwSearchApi
|
||||
@@ -24,19 +27,41 @@ namespace FwSearchApi
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(Configuration)
|
||||
.CreateLogger();
|
||||
|
||||
try {
|
||||
CreateWebHostBuilder(args).Build().Run();
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
finally{
|
||||
finally
|
||||
{
|
||||
Log.CloseAndFlush();
|
||||
}
|
||||
}
|
||||
|
||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
||||
WebHost.CreateDefaultBuilder(args)
|
||||
.UseConfiguration(Configuration)
|
||||
.UseStartup<Startup>()
|
||||
.UseSerilog()
|
||||
.SuppressStatusMessages(true);
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStartup<Startup>();
|
||||
webBuilder.UseSerilog();
|
||||
webBuilder.UseConfiguration(Configuration);
|
||||
webBuilder.SuppressStatusMessages(true);
|
||||
})
|
||||
.ConfigureLogging((context, builder) =>
|
||||
{
|
||||
builder.ClearProviders();
|
||||
builder.AddConsole();
|
||||
builder.AddSerilog();
|
||||
|
||||
builder.AddOpenTelemetry(options =>
|
||||
{
|
||||
options.IncludeScopes = true;
|
||||
options.ParseStateValues = true;
|
||||
options.IncludeFormattedMessage = true;
|
||||
options.AddConsoleExporter();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,37 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.16" />
|
||||
<PackageReference Include="Elastic.Apm.EntityFrameworkCore" Version="1.11.1" />
|
||||
<PackageReference Include="Elastic.Apm.NetCoreAll" Version="1.11.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="OpenTelemetry.Contrib.Instrumentation.EntityFrameworkCore" Version="1.0.0-beta2" />
|
||||
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.1.0" />
|
||||
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.1.0" />
|
||||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc8" />
|
||||
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc8" />
|
||||
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc8" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.4" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.1.4" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.1.4" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.1.4" />
|
||||
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
|
||||
<PackageReference Include="Serilog.Enrichers.ExceptionStackTraceHash" Version="1.3.0" />
|
||||
<PackageReference Include="Serilog.Exceptions" Version="7.1.0" />
|
||||
<PackageReference Include="Serilog.Formatting.Elasticsearch" Version="8.4.1" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
|
||||
<PackageReference Include="serilog.sinks.console" Version="4.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.ElasticSearch" Version="8.4.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.2" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.2.2" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.2.2" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.2.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BusinessLogic\LookupLogic\LookupLogic.csproj" />
|
||||
<ProjectReference Include="..\BusinessLogic\SearchLogic\SearchLogic.csproj" />
|
||||
<ProjectReference Include="..\Datamodels\Datamodels.csproj" />
|
||||
<ProjectReference Include="..\Repositories\Repositories.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
||||
@@ -1,20 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.HttpsPolicy;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Repositories;
|
||||
using Repositories.Interfaces;
|
||||
|
||||
using BusinessLogic.LookupLogic;
|
||||
using BusinessLogic.LookupLogic.Interfaces;
|
||||
using SearchLogic;
|
||||
|
||||
using OpenTelemetry.Resources;
|
||||
using OpenTelemetry.Trace;
|
||||
|
||||
using Repositories;
|
||||
using Repositories.Interfaces;
|
||||
|
||||
using SearchApi.SearchLogic;
|
||||
|
||||
namespace FwSearchApi
|
||||
{
|
||||
@@ -24,11 +26,10 @@ namespace FwSearchApi
|
||||
readonly ILogger<Startup> _logger;
|
||||
public IConfiguration _configuration { get; }
|
||||
|
||||
public Startup(IConfiguration configuration, ILogger<Startup> logger)
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_logger = logger;
|
||||
_logger.LogInformation("Starting up FeatureWerk Search API");
|
||||
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
@@ -42,10 +43,20 @@ namespace FwSearchApi
|
||||
services.AddTransient<ILookupLogic, FwLookupLogic>();
|
||||
services.AddTransient<IFwMariaLookupRepo, FwMariaLookupRepo>();
|
||||
services.AddTransient<IFwMariaSearchRepo, FwMariaSearchRepo>();
|
||||
services.AddTransient<ISearchLogic, SearchLogic.SearchLogic>();
|
||||
services.AddTransient<ISearchLogic, SearchLogic>();
|
||||
services.AddSwaggerGen();
|
||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); //needed if no Security is used when calling APM Server
|
||||
services.AddOpenTelemetryTracing((builder) => builder
|
||||
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("TxSearchApi"))
|
||||
.AddAspNetCoreInstrumentation()
|
||||
.AddHttpClientInstrumentation()
|
||||
.AddEntityFrameworkCoreInstrumentation(o => o.SetDbStatementForText = true) //logging of Statement as Span
|
||||
.AddOtlpExporter(otlpOptions => {
|
||||
otlpOptions.Endpoint = new Uri("http://192.168.178.44:8200");
|
||||
}));
|
||||
|
||||
|
||||
|
||||
_logger.LogInformation("Services for FeatureWerkAPIs configured");
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Warning",
|
||||
"Microsoft": "Warning",
|
||||
"Default": "Information",
|
||||
"Microsoft": "Information",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
@@ -20,20 +20,24 @@
|
||||
"Default": "Information",
|
||||
"Override": {
|
||||
"System": "Information",
|
||||
"Microsoft": "Warning"
|
||||
"Microsoft": "Information"
|
||||
}
|
||||
},
|
||||
"WriteTo": [
|
||||
{ "Name": "File",
|
||||
{
|
||||
"Name": "Elasticsearch",
|
||||
"Args": {
|
||||
"path": "/tmp/FwSearchApi.log",
|
||||
"rollingInterval": "Day"
|
||||
"nodeUris": "http://192.168.178.44:9200",
|
||||
"indexFormat": "TextorSearchLoggingIndex-{0:yyyy.MM}",
|
||||
"autoRegisterTemplate": true,
|
||||
"autoRegisterTemplateVersion": "ESv7",
|
||||
"registerTemplateFailure": "IndexAnyway"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enrich": ["FromLogContext", "WithMachineName"],
|
||||
"Enrich": ["FromLogContext", "WithMachineName", "WithProcessId", "WithProcessName"],
|
||||
"Properties": {
|
||||
"Appname": "FeatureWerkSearchAPI",
|
||||
"Appname": "TxSearchApi",
|
||||
"Environment": "Development"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,42 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Information",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
"Default": "Information"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
"ElasticApm":
|
||||
{
|
||||
"ServerUrl": "http://192.168.178.44:8200",
|
||||
"SecretToken": "",
|
||||
"ServiceName": "TxSearchApi",
|
||||
"Environment": "Development",
|
||||
"CaptureBody": "all"
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
"Default": "Information",
|
||||
"Override": {
|
||||
"System": "Information",
|
||||
"Microsoft": "Information"
|
||||
}
|
||||
},
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "Elasticsearch",
|
||||
"Args": {
|
||||
"nodeUris": "http://192.168.178.44:9200",
|
||||
"indexFormat": "TextorSearchLoggingIndex-{0:yyyy.MM}",
|
||||
"autoRegisterTemplate": true,
|
||||
"autoRegisterTemplateVersion": "ESv7",
|
||||
"registerTemplateFailure": "IndexAnyway"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enrich": ["FromLogContext", "WithMachineName", "WithProcessId", "WithProcessName"],
|
||||
"Properties": {
|
||||
"Appname": "TxSearchApi",
|
||||
"Environment": "Production"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Repositories\Repositories.csproj" />
|
||||
<ProjectReference Include="..\..\..\Repositories\Repositories.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.16">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0-rc.2.21480.5">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user