fix: fallback journal history when storage resolution fails

This commit is contained in:
Meik
2026-07-01 00:42:03 +02:00
parent d472923442
commit 45b8e1d223
2 changed files with 44 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
using C4IT.F4SDM;
using C4IT.FASD.Base;
using C4IT.Logging;
using Matrix42.BizLogic.Common.Journal;
using Matrix42.Common;
using Newtonsoft.Json;
using System;
@@ -1475,6 +1476,12 @@ 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;
}
}
@@ -1482,6 +1489,38 @@ 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;