New: Report-System using globally available Interfaces.

This commit is contained in:
2026-02-12 19:01:30 +01:00
parent a94527f294
commit 28925a3cfa
21 changed files with 847 additions and 8 deletions

View File

@@ -0,0 +1,79 @@
@namespace SZUAbsolventenverein.Module.ReportSystem
@using Microsoft.VisualBasic.FileIO
@using SZUAbsolventenverein.Module.ReportSystem.Models
@using SZUAbsolventenverein.Module.ReportSystem.Services
@inherits ModuleBase
@inject NavigationManager NavigationManager
@inject IReportSystemReportingService ReportingService
@inject IStringLocalizer<Index> Localizer
@if (reportings == null)
{
<p><em>Loading...</em></p>
}
else
{
<br />
<br />
@if (reportings.Count != 0)
{
<Pager Items="@reportings">
<Header>
<th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th>
<th>@Localizer["Name"]</th>
</Header>
<Row>
<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><ActionLink Action="Send" Parameters="@($"id=" + context.ReportingID)" ResourceKey="Send" /></td>
<td>@context.Reason</td>
</Row>
</Pager>
}
else
{
<p>@Localizer["Message.DisplayNone"]</p>
}
}
@code {
public override string RenderMode => RenderModes.Interactive;
public override List<Resource> Resources => new List<Resource>()
{
new Stylesheet("_content/SZUAbsolventenverein.Module.ReportSystem/Module.css"),
new Script("_content/SZUAbsolventenverein.Module.ReportSystem/Module.js")
};
private List<Reporting> reportings = new List<Reporting>();
protected override async Task OnInitializedAsync()
{
try
{
reportings = await ReportingService.GetReportsAsync(ModuleState.ModuleId);
}
catch (Exception ex)
{
logger.LogError("Error fetching reportings: {Message}", ex.Message);
};
}
private async Task Delete(Reporting reporting)
{
try
{
await ReportingService.DeleteReportingAsync(reporting.ReportingID, ModuleState.ModuleId);
reportings.Remove(reporting);
StateHasChanged();
}
catch (Exception ex)
{
logger.LogError("Error deleting reporting: {Message}", ex.Message);
}
}
}

View File

@@ -0,0 +1,21 @@
using System;
using Oqtane.Models;
using Oqtane.Modules;
namespace SZUAbsolventenverein.Module.ReportSystem
{
public class ModuleInfo : IModule
{
public ModuleDefinition ModuleDefinition => new ModuleDefinition
{
Name = "ReportSystem",
Description = "Handle Systemwide Reporting",
Version = "1.0.0",
ServerManagerType =
"SZUAbsolventenverein.Module.ReportSystem.Manager.ReportSystemManager, SZUAbsolventenverein.Module.AdminModules.Server.Oqtane",
ReleaseVersions = "1.0.0",
Dependencies = "SZUAbsolventenverein.Module.ReportSystem.Shared.Oqtane",
PackageName = "SZUAbsolventenverein.Module.ReportSystem",
};
}
}

View File

@@ -0,0 +1,49 @@
@namespace SZUAbsolventenverein.Module.ReportSystem
@inherits ModuleBase
@inject ISettingService SettingService
@inject IStringLocalizer<Settings> Localizer
<div class="container">
<div class="row mb-1 align-items-center">
<Label Class="col-sm-3" For="value" HelpText="Enter a value" ResourceKey="SettingName"
ResourceType="@resourceType">Name: </Label>
<div class="col-sm-9">
<input id="value" type="text" class="form-control" @bind="@_value"/>
</div>
</div>
</div>
@code {
private string resourceType = "SZUAbsolventenverein.Module.ReportSystem.Settings, SZUAbsolventenverein.Module.AdminModules.Client.Oqtane"; // for localization
public override string Title => "ReportSystem Settings";
string _value;
protected override async Task OnInitializedAsync()
{
try
{
Dictionary<string, string> settings = await SettingService.GetModuleSettingsAsync(ModuleState.ModuleId);
_value = SettingService.GetSetting(settings, "SettingName", "");
}
catch (Exception ex)
{
AddModuleMessage(ex.Message, MessageType.Error);
}
}
public async Task UpdateSettings()
{
try
{
Dictionary<string, string> settings = await SettingService.GetModuleSettingsAsync(ModuleState.ModuleId);
SettingService.SetSetting(settings, "SettingName", _value);
await SettingService.UpdateModuleSettingsAsync(settings, ModuleState.ModuleId);
}
catch (Exception ex)
{
AddModuleMessage(ex.Message, MessageType.Error);
}
}
}

View File

@@ -25,10 +25,18 @@
</ItemGroup>
<ItemGroup>
<Reference Include="Interfaces">
<HintPath>..\..\interfaces\Interfaces\bin\Debug\net10.0\Interfaces.dll</HintPath>
</Reference>
<Reference Include="Oqtane.Client"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net10.0\Oqtane.Client.dll</HintPath></Reference>
<Reference Include="Oqtane.Shared"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net10.0\Oqtane.Shared.dll</HintPath></Reference>
</ItemGroup>
<!-- <ItemGroup>
<AdditionalFiles Include="Modules\SZUAbsolventenverein.Module.ReportSystem\Index.razor" />
<AdditionalFiles Include="Modules\SZUAbsolventenverein.Module.ReportSystem\Settings.razor" />
</ItemGroup> -->
<PropertyGroup>
<!-- there may be other elements here -->
<BlazorWebAssemblyEnableLinking>false</BlazorWebAssemblyEnableLinking>

View File

@@ -0,0 +1,51 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Interfaces;
using SZUAbsolventenverein.Module.ReportSystem.Models;
namespace SZUAbsolventenverein.Module.ReportSystem.Services
{
public interface IReportSystemReportingService
{
Task<Reporting> CreateReportAsync(Reporting reporting);
Task<List<Reporting>> GetReportsAsync(int ModuleId);
Task<Reporting> GetReportAsync(int ReportableId, int ModuleId);
Task<Reporting> UpdateReport(Reporting reporting);
Task DeleteReportingAsync(int ReportingId, int ModuleId);
}
public class ReportSystemReportingService : IReportSystemReportingService, IReportingHandler
{
public void Report(IReportable reportable, string note)
{
CreateReportAsync(new Reporting
{ ModuleId = reportable.ModuleID, EntityId = reportable.EntityID, Note = note, Reason = "Default Reason" });
}
public Task<Reporting> CreateReportAsync(Reporting reporting)
{
throw new System.NotImplementedException();
}
public Task<List<Reporting>> GetReportsAsync(int ModuleId)
{
throw new System.NotImplementedException();
}
public Task<Reporting> GetReportAsync(int ReportableId, int ModuleId)
{
throw new System.NotImplementedException();
}
public Task<Reporting> UpdateReport(Reporting Reporting)
{
throw new System.NotImplementedException();
}
public Task DeleteReportingAsync(int ReportingId, int ModuleId)
{
throw new System.NotImplementedException();
}
}
}

View File

@@ -1,7 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
using System.Linq;
using Interfaces;
using Oqtane.Services;
using SZUAbsolventenverein.Module.AdminModules.Services;
using SZUAbsolventenverein.Module.ReportSystem.Services;
namespace SZUAbsolventenverein.Module.AdminModules.Startup
{
@@ -13,6 +15,15 @@ namespace SZUAbsolventenverein.Module.AdminModules.Startup
{
services.AddScoped<IAdminModulesService, AdminModulesService>();
}
if (!services.Any(s => s.ServiceType == typeof(IReportingHandler)))
{
services.AddScoped<IReportingHandler, ReportSystemReportingService>();
}
if (!services.Any(s => s.ServiceType == typeof(IReportSystemReportingService)))
{
services.AddScoped<IReportSystemReportingService, ReportSystemReportingService>();
}
}
}
}