Skip to content

Instantly share code, notes, and snippets.

@Adamsimsy
Last active August 15, 2019 08:38
Show Gist options
  • Save Adamsimsy/f2febd70e9d83c36c4517ef2bfd97122 to your computer and use it in GitHub Desktop.
Save Adamsimsy/f2febd70e9d83c36c4517ef2bfd97122 to your computer and use it in GitHub Desktop.
Sitecore admin tools no login
<%@ Page language="c#" %>
<%@ Import Namespace="Sitecore" %>
<%@ Import Namespace="Sitecore.Diagnostics" %>
<%@ Import Namespace="Sitecore.Web" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.HtmlControls" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<!DOCTYPE html>
<script runat="server">
/// <summary>Handles the Click event of the 'Reset' button.</summary>
/// <param name="sender">The sender.</param>
/// <param name="arguments">
/// The <see cref="T:System.EventArgs" /> instance containing the event data.
/// </param>
protected void c_reset_Click(object sender, EventArgs arguments)
{
Statistics.Clear();
this.renderings.Controls.Clear();
}
/// <summary>Handles the Load event of the Page control.</summary>
/// <param name="sender">The source of the event.</param>
/// <param name="arguments">
/// The <see cref="T:System.EventArgs" /> instance containing the event data.
/// </param>
protected void Page_Load(object sender, EventArgs arguments)
{
this.ShowSiteSelector();
this.ShowRenderingStats(this.Request.QueryString["site"]);
}
/// <summary>Gets the site names.</summary>
/// <returns>The site names.</returns>
private string[] GetSiteNames()
{
List<string> stringList = new List<string>();
foreach (Statistics.RenderingData renderingStatistic in Statistics.RenderingStatistics)
{
if (!stringList.Contains(renderingStatistic.SiteName))
stringList.Add(renderingStatistic.SiteName);
}
return stringList.ToArray();
}
/// <summary>Shows the rendering stats.</summary>
/// <param name="siteName">Name of the site.</param>
private void ShowRenderingStats(string siteName)
{
HtmlTable table = new HtmlTable()
{
Border = 1,
CellPadding = 2
};
HtmlUtil.AddRow(table, "Rendering", "Site", "Count", "From cache", "Avg. time (ms)", "Avg. items", "Max. time", "Max. items", "Total time", "Total items", "Last run");
SortedList<string, Statistics.RenderingData> sortedList = new SortedList<string, Statistics.RenderingData>();
foreach (Statistics.RenderingData renderingStatistic in Statistics.RenderingStatistics)
{
if (siteName == null || renderingStatistic.SiteName.Equals(siteName, StringComparison.OrdinalIgnoreCase))
sortedList.Add(renderingStatistic.SiteName + (object) (int) byte.MaxValue + renderingStatistic.TraceName, renderingStatistic);
}
foreach (Statistics.RenderingData renderingData in (IEnumerable<Statistics.RenderingData>) sortedList.Values)
{
HtmlTableRow htmlTableRow = HtmlUtil.AddRow(table, (object) renderingData.TraceName, (object) renderingData.SiteName, (object) renderingData.RenderCount, (object) renderingData.UsedCache, (object) renderingData.AverageTime.TotalMilliseconds, (object) renderingData.AverageItemsAccessed, (object) renderingData.MaxTime.TotalMilliseconds, (object) renderingData.MaxItemsAccessed, (object) renderingData.TotalTime, (object) renderingData.TotalItemsAccessed, (object) DateUtil.ToServerTime(renderingData.LastRendered));
for (int index = 2; index < htmlTableRow.Cells.Count; ++index)
htmlTableRow.Cells[index].Align = "right";
}
this.renderings.Controls.Add((Control) table);
}
/// <summary>Shows the site selector.</summary>
private void ShowSiteSelector()
{
string[] siteNames = this.GetSiteNames();
Array.Sort<string>(siteNames);
HtmlTable table = HtmlUtil.CreateTable(1, siteNames.Length + 1);
table.Border = 0;
table.CellPadding = 5;
table.Rows[0].Cells[0].InnerHtml = "<a href=\"?\">All sites</a>";
int index = 1;
foreach (string str in siteNames)
{
table.Rows[0].Cells[index].InnerHtml = string.Format("<a href=\"?site={0}\">{0}</a>", (object) str);
++index;
}
this.siteSelector.Controls.Add((Control) table);
}
</script>
<html>
<head runat="server">
<title>Statistics</title>
<link rel="shortcut icon" href="/sitecore/images/favicon.ico" />
</head>
<body>
<form id="form1" runat="server">
<h1>Statistics</h1>
<h2>Renderings</h2>
<div style="margin-bottom:10px" runat="server" id="siteSelector">
</div>
<asp:PlaceHolder ID="renderings" runat="server" />
<!-- <asp:Button id="c_reset" runat="server" OnClick="c_reset_Click" Text="Reset" /> -->
</form>
</body>
</html>
<%@ Page language="c#" %>
<%@ Import Namespace="Sitecore" %>
<%@ Import Namespace="Sitecore.Diagnostics" %>
<%@ Import Namespace="Sitecore.Web" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.HtmlControls" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<!DOCTYPE html>
<script runat="server">
/// <summary>Handles the Click event of the 'Reset' button.</summary>
/// <param name="sender">The sender.</param>
/// <param name="arguments">
/// The <see cref="T:System.EventArgs" /> instance containing the event data.
/// </param>
protected void c_reset_Click(object sender, EventArgs arguments)
{
Statistics.Clear();
this.renderings.Controls.Clear();
}
/// <summary>Handles the Load event of the Page control.</summary>
/// <param name="sender">The source of the event.</param>
/// <param name="arguments">
/// The <see cref="T:System.EventArgs" /> instance containing the event data.
/// </param>
protected void Page_Load(object sender, EventArgs arguments)
{
this.ShowSiteSelector();
this.ShowRenderingStats(this.Request.QueryString["site"]);
}
/// <summary>Gets the site names.</summary>
/// <returns>The site names.</returns>
private string[] GetSiteNames()
{
List<string> stringList = new List<string>();
foreach (Statistics.RenderingData renderingStatistic in Statistics.RenderingStatistics)
{
if (!stringList.Contains(renderingStatistic.SiteName))
stringList.Add(renderingStatistic.SiteName);
}
return stringList.ToArray();
}
/// <summary>Shows the rendering stats.</summary>
/// <param name="siteName">Name of the site.</param>
private void ShowRenderingStats(string siteName)
{
HtmlTable table = new HtmlTable()
{
Border = 1,
CellPadding = 2
};
HtmlUtil.AddRow(table, "Rendering", "Site", "Count", "From cache", "Avg. time (ms)", "Avg. items", "Max. time", "Max. items", "Total time", "Total items", "Last run");
SortedList<string, Statistics.RenderingData> sortedList = new SortedList<string, Statistics.RenderingData>();
foreach (Statistics.RenderingData renderingStatistic in Statistics.RenderingStatistics)
{
if (siteName == null || renderingStatistic.SiteName.Equals(siteName, StringComparison.OrdinalIgnoreCase))
sortedList.Add(renderingStatistic.SiteName + (object) (int) byte.MaxValue + renderingStatistic.TraceName, renderingStatistic);
}
foreach (Statistics.RenderingData renderingData in (IEnumerable<Statistics.RenderingData>) sortedList.Values)
{
HtmlTableRow htmlTableRow = HtmlUtil.AddRow(table, (object) renderingData.TraceName, (object) renderingData.SiteName, (object) renderingData.RenderCount, (object) renderingData.UsedCache, (object) renderingData.AverageTime.TotalMilliseconds, (object) renderingData.AverageItemsAccessed, (object) renderingData.MaxTime.TotalMilliseconds, (object) renderingData.MaxItemsAccessed, (object) renderingData.TotalTime, (object) renderingData.TotalItemsAccessed, (object) DateUtil.ToServerTime(renderingData.LastRendered));
for (int index = 2; index < htmlTableRow.Cells.Count; ++index)
htmlTableRow.Cells[index].Align = "right";
}
this.renderings.Controls.Add((Control) table);
}
/// <summary>Shows the site selector.</summary>
private void ShowSiteSelector()
{
string[] siteNames = this.GetSiteNames();
Array.Sort<string>(siteNames);
HtmlTable table = HtmlUtil.CreateTable(1, siteNames.Length + 1);
table.Border = 0;
table.CellPadding = 5;
table.Rows[0].Cells[0].InnerHtml = "<a href=\"?\">All sites</a>";
int index = 1;
foreach (string str in siteNames)
{
table.Rows[0].Cells[index].InnerHtml = string.Format("<a href=\"?site={0}\">{0}</a>", (object) str);
++index;
}
this.siteSelector.Controls.Add((Control) table);
}
</script>
<html>
<head runat="server">
<title>Statistics</title>
<link rel="shortcut icon" href="/sitecore/images/favicon.ico" />
</head>
<body>
<form id="form1" runat="server">
<h1>Statistics</h1>
<h2>Renderings</h2>
<div style="margin-bottom:10px" runat="server" id="siteSelector">
</div>
<asp:PlaceHolder ID="renderings" runat="server" />
<!-- <asp:Button id="c_reset" runat="server" OnClick="c_reset_Click" Text="Reset" /> -->
</form>
</body>
</html>
<%@ Page language="c#" %>
<%@ Import Namespace="Sitecore" %>
<%@ Import Namespace="Sitecore.Diagnostics" %>
<%@ Import Namespace="Sitecore.Web" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.HtmlControls" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<!DOCTYPE html>
<script runat="server">
/// <summary>Handles the Click event of the 'Reset' button.</summary>
/// <param name="sender">The sender.</param>
/// <param name="arguments">
/// The <see cref="T:System.EventArgs" /> instance containing the event data.
/// </param>
protected void c_reset_Click(object sender, EventArgs arguments)
{
Statistics.Clear();
this.renderings.Controls.Clear();
}
/// <summary>Handles the Load event of the Page control.</summary>
/// <param name="sender">The source of the event.</param>
/// <param name="arguments">
/// The <see cref="T:System.EventArgs" /> instance containing the event data.
/// </param>
protected void Page_Load(object sender, EventArgs arguments)
{
this.ShowSiteSelector();
this.ShowRenderingStats(this.Request.QueryString["site"]);
}
/// <summary>Gets the site names.</summary>
/// <returns>The site names.</returns>
private string[] GetSiteNames()
{
List<string> stringList = new List<string>();
foreach (Statistics.RenderingData renderingStatistic in Statistics.RenderingStatistics)
{
if (!stringList.Contains(renderingStatistic.SiteName))
stringList.Add(renderingStatistic.SiteName);
}
return stringList.ToArray();
}
/// <summary>Shows the rendering stats.</summary>
/// <param name="siteName">Name of the site.</param>
private void ShowRenderingStats(string siteName)
{
HtmlTable table = new HtmlTable()
{
Border = 1,
CellPadding = 2
};
HtmlUtil.AddRow(table, "Rendering", "Site", "Count", "From cache", "Avg. time (ms)", "Avg. items", "Max. time", "Max. items", "Total time", "Total items", "Last run");
SortedList<string, Statistics.RenderingData> sortedList = new SortedList<string, Statistics.RenderingData>();
foreach (Statistics.RenderingData renderingStatistic in Statistics.RenderingStatistics)
{
if (siteName == null || renderingStatistic.SiteName.Equals(siteName, StringComparison.OrdinalIgnoreCase))
sortedList.Add(renderingStatistic.SiteName + (object) (int) byte.MaxValue + renderingStatistic.TraceName, renderingStatistic);
}
foreach (Statistics.RenderingData renderingData in (IEnumerable<Statistics.RenderingData>) sortedList.Values)
{
HtmlTableRow htmlTableRow = HtmlUtil.AddRow(table, (object) renderingData.TraceName, (object) renderingData.SiteName, (object) renderingData.RenderCount, (object) renderingData.UsedCache, (object) renderingData.AverageTime.TotalMilliseconds, (object) renderingData.AverageItemsAccessed, (object) renderingData.MaxTime.TotalMilliseconds, (object) renderingData.MaxItemsAccessed, (object) renderingData.TotalTime, (object) renderingData.TotalItemsAccessed, (object) DateUtil.ToServerTime(renderingData.LastRendered));
for (int index = 2; index < htmlTableRow.Cells.Count; ++index)
htmlTableRow.Cells[index].Align = "right";
}
this.renderings.Controls.Add((Control) table);
}
/// <summary>Shows the site selector.</summary>
private void ShowSiteSelector()
{
string[] siteNames = this.GetSiteNames();
Array.Sort<string>(siteNames);
HtmlTable table = HtmlUtil.CreateTable(1, siteNames.Length + 1);
table.Border = 0;
table.CellPadding = 5;
table.Rows[0].Cells[0].InnerHtml = "<a href=\"?\">All sites</a>";
int index = 1;
foreach (string str in siteNames)
{
table.Rows[0].Cells[index].InnerHtml = string.Format("<a href=\"?site={0}\">{0}</a>", (object) str);
++index;
}
this.siteSelector.Controls.Add((Control) table);
}
</script>
<html>
<head runat="server">
<title>Statistics</title>
<link rel="shortcut icon" href="/sitecore/images/favicon.ico" />
</head>
<body>
<form id="form1" runat="server">
<h1>Statistics</h1>
<h2>Renderings</h2>
<div style="margin-bottom:10px" runat="server" id="siteSelector">
</div>
<asp:PlaceHolder ID="renderings" runat="server" />
<!-- <asp:Button id="c_reset" runat="server" OnClick="c_reset_Click" Text="Reset" /> -->
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment