Merge pull request 'ReportSystemUI accessible via Dependency Injection' (#10) from ReportSystem into main
Reviewed-on: #10
This commit is contained in:
95
Client/Components/ReportComponent.razor
Normal file
95
Client/Components/ReportComponent.razor
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
@inherits LocalizableComponent
|
||||||
|
@using Interfaces
|
||||||
|
@implements Interfaces.IReportUI
|
||||||
|
@inject IReportingHandler ReportingHandler
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-warning btn-lg px-4" @onclick="ShowReportModal">
|
||||||
|
<i class="oi oi-warning me-2"></i> Melden
|
||||||
|
</button>
|
||||||
|
|
||||||
|
@if (_showReportModal)
|
||||||
|
{
|
||||||
|
<div class="modal fade show" style="display: block; background: rgba(0,0,0,0.5); z-index: 1050;" tabindex="-1">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Eintrag melden</h5>
|
||||||
|
<button type="button" class="btn-close" @onclick="CloseReportModal"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>Warum möchtest du diesen Eintrag melden?</p>
|
||||||
|
<textarea class="form-control" @bind="_reportReason" rows="3" placeholder="Grund für die Meldung..."></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" @onclick="CloseReportModal">Abbrechen</button>
|
||||||
|
<button type="button" class="btn btn-danger" @onclick="ReportEntry">Melden</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
public Type ReportType => typeof(ReportComponent);
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public IReportable ReportableEntity { get; set; }
|
||||||
|
|
||||||
|
private bool _showReportModal = false;
|
||||||
|
private string _reportReason = "";
|
||||||
|
|
||||||
|
private Task ShowReportModal()
|
||||||
|
{
|
||||||
|
_reportReason = "";
|
||||||
|
_showReportModal = true;
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CloseReportModal()
|
||||||
|
{
|
||||||
|
_showReportModal = false;
|
||||||
|
}
|
||||||
|
public Dictionary<string, object> ConstructParameterList(IReportable reportableEntity, object RenderModeBoundary) {
|
||||||
|
Dictionary<string, object> _parameters = new Dictionary<string, object>();
|
||||||
|
|
||||||
|
_parameters["ReportableEntity"] = reportableEntity;
|
||||||
|
_parameters["RenderModeBoundary"] = RenderModeBoundary;
|
||||||
|
|
||||||
|
return _parameters;
|
||||||
|
}
|
||||||
|
private async Task ReportEntry()
|
||||||
|
{
|
||||||
|
// Basic null checks to avoid runtime NREs
|
||||||
|
if (ReportingHandler == null)
|
||||||
|
{
|
||||||
|
Console.WriteLine("ReportingHandler is not available (null). Ensure it is registered and injected.");
|
||||||
|
CloseReportModal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ReportableEntity == null)
|
||||||
|
{
|
||||||
|
Console.WriteLine("ReportableEntity is null. Cannot report.");
|
||||||
|
CloseReportModal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// If the handler exposes an async API use it instead. We run the synchronous call off the UI thread to avoid blocking.
|
||||||
|
await Task.Run(() => ReportingHandler.Report(ReportableEntity, _reportReason));
|
||||||
|
Console.WriteLine($"Eintrag gemeldet mit Grund: {_reportReason}");
|
||||||
|
AddModuleMessage($"Eintrag mit Grund {_reportReason} gemeldet.", MessageType.Success);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Reporting failed: {ex.Message}");
|
||||||
|
AddModuleMessage($"Eintrag konnte nicht gemeldet werden, bitte melden sie sich direkt beim Absolventenverein: ({ex.StackTrace}).", MessageType.Error);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseReportModal();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
@using Oqtane.Modules.Controls
|
@using Oqtane.Modules.Controls
|
||||||
|
@using SZUAbsolventenverein.Module.AdminModules.Client.Components
|
||||||
@using SZUAbsolventenverein.Module.AdminModules.Services
|
@using SZUAbsolventenverein.Module.AdminModules.Services
|
||||||
@using SZUAbsolventenverein.Module.AdminModules.Models
|
@using SZUAbsolventenverein.Module.AdminModules.Models
|
||||||
|
|
||||||
@@ -24,6 +25,8 @@
|
|||||||
<button type="button" class="btn btn-success" @onclick="Save">@Localizer["Save"]</button>
|
<button type="button" class="btn btn-success" @onclick="Save">@Localizer["Save"]</button>
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
<ReportComponent ReportableEntity="@AdminModules" RenderModeBoundary="@RenderModeBoundary" />
|
||||||
|
<br /><br />
|
||||||
@if (PageState.Action == "Edit")
|
@if (PageState.Action == "Edit")
|
||||||
{
|
{
|
||||||
<AuditInfo CreatedBy="@_createdby" CreatedOn="@_createdon" ModifiedBy="@_modifiedby" ModifiedOn="@_modifiedon"></AuditInfo>
|
<AuditInfo CreatedBy="@_createdby" CreatedOn="@_createdon" ModifiedBy="@_modifiedby" ModifiedOn="@_modifiedon"></AuditInfo>
|
||||||
@@ -54,6 +57,8 @@
|
|||||||
private string _modifiedby;
|
private string _modifiedby;
|
||||||
private DateTime _modifiedon;
|
private DateTime _modifiedon;
|
||||||
|
|
||||||
|
private AdminModules AdminModules;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -70,6 +75,7 @@
|
|||||||
_createdon = AdminModules.CreatedOn;
|
_createdon = AdminModules.CreatedOn;
|
||||||
_modifiedby = AdminModules.ModifiedBy;
|
_modifiedby = AdminModules.ModifiedBy;
|
||||||
_modifiedon = AdminModules.ModifiedOn;
|
_modifiedon = AdminModules.ModifiedOn;
|
||||||
|
this.AdminModules = AdminModules;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
@using Interfaces
|
||||||
@using SZUAbsolventenverein.Module.AdminModules.Services
|
@using SZUAbsolventenverein.Module.AdminModules.Services
|
||||||
@using SZUAbsolventenverein.Module.AdminModules.Models
|
@using SZUAbsolventenverein.Module.AdminModules.Models
|
||||||
|
|
||||||
@@ -6,6 +7,7 @@
|
|||||||
@inject IAdminModulesService AdminModulesService
|
@inject IAdminModulesService AdminModulesService
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IStringLocalizer<Index> Localizer
|
@inject IStringLocalizer<Index> Localizer
|
||||||
|
@inject IReportingHandler ReportingHandler;
|
||||||
|
|
||||||
@if (_AdminModuless == null)
|
@if (_AdminModuless == null)
|
||||||
{
|
{
|
||||||
@@ -23,11 +25,13 @@ else
|
|||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
|
<th style="width: 1px;"> </th>
|
||||||
<th>@Localizer["Name"]</th>
|
<th>@Localizer["Name"]</th>
|
||||||
</Header>
|
</Header>
|
||||||
<Row>
|
<Row>
|
||||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.AdminModulesId.ToString())" ResourceKey="Edit" /></td>
|
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.AdminModulesId.ToString())" ResourceKey="Edit" /></td>
|
||||||
<td><ActionDialog Header="Delete AdminModules" Message="Are You Sure You Wish To Delete This AdminModules?" Action="Delete" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" OnClick="@(async () => await Delete(context))" ResourceKey="Delete" Id="@context.AdminModulesId.ToString()" /></td>
|
<td><ActionDialog Header="Delete AdminModules" Message="Are You Sure You Wish To Delete This AdminModules?" Action="Delete" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" OnClick="@(() => Delete(context))" ResourceKey="Delete" Id="@("Delete-"+context.AdminModulesId)" /></td>
|
||||||
|
<td><ActionDialog Header="Report AdminModules" Message="Are You Sure You Wish To Report This AdminModules?" Action="Report" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" OnClick="@(() => Report(context))" ResourceKey="Report" Id="@("Report-"+context.AdminModulesId)" /></td>
|
||||||
<td><ActionLink Action="Send" Parameters="@($"id=" + context.AdminModulesId.ToString())" ResourceKey="Send" /></td>
|
<td><ActionLink Action="Send" Parameters="@($"id=" + context.AdminModulesId.ToString())" ResourceKey="Send" /></td>
|
||||||
<td>@context.Name</td>
|
<td>@context.Name</td>
|
||||||
</Row>
|
</Row>
|
||||||
@@ -40,7 +44,7 @@ else
|
|||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override string RenderMode => RenderModes.Static;
|
public override string RenderMode => RenderModes.Interactive;
|
||||||
|
|
||||||
public override List<Resource> Resources => new List<Resource>()
|
public override List<Resource> Resources => new List<Resource>()
|
||||||
{
|
{
|
||||||
@@ -78,4 +82,19 @@ else
|
|||||||
AddModuleMessage(Localizer["Message.DeleteError"], MessageType.Error);
|
AddModuleMessage(Localizer["Message.DeleteError"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task Report(AdminModules AdminModules)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ReportingHandler.Report(AdminModules, "Reported by User");
|
||||||
|
await logger.LogInformation("AdminModules Reported {AdminModules}", AdminModules);
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Reportign AdminModules {AdminModules} {Error}", AdminModules, ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Message.DeleteError"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -7,8 +7,9 @@
|
|||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IReportSystemReportingService ReportingService
|
@inject IReportSystemReportingService ReportingService
|
||||||
@inject IStringLocalizer<Index> Localizer
|
@inject IStringLocalizer<Index> Localizer
|
||||||
|
@inject IModuleService ModuleService
|
||||||
|
|
||||||
@if (reportings == null)
|
@if (_reportings == null)
|
||||||
{
|
{
|
||||||
<p><em>Loading...</em></p>
|
<p><em>Loading...</em></p>
|
||||||
}
|
}
|
||||||
@@ -16,19 +17,24 @@ else
|
|||||||
{
|
{
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
@if (reportings.Count != 0)
|
@if (_reportings.Count != 0)
|
||||||
{
|
{
|
||||||
<Pager Items="@reportings">
|
<Pager Items="@_reportings">
|
||||||
<Header>
|
<Header>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th style="width: 1px;"> </th>
|
<th style="width: 1px;"> </th>
|
||||||
<th style="width: 1px;"> </th>
|
<th>@Localizer["Submitter"]</th>
|
||||||
|
<th>@Localizer["Note"]</th>
|
||||||
<th>@Localizer["Name"]</th>
|
<th>@Localizer["Name"]</th>
|
||||||
</Header>
|
</Header>
|
||||||
<Row>
|
<Row>
|
||||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.ReportingID)" ResourceKey="Edit" /></td>
|
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.ReportingID)" ResourceKey="Edit" /></td>
|
||||||
<td><ActionDialog Header="Delete AdminModules" Message="Are You Sure You Wish To Delete This AdminModules?" Action="Delete" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" OnClick="@(async () => await Delete(context))" ResourceKey="Delete" Id="@context.ReportingID.ToString()" /></td>
|
<td><ActionDialog Header="Delete AdminModules" Message="Are You Sure You Wish To Delete This AdminModules?" Action="Delete" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" OnClick="@(async () => await Delete(context))" ResourceKey="Delete" Id="@context.ReportingID.ToString()" /></td>
|
||||||
<td><ActionLink Action="Send" Parameters="@($"id=" + context.ReportingID)" ResourceKey="Send" /></td>
|
<td>@context.CreatedBy</td>
|
||||||
|
<td>@context.CreatedOn</td>
|
||||||
|
<td>@context.ModuleId</td>
|
||||||
|
<td>@context.ReportingID</td>
|
||||||
|
<td>@context.Note</td>
|
||||||
<td>@context.Reason</td>
|
<td>@context.Reason</td>
|
||||||
</Row>
|
</Row>
|
||||||
</Pager>
|
</Pager>
|
||||||
@@ -39,7 +45,6 @@ else
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override string RenderMode => RenderModes.Interactive;
|
public override string RenderMode => RenderModes.Interactive;
|
||||||
|
|
||||||
@@ -49,13 +54,28 @@ else
|
|||||||
new Script("_content/SZUAbsolventenverein.Module.ReportSystem/Module.js")
|
new Script("_content/SZUAbsolventenverein.Module.ReportSystem/Module.js")
|
||||||
};
|
};
|
||||||
|
|
||||||
private List<Reporting> reportings = new List<Reporting>();
|
private List<Reporting> _reportings = new List<Reporting>();
|
||||||
|
private Dictionary<int, Module> _modules = new Dictionary<int, Module>();
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
reportings = await ReportingService.GetReportsAsync(ModuleState.ModuleId);
|
_reportings = await ReportingService.GetReportsAsync(ModuleState.ModuleId);
|
||||||
|
foreach (var moduleId in _reportings.Select(r => r.ModuleId).Distinct())
|
||||||
|
{
|
||||||
|
Console.WriteLine(moduleId);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_modules.Add(moduleId, await ModuleService.GetModuleAsync(moduleId));
|
||||||
|
await logger.LogDebug(LogFunction.Create, "Module found {ModuleId} while loading Modules for Reportings.", moduleId);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_modules.Add(moduleId, new Module {Title = $"Module not found {ex.Message}"});
|
||||||
|
await logger.LogDebug("Module not found {ModuleId} while loading Modules for Reportings. {error}", moduleId, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -68,7 +88,7 @@ else
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
await ReportingService.DeleteReportingAsync(reporting.ReportingID, ModuleState.ModuleId);
|
await ReportingService.DeleteReportingAsync(reporting.ReportingID, ModuleState.ModuleId);
|
||||||
reportings.Remove(reporting);
|
_reportings.Remove(reporting);
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Interfaces" Version="0.0.0-12" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.1" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="10.0.1" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="10.0.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="10.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Localization" Version="10.0.1" />
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace SZUAbsolventenverein.Module.ReportSystem.Services
|
|||||||
public void Report(IReportable reportable, string note)
|
public void Report(IReportable reportable, string note)
|
||||||
{
|
{
|
||||||
CreateReportAsync(new Reporting
|
CreateReportAsync(new Reporting
|
||||||
{ ModuleId = reportable.ModuleID, EntityId = reportable.EntityID, Note = note, Reason = "Default Reason" });
|
{ ModuleId = reportable.ModuleID, EntityId = reportable.EntityID, Note = note, UserName = reportable.UserName, Reason = "Default Reason" });
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<Reporting> CreateReportAsync(Reporting reporting)
|
public Task<Reporting> CreateReportAsync(Reporting reporting)
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
using System;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Interfaces;
|
using Interfaces;
|
||||||
using Oqtane.Services;
|
using Oqtane.Services;
|
||||||
|
using SZUAbsolventenverein.Module.AdminModules.Client.Components;
|
||||||
using SZUAbsolventenverein.Module.AdminModules.Services;
|
using SZUAbsolventenverein.Module.AdminModules.Services;
|
||||||
using SZUAbsolventenverein.Module.ReportSystem.Services;
|
using SZUAbsolventenverein.Module.ReportSystem.Services;
|
||||||
|
|
||||||
@@ -20,10 +22,16 @@ namespace SZUAbsolventenverein.Module.AdminModules.Startup
|
|||||||
{
|
{
|
||||||
services.AddScoped<IReportingHandler, ReportSystemReportingService>();
|
services.AddScoped<IReportingHandler, ReportSystemReportingService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!services.Any(s => s.ServiceType == typeof(IReportSystemReportingService)))
|
if (!services.Any(s => s.ServiceType == typeof(IReportSystemReportingService)))
|
||||||
{
|
{
|
||||||
services.AddScoped<IReportSystemReportingService, ReportSystemReportingService>();
|
services.AddScoped<IReportSystemReportingService, ReportSystemReportingService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!services.Any(s => s.ServiceType == typeof(IReportUI)))
|
||||||
|
{
|
||||||
|
services.AddScoped<IReportUI, ReportComponent>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=_002Fhome_002Fkocoder_002Falumnihub_005F10_002E0_005Famd64_002Finterfaces_002FInterfaces_002Fbin_002FDebug_002Fnet10_002E0_002FInterfaces_002Edll/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=_002Fhome_002Fkocoder_002Falumnihub_005F10_002E0_005Famd64_002Finterfaces_002FInterfaces_002Fbin_002FDebug_002Fnet10_002E0_002FInterfaces_002Edll/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=_002Fhome_002Fkocoder_002Falumnihub_005F10_002E0_005Famd64_002FSZUAbsolventenverein_002FInterfaces_002Fbin_002FDebug_002Fnet10_002E0_002FInterfaces_002Edll/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=_002Fhome_002Fkocoder_002Falumnihub_005F10_002E0_005Famd64_002FSZUAbsolventenverein_002FInterfaces_002Fbin_002FDebug_002Fnet10_002E0_002FInterfaces_002Edll/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AComponentBase_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa1ecd5c0c773451bb67865cbd48f5976e4e00_003F15_003F972ec13f_003FComponentBase_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AComponentBase_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fc79a534484f3c079e696a1b8489d234b7066e25afd8a9b4bd1be4257d3167_003FComponentBase_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AComponentBase_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fc79a534484f3c079e696a1b8489d234b7066e25afd8a9b4bd1be4257d3167_003FComponentBase_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue"><AssemblyExplorer>
|
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue"><AssemblyExplorer>
|
||||||
<Assembly Path="/home/kocoder/alumnihub_10.0_amd64/SZUAbsolventenverein/Interfaces/bin/Debug/net10.0/Interfaces.dll" />
|
<Assembly Path="/home/kocoder/alumnihub_10.0_amd64/SZUAbsolventenverein/Interfaces/bin/Debug/net10.0/Interfaces.dll" />
|
||||||
|
|||||||
30
Server/Migrations/ReportSystem/01000001_AddUserName.cs
Normal file
30
Server/Migrations/ReportSystem/01000001_AddUserName.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Oqtane.Databases.Interfaces;
|
||||||
|
using Oqtane.Migrations;
|
||||||
|
using SZUAbsolventenverein.Module.AdminModules.Migrations.EntityBuilders;
|
||||||
|
using SZUAbsolventenverein.Module.AdminModules.Repository;
|
||||||
|
|
||||||
|
namespace SZUAbsolventenverein.Module.ReportSystem.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(ReportingContext))]
|
||||||
|
[Migration("SZUAbsolventenverein.Module.ReportSystem.01.00.00.01")]
|
||||||
|
public class AddUserName : MultiDatabaseMigration
|
||||||
|
{
|
||||||
|
public AddUserName(IDatabase database) : base(database)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
var entityBuilder = new ReportingEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||||
|
entityBuilder.AddStringColumn("UserName", 256, false, false, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
var entityBuilder = new ReportingEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||||
|
entityBuilder.DropColumn("UserName");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Oqtane.Modules;
|
|
||||||
using Oqtane.Repository;
|
|
||||||
using Oqtane.Infrastructure;
|
|
||||||
using Oqtane.Repository.Databases.Interfaces;
|
|
||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.AdminModules.Repository
|
|
||||||
{
|
|
||||||
public class AdminModulesContext : DBContextBase, ITransientService, IMultiDatabase
|
|
||||||
{
|
|
||||||
public virtual DbSet<Models.AdminModules> AdminModules { get; set; }
|
|
||||||
|
|
||||||
public AdminModulesContext(IDBContextDependencies DBContextDependencies) : base(DBContextDependencies)
|
|
||||||
{
|
|
||||||
// ContextBase handles multi-tenant database connections
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder builder)
|
|
||||||
{
|
|
||||||
base.OnModelCreating(builder);
|
|
||||||
|
|
||||||
builder.Entity<Models.AdminModules>().ToTable(ActiveDatabase.RewriteName("SZUAbsolventenvereinAdminModules"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Oqtane.Modules;
|
|
||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.AdminModules.Repository
|
|
||||||
{
|
|
||||||
public interface IAdminModulesRepository
|
|
||||||
{
|
|
||||||
IEnumerable<Models.AdminModules> GetAdminModuless(int ModuleId);
|
|
||||||
Models.AdminModules GetAdminModules(int AdminModulesId);
|
|
||||||
Models.AdminModules GetAdminModules(int AdminModulesId, bool tracking);
|
|
||||||
Models.AdminModules AddAdminModules(Models.AdminModules AdminModules);
|
|
||||||
Models.AdminModules UpdateAdminModules(Models.AdminModules AdminModules);
|
|
||||||
void DeleteAdminModules(int AdminModulesId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class AdminModulesRepository : IAdminModulesRepository, ITransientService
|
|
||||||
{
|
|
||||||
private readonly IDbContextFactory<AdminModulesContext> _factory;
|
|
||||||
|
|
||||||
public AdminModulesRepository(IDbContextFactory<AdminModulesContext> factory)
|
|
||||||
{
|
|
||||||
_factory = factory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Models.AdminModules> GetAdminModuless(int ModuleId)
|
|
||||||
{
|
|
||||||
using var db = _factory.CreateDbContext();
|
|
||||||
return db.AdminModules.Where(item => item.ModuleId == ModuleId).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Models.AdminModules GetAdminModules(int AdminModulesId)
|
|
||||||
{
|
|
||||||
return GetAdminModules(AdminModulesId, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Models.AdminModules GetAdminModules(int AdminModulesId, bool tracking)
|
|
||||||
{
|
|
||||||
using var db = _factory.CreateDbContext();
|
|
||||||
if (tracking)
|
|
||||||
{
|
|
||||||
return db.AdminModules.Find(AdminModulesId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return db.AdminModules.AsNoTracking().FirstOrDefault(item => item.AdminModulesId == AdminModulesId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Models.AdminModules AddAdminModules(Models.AdminModules AdminModules)
|
|
||||||
{
|
|
||||||
using var db = _factory.CreateDbContext();
|
|
||||||
db.AdminModules.Add(AdminModules);
|
|
||||||
db.SaveChanges();
|
|
||||||
return AdminModules;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Models.AdminModules UpdateAdminModules(Models.AdminModules AdminModules)
|
|
||||||
{
|
|
||||||
using var db = _factory.CreateDbContext();
|
|
||||||
db.Entry(AdminModules).State = EntityState.Modified;
|
|
||||||
db.SaveChanges();
|
|
||||||
return AdminModules;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteAdminModules(int AdminModulesId)
|
|
||||||
{
|
|
||||||
using var db = _factory.CreateDbContext();
|
|
||||||
Models.AdminModules AdminModules = db.AdminModules.Find(AdminModulesId);
|
|
||||||
db.AdminModules.Remove(AdminModules);
|
|
||||||
db.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,42 +7,55 @@ using Microsoft.AspNetCore.Http;
|
|||||||
using Oqtane.Enums;
|
using Oqtane.Enums;
|
||||||
using Oqtane.Infrastructure;
|
using Oqtane.Infrastructure;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
|
using Oqtane.Repository;
|
||||||
using Oqtane.Security;
|
using Oqtane.Security;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
using SZUAbsolventenverein.Module.ReportSystem.Models;
|
using SZUAbsolventenverein.Module.ReportSystem.Models;
|
||||||
|
using SZUAbsolventenverein.Module.ReportSystem.Permissions;
|
||||||
using SZUAbsolventenverein.Module.ReportSystem.Repository;
|
using SZUAbsolventenverein.Module.ReportSystem.Repository;
|
||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.ReportSystem.Services
|
namespace SZUAbsolventenverein.Module.ReportSystem.Services
|
||||||
{
|
{
|
||||||
public class ServerReportSystemReportingService : IReportSystemReportingService, IReportingHandler
|
public class ServerReportSystemReportingService : IReportSystemReportingService, IReportingHandler
|
||||||
{
|
{
|
||||||
|
private readonly IModuleDefinitionRepository _moduleDefinitionRepository;
|
||||||
private readonly IReportingRepository _reportSystemRepository;
|
private readonly IReportingRepository _reportSystemRepository;
|
||||||
private readonly IUserPermissions _userPermissions;
|
private readonly IUserPermissions _userPermissions;
|
||||||
private readonly ILogManager _logger;
|
private readonly ILogManager _logger;
|
||||||
private readonly IHttpContextAccessor _accessor;
|
private readonly IHttpContextAccessor _accessor;
|
||||||
private readonly Alias _alias;
|
private readonly Alias _alias;
|
||||||
|
private readonly int _moduleDefinitionId;
|
||||||
|
|
||||||
public ServerReportSystemReportingService(IReportingRepository reportSystemRepository, IUserPermissions userPermissions, ITenantManager tenantManager, ILogManager logger, IHttpContextAccessor accessor)
|
public ServerReportSystemReportingService(IModuleDefinitionRepository moduleDefinitionRepository, IReportingRepository reportSystemRepository, IUserPermissions userPermissions, ITenantManager tenantManager, ILogManager logger, IHttpContextAccessor accessor)
|
||||||
{
|
{
|
||||||
|
_moduleDefinitionRepository = moduleDefinitionRepository;
|
||||||
_reportSystemRepository = reportSystemRepository;
|
_reportSystemRepository = reportSystemRepository;
|
||||||
_userPermissions = userPermissions;
|
_userPermissions = userPermissions;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_accessor = accessor;
|
_accessor = accessor;
|
||||||
_alias = tenantManager.GetAlias();
|
_alias = tenantManager.GetAlias();
|
||||||
|
|
||||||
|
ModuleDefinition md = moduleDefinitionRepository.GetModuleDefinitions(_alias.SiteId).ToList().Find(md => md.IsEnabled && md.Name == new ModuleInfo().ModuleDefinition.Name);
|
||||||
|
if (md == null)
|
||||||
|
{
|
||||||
|
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Reporting Module Not Found {ModuleName}", new ModuleInfo().ModuleDefinition.Name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_moduleDefinitionId = md.ModuleDefinitionId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<Reporting> CreateReportAsync(Reporting Reporting)
|
public Task<Reporting> CreateReportAsync(Reporting Reporting)
|
||||||
{
|
{
|
||||||
// true ||
|
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.ModuleDefinition, _moduleDefinitionId, PermissionNames.Utilize))
|
||||||
Console.WriteLine("HELP");
|
|
||||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.ModuleDefinition, 53, PermissionNames.Utilize))
|
|
||||||
{
|
{
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Reporting Updated {Reporting}", Reporting);
|
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Reporting created {Reporting}", Reporting);
|
||||||
return Task.FromResult(_reportSystemRepository.AddReporting(Reporting));
|
return Task.FromResult(_reportSystemRepository.AddReporting(Reporting));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Reporting Update Attempt {Reporting}", Reporting);
|
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Reporting create attempt {Reporting}", Reporting);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,8 +120,11 @@ namespace SZUAbsolventenverein.Module.ReportSystem.Services
|
|||||||
{
|
{
|
||||||
// if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.Edit))
|
// if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.Edit))
|
||||||
{
|
{
|
||||||
Reporting reporting = await CreateReportAsync(new Reporting {ModuleId = reportable.ModuleID, EntityId = reportable.EntityID, Note = note, Reason = "Default Reason"});
|
Reporting reporting = await CreateReportAsync(new Reporting {ModuleId = reportable.ModuleID, EntityId = reportable.EntityID, UserName = reportable.UserName, Note = note, Reason = "Default Reason"});
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Reporting recieved {ReportingId}", reporting.ReportingID);
|
if (reporting != null)
|
||||||
|
{
|
||||||
|
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Reporting recieved {ReportingId}", reporting.ReportingID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// else
|
// else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using Interfaces;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.AdminModules.Models
|
namespace SZUAbsolventenverein.Module.AdminModules.Models
|
||||||
{
|
{
|
||||||
[Table("SZUAbsolventenvereinAdminModules")]
|
[Table("SZUAbsolventenvereinAdminModules")]
|
||||||
public class AdminModules : IAuditable
|
public class AdminModules : IAuditable, IReportable
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
public int AdminModulesId { get; set; }
|
public int AdminModulesId { get; set; }
|
||||||
@@ -18,5 +19,13 @@ namespace SZUAbsolventenverein.Module.AdminModules.Models
|
|||||||
public DateTime CreatedOn { get; set; }
|
public DateTime CreatedOn { get; set; }
|
||||||
public string ModifiedBy { get; set; }
|
public string ModifiedBy { get; set; }
|
||||||
public DateTime ModifiedOn { get; set; }
|
public DateTime ModifiedOn { get; set; }
|
||||||
|
|
||||||
|
[NotMapped] public string ModuleName => "";
|
||||||
|
|
||||||
|
[NotMapped] public int ModuleID => ModuleId;
|
||||||
|
|
||||||
|
[NotMapped] public int EntityID => AdminModulesId;
|
||||||
|
|
||||||
|
[NotMapped] public string UserName => CreatedBy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ public class Reporting : IAuditable
|
|||||||
public int ReportingID { get; set; }
|
public int ReportingID { get; set; }
|
||||||
public int ModuleId { get; set; }
|
public int ModuleId { get; set; }
|
||||||
public int EntityId { get; set; }
|
public int EntityId { get; set; }
|
||||||
|
public string UserName { get; set; }
|
||||||
public string Note { get; set; }
|
public string Note { get; set; }
|
||||||
public string Reason { get; set; }
|
public string Reason { get; set; }
|
||||||
|
|
||||||
|
|||||||
8
Shared/Permissions/ReportSystemPermissionNames.cs
Normal file
8
Shared/Permissions/ReportSystemPermissionNames.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace SZUAbsolventenverein.Module.ReportSystem.Permissions
|
||||||
|
{
|
||||||
|
public class ReportSystemPermissionNames
|
||||||
|
{
|
||||||
|
public const string Report = "Report";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Interfaces" Version="0.0.0-12" />
|
||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user