diagnose: surface missing method details for ticket history

This commit is contained in:
Meik
2026-06-30 23:57:59 +02:00
parent ec69a95c22
commit 3d6a8f514c
3 changed files with 80 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -140,7 +141,80 @@ namespace C4IT.F4SD
[Route("getTicketHistory"), HttpGet]
public async Task<List<cTicketJournalItem>> getTicketHistory(Guid objectId)
{
return await _f4stHelperService.GetJournalEntries(objectId);
try
{
return await _f4stHelperService.GetJournalEntries(objectId);
}
catch (MissingMethodException ex)
{
return CreateMissingMethodDiagnostics("getTicketHistory controller", objectId, ex);
}
}
internal static List<cTicketJournalItem> CreateMissingMethodDiagnostics(string stage, Guid objectId, MissingMethodException ex)
{
var details = BuildMissingMethodDiagnostic(stage, objectId, ex);
LogEntry(details, LogLevels.Warning);
return new List<cTicketJournalItem>
{
new cTicketJournalItem
{
ActivityObjectId = objectId,
CreatedBy = "C4ITF4SDM42WebApi",
CreationDate = DateTime.Now,
Header = "MissingMethodException diagnostic",
Description = details,
DescriptionHtml = WebUtility.HtmlEncode(details).Replace(Environment.NewLine, "<br />"),
IsVisibleForUser = false
}
};
}
private static string BuildMissingMethodDiagnostic(string stage, Guid objectId, MissingMethodException ex)
{
var builder = new StringBuilder();
builder.AppendLine($"Stage: {stage}");
builder.AppendLine($"ObjectId: {objectId}");
builder.AppendLine(ex.ToString());
builder.AppendLine("Loaded assemblies:");
var assemblyNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
"C4ITF4SDM42WebApi",
"C4ITF4SDM42WebApiHelper",
"Matrix42.Common",
"Matrix42.Common.Html",
"Matrix42.Contracts.Platform",
"Matrix42.Contracts.ServiceManagement",
"Matrix42.ServiceManager.BizLogic",
"Matrix42.BizLogic.Journal",
"Newtonsoft.Json",
"System.Net.Http.Formatting",
"update4u.SPS.DataLayer",
"update4u.SPS.Security"
};
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()
.Where(assembly => assemblyNames.Contains(assembly.GetName().Name))
.OrderBy(assembly => assembly.GetName().Name))
{
builder.AppendLine($"{assembly.GetName().Name}, Version={assembly.GetName().Version}, Location={GetAssemblyLocation(assembly)}");
}
return builder.ToString();
}
private static string GetAssemblyLocation(Assembly assembly)
{
try
{
return assembly.Location;
}
catch
{
return string.Empty;
}
}
[Route("getTicketOverviewCounts"), HttpGet]