fix: simplify journal history service loading

This commit is contained in:
Meik
2026-07-01 01:09:11 +02:00
parent 258ca8a837
commit f84d840e51
4 changed files with 3 additions and 301 deletions

View File

@@ -1,7 +1,6 @@
using C4IT.F4SDM;
using C4IT.FASD.Base;
using C4IT.Logging;
using Matrix42.BizLogic.Common.Journal;
using Matrix42.Common;
using Newtonsoft.Json;
using System;
@@ -1455,7 +1454,7 @@ namespace C4IT.F4SD
private static IReadOnlyList<Matrix42.Contracts.Platform.Data.JournalEntryInfo> LoadJournalEntries(Guid activityEOID)
{
var journalService = F4SDM42WebApiController.defaultInstance.GetJournalServiceInstance();
var journalService = F4SDM42WebApiController.defaultInstance.GetJournalService();
var serviceType = journalService.GetType();
var objectLinkTemplate = "<a href=\"#\" class=\"mx-object-journal--link {0} {1}\">{2}</a>";
var methods = serviceType
@@ -1482,12 +1481,6 @@ namespace C4IT.F4SD
}
catch (TargetInvocationException ex) when (ex.InnerException != null)
{
if (IsStorageWebApiExplorerResolutionFailure(ex.InnerException))
{
LogEntry("JournalService.GetJournalList requires IStorageService in this Matrix42 build. Falling back to JournalManager.GetObjectEntries for sandbox compatibility.", LogLevels.Warning);
return LoadJournalEntriesFromJournalManager(activityEOID, objectLinkTemplate);
}
throw ex.InnerException;
}
}
@@ -1495,38 +1488,6 @@ namespace C4IT.F4SD
throw new MissingMethodException($"No compatible IJournalService.GetJournalList overload was found on '{serviceType.FullName}'. Available overloads: {string.Join("; ", methods.Select(FormatMethodSignature))}");
}
private static IReadOnlyList<Matrix42.Contracts.Platform.Data.JournalEntryInfo> LoadJournalEntriesFromJournalManager(Guid activityEOID, string objectLinkTemplate)
{
var entries = JournalManager.GetObjectEntries(
activityEOID,
false,
null,
0,
50,
false,
objectLinkTemplate,
120);
return entries
.Select(item => new Matrix42.Contracts.Platform.Data.JournalEntryInfo
{
Id = item.Id,
Creator = item.CreatorName,
CreatedDate = item.CreatedDate,
Header = item.Header,
Text = item.Body ?? string.Empty,
VisibleInPortal = item.VisibleInPortal
})
.ToList();
}
private static bool IsStorageWebApiExplorerResolutionFailure(Exception exception)
{
var details = exception.ToString();
return details.Contains("Matrix42.StorageService.Contracts.IStorageService")
&& details.Contains("System.Web.Http.Description.IApiExplorer");
}
private static bool IsJournalReaderMethod(MethodInfo method)
{
var methodName = method.Name;