diff --git a/F4SDM42WebApi/F4SD - M42WebApi.csproj b/F4SDM42WebApi/F4SD - M42WebApi.csproj index d25e1b4..9e3939e 100644 --- a/F4SDM42WebApi/F4SD - M42WebApi.csproj +++ b/F4SDM42WebApi/F4SD - M42WebApi.csproj @@ -13,7 +13,7 @@ false 6673a25d-33d6-4072-91d9-abed4be1a966 C4ITF4SD*.* - 1.4.0.22 + 1.4.0.23 true diff --git a/F4SDM42WebApi/F4SDHelperService.cs b/F4SDM42WebApi/F4SDHelperService.cs index 6a3141d..6dcb390 100644 --- a/F4SDM42WebApi/F4SDHelperService.cs +++ b/F4SDM42WebApi/F4SDHelperService.cs @@ -1431,6 +1431,10 @@ namespace C4IT.F4SD } return journalEntries; } + catch (MissingMethodException E) + { + return F4SDM42WebApiController.CreateMissingMethodDiagnostics("GetJournalEntries helper", activityEOID, E); + } catch (Exception E) { LogException(E); diff --git a/F4SDM42WebApi/F4SDM42WebApiController.cs b/F4SDM42WebApi/F4SDM42WebApiController.cs index 5b55b55..f78f88b 100644 --- a/F4SDM42WebApi/F4SDM42WebApiController.cs +++ b/F4SDM42WebApi/F4SDM42WebApiController.cs @@ -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> 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 CreateMissingMethodDiagnostics(string stage, Guid objectId, MissingMethodException ex) + { + var details = BuildMissingMethodDiagnostic(stage, objectId, ex); + LogEntry(details, LogLevels.Warning); + + return new List + { + new cTicketJournalItem + { + ActivityObjectId = objectId, + CreatedBy = "C4ITF4SDM42WebApi", + CreationDate = DateTime.Now, + Header = "MissingMethodException diagnostic", + Description = details, + DescriptionHtml = WebUtility.HtmlEncode(details).Replace(Environment.NewLine, "
"), + 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(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]