Skip to content

Instantly share code, notes, and snippets.

@lowedown
Last active April 11, 2016 20:38
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lowedown/7b6b4828de2204362edf to your computer and use it in GitHub Desktop.
Save lowedown/7b6b4828de2204362edf to your computer and use it in GitHub Desktop.
Sitecore Admin Page to show currently running Jobs
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="Sitecore.Jobs" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Running Sitecore Background Jobs</title>
<meta http-equiv="refresh" content="3" />
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Running Sitecore Background Jobs</h1>
<table>
<tr>
<th>Name</th>
<th>Category</th>
<th>State</th>
<th>Is Done</th>
<th>Queue Time (local time)</th>
<th>Processed</th>
<th>Last Message</th>
</tr>
<asp:Repeater runat="server" ID="repContent" ItemType="Sitecore.Jobs.Job">
<ItemTemplate>
<tr class="<%# Container.ItemIndex % 2 == 0 ? "" : "alternate" %>">
<td><%# Item.Name %></td>
<td><%# Item.Category %></td>
<td><%# Item.Status.State %></td>
<td><%# Item.IsDone %></td>
<td><%# Item.QueueTime %></td>
<td><%# (Item.Status != null) ? Item.Status.Processed : 0 %> <%# (Item.Status != null && Item.Status.Total > 1) ? ((Item.Status.Processed * 100) / Item.Status.Total).ToString("(#.#") + "%)" : string.Empty %></td>
<td><%# (Item.Status != null && Item.Status.Messages.Count > 0) ? Item.Status.Messages[Item.Status.Messages.Count - 1] : string.Empty %></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</div>
<script runat="server">
protected override void OnInit(EventArgs arguments)
{
CheckSecurity(true);
}
protected void CheckSecurity(bool isDeveloperAllowed)
{
if (Sitecore.Context.User.IsAdministrator || (isDeveloperAllowed && this.IsDeveloper)) return;
var site = Sitecore.Context.Site;
if (site != null)
{
base.Response.Redirect(string.Format("{0}?returnUrl={1}", site.LoginPage, HttpUtility.UrlEncode(base.Request.Url.PathAndQuery)));
}
}
private bool IsDeveloper
{
get
{
return User.IsInRole(@"sitecore\developer") || User.IsInRole(@"sitecore\sitecore client developing");
}
}
protected void Page_Load(object sender, EventArgs e)
{
var jobs = JobManager.GetJobs();
repContent.DataSource = jobs;
repContent.DataBind();
}
</script>
</form>
</body>
</html>
@lowedown
Copy link
Author

Simple unstyled admin page that will show you all the jobs currently running and ones that have finished shortly ago. The page will refresh every 3 seconds.

@lowedown
Copy link
Author

lowedown commented Jul 7, 2014

Update: Added the "Last Message" column and Percentage if a total is known.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment