From 1d45916b6a364ae99121467051ac7a2270cb61a0 Mon Sep 17 00:00:00 2001
From: epenet <6771947+epenet@users.noreply.github.com>
Date: Fri, 22 Mar 2024 11:55:23 +0100
Subject: [PATCH] Add Source section to dashboard job details
---
.../Content/resx/Strings.Designer.cs | 9 ++
.../Dashboard/Content/resx/Strings.resx | 3 +
.../Dashboard/Pages/JobDetailsPage.cshtml | 17 +-
.../Dashboard/Pages/JobDetailsPage.cshtml.cs | 145 +++++++++++++-----
.../SqlServerMonitoringApi.cs | 3 +
5 files changed, 139 insertions(+), 38 deletions(-)
diff --git a/src/Hangfire.Core/Dashboard/Content/resx/Strings.Designer.cs b/src/Hangfire.Core/Dashboard/Content/resx/Strings.Designer.cs
index 881a05478..6dd2d3217 100644
--- a/src/Hangfire.Core/Dashboard/Content/resx/Strings.Designer.cs
+++ b/src/Hangfire.Core/Dashboard/Content/resx/Strings.Designer.cs
@@ -637,6 +637,15 @@ public static string JobDetailsPage_Requeue {
}
}
+ ///
+ /// Looks up a localized string similar to Source.
+ ///
+ public static string JobDetailsPage_Source {
+ get {
+ return ResourceManager.GetString("JobDetailsPage_Source", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to State.
///
diff --git a/src/Hangfire.Core/Dashboard/Content/resx/Strings.resx b/src/Hangfire.Core/Dashboard/Content/resx/Strings.resx
index fff592276..c229f7152 100644
--- a/src/Hangfire.Core/Dashboard/Content/resx/Strings.resx
+++ b/src/Hangfire.Core/Dashboard/Content/resx/Strings.resx
@@ -578,4 +578,7 @@
Log File(s) Used (MB)
+
+ Source
+
\ No newline at end of file
diff --git a/src/Hangfire.Core/Dashboard/Pages/JobDetailsPage.cshtml b/src/Hangfire.Core/Dashboard/Pages/JobDetailsPage.cshtml
index 0137693a4..8c34664a8 100644
--- a/src/Hangfire.Core/Dashboard/Pages/JobDetailsPage.cshtml
+++ b/src/Hangfire.Core/Dashboard/Pages/JobDetailsPage.cshtml
@@ -108,7 +108,7 @@
}
- var displayParameters = job.Properties.Where(x => !x.Key.StartsWith("DBG_") && x.Key != "Continuations").ToArray();
+ var displayParameters = job.Properties.Where(x => !x.Key.StartsWith("DBG_") && !x.Key.StartsWith("SRC_") && x.Key != "Continuations").ToArray();
if (displayParameters.Length > 0)
{
@@ -190,6 +190,21 @@
}
}
+ var srcParameters = job.Properties.Where(x => x.Key.StartsWith("SRC_")).ToArray();
+ if (job.Job != null && srcParameters.Length > 0)
+ {
+
@Strings.JobDetailsPage_Source
+
+ @foreach (var parameter in srcParameters)
+ {
+
+ @parameter.Key.Substring(4) |
+ @parameter.Value
|
+
+ }
+
+ }
+
@if (job.History.Count > 1)
{
diff --git a/src/Hangfire.Core/Dashboard/Pages/JobDetailsPage.cshtml.cs b/src/Hangfire.Core/Dashboard/Pages/JobDetailsPage.cshtml.cs
index f5e2afa7d..ac658f8bc 100644
--- a/src/Hangfire.Core/Dashboard/Pages/JobDetailsPage.cshtml.cs
+++ b/src/Hangfire.Core/Dashboard/Pages/JobDetailsPage.cshtml.cs
@@ -423,7 +423,7 @@ public override void Execute()
#line 109 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
}
- var displayParameters = job.Properties.Where(x => !x.Key.StartsWith("DBG_") && x.Key != "Continuations").ToArray();
+ var displayParameters = job.Properties.Where(x => !x.Key.StartsWith("DBG_") && !x.Key.StartsWith("SRC_") && x.Key != "Continuations").ToArray();
if (displayParameters.Length > 0)
{
@@ -794,6 +794,77 @@ public override void Execute()
}
}
+ var srcParameters = job.Properties.Where(x => x.Key.StartsWith("SRC_")).ToArray();
+ if (job.Job != null && srcParameters.Length > 0)
+ {
+
+
+ #line default
+ #line hidden
+WriteLiteral(" ");
+
+
+
+ #line 196 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ Write(Strings.JobDetailsPage_Source);
+
+
+ #line default
+ #line hidden
+WriteLiteral("
\r\n");
+
+
+
+WriteLiteral("
\r\n");
+
+
+
+ #line 198 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ foreach (var parameter in srcParameters)
+ {
+
+
+ #line default
+ #line hidden
+WriteLiteral(" \r\n ");
+
+
+
+ #line 201 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ Write(parameter.Key.Substring(4));
+
+
+ #line default
+ #line hidden
+WriteLiteral(" | \r\n ");
+
+
+
+ #line 202 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ Write(parameter.Value);
+
+
+ #line default
+ #line hidden
+WriteLiteral("
| \r\n
\r\n");
+
+
+
+ #line 204 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ }
+
+
+ #line default
+ #line hidden
+WriteLiteral("
\r\n");
+
+
+
+ #line 206 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ }
+
#line default
@@ -802,7 +873,7 @@ public override void Execute()
- #line 194 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 209 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
if (job.History.Count > 1)
{
@@ -813,7 +884,7 @@ public override void Execute()
- #line 197 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 212 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
if (!IsReadOnly)
{
@@ -825,7 +896,7 @@ public override void Execute()
- #line 200 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 215 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
Write(Url.To("/jobs/actions/requeue/" + JobId));
@@ -835,7 +906,7 @@ public override void Execute()
- #line 201 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 216 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
Write(Strings.Common_Enqueueing);
@@ -845,7 +916,7 @@ public override void Execute()
- #line 202 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 217 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
Write(Strings.JobDetailsPage_Requeue);
@@ -855,7 +926,7 @@ public override void Execute()
- #line 204 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 219 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
}
@@ -863,7 +934,7 @@ public override void Execute()
#line hidden
- #line 205 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 220 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
if (!IsReadOnly)
{
@@ -875,7 +946,7 @@ public override void Execute()
- #line 208 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 223 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
Write(Url.To("/jobs/actions/delete/" + JobId));
@@ -885,7 +956,7 @@ public override void Execute()
- #line 209 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 224 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
Write(Strings.Common_Deleting);
@@ -895,7 +966,7 @@ public override void Execute()
- #line 210 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 225 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
Write(Strings.JobDetailsPage_DeleteConfirm);
@@ -905,7 +976,7 @@ public override void Execute()
- #line 211 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 226 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
Write(Strings.Common_Delete);
@@ -915,7 +986,7 @@ public override void Execute()
- #line 213 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 228 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
}
@@ -925,7 +996,7 @@ public override void Execute()
- #line 215 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 230 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
}
@@ -935,7 +1006,7 @@ public override void Execute()
- #line 217 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 232 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
Write(Strings.JobDetailsPage_State);
@@ -945,7 +1016,7 @@ public override void Execute()
- #line 219 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 234 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
var index = 0;
@@ -966,7 +1037,7 @@ public override void Execute()
- #line 231 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 246 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
Write(cardCss != null ? "state-card-state-" + cardCss : null);
@@ -976,7 +1047,7 @@ public override void Execute()
- #line 231 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 246 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
Write(cardStyle);
@@ -986,7 +1057,7 @@ public override void Execute()
- #line 232 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 247 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
Write(cardTitleStyle);
@@ -996,7 +1067,7 @@ public override void Execute()
- #line 234 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 249 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
if (index == job.History.Count - 1)
{
@@ -1004,14 +1075,14 @@ public override void Execute()
#line default
#line hidden
- #line 236 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 251 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
Write(Html.RelativeTime(entry.CreatedAt));
#line default
#line hidden
- #line 236 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 251 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
}
else
@@ -1030,7 +1101,7 @@ public override void Execute()
- #line 244 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 259 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
Write(Html.RelativeTime(entry.CreatedAt));
@@ -1040,7 +1111,7 @@ public override void Execute()
- #line 244 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 259 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
Write(duration);
@@ -1050,7 +1121,7 @@ public override void Execute()
- #line 245 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 260 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
}
else
{
@@ -1064,7 +1135,7 @@ public override void Execute()
- #line 248 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 263 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
Write(Html.MomentTitle(entry.CreatedAt, duration));
@@ -1074,7 +1145,7 @@ public override void Execute()
- #line 249 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 264 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
}
}
@@ -1085,7 +1156,7 @@ public override void Execute()
- #line 253 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 268 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
Write(entry.StateName);
@@ -1095,7 +1166,7 @@ public override void Execute()
- #line 256 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 271 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
if (!String.IsNullOrWhiteSpace(entry.Reason))
{
@@ -1106,7 +1177,7 @@ public override void Execute()
- #line 258 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 273 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
Write(entry.Reason);
@@ -1116,7 +1187,7 @@ public override void Execute()
- #line 259 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 274 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
}
@@ -1126,7 +1197,7 @@ public override void Execute()
- #line 261 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 276 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
var rendered = Html.RenderHistory(entry.StateName, entry.Data);
@@ -1138,7 +1209,7 @@ public override void Execute()
- #line 265 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 280 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
if (rendered != null)
{
@@ -1149,7 +1220,7 @@ public override void Execute()
- #line 267 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 282 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
Write(cardBackgroundStyle);
@@ -1159,7 +1230,7 @@ public override void Execute()
- #line 268 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 283 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
Write(rendered);
@@ -1169,7 +1240,7 @@ public override void Execute()
- #line 270 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 285 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
}
@@ -1179,7 +1250,7 @@ public override void Execute()
- #line 272 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
+ #line 287 "..\..\Dashboard\Pages\JobDetailsPage.cshtml"
index++;
}
diff --git a/src/Hangfire.SqlServer/SqlServerMonitoringApi.cs b/src/Hangfire.SqlServer/SqlServerMonitoringApi.cs
index 66f0a58b1..66c125f2a 100644
--- a/src/Hangfire.SqlServer/SqlServerMonitoringApi.cs
+++ b/src/Hangfire.SqlServer/SqlServerMonitoringApi.cs
@@ -369,6 +369,9 @@ public override JobDetailsDto JobDetails(string jobId)
.Select(grp => grp.First())
.ToDictionary(x => x.Name, x => x.Value);
+ parameters.Add("SRC_InvocationData", job.InvocationData);
+ parameters.Add("SRC_Arguments", job.Arguments);
+
var deserializedJob = DeserializeJob(job.InvocationData, job.Arguments, out var payload, out var exception);
if (deserializedJob == null)