refactor: Projektdateien migriert. Cloud-NuGet-Pakete durch lokale NuGet-Projekte ersetzt.

This commit is contained in:
Developer 02
2024-08-01 18:44:39 +02:00
parent 0d82f7af6f
commit 62ddd4873f
206 changed files with 10927 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
{
"version": 1,
"isRoot": true,
"tools": {}
}

View File

@@ -0,0 +1,15 @@
using DAL.Models.Entities;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class AdWebAppToWebAppRoleController : BaseController<AdWebAppToWebAppRole>
{
public AdWebAppToWebAppRoleController(IBaseRepository<AdWebAppToWebAppRole> repositoryBase) : base(repositoryBase)
{
}
}
}

View File

@@ -0,0 +1,15 @@
using DAL.Models.Entities;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class CostCentreController : BaseController<CostCentre>
{
public CostCentreController(IBaseRepository<CostCentre> repositoryBase) : base(repositoryBase)
{
}
}
}

View File

@@ -0,0 +1,54 @@
using DAL.Models.Entities;
using DAL.Models.Filters;
using DAL.Repositories;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class DepartmentController : BaseController<Department>
{
public DepartmentController(IBaseRepository<Department> repositoryBase) : base(repositoryBase)
{
}
[HttpPost("DepartmentFullFilter")]
public async Task<IActionResult> GetDepartmentListAsync([FromBody] DepartmentFullFilter filter)
{
try
{
var list = await ((DepartmentRepository)EntityRepository).GetDepartmentListAsync(filter);
return new OkObjectResult(list);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Cann't get the filtered list of {typeof(Employee).Name}");
}
}
[HttpPut("CopyWindreamTiles/{DepartmentId}")]
public async Task<IActionResult> GetVisitorListAsync(int DepartmentId, [FromBody] List<int> trgDepartmentIds)
{
var strTrgDepartmentIds = string.Join(",", trgDepartmentIds);
try
{
await ((DepartmentRepository)EntityRepository).ReplaceWindreamTiles(DepartmentId, strTrgDepartmentIds);
this.WriteLogWarn($"Windream Search Tiles from Department Id={DepartmentId} are replaced Tiles in the Departments with Ids={strTrgDepartmentIds}");
return new OkObjectResult(true);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Windream Search Tiles from Department Id={DepartmentId} cann't replace Tiles in the Departments with Ids={strTrgDepartmentIds}");
}
}
}
}

View File

@@ -0,0 +1,36 @@
using DAL.Models.Entities;
using DAL.Models.Filters;
using DAL.Repositories;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class DepartmentToWebAppToEmployeeForWindreamController : BaseController<DepartmentToWebAppToEmployeeForWindream>
{
public DepartmentToWebAppToEmployeeForWindreamController(IBaseRepository<DepartmentToWebAppToEmployeeForWindream> repositoryBase) : base(repositoryBase)
{
}
[HttpPost("EmployeeFilter")]
public async Task<IActionResult> GetDepartmentToWebAppToEmployeeForWindreamListAsync([FromBody] EmployeeFilter filter)
{
try
{
var list = await ((DepartmentToWebAppToEmployeeForWindreamRepository)EntityRepository).GetListByFilterAsync(filter);
return new OkObjectResult(list);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Cann't get the filtered list of {typeof(DepartmentToWebAppToEmployeeForWindream).Name}");
}
}
}
}

View File

@@ -0,0 +1,15 @@
using DAL.Models.Entities;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class DocumentArtController : BaseController<DocumentArt>
{
public DocumentArtController(IBaseRepository<DocumentArt> repositoryBase) : base(repositoryBase)
{
}
}
}

View File

@@ -0,0 +1,36 @@
using DAL.Models.Entities;
using DAL.Models.Filters;
using DAL.Repositories;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class DocumentArtToDepartmentController : BaseController<DocumentArtToDepartment>
{
public DocumentArtToDepartmentController(IBaseRepository<DocumentArtToDepartment> repositoryBase) : base(repositoryBase)
{
}
[HttpPost("DepartmentFilter")]
public async Task<IActionResult> GetDocumentArtToDepartmentListAsync([FromBody] DepartmentFilter filter)
{
try
{
var list = await ((DocumentArtToDepartmentRepository)EntityRepository).GetListByFilterAsync(filter);
return new OkObjectResult(list);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Cann't get the filtered list of {typeof(DocumentArtToDepartment).Name}");
}
}
}
}

View File

@@ -0,0 +1,15 @@
using DAL.Models.Entities;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class EmployeeAttributeController : BaseController<EmployeeAttribute>
{
public EmployeeAttributeController(IBaseRepository<EmployeeAttribute> repositoryBase) : base(repositoryBase)
{
}
}
}

View File

@@ -0,0 +1,36 @@
using DAL.Models.Entities;
using DAL.Models.Filters;
using DAL.Repositories;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class EmployeeController : BaseController<Employee>
{
public EmployeeController(IBaseRepository<Employee> repositoryBase) : base(repositoryBase)
{
}
[HttpPost("EmployeeFullFilter")]
public async Task<IActionResult> GetEmployeeListAsync([FromBody] EmployeeFullFilter filter)
{
try
{
var list = await ((EmployeeRepository)EntityRepository).GetListByFilterAsync(filter);
return new OkObjectResult(list);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Cann't get the filtered list of {typeof(Employee).Name}");
}
}
}
}

View File

@@ -0,0 +1,15 @@
using DAL.Models.Entities;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class EmployeeStatusController : BaseController<EmployeeStatus>
{
public EmployeeStatusController(IBaseRepository<EmployeeStatus> repositoryBase) : base(repositoryBase)
{
}
}
}

View File

@@ -0,0 +1,36 @@
using DAL.Models.Entities;
using DAL.Models.Filters;
using DAL.Repositories;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class EmployeeToAttributeController : BaseController<EmployeeToAttribute>
{
public EmployeeToAttributeController(IBaseRepository<EmployeeToAttribute> repositoryBase) : base(repositoryBase)
{
}
[HttpPost("EmployeeFilter")]
public async Task<IActionResult> GetEmployeeToAttributeListAsync([FromBody] EmployeeFilter filter)
{
try
{
var list = await ((EmployeeToAttributeRepository)EntityRepository).GetListByFilterAsync(filter);
return new OkObjectResult(list);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Cann't get the filtered list of {typeof(EmployeeToAttribute).Name}");
}
}
}
}

View File

@@ -0,0 +1,36 @@
using DAL.Models.Entities;
using DAL.Models.Filters;
using DAL.Repositories;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class EmployeeToDepartmentController : BaseController<EmployeeToDepartment>
{
public EmployeeToDepartmentController(IBaseRepository<EmployeeToDepartment> repositoryBase) : base(repositoryBase)
{
}
[HttpPost("EmployeeFilter")]
public async Task<IActionResult> GetEmployeeToDepartmentListAsync([FromBody] EmployeeFilter filter)
{
try
{
var list = await ((EmployeeToDepartmentRepository)EntityRepository).GetListByFilterAsync(filter);
return new OkObjectResult(list);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Cann't get the filtered list of {typeof(EmployeeToDepartment).Name}");
}
}
}
}

View File

@@ -0,0 +1,36 @@
using DAL.Models.Entities;
using DAL.Models.Filters;
using DAL.Repositories;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class EmployeeToWebAppController : BaseController<EmployeeToWebApp>
{
public EmployeeToWebAppController(IBaseRepository<EmployeeToWebApp> repositoryBase) : base(repositoryBase)
{
}
[HttpPost("EmployeeFilter")]
public async Task<IActionResult> GetEmployeeToWebAppListAsync([FromBody] EmployeeFilter filter)
{
try
{
var list = await ((EmployeeToWebAppRepository)EntityRepository).GetListByFilterAsync(filter);
return new OkObjectResult(list);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Cann't get the filtered list of {typeof(EmployeeToWebApp).Name}");
}
}
}
}

View File

@@ -0,0 +1,15 @@
using DAL.Models.Entities;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class ProjectController : BaseController<Project>
{
public ProjectController(IBaseRepository<Project> repositoryBase) : base(repositoryBase)
{
}
}
}

View File

@@ -0,0 +1,15 @@
using DAL.Models.Entities;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class RangController : BaseController<Rang>
{
public RangController(IBaseRepository<Rang> repositoryBase) : base(repositoryBase)
{
}
}
}

View File

@@ -0,0 +1,15 @@
using DAL.Models.Entities;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class SubsidiaryController : BaseController<Subsidiary>
{
public SubsidiaryController(IBaseRepository<Subsidiary> repositoryBase) : base(repositoryBase)
{
}
}
}

View File

@@ -0,0 +1,36 @@
using DAL.Models.Entities;
using DAL.Models.Filters;
using DAL.Repositories;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class WebAppAdditionalRoleController : BaseController<WebAppAdditionalRole>
{
public WebAppAdditionalRoleController(IBaseRepository<WebAppAdditionalRole> repositoryBase) : base(repositoryBase)
{
}
[HttpPost("WebAppFilter")]
public async Task<IActionResult> GetWebAppAdditionalRoleListAsync([FromBody] WebAppFilter filter)
{
try
{
var list = await ((WebAppAdditionalRoleRepository)EntityRepository).GetListByFilterAsync(filter);
return new OkObjectResult(list);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Cann't get the filtered list of {typeof(WebAppAdditionalRole).Name}");
}
}
}
}

View File

@@ -0,0 +1,15 @@
using DAL.Models.Entities;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class WebAppController : BaseController<WebApp>
{
public WebAppController(IBaseRepository<WebApp> repositoryBase) : base(repositoryBase)
{
}
}
}

View File

@@ -0,0 +1,15 @@
using DAL.Models.Entities;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class WebAppRoleController : BaseController<WebAppRole>
{
public WebAppRoleController(IBaseRepository<WebAppRole> repositoryBase) : base(repositoryBase)
{
}
}
}

View File

@@ -0,0 +1,36 @@
using DAL.Models.Entities;
using DAL.Models.Filters;
using DAL.Repositories;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class WebAppToDepartmentController : BaseController<WebAppToDepartment>
{
public WebAppToDepartmentController(IBaseRepository<WebAppToDepartment> repositoryBase) : base(repositoryBase)
{
}
[HttpPost("EmployeeToWebAppFilter")]
public async Task<IActionResult> GetWebAppToDepartmentListAsync([FromBody] EmployeeToWebAppFilter filter)
{
try
{
var list = await ((WebAppToDepartmentRepository)EntityRepository).GetListByFilterAsync(filter);
return new OkObjectResult(list);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Cann't get the filtered list of {typeof(WebAppToDepartment).Name}");
}
}
}
}

View File

@@ -0,0 +1,36 @@
using DAL.Models.Entities;
using DAL.Models.Filters;
using DAL.Repositories;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class WebAppToWebAppAdditionalRoleController : BaseController<WebAppToWebAppAdditionalRole>
{
public WebAppToWebAppAdditionalRoleController(IBaseRepository<WebAppToWebAppAdditionalRole> repositoryBase) : base(repositoryBase)
{
}
[HttpPost("EmployeeToWebAppFilter")]
public async Task<IActionResult> GetWebAppToWebAppAdditionalRoleListAsync([FromBody] EmployeeToWebAppFilter filter)
{
try
{
var list = await ((WebAppToWebAppAdditionalRoleRepository)EntityRepository).GetListByFilterAsync(filter);
return new OkObjectResult(list);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Cann't get the filtered list of {typeof(WebAppToWebAppAdditionalRole).Name}");
}
}
}
}

View File

@@ -0,0 +1,36 @@
using DAL.Models.Entities;
using DAL.Models.Filters;
using DAL.Repositories;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class WebAppToWebAppRoleController : BaseController<WebAppToWebAppRole>
{
public WebAppToWebAppRoleController(IBaseRepository<WebAppToWebAppRole> repositoryBase) : base(repositoryBase)
{
}
[HttpPost("WebAppFilter")]
public async Task<IActionResult> GetWebAppToWebAppRoleListAsync([FromBody] WebAppFilter filter)
{
try
{
var list = await ((WebAppToWebAppRoleRepository)EntityRepository).GetListByFilterAsync(filter);
return new OkObjectResult(list);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Cann't get the filtered list of {typeof(WebAppToWebAppRole).Name}");
}
}
}
}

View File

@@ -0,0 +1,36 @@
using DAL.Models.Entities;
using DAL.Models.Filters;
using DAL.Repositories;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class WindreamColumnsToDepartmentController : BaseController<WindreamColumnsToDepartment>
{
public WindreamColumnsToDepartmentController(IBaseRepository<WindreamColumnsToDepartment> repositoryBase) : base(repositoryBase)
{
}
[HttpPost("DepartmentFilter")]
public async Task<IActionResult> GetWindreamColumnsToDepartmentListAsync([FromBody] DepartmentFilter filter)
{
try
{
var list = await ((WindreamColumnsToDepartmentRepository)EntityRepository).GetListByFilterAsync(filter);
return new OkObjectResult(list);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Cann't get the filtered list of {typeof(WindreamColumnsToDepartment).Name}");
}
}
}
}

View File

@@ -0,0 +1,36 @@
using DAL.Models.Entities;
using DAL.Models.Filters;
using DAL.Repositories;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class WindreamIndexController : BaseController<WindreamIndex>
{
public WindreamIndexController(IBaseRepository<WindreamIndex> repositoryBase) : base(repositoryBase)
{
}
[HttpPost("ClientIdFilter")]
public async Task<IActionResult> GetWindreamIndexListAsync([FromBody] ClientIdFilter filter)
{
try
{
var list = await ((WindreamIndexRepository)EntityRepository).GetListByFilterAsync(filter);
return new OkObjectResult(list);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Cann't get the filtered list of {typeof(WindreamIndex).Name}");
}
}
}
}

View File

@@ -0,0 +1,36 @@
using DAL.Models.Entities;
using DAL.Models.Filters;
using DAL.Repositories;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class WindreamIndexToWindreamSearchToDepartmentController : BaseController<WindreamIndexToWindreamSearchToDepartment>
{
public WindreamIndexToWindreamSearchToDepartmentController(IBaseRepository<WindreamIndexToWindreamSearchToDepartment> repositoryBase) : base(repositoryBase)
{
}
[HttpPost("WindreamSearchToDepartmentFilter")]
public async Task<IActionResult> GetWindreamIndexToWindreamSearchToDepartmentListAsync([FromBody] WindreamSearchToDepartmentFilter filter)
{
try
{
var list = await ((WindreamIndexToWindreamSearchToDepartmentRepository)EntityRepository).GetListByFilterAsync(filter);
return new OkObjectResult(list);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Cann't get the filtered list of {typeof(WindreamIndexToWindreamSearchToDepartment).Name}");
}
}
}
}

View File

@@ -0,0 +1,36 @@
using DAL.Models.Entities;
using DAL.Models.Filters;
using DAL.Repositories;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class WindreamInputFolderController : BaseController<WindreamInputFolder>
{
public WindreamInputFolderController(IBaseRepository<WindreamInputFolder> repositoryBase) : base(repositoryBase)
{
}
[HttpPost("WindreamInputFolderFilter")]
public async Task<IActionResult> GetWindreamInputFolderListAsync([FromBody] WindreamInputFolderFilter filter)
{
try
{
var list = await ((WindreamInputFolderRepository)EntityRepository).GetListByFilterAsync(filter);
return new OkObjectResult(list);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Cann't get the filtered list of {typeof(WindreamInputFolder).Name}");
}
}
}
}

View File

@@ -0,0 +1,36 @@
using DAL.Models.Entities;
using DAL.Models.Filters;
using DAL.Repositories;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class WindreamSearchController : BaseController<WindreamSearch>
{
public WindreamSearchController(IBaseRepository<WindreamSearch> repositoryBase) : base(repositoryBase)
{
}
[HttpPost("ClientIdFilter")]
public async Task<IActionResult> GetWindreamSearchListAsync([FromBody] ClientIdFilter filter)
{
try
{
var list = await ((WindreamSearchRepository)EntityRepository).GetListByFilterAsync(filter);
return new OkObjectResult(list);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Cann't get the filtered list of {typeof(WindreamSearch).Name}");
}
}
}
}

View File

@@ -0,0 +1,36 @@
using DAL.Models.Entities;
using DAL.Models.Filters;
using DAL.Repositories;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class WindreamSearchItemController : BaseController<WindreamSearchItem>
{
public WindreamSearchItemController(IBaseRepository<WindreamSearchItem> repositoryBase) : base(repositoryBase)
{
}
[HttpPost("ClientIdFilter")]
public async Task<IActionResult> GetWindreamSearchItemListAsync([FromBody] ClientIdFilter filter)
{
try
{
var list = await ((WindreamSearchItemRepository)EntityRepository).GetListByFilterAsync(filter);
return new OkObjectResult(list);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Cann't get the filtered list of {typeof(WindreamSearchItem).Name}");
}
}
}
}

View File

@@ -0,0 +1,36 @@
using DAL.Models.Entities;
using DAL.Models.Filters;
using DAL.Repositories;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class WindreamSearchItemToWindreamSearchToDepartmentController : BaseController<WindreamSearchItemToWindreamSearchToDepartment>
{
public WindreamSearchItemToWindreamSearchToDepartmentController(IBaseRepository<WindreamSearchItemToWindreamSearchToDepartment> repositoryBase) : base(repositoryBase)
{
}
[HttpPost("WindreamSearchToDepartmentFilter")]
public async Task<IActionResult> GetWindreamSearchItemToWindreamSearchToDepartmentListAsync([FromBody] WindreamSearchToDepartmentFilter filter)
{
try
{
var list = await ((WindreamSearchItemToWindreamSearchToDepartmentRepository)EntityRepository).GetListByFilterAsync(filter);
return new OkObjectResult(list);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Cann't get the filtered list of {typeof(WindreamSearchItemToWindreamSearchToDepartment).Name}");
}
}
}
}

View File

@@ -0,0 +1,54 @@
using DAL.Models.Entities;
using DAL.Models.Filters;
using DAL.Repositories;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using HRD.WebApi.Repositories;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace StaffDBServer.Controllers
{
[JWTAuthorize]
public class WindreamSearchToDepartmentController : BaseController<WindreamSearchToDepartment>
{
public WindreamSearchToDepartmentController(IBaseRepository<WindreamSearchToDepartment> repositoryBase) : base(repositoryBase)
{
}
[HttpPost("DepartmentFilter")]
public async Task<IActionResult> GetWindreamSearchToDepartmentListAsync([FromBody] DepartmentFilter filter)
{
try
{
var list = await ((WindreamSearchToDepartmentRepository)EntityRepository).GetListByFilterAsync(filter);
return new OkObjectResult(list);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Cann't get the filtered list of {typeof(WindreamSearchToDepartment).Name}");
}
}
[HttpPut("CopyWindreamTile/{WindreamSearchToDepartmentId}")]
public async Task<IActionResult> GetVisitorListAsync(int WindreamSearchToDepartmentId, [FromBody] List<int> trgDepartmentIds)
{
var strTrgDepartmentIds = string.Join(",", trgDepartmentIds);
try
{
await ((WindreamSearchToDepartmentRepository)EntityRepository).AddWindreamTile(WindreamSearchToDepartmentId, strTrgDepartmentIds);
this.WriteLogWarn($"Windream Search Tile Id={WindreamSearchToDepartmentId} is added to Departments wit Ids={strTrgDepartmentIds}");
return new OkObjectResult(true);
}
catch (Exception ex)
{
this.WriteLogException(ex);
return StatusCode(StatusCodes.Status400BadRequest, $"Cann't add Windream Search Tile Id={WindreamSearchToDepartmentId} to Departments wit Ids={strTrgDepartmentIds}");
}
}
}
}

View File

@@ -0,0 +1,37 @@
using HRD.LDAPService;
using HRD.LDAPService.JWT;
using HRD.WebApi;
using System.Collections.Generic;
namespace StaffDBServer.Extends
{
public static class JwtMiddlewareOptionsHelper
{
public static JwtMiddlewareOptions GetJwtMiddlewareOptions()
{
var list = new List<JwtRole>();
var ADGroupPrefix = WebApiConfig.IsLive ? "" : "__Test";
//Admin Role
list.Add(new JwtRole(JwtGlobals.ROLE_ADMIN, "GG_WebApp" + ADGroupPrefix + "_StaffDB_Admin"));
//Core RoleList
list.Add(new JwtRole(JwtGlobals.ROLE_USER, "GG_WebApp" + ADGroupPrefix + "_StaffDB_User")); //(RO) nur eigene
list.Add(new JwtRole(JwtGlobals.ROLE_MASTER, "GG_WebApp" + ADGroupPrefix + "_StaffDB_Master")); //RW ALLE Abteilungen
list.Add(new JwtRole(JwtGlobals.ROLE_DEPARTMENTUSER, "GG_WebApp" + ADGroupPrefix + "_StaffDB_DepartmentUser")); //(RW) auch andere aus eigener Abteilung
list.Add(new JwtRole(JwtGlobals.ROLE_DEPARTMENTMASTER, "GG_WebApp" + ADGroupPrefix + "_StaffDB_DepartmentMaster")); //(RW) auch andere aus eigener Abteilung
JwtMiddlewareOptions options = new JwtMiddlewareOptions()
{
Secret = "12345678901234567809_MY_VERY_LONG_SECRET",
JwtRoleList = list,
ExpirationInMin = 60 * 24 * 30 * 1, //1 Month
AktivateAuthorizationFilter = true,
AuthorizationFilterWhitelistPath = new List<string>() { "api/WebAppUser/LoginWithNameAndPassword", "api/Info" },
AuthorizationFilterBlacklistPath = new List<string>() { "api/WebAppUser/all" }
};
return options;
}
}
}

View File

@@ -0,0 +1,47 @@
using DAL._Shared.SharedModels;
using DAL._Shared.SharedRepositories;
using DAL.Models.Entities;
using DAL.Repositories;
using HRD.WebApi.Repositories;
using Microsoft.Extensions.DependencyInjection;
namespace StaffDBServer.Extends
{
public static class ServiceExtensions4BaseRepository
{
public static void ConfigureRepositoryWrapper(this IServiceCollection services)
{
services.AddScoped(typeof(IBaseRepository<Subsidiary>), typeof(SubsidiaryRepository));
services.AddScoped(typeof(IBaseRepository<WindreamInputFolder>), typeof(WindreamInputFolderRepository));
services.AddScoped(typeof(IBaseRepository<WindreamSearchToDepartment>), typeof(WindreamSearchToDepartmentRepository));
services.AddScoped(typeof(IBaseRepository<WindreamSearchItemToWindreamSearchToDepartment>), typeof(WindreamSearchItemToWindreamSearchToDepartmentRepository));
services.AddScoped(typeof(IBaseRepository<WindreamSearchItem>), typeof(WindreamSearchItemRepository));
services.AddScoped(typeof(IBaseRepository<WindreamSearch>), typeof(WindreamSearchRepository));
services.AddScoped(typeof(IBaseRepository<WindreamIndexToWindreamSearchToDepartment>), typeof(WindreamIndexToWindreamSearchToDepartmentRepository));
services.AddScoped(typeof(IBaseRepository<WindreamIndex>), typeof(WindreamIndexRepository));
services.AddScoped(typeof(IBaseRepository<WindreamColumnsToDepartment>), typeof(WindreamColumnsToDepartmentRepository));
services.AddScoped(typeof(IBaseRepository<WebAppToWebAppRole>), typeof(WebAppToWebAppRoleRepository));
services.AddScoped(typeof(IBaseRepository<WebAppToWebAppAdditionalRole>), typeof(WebAppToWebAppAdditionalRoleRepository));
services.AddScoped(typeof(IBaseRepository<WebAppToDepartment>), typeof(WebAppToDepartmentRepository));
services.AddScoped(typeof(IBaseRepository<WebAppAdditionalRole>), typeof(WebAppAdditionalRoleRepository));
services.AddScoped(typeof(IBaseRepository<EmployeeToWebApp>), typeof(EmployeeToWebAppRepository));
services.AddScoped(typeof(IBaseRepository<EmployeeToDepartment>), typeof(EmployeeToDepartmentRepository));
services.AddScoped(typeof(IBaseRepository<EmployeeToAttribute>), typeof(EmployeeToAttributeRepository));
services.AddScoped(typeof(IBaseRepository<Employee>), typeof(EmployeeRepository));
services.AddScoped(typeof(IBaseRepository<DocumentArtToDepartment>), typeof(DocumentArtToDepartmentRepository));
services.AddScoped(typeof(IBaseRepository<DepartmentToWebAppToEmployeeForWindream>), typeof(DepartmentToWebAppToEmployeeForWindreamRepository));
services.AddScoped(typeof(IBaseRepository<WebAppRole>), typeof(WebAppRoleRepository));
services.AddScoped(typeof(IBaseRepository<WebApp>), typeof(WebAppRepository));
services.AddScoped(typeof(IBaseRepository<Rang>), typeof(RangRepository));
services.AddScoped(typeof(IBaseRepository<Project>), typeof(ProjectRepository));
services.AddScoped(typeof(IBaseRepository<EmployeeStatus>), typeof(EmployeeStatusRepository));
services.AddScoped(typeof(IBaseRepository<EmployeeAttribute>), typeof(EmployeeAttributeRepository));
services.AddScoped(typeof(IBaseRepository<DocumentArt>), typeof(DocumentArtRepository));
services.AddScoped(typeof(IBaseRepository<Department>), typeof(DepartmentRepository));
services.AddScoped(typeof(IBaseRepository<CostCentre>), typeof(CostCentreRepository));
services.AddScoped(typeof(IBaseRepository<AdWebAppToWebAppRole>), typeof(AdWebAppToWebAppRoleRepository));
services.AddScoped(typeof(IBaseRepository<WebAppUser>), typeof(WebAppUserRepository));
services.AddScoped(typeof(IBaseRepository<WebAppEmployeeInfo>), typeof(WebAppEmployeeInfo));
}
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<packageSources>
<clear />
<add key="NuGet Official" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Hensel Packages" value="https://pkgs.dev.azure.com/hensel-recycling/_packaging/HenselFeed/nuget/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>

67
StaffDBServer/Program.cs Normal file
View File

@@ -0,0 +1,67 @@
using HRD.AppLogger;
using HRD.WebApi;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NLog.Web;
using System;
using System.Reflection;
namespace StaffDBServer
{
public class Program
{
public static void Main(string[] args)
{
AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
IConfiguration configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json", true, true).Build();
WebApiConfig.Init(configuration, Assembly.GetExecutingAssembly().GetName());
ILoggerManager logger = new LoggerManager();
logger.LogWarn($"[Start WebApi Server] BaseDirectory: {AppDomain.CurrentDomain.BaseDirectory}; TargetFrameworkName: {AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName}");
try
{
CreateWebHostBuilder(args)
.Build()
.Run();
}
catch (Exception ex)
{
logger.LogException(ex, "Stopped program because of exception");
throw;
}
finally
{
// Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux)
NLog.LogManager.Flush();
NLog.LogManager.Shutdown();
}
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging(options => options.ClearProviders())
.UseStartup<Startup>().ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.SetMinimumLevel(LogLevel.Warning);
})
.UseNLog();
private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs)
{
ILoggerManager logger = new LoggerManager();
logger.LogException((Exception)unhandledExceptionEventArgs.ExceptionObject, "Application closed due to exception.");
NLog.LogManager.Flush();
}
}
}

View File

@@ -0,0 +1,13 @@
{
"profiles": {
"StaffDBServer": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:54305;http://localhost:54306",
"sqlDebugging": true
}
}
}

View File

@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp7.0</TargetFramework>
<Version>1.0.0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;$(NoWarn);1591</NoWarn>
<DocumentationFile></DocumentationFile>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.PlatformAbstractions" Version="1.1.0" />
<PackageReference Include="NSwag.AspNetCore" Version="14.0.7" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DAL\DAL.csproj" />
<ProjectReference Include="..\HRD.LDAPService\HRD.LDAPService.csproj" />
</ItemGroup>
</Project>

69
StaffDBServer/Startup.cs Normal file
View File

@@ -0,0 +1,69 @@
using DAL;
using HRD.LDAPService.JWT;
using HRD.WebApi;
using HRD.WebApi.DAL.Middleware;
using HRD.WebApi.Helpers;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using NLog.Web;
using StaffDBServer.Extends;
using StaffDBServer.SharedExtensions;
using System;
namespace StaffDBServer
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.ConfigureWebApiExtensionsAtFirst(); //at first
services.ConfigureRepositoryWrapper(); //add repos
services.AddDbContext<WebApiContext>(options =>
{
const int dbTimeoutInMin = 5;
options
.UseSqlServer(WebApiConfig.ConnectionString(EN_ConnectionType.SQLServer),
opts => opts.CommandTimeout((int)TimeSpan.FromMinutes(dbTimeoutInMin).TotalSeconds));
});
services.ConfigureWebApiExtensionsEnd(); //should come last
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.ApplicationServices.SetupNLogServiceLocator();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
}
app.AddCustomExceptionHandling();
app.UseHttpsRedirection();
app.UseRouting();
app.UseCors("AllowAllOrigins");
app.UseOpenApi();
app.UseDALMiddleware();
app.UseJwtMiddleware();
app.ConfigureSwagger();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}

View File

@@ -0,0 +1,16 @@
using DAL;
using HRD.WebApi.Controllers;
using Microsoft.AspNetCore.Mvc;
namespace StaffDBServer.SharedExtensions
{
[Route("api/[controller]")]
[Produces("application/json")]
[ApiController]
public class InfoController : InfoBaseController
{
public InfoController() : base(new WebApiContext())
{
}
}
}

View File

@@ -0,0 +1,99 @@
using DAL;
using DAL._Shared.SharedModels;
using DAL._Shared.SharedRepositories;
using HRD.LDAPService.JWT;
using HRD.WebApi.Controllers;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Net.Http.Headers;
using System;
using System.Threading.Tasks;
namespace StaffDBServer.SharedControllers
{
[JWTAuthorizeAttribute]
public class WebAppUserController : BaseMiniController
{
public WebAppUserController() : base(new WebApiContext())
{
}
[HttpPost("Culture")]
public async Task<IActionResult> UpdateCultureAsync([FromBody] WebAppUser userFromClient)
{
try
{
//User Should by in the DB
WebAppUserRepository webAppUserRepository = new WebAppUserRepository();
WebAppUser userFromDB = await webAppUserRepository.GetByAsync(u => u.LoginName == userFromClient.LoginName, false);
if (userFromDB != default) //first login, get User from WebAppEmployeeInfo
{
userFromDB.Language = userFromClient.Language;
userFromDB.Culture = userFromClient.Culture;
if (!await webAppUserRepository.UpdateAsync(userFromDB))
{
return StatusCode(StatusCodes.Status400BadRequest, $"Cannot set User's language/culture");
}
}
return new OkObjectResult(userFromClient);
}
catch (Exception ex)
{
WriteLogException(ex, ex.Message);
return StatusCode(StatusCodes.Status400BadRequest, $"Cannot set User's language/culture");
}
}
[HttpPost("LoginWithJWT")]
public async Task<IActionResult> LoginWithAuthorizationAsync([FromBody] WebAppUser userFromClient)
{
try
{
var accessToken = Request.Headers[HeaderNames.Authorization];
WebAppUserHelper webAppUserHelper = new WebAppUserHelper();
WebAppUser result = await webAppUserHelper.CheckLoginWithJWTAsync(accessToken, userFromClient.ClientVersion);
return new OkObjectResult(result);
}
catch (Exception ex)
{
WriteLogException(ex, ex.Message);
return Unauthorized(ex.Message);
}
}
[HttpPost("LoginWithNameAndPassword/{webApiId}"),]
[Microsoft.AspNetCore.Authorization.AllowAnonymous]
public async Task<IActionResult> LoginWithNameAndPasswordAsync([FromBody] WebAppUser userFromClient, int webApiId)
{
try
{
WebAppUserHelper webAppUserHelper = new WebAppUserHelper();
var result = await webAppUserHelper.CheckLoginWithNameAndPasswordAsync(userFromClient, webApiId);
return new OkObjectResult(result);
}
catch (Exception ex)
{
WriteLogException(ex, ex.Message);
return NotFound(ex.Message);
}
}
[HttpPost("LoginWithNameAndPassword")]
[Microsoft.AspNetCore.Authorization.AllowAnonymous]
public async Task<IActionResult> LoginWithNameAndPasswordAsync([FromBody] WebAppUser userFromClient)
{
try
{
WebAppUserHelper webAppUserHelper = new WebAppUserHelper();
var result = await webAppUserHelper.CheckLoginWithNameAndPasswordAsync(userFromClient);
return new OkObjectResult(result);
}
catch (Exception ex)
{
WriteLogException(ex, ex.Message);
return NotFound(ex.Message);
}
}
}
}

View File

@@ -0,0 +1,204 @@
using DAL._Shared.SharedModels;
using DAL._Shared.SharedRepositories;
using HRD.LDAPService;
using HRD.LDAPService.JWT;
using Microsoft.Extensions.Primitives;
using System;
using System.Threading.Tasks;
namespace StaffDBServer.SharedControllers
{
public class WebAppUserHelper
{
private const int GLB_LOGIN_LOCK_TIME_IN_MIN = 5;
public int GlbWebApiIdStaffDB { get; private set; } = 2;
public async Task<WebAppUser> CheckLoginWithJWTAsync(StringValues accessToken, string clientVersion)
{
WebAppUserRepository webAppUserRepository = new WebAppUserRepository();
if (!JwtManager.IsValidatJwtTokenSubject(accessToken))
{
throw new UnauthorizedAccessException($"Not valid JWT");
}
var ldapUser = JwtManager.DecryptTokenAsLdapUser(accessToken);
if (ldapUser == null)
{
throw new UnauthorizedAccessException($"Unable to decrypt JWT");
}
WebAppEmployeeInfoRepository webAppEmployeeInfoRepository = new WebAppEmployeeInfoRepository();
WebAppEmployeeInfo webAppEmployeeInfo = await webAppEmployeeInfoRepository.GetByAsync(x => x.LoginName == ldapUser.LoginName);
if (webAppEmployeeInfo == default)
{
throw new UnauthorizedAccessException($"User '{ldapUser.LoginName}' cannot be found in StaffDB.");
}
var userFromDB = await webAppUserRepository.GetByAsync(u => u.LoginName == ldapUser.LoginName, false);
if (userFromDB == default)
{
throw new UnauthorizedAccessException($"Unable to load WebApiUser:{ldapUser.LoginName}");
}
if (userFromDB.JwtExpiredOn == null)
{
throw new UnauthorizedAccessException($"User have to relogin; LoginName: {ldapUser.LoginName}");
}
userFromDB.RoleList = ldapUser.RoleListAsString(EN_LdapRoleListFilter.OnlyRoleList);
userFromDB.WebAppRoleList = ldapUser.RoleListAsString(EN_LdapRoleListFilter.OnlyWebAppRoleList);
userFromDB.Token = ldapUser.Token;
userFromDB.JwtExpiredOn = ldapUser.JwtExpiredOn;
userFromDB.LastLogin = DateTime.Now;
userFromDB.ClientVersion = clientVersion;
if (await webAppUserRepository.SaveChangesAsync())
{
return userFromDB;
}
return (default);
}
public async Task<WebAppUser> CheckLoginWithNameAndPasswordAsync(WebAppUser userFromClient, int webAppId)
{
try
{
WebAppEmployeeInfoRepository webAppEmployeeInfoRepository = new WebAppEmployeeInfoRepository();
WebAppEmployeeInfo webAppEmployeeInfo = await webAppEmployeeInfoRepository.GetByAsync(x => x.LoginName == userFromClient.LoginName && x.WebAppId == webAppId);
WebAppUserRepository webAppUserRepository = new WebAppUserRepository();
return await DoCheckLoginWithNameAndPasswordAsync(userFromClient, webAppUserRepository, webAppEmployeeInfoRepository);
}
catch (Exception ex)
{
throw ex;
}
}
public async Task<WebAppUser> CheckLoginWithNameAndPasswordAsync(WebAppUser userFromClient)
{
try
{
WebAppEmployeeInfoRepository webAppEmployeeInfoRepository = new WebAppEmployeeInfoRepository();
WebAppEmployeeInfo webAppEmployeeInfo = await webAppEmployeeInfoRepository.GetByAsync(x => x.LoginName == userFromClient.LoginName && x.WebAppId == GlbWebApiIdStaffDB);
WebAppUserRepository webAppUserRepository = new WebAppUserRepository();
return await DoCheckLoginWithNameAndPasswordAsync(userFromClient, webAppUserRepository, webAppEmployeeInfoRepository);
}
catch (Exception ex)
{
throw ex;
}
}
private static async Task<WebAppUser> DoCheckLoginWithNameAndPasswordAsync(WebAppUser userFromClient, WebAppUserRepository webAppUserRepository, WebAppEmployeeInfoRepository webAppEmployeeInfoRepository)
{
try
{
WebAppEmployeeInfo webAppEmployeeInfo = await webAppEmployeeInfoRepository.GetByAsync(x => x.LoginName == userFromClient.LoginName);
if (webAppEmployeeInfo == default)
{
if (userFromClient.IsGermanCulture())
{
throw new UnauthorizedAccessException($"Benutzer '{userFromClient.LoginName}' wurde in der StaffDB nicht freigeschaltet.");
}
else
{
throw new UnauthorizedAccessException($"User '{userFromClient.LoginName}' was not set in der StaffDB.");
}
}
LdapUser ldapUser = new LdapUser(userFromClient.LoginName, webAppEmployeeInfo.EmployeeId, userFromClient.Password, webAppEmployeeInfo.DepartmentId, webAppEmployeeInfo.ExtendedDepartmentIdList);
if (!JwtManager.GenerateLdapUserWithJwtToken(ldapUser))
{
if (ldapUser == default)
{
if (userFromClient.IsGermanCulture())
{
throw new UnauthorizedAccessException($"Mit den Anmeldeinformationen (Loginname: '{userFromClient.LoginName}') konnte keine Verbindung hergestellt werden");
}
else
{
throw new UnauthorizedAccessException($"With login data (Loginname: '{userFromClient.LoginName}') cannot be logged");
}
}
if (ldapUser.IsAccountLockedOut)
{
System.Globalization.CultureInfo cultureinfo = new System.Globalization.CultureInfo(userFromClient.Culture);
var lastBadPasswordAttemptLocalTime = ldapUser.AccountLockoutTime - TimeSpan.FromMinutes(userFromClient.TimeZoneOffsetInMin);
var waitTillTime = lastBadPasswordAttemptLocalTime?.AddMinutes(GLB_LOGIN_LOCK_TIME_IN_MIN + 1);
if (userFromClient.IsGermanCulture())
{
throw new UnauthorizedAccessException($"Der Benutzer mit Loginnamen '{ldapUser.LoginName}' wurde am {lastBadPasswordAttemptLocalTime?.ToString(cultureinfo)} gesperrt!\nVersuchen Sie sich um {waitTillTime?.ToString(cultureinfo.DateTimeFormat.ShortTimePattern)} neuanzumelden.");
}
else
{
throw new UnauthorizedAccessException($"The user with the loginname '{ldapUser.LoginName}' was locked on {lastBadPasswordAttemptLocalTime?.ToString(cultureinfo)}!\nTry to log again at {waitTillTime?.ToString(cultureinfo.DateTimeFormat.ShortTimePattern)}.");
}
}
if (!ldapUser.Enabled)
{
if (userFromClient.IsGermanCulture())
{
throw new UnauthorizedAccessException($"Der Benutzer mit Loginnamen '{userFromClient.LoginName}' ist deaktiviert!");
}
else
{
throw new UnauthorizedAccessException($"The user with loginname '{userFromClient.LoginName}' is inactive!");
}
}
if (!ldapUser.IsValidatCredentials)
{
if (userFromClient.IsGermanCulture())
{
throw new UnauthorizedAccessException($"Sie haben Ihren Loginnamen '{userFromClient.LoginName}' oder Ihr Passwort falsch eingegeben.\nAchtung, das Passwort wurde {ldapUser.BadLogonCount} Mal falsch eingegeben!");
}
else
{
throw new UnauthorizedAccessException($"Your loginname '{userFromClient.LoginName}' or password is wrong.\nAttention, you have input wrong password {ldapUser.BadLogonCount} times!");
}
}
}
WebAppUser userFromDB = await webAppUserRepository.GetByAsync(u => u.LoginName == userFromClient.LoginName, false);
if (userFromDB == default) //get the WebAppUser data from LDAP & StaffDB
{
userFromDB = new WebAppUser(ldapUser.LoginName, webAppEmployeeInfo.ShortName, ldapUser.RoleListAsString(), $"{webAppEmployeeInfo.FirstName} {webAppEmployeeInfo.LastName}");
userFromDB.Language = userFromClient.Language;
userFromDB.Culture = userFromClient.Culture;
if (!await webAppUserRepository.AddAsync(userFromDB))
{
if (userFromClient.IsGermanCulture())
{
throw new UnauthorizedAccessException($"Benutzer '{userFromClient.LoginName}' konnte nicht automatisch erstellt werden.");
}
else
{
throw new UnauthorizedAccessException($"User '{userFromClient.LoginName}' cannot be created automatically.");
}
}
}
userFromDB.RoleList = ldapUser.RoleListAsString(EN_LdapRoleListFilter.OnlyRoleList);
userFromDB.WebAppRoleList = ldapUser.RoleListAsString(EN_LdapRoleListFilter.OnlyWebAppRoleList);
userFromDB.Token = ldapUser.Token;
userFromDB.JwtExpiredOn = ldapUser.JwtExpiredOn;
userFromDB.LastLogin = DateTime.Now;
userFromDB.ClientVersion = userFromClient.ClientVersion;
if (await webAppUserRepository.SaveChangesAsync())
{
return userFromDB;
}
return (default);
}
catch (Exception ex)
{
throw ex;
}
}
}
}

View File

@@ -0,0 +1,49 @@
using HRD.AppLogger;
using HRD.LDAPService.JWT;
using HRD.WebApi.DAL.Middleware;
using HRD.WebApi.Helpers;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Server.IISIntegration;
using Microsoft.Extensions.DependencyInjection;
namespace StaffDBServer.SharedExtensions
{
public static class ServiceExtensions
{
public static void ConfigureWebApiExtensionsAtFirst(this IServiceCollection services)
{
//services.AddCors();
services.AddCustomCors("AllowAllOrigins");
services.Configure<IISOptions>(options =>
{
options.AuthenticationDisplayName = "Windows";
options.ForwardClientCertificate = true;
options.AutomaticAuthentication = true;
});
services.AddAuthentication(IISDefaults.AuthenticationScheme);
services.ConfigureJWT(Extends.JwtMiddlewareOptionsHelper.GetJwtMiddlewareOptions()); ;
services.ConfigureDAL(WebApiMiddlewareOptionsHelper.GetWebApiMiddlewareOptions());
services.AddSingleton<ILoggerManager, LoggerManager>();
services.ConfigureSwagger();
}
public static void ConfigureWebApiExtensionsEnd(this IServiceCollection services)
{
services.AddMvc()
.ConfigureApiBehaviorOptions(options =>
{
options.InvalidModelStateResponseFactory = context =>
{
var errors = new HRD.WebApi.Helpers.HttpErrorDetails(context);
return new BadRequestObjectResult(errors);
};
});
}
}
}

View File

@@ -0,0 +1,59 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.PlatformAbstractions;
using NSwag;
using NSwag.Generation.Processors.Security;
using System.Linq;
namespace StaffDBServer.SharedExtensions
{
public static class ServiceSwaggerExtensions
{
public static void ConfigureSwagger(this IApplicationBuilder app)
{
app.UseSwaggerUi(cfg =>
cfg.DocExpansion = "none" //"list"
);
}
public static void ConfigureSwagger(this IServiceCollection services)
{
services.AddSwaggerDocument(config =>
{
#region add Bearer Authorization
config.AddSecurity("JWT", Enumerable.Empty<string>(), new OpenApiSecurityScheme
{
Type = OpenApiSecuritySchemeType.ApiKey,
Name = "Authorization",
In = OpenApiSecurityApiKeyLocation.Header,
Description = "Bearer JWT token."
});
config.OperationProcessors.Add(
new AspNetCoreOperationSecurityScopeProcessor("JWT"));
#endregion add Bearer Authorization
config.PostProcess = document =>
{
document.Info.Version = "V." + PlatformServices.Default.Application.ApplicationVersion + "; " + PlatformServices.Default.Application.RuntimeFramework;
document.Info.Title = $" {PlatformServices.Default.Application.ApplicationName} API";
document.Info.Description = $" {PlatformServices.Default.Application.ApplicationName} Backend ";
document.Info.TermsOfService = "None";
document.Info.Contact = new NSwag.OpenApiContact
{
Name = "IT",
Email = string.Empty,
Url = "https://hensel-recycling.com"
};
document.Info.License = new NSwag.OpenApiLicense
{
Name = "Commercial License",
Url = "https://hensel-recycling.com"
};
};
});
}
}
}

View File

@@ -0,0 +1,26 @@
using HRD.WebApi;
using HRD.WebApi.DAL.Middleware;
namespace StaffDBServer.SharedExtensions
{
public static class WebApiMiddlewareOptionsHelper
{
public static WebApiMiddlewareOptions GetWebApiMiddlewareOptions()
{
WebApiMiddlewareOptions options = new WebApiMiddlewareOptions
{
AssemblyVersion = WebApiConfig.AssemblyVersion,
AssemblyName = WebApiConfig.AssemblyName,
ClientVersion = WebApiConfig.ClientVersion,
Connectionstring = WebApiConfig.Connectionstring,
NlogConnectionstring = WebApiConfig.NlogConnectionstring,
NlogDBLogLevel = WebApiConfig.NlogDBLogLevel,
NlogFileLogLevel = WebApiConfig.NlogFileLogLevel,
NlogLogDirectory = WebApiConfig.NlogLogDirectory
};
return options;
}
}
}

View File

@@ -0,0 +1,30 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"ConnectionStrings": {
"sqlConnection": "server=DHDEAB-S883-2\\Dev2; database=DDStaffDB; TrustServerCertificate=True; Encrypt=False; MultipleActiveResultSets=True; User Id=webApiUser; Password=webApiUserPWD!"
},
"AppConfig": {
"LDAP_WebAppGroup_Is_Live": "false",
"ClientVersion": "1.6.8",
"OfficeFileServerUrl": ""
},
"Nlog": {
"NlogConnectionstring": "%sqlConnection%",
"NlogDBLogLevel": "Warn",
"NlogFileLogLevel": "Warn",
"NlogLogDirectory": "c:\\temp\\_logs\\",
"NlogSentryDSN": "",
"NlogSentryIsEnable": "false"
},
"CustomConfig": {
},
"AllowedHosts": "*"
}