diagnose: surface missing method details for ticket history
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<M42ExtensionId>6673a25d-33d6-4072-91d9-abed4be1a966</M42ExtensionId>
|
||||
<M42AssemblyPattern>C4ITF4SD*.*</M42AssemblyPattern>
|
||||
<M42PackageVersion>1.4.0.22</M42PackageVersion>
|
||||
<M42PackageVersion>1.4.0.23</M42PackageVersion>
|
||||
<M42BuildPackage>true</M42BuildPackage>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -1431,6 +1431,10 @@ namespace C4IT.F4SD
|
||||
}
|
||||
return journalEntries;
|
||||
}
|
||||
catch (MissingMethodException E)
|
||||
{
|
||||
return F4SDM42WebApiController.CreateMissingMethodDiagnostics("GetJournalEntries helper", activityEOID, E);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user