From 81ac7cf761394d98214e9a5a1cef6c600d8b7aed Mon Sep 17 00:00:00 2001 From: KoCoder Date: Thu, 4 Dec 2025 09:06:39 +0100 Subject: [PATCH 1/4] Fix: Linux debug.sh ($ after the path) --- Package/debug.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Package/debug.sh b/Package/debug.sh index c4d069f..01a9758 100644 --- a/Package/debug.sh +++ b/Package/debug.sh @@ -3,10 +3,10 @@ TargetFramework=$1 ProjectName=$2 -cp -f "../Client/bin/Debug/$TargetFramework/$ProjectName$.Client.Oqtane.dll" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/" -cp -f "../Client/bin/Debug/$TargetFramework/$ProjectName$.Client.Oqtane.pdb" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/" -cp -f "../Server/bin/Debug/$TargetFramework/$ProjectName$.Server.Oqtane.dll" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/" -cp -f "../Server/bin/Debug/$TargetFramework/$ProjectName$.Server.Oqtane.pdb" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/" -cp -f "../Shared/bin/Debug/$TargetFramework/$ProjectName$.Shared.Oqtane.dll" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/" -cp -f "../Shared/bin/Debug/$TargetFramework/$ProjectName$.Shared.Oqtane.pdb" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/" +cp -f "../Client/bin/Debug/$TargetFramework/$ProjectName.Client.Oqtane.dll" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/" +cp -f "../Client/bin/Debug/$TargetFramework/$ProjectName.Client.Oqtane.pdb" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/" +cp -f "../Server/bin/Debug/$TargetFramework/$ProjectName.Server.Oqtane.dll" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/" +cp -f "../Server/bin/Debug/$TargetFramework/$ProjectName.Server.Oqtane.pdb" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/" +cp -f "../Shared/bin/Debug/$TargetFramework/$ProjectName.Shared.Oqtane.dll" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/" +cp -f "../Shared/bin/Debug/$TargetFramework/$ProjectName.Shared.Oqtane.pdb" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/" cp -rf "../Server/wwwroot/"* "../../oqtane.framework/Oqtane.Server/wwwroot/" \ No newline at end of file -- 2.49.0 From 9c52e734c5e19a08979425385908b5021468da11 Mon Sep 17 00:00:00 2001 From: KoCoder Date: Thu, 18 Dec 2025 11:06:36 +0100 Subject: [PATCH 2/4] Client Side structure for recommended 10 Users (ready for Florian) --- Client/Components/UserComponent.razor | 6 ++++++ .../Details.razor | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 Client/Components/UserComponent.razor diff --git a/Client/Components/UserComponent.razor b/Client/Components/UserComponent.razor new file mode 100644 index 0000000..7386d11 --- /dev/null +++ b/Client/Components/UserComponent.razor @@ -0,0 +1,6 @@ +

@user.DisplayName

+ +@code { + [Parameter] + public User user { get; set; } +} \ No newline at end of file diff --git a/Client/Modules/SZUAbsolventenverein.Module.EventRegistration/Details.razor b/Client/Modules/SZUAbsolventenverein.Module.EventRegistration/Details.razor index 6fdccf0..fc1293c 100644 --- a/Client/Modules/SZUAbsolventenverein.Module.EventRegistration/Details.razor +++ b/Client/Modules/SZUAbsolventenverein.Module.EventRegistration/Details.razor @@ -4,6 +4,7 @@ @using SZUAbsolventenverein.Module.EventRegistration.Services @using SZUAbsolventenverein.Module.EventRegistration.Models @using System.Text.RegularExpressions +@using SZUAbsolventenverein.Module.EventRegistration.Client.Components @namespace SZUAbsolventenverein.Module.EventRegistration @inherits ModuleBase @@ -44,6 +45,10 @@ } + @foreach (User u in _users) + { + + } } else {

Um dich für dieses Event zu registrieren, muss man sich zuerst anmelden.

@@ -79,6 +84,8 @@ private List _profiles = new List(); private Dictionary _settings; + + private List _users = new List() {new User() {DisplayName = "Hello"}, new User() {DisplayName = "World"}}; private async Task SendResponse(bool response) { -- 2.49.0 From 38daf1801b2aa19afca7bae824d1ba210bfba9d2 Mon Sep 17 00:00:00 2001 From: KoCoder Date: Thu, 18 Dec 2025 13:27:22 +0100 Subject: [PATCH 3/4] Serverseitig: 10 Benutzer Scoring Serverseiting reimplementiert --- .../Details.razor | 25 ++- Server/Services/EventRegistrationService.cs | 158 ++++++++++++------ .../Interfaces/IEventRegistrationService.cs | 2 + 3 files changed, 121 insertions(+), 64 deletions(-) diff --git a/Client/Modules/SZUAbsolventenverein.Module.EventRegistration/Details.razor b/Client/Modules/SZUAbsolventenverein.Module.EventRegistration/Details.razor index fc1293c..e2cc824 100644 --- a/Client/Modules/SZUAbsolventenverein.Module.EventRegistration/Details.razor +++ b/Client/Modules/SZUAbsolventenverein.Module.EventRegistration/Details.razor @@ -32,17 +32,17 @@ @if (Status == true) { @Localizer["Zugesagt"]
-

+

} else { @Localizer["Abgesagt"]
-

+

}

} else {
- - + +
} @foreach (User u in _users) @@ -70,9 +70,6 @@ new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" } }; - // private ElementReference form; - // private bool validated = false; - private int _id; private string _name; private string _description; @@ -85,7 +82,7 @@ private List _profiles = new List(); private Dictionary _settings; - private List _users = new List() {new User() {DisplayName = "Hello"}, new User() {DisplayName = "World"}}; + private List _users = new List(); private async Task SendResponse(bool response) { @@ -114,12 +111,12 @@ } } - private async void Zusage() + private async void Accept() { await SendResponse(true); } - private async void Absage() + private async void Reject() { await SendResponse(false); } @@ -128,6 +125,8 @@ { try { + _id = Int32.Parse(PageState.QueryString["id"]); + if(PageState.User != null) { _profiles = await ProfileService.GetProfilesAsync(PageState.Site.SiteId); var user = await UserService.GetUserAsync(PageState.User.UserId, PageState.Site.SiteId); @@ -135,10 +134,10 @@ { _settings = user.Settings; } + _users = await EventRegistrationService.GetRecommendedResponses(_id, ModuleState.ModuleId); + _users.ForEach(u => Console.WriteLine(u.UserId)); } - - _id = Int32.Parse(PageState.QueryString["id"]); - + Event currentEvent; Response rsvp; (currentEvent, rsvp) = await EventRegistrationService.GetEventDetails(_id, ModuleState.ModuleId); diff --git a/Server/Services/EventRegistrationService.cs b/Server/Services/EventRegistrationService.cs index 2a6f537..19ca9ab 100644 --- a/Server/Services/EventRegistrationService.cs +++ b/Server/Services/EventRegistrationService.cs @@ -1,5 +1,7 @@ +using System; using System.Collections.Generic; using System.Linq; +using System.Numerics; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Oqtane.Enums; @@ -23,9 +25,10 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services private readonly IUserPermissions _userPermissions; private readonly ILogManager _logger; private readonly IHttpContextAccessor _accessor; + private readonly ISettingRepository _settingRepository; private readonly Alias _alias; - public ServerEventRegistrationService(IEventRepository EventRepository, IResponseRepository ResponseRepository, INotificationRepository NotificationRepository, IUserRepository UserRepository, IUserPermissions userPermissions, ITenantManager tenantManager, ILogManager logger, IHttpContextAccessor accessor) + public ServerEventRegistrationService(IEventRepository EventRepository, IResponseRepository ResponseRepository, INotificationRepository NotificationRepository, IUserRepository UserRepository, IUserPermissions userPermissions, ITenantManager tenantManager, ILogManager logger, IHttpContextAccessor accessor, ISettingRepository settingRepository) { _EventRepository = EventRepository; _ResponseRepository = ResponseRepository; @@ -34,6 +37,7 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services _userPermissions = userPermissions; _logger = logger; _accessor = accessor; + _settingRepository = settingRepository; _alias = tenantManager.GetAlias(); } @@ -148,7 +152,39 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Event Response Get Attempt {ModuleId}", ModuleId); return null; } - throw new System.NotImplementedException(); + } + + public async Task> GetRecommendedResponses(int EventId, int ModuleId) + { + if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View)) + { + IEnumerable responses = _ResponseRepository.GetResponses(EventId, ModuleId).DistinctBy(r => r.OwnerId).Where(r => r.OwnerId != _accessor.HttpContext.User.UserId() && r.ResponseType); + IEnumerable users = _UserRepository.GetUsers(); + + List userSettings = _settingRepository.GetSettings("User").ToList(); + + List requestorSettings = userSettings.FindAll(s => s.EntityId == _accessor.HttpContext.User.UserId()); + string targetFachrichtung = requestorSettings.FirstOrDefault(s => s.SettingName == "Fachrichtung")?.SettingValue; + int targetStartjahr = int.Parse(requestorSettings.FirstOrDefault(s => s.SettingName == "Jahrgang")?.SettingValue ?? "0"); + + + IEnumerable gu = responses.Join(users, r => r.OwnerId, u => u.UserId, + (response, user) => new GroupingUser(user, response)).GroupJoin(userSettings, gu => gu.User.UserId, + s => s.EntityId, (gu, s) => + { + gu.Settings = s; + gu.TargetJahr = targetStartjahr; + gu.TargetFachrichtung = targetFachrichtung; + + return gu; + }).OrderBy(gu => gu.Score()); + return gu.Select(gu => gu.User).ToList(); + } + else + { + _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Event Response Get Attempt {ModuleId}", ModuleId); + return null; + } } public Task> GetEventsAsync(int ModuleId) @@ -179,55 +215,6 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services return Task.FromResult(NewEvent); } - // TODO: Implement the methods for EventResponses - - /* - - public Task GetEventRegistrationAsync(int EventRegistrationId, int ModuleId) - { - if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View)) - { - return Task.FromResult(_EventRegistrationRepository.GetEventRegistration(EventRegistrationId)); - } - else - { - _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Get Attempt {EventRegistrationId} {ModuleId}", EventRegistrationId, ModuleId); - return null; - } - } - - public Task AddEventRegistrationAsync(Models.Event EventRegistration) - { - if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, EventRegistration.ModuleId, PermissionNames.Edit)) - { - EventRegistration = _EventRegistrationRepository.AddEventRegistration(EventRegistration); - _logger.Log(LogLevel.Information, this, LogFunction.Create, "EventRegistration Added {EventRegistration}", EventRegistration); - } - else - { - _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Add Attempt {EventRegistration}", EventRegistration); - EventRegistration = null; - } - return Task.FromResult(EventRegistration); - } - - public Task UpdateEventRegistrationAsync(Models.Event EventRegistration) - { - if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, EventRegistration.ModuleId, PermissionNames.Edit)) - { - EventRegistration = _EventRegistrationRepository.UpdateEventRegistration(EventRegistration); - _logger.Log(LogLevel.Information, this, LogFunction.Update, "EventRegistration Updated {EventRegistration}", EventRegistration); - } - else - { - _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized EventRegistration Update Attempt {EventRegistration}", EventRegistration); - EventRegistration = null; - } - return Task.FromResult(EventRegistration); - } - - }*/ - private void SendEventResponseNotification(string subject, string body) { User user = _UserRepository.GetUser(_accessor.HttpContext.User.UserId()); @@ -235,4 +222,73 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services _NotificationRepository.AddNotification(notification); } } + + public class GroupingUser + { + private User _user; + private Response _response; + + private string _fachrichtung; + private int _startjahr; + + private int _targetyear; + private string _targetfachrichtung; + public User User { get { return _user; } } + + public IEnumerable Settings + { + set + { + if (value == null) + { + _fachrichtung = "-"; + _startjahr = 0; + return; + } + _fachrichtung = value.FirstOrDefault(v => v.SettingName == "Fachrichtung", new Setting(){SettingValue = "-"}).SettingValue; + _startjahr = int.Parse(value.FirstOrDefault(v => v.SettingName == "Jahrgang", new Setting(){SettingValue = "0"}).SettingValue); + } + } + + public string TargetFachrichtung + { + set { _targetfachrichtung = value; } + } + public int TargetJahr + { + set { _targetyear = value; } + } + + public GroupingUser(User user, Response response) + { + _user = user; + _response = response; + } + + public int Score() + { + int total = 0; + total += ScoreYear() * 5; + total += ScoreFachrichtung() * 3; + + return total; + } + + private int ScoreYear() + { + return Math.Abs(_targetyear - _startjahr); + } + + private int ScoreFachrichtung() + { + if (_fachrichtung == _targetfachrichtung) + { + return 1; + } + else + { + return 0; + } + } + } } diff --git a/Shared/Interfaces/IEventRegistrationService.cs b/Shared/Interfaces/IEventRegistrationService.cs index 864b30f..d621bae 100644 --- a/Shared/Interfaces/IEventRegistrationService.cs +++ b/Shared/Interfaces/IEventRegistrationService.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using Oqtane.Models; using SZUAbsolventenverein.Module.EventRegistration.Models; namespace SZUAbsolventenverein.Module.EventRegistration.Services @@ -26,5 +27,6 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services Task<(Event, Response)> GetEventDetails(int EventId, int ModuleId); Task> GetEventResponses(int EventId, int ModuleId); + Task> GetRecommendedResponses(int EventId, int ModuleId); } } -- 2.49.0 From a9baccb998b4a6884fbde33fe59da4c53a431867 Mon Sep 17 00:00:00 2001 From: KoCoder Date: Mon, 22 Dec 2025 18:29:32 +0100 Subject: [PATCH 4/4] Cosmetic: Komment ERS entfernt und kleiner Cleanup beim Server Service --- Client/Services/EventRegistrationService.cs | 27 +++++---------------- Server/Services/EventRegistrationService.cs | 18 ++++++-------- 2 files changed, 13 insertions(+), 32 deletions(-) diff --git a/Client/Services/EventRegistrationService.cs b/Client/Services/EventRegistrationService.cs index 6e45618..3462820 100644 --- a/Client/Services/EventRegistrationService.cs +++ b/Client/Services/EventRegistrationService.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Net.Http; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Oqtane.Models; using Oqtane.Services; using Oqtane.Shared; using SZUAbsolventenverein.Module.EventRegistration.Models; @@ -15,27 +16,6 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services private string Apiurl => CreateApiUrl("EventRegistration"); - /*public async Task> GetEventRegistrationsAsync(int ModuleId) - { - List EventRegistrations = await GetJsonAsync>(CreateAuthorizationPolicyUrl($"{Apiurl}?moduleid={ModuleId}", EntityNames.Module, ModuleId), Enumerable.Empty().ToList()); - return EventRegistrations.OrderBy(item => item.Name).ToList(); - } - - public async Task GetEventRegistrationAsync(int EventRegistrationId, int ModuleId) - { - return await GetJsonAsync(CreateAuthorizationPolicyUrl($"{Apiurl}/{EventRegistrationId}/{ModuleId}", EntityNames.Module, ModuleId)); - } - - public async Task AddEventRegistrationAsync(Models.Event EventRegistration) - { - return await PostJsonAsync(CreateAuthorizationPolicyUrl($"{Apiurl}", EntityNames.Module, EventRegistration.ModuleId), EventRegistration); - } - - public async Task UpdateEventRegistrationAsync(Models.Event EventRegistration) - { - return await PutJsonAsync(CreateAuthorizationPolicyUrl($"{Apiurl}/{EventRegistration.EventRegistrationId}", EntityNames.Module, EventRegistration.ModuleId), EventRegistration); - }*/ - public async Task> GetEventsAsync(int ModuleId) { List EventRegistrations = await GetJsonAsync(CreateAuthorizationPolicyUrl($"{Apiurl}?moduleid={ModuleId}", EntityNames.Module, ModuleId), Enumerable.Empty().ToList()); @@ -80,5 +60,10 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services { throw new System.NotImplementedException(); } + + public Task> GetRecommendedResponses(int EventId, int ModuleId) + { + throw new System.NotImplementedException(); + } } } diff --git a/Server/Services/EventRegistrationService.cs b/Server/Services/EventRegistrationService.cs index 19ca9ab..ca5b73d 100644 --- a/Server/Services/EventRegistrationService.cs +++ b/Server/Services/EventRegistrationService.cs @@ -169,16 +169,9 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services IEnumerable gu = responses.Join(users, r => r.OwnerId, u => u.UserId, - (response, user) => new GroupingUser(user, response)).GroupJoin(userSettings, gu => gu.User.UserId, - s => s.EntityId, (gu, s) => - { - gu.Settings = s; - gu.TargetJahr = targetStartjahr; - gu.TargetFachrichtung = targetFachrichtung; - - return gu; - }).OrderBy(gu => gu.Score()); - return gu.Select(gu => gu.User).ToList(); + (response, user) => (response, user)).GroupJoin(userSettings, ru => ru.user.UserId, + s => s.EntityId, (ru, s) => new GroupingUser(ru.user, ru.response, s, targetStartjahr, targetFachrichtung)).OrderBy(gu => gu.Score()); + return gu.Select(gu => gu.User).Take(10).ToList(); } else { @@ -259,10 +252,13 @@ namespace SZUAbsolventenverein.Module.EventRegistration.Services set { _targetyear = value; } } - public GroupingUser(User user, Response response) + public GroupingUser(User user, Response response, IEnumerable settings, int targetyear, string targetfachrichtung) { _user = user; _response = response; + Settings = settings; + TargetJahr = targetyear; + TargetFachrichtung = targetfachrichtung; } public int Score() -- 2.49.0