2 Commits

Author SHA1 Message Date
Meik
de9a226272 build: bump m42 package to 1.4.0.17 2026-06-30 18:57:21 +02:00
Meik
a9a9e28924 fix: avoid direct journal service method binding 2026-06-30 18:55:58 +02:00
2 changed files with 59 additions and 11 deletions

View File

@@ -13,7 +13,7 @@
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<M42ExtensionId>6673a25d-33d6-4072-91d9-abed4be1a966</M42ExtensionId>
<M42AssemblyPattern>C4ITF4SD*.*</M42AssemblyPattern>
<M42PackageVersion>1.4.0.16</M42PackageVersion>
<M42PackageVersion>1.4.0.17</M42PackageVersion>
<M42BuildPackage>true</M42BuildPackage>
</PropertyGroup>

View File

@@ -1408,22 +1408,29 @@ namespace C4IT.F4SD
{
await Task.Delay(0);
List<cTicketJournalItem> journalEntries = new List<cTicketJournalItem>();
var entries = F4SDM42WebApiController.defaultInstance.GetJournalService().GetJournalList(activityEOID, false, 0, 50, "<a href=\"#\" class=\"mx-object-journal--link {0} {1}\">{2}</a>", 120);
var entries = GetJournalList(activityEOID);
LogEntry($"{entries.Length} Journal entries found for ObjectID={activityEOID}", LogLevels.Debug);
for (int i = 0; i < entries.Length; i++)
{
Matrix42.Contracts.Platform.Data.JournalEntryInfo item = entries[i];
LogEntry($"Journal entry {i + 1}/{entries.Length}: ID={item.Id}, CreatedDate={item.CreatedDate}, CreatedBy={item.Creator}, Header={item.Header}", LogLevels.Debug);
var item = entries.GetValue(i);
var journalId = GetJournalEntryValue(item, "Id", Guid.Empty);
var createdDate = GetJournalEntryValue(item, "CreatedDate", DateTime.MinValue);
var creator = GetJournalEntryValue(item, "Creator", string.Empty);
var text = GetJournalEntryValue(item, "Text", string.Empty);
var header = GetJournalEntryValue(item, "Header", string.Empty);
var visibleInPortal = GetJournalEntryValue(item, "VisibleInPortal", false);
LogEntry($"Journal entry {i + 1}/{entries.Length}: ID={journalId}, CreatedDate={createdDate}, CreatedBy={creator}, Header={header}", LogLevels.Debug);
journalEntries.Add(new cTicketJournalItem()
{
JournalId = item.Id,
JournalId = journalId,
ActivityObjectId = activityEOID,
CreatedBy = item.Creator,
CreationDate = (DateTime)item.CreatedDate,
DescriptionHtml = item.Text,
Description = Matrix42.Common.Html.HtmlConverter.ConvertHtmlToPlainText(item.Text),
Header = item.Header,
IsVisibleForUser = item.VisibleInPortal
CreatedBy = creator,
CreationDate = createdDate,
DescriptionHtml = text,
Description = string.IsNullOrEmpty(text) ? string.Empty : Matrix42.Common.Html.HtmlConverter.ConvertHtmlToPlainText(text),
Header = header,
IsVisibleForUser = visibleInPortal
});
}
return journalEntries;
@@ -1439,6 +1446,47 @@ namespace C4IT.F4SD
}
}
private static Array GetJournalList(Guid activityEOID)
{
var journalService = F4SDM42WebApiController.defaultInstance.GetJournalService();
var method = FindJournalListMethod(journalService.GetType());
if (method == null)
throw new MissingMethodException(journalService.GetType().FullName, "GetJournalList(Guid, Boolean, Int32, Int32, String, Int32)");
return method.Invoke(journalService, new object[]
{
activityEOID,
false,
0,
50,
"<a href=\"#\" class=\"mx-object-journal--link {0} {1}\">{2}</a>",
120
}) as Array ?? Array.Empty<object>();
}
private static MethodInfo FindJournalListMethod(Type serviceType)
{
var parameterTypes = new[] { typeof(Guid), typeof(bool), typeof(int), typeof(int), typeof(string), typeof(int) };
return new[] { serviceType }
.Concat(serviceType.GetInterfaces())
.Select(type => type.GetMethod("GetJournalList", parameterTypes))
.FirstOrDefault(method => method != null);
}
private static T GetJournalEntryValue<T>(object entry, string propertyName, T defaultValue)
{
var property = entry?.GetType().GetProperty(propertyName);
var value = property?.GetValue(entry);
if (value == null || value == DBNull.Value)
return defaultValue;
if (value is T typedValue)
return typedValue;
var targetType = Nullable.GetUnderlyingType(typeof(T)) ?? typeof(T);
return (T)Convert.ChangeType(value, targetType, CultureInfo.InvariantCulture);
}
internal async Task<bool> updateActivitySolution(Guid objectId, string solutionHtml)
{