Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A Episeserver admin mode plugin that let's you see all log messages for a scheduled job instead of having to use paging
<%@ Page Language="c#" CodeBehind="LogViewer.aspx.cs" AutoEventWireup="False" Inherits="LatestEpi.modules.ScheduledJobLogViewer.LogViewer" Title="Title" %>
<%@ Import Namespace="EPiServer.DataAbstraction" %>
<asp:content contentplaceholderid="MainRegion" runat="server">
<script type="text/javascript">
function SetSelected() {
$('#SelectedScheduledJobGUID').val($('#JobSelector').val());
//console.log($('#JobSelector option:selected').text());
}
</script>
<asp:HiddenField runat="server" id="SelectedScheduledJobGUID" ClientIDMode="static" />
<div class="epi-size20">
<div style="margin-bottom:15px">
<asp:Repeater id="rptJobs" runat="server">
<HeaderTemplate>
<select id="JobSelector">
</HeaderTemplate>
<ItemTemplate>
<option value="<%#Job.ID %>"><%#Job.Name %></option>
</ItemTemplate>
<FooterTemplate>
</select>
</FooterTemplate>
</asp:Repeater>
<div class="epi-buttonContainer epi-marginVertical">
<span class="epi-cmsButton">
<asp:Button OnClientClick="SetSelected()" ClientIDMode="Static" Text="Display log" CssClass="epi-cmsButton-text epi-cmsButton-tools epi-cmsButton-Save" id="savereset" onmouseover="EPi.ToolButton.MouseDownHandler(this)" onmouseout="EPi.ToolButton.ResetMouseDownHandler(this)" runat="server" />
</span>
</div>
</div>
</div>
<asp:Repeater id="rptEntries" runat="server">
<HeaderTemplate>
<table id="logtable" class="epi-default">
<tbody>
<tr>
<th class="epitableheading">Date</th>
<th class="epitableheading">Duration</th>
<th class="epitableheading">Status</th>
<th class="epitableheading">Server</th>
<th class="epitableheading">Message</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td class="epitableheading"><%#LogItem.CompletedUtc %></td>
<td class="epitableheading"><%#LogItem.Duration %></td>
<td class="epitableheading"><%#LogItem.Status %></td>
<td class="epitableheading"><%#LogItem.Server %></td>
<td class="epitableheading"><%#LogItem.Message %></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</FooterTemplate>
</asp:Repeater>
</asp:content>
using System;
using System.Collections.Generic;
using System.Web.Security;
using System.Web.UI.WebControls;
using EPiServer.Personalization;
using EPiServer.PlugIn;
using EPiServer.Security;
using EPiServer.Util.PlugIns;
using System.Web.UI;
using EPiServer.Shell.WebForms;
using EPiServer;
using System.Data;
using EPiServer.ServiceLocation;
using EPiServer.DataAbstraction;
using EPiServer.Scheduler;
namespace LatestEpi.modules.ScheduledJobLogViewer
{
[GuiPlugIn(DisplayName = "ScheduledJob Logviewer", Description = "Display log items without paging", Area = PlugInArea.AdminMenu, Url = "~/modules/ScheduledJobLogViewer/LogViewer.aspx")]
public partial class LogViewer : WebFormsBase
{
protected ScheduledJob Job { get { return Page.GetDataItem() as ScheduledJob; } }
protected ScheduledJobLogItem LogItem { get { return Page.GetDataItem() as ScheduledJobLogItem; } }
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
MasterPageFile = UriSupport.ResolveUrlFromUIBySettings("MasterPages/EPiServerUI.master");
SystemMessageContainer.Heading = "ScheduledJob Logviewer";
SystemMessageContainer.Description = "A plugin to let you view a scheduledjobs all (up to a million) without paging..";
}
protected override void OnLoad(EventArgs e)
{
var jobRepository = ServiceLocator.Current.GetInstance<IScheduledJobRepository>();
var jobs = jobRepository.List();
rptJobs.DataSource = jobs;
rptJobs.DataBind();
if (IsPostBack)
{
var selectedJobGuid = Guid.Parse(SelectedScheduledJobGUID.Value);
var JobLogRepository = base.Locate.Advanced.GetInstance<IScheduledJobLogRepository>();
PagedScheduledJobLogResult result = JobLogRepository.GetAsync(selectedJobGuid, 1, 1000000).GetAwaiter().GetResult();
rptEntries.DataSource = result.PagedResult;
rptEntries.DataBind();
}
}
}
}
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace LatestEpi.modules.ScheduledJobLogViewer {
public partial class LogViewer {
/// <summary>
/// SelectedScheduledJobGUID control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.HiddenField SelectedScheduledJobGUID;
/// <summary>
/// rptJobs control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Repeater rptJobs;
/// <summary>
/// savereset control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button savereset;
/// <summary>
/// rptEntries control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Repeater rptEntries;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment