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

@@ -13,7 +13,7 @@
<EnableDefaultCompileItems>false</EnableDefaultCompileItems> <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<M42ExtensionId>6673a25d-33d6-4072-91d9-abed4be1a966</M42ExtensionId> <M42ExtensionId>6673a25d-33d6-4072-91d9-abed4be1a966</M42ExtensionId>
<M42AssemblyPattern>C4ITF4SD*.*</M42AssemblyPattern> <M42AssemblyPattern>C4ITF4SD*.*</M42AssemblyPattern>
<M42PackageVersion>1.4.0.29</M42PackageVersion> <M42PackageVersion>1.4.0.30</M42PackageVersion>
<M42BuildPackage>true</M42BuildPackage> <M42BuildPackage>true</M42BuildPackage>
</PropertyGroup> </PropertyGroup>
@@ -34,6 +34,10 @@
<HintPath>M42Libraries\26.1\Matrix42.Contracts.ServiceManagement.dll</HintPath> <HintPath>M42Libraries\26.1\Matrix42.Contracts.ServiceManagement.dll</HintPath>
<Private>false</Private> <Private>false</Private>
</Reference> </Reference>
<Reference Include="Matrix42.BizLogic.Journal">
<HintPath>M42Libraries\26.1\Matrix42.BizLogic.Journal.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Matrix42.Hosting.Contracts"> <Reference Include="Matrix42.Hosting.Contracts">
<HintPath>M42Libraries\26.1\Matrix42.Hosting.Contracts.dll</HintPath> <HintPath>M42Libraries\26.1\Matrix42.Hosting.Contracts.dll</HintPath>
<Private>false</Private> <Private>false</Private>

View File

@@ -1,6 +1,7 @@
using C4IT.F4SDM; using C4IT.F4SDM;
using C4IT.FASD.Base; using C4IT.FASD.Base;
using C4IT.Logging; using C4IT.Logging;
using Matrix42.BizLogic.Common.Journal;
using Matrix42.Common; using Matrix42.Common;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
@@ -1475,6 +1476,12 @@ namespace C4IT.F4SD
} }
catch (TargetInvocationException ex) when (ex.InnerException != null) 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; 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))}"); 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) private static bool IsJournalReaderMethod(MethodInfo method)
{ {
var methodName = method.Name; var methodName = method.Name;