-
-
Save anonymous/29deb19a382dcb64055c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Xml.Linq; | |
using AzureLogViewer.ViewModel.AzureDiagnostics; | |
namespace AzureLogViewer.CSViews.AzureDiagnostics | |
{ | |
/// <summary> | |
/// View for ShowLog controller. | |
/// </summary> | |
public class ShowPerformanceCountersView : AbstractAzureDiagnosticsView<ShowPerformanceCountersViewModel> | |
{ | |
private Func<PerformanceCounterColumnKey, object> ShowPerformanceCounterValue(IDictionary<PerformanceCounterColumnKey, double?> data) | |
{ | |
return column => new object[] | |
{ | |
new XAttribute("class", "data"), | |
data[column].HasValue ? data[column].Value.ToString("0.0000") : "-", | |
}; | |
} | |
private IEnumerable<object> ShowPerformanceCounterEntry(Tuple<AzureDiagnosticsRowKey, IDictionary<PerformanceCounterColumnKey, double?>> entry) | |
{ | |
return new[] { GetAzureDiagnosticsRowDescription(entry.Item1) } | |
.Concat(Model.PerformanceCounterTable.Columns.Select(ShowPerformanceCounterValue(entry.Item2))); | |
} | |
/// <summary> | |
/// Returns the page main content (excuding headers/footers/etc). | |
/// </summary> | |
protected override XElement[] GetSpecificAzureDiagnosticsBodyContent() | |
{ | |
return new[] | |
{ | |
Model.HasRemainingPerformanceCounterEntries | |
? ShowWarning("Some entries might not be shown. Total {0} entries shown.", Model.PerformanceCounterTable.Count) | |
: null, | |
Model.PerformanceCounterTable.Any() | |
? Html.XCreateTable( | |
attributes: new[] { Html.CreateClassAttribute("list") }, | |
tHeadData: new[] | |
{ | |
Html.XCreateTableHeadRow( | |
tCellsContent: new object[] | |
{ | |
new object[] | |
{ | |
Html.CreateClassAttribute("loghead-information"), | |
"Information" | |
}, | |
} | |
.Concat(Model.PerformanceCounterTable.Columns.Select(column => column.CounterName))), | |
}, | |
tRowsContent: Model.PerformanceCounterTable.OrderByDescending(entry => entry.Item1.Timestamp).Select(ShowPerformanceCounterEntry), | |
tFootData: new[] | |
{ | |
Html.XCreateTableHeadRow( | |
tCellsContent: new object[] | |
{ | |
new object[] | |
{ | |
new XAttribute("colspan", "3"), | |
string.Format("Total {0} entries", Model.PerformanceCounterTable.Count) | |
}, | |
}), | |
}) | |
: ShowWarning("No entries found for your request."), | |
}; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment