public override TabSection Create() { var section = new TabSection("", GetSectionHeader()); var licenseSection = new LicenseSection(RequestData).Create(); if (licenseSection != null) { section.AddRow().Column("License").Column(licenseSection); } var userListSection = new UserListSection(RequestData).Create(); if (userListSection != null) { section.AddRow().Column("Current Users").Column(userListSection); } var servicesSection = new ServicesSection(RequestData).Create(); if (servicesSection != null) { section.AddRow().Column("Sitecore Services").Column(servicesSection); } var controllersSection = new ControllersSection(RequestData).Create(); if (controllersSection != null) { section.AddRow().Column("Controllers").Column(controllersSection); } return section; }
protected static void DisplayFields(KeyValuePair<string, object>[] fields, TabSection section) { foreach (var field in fields) { section.AddRow().Column(field.Key).Column(field.Value); } }
public static TabSection Create(ISecurityConfiguration configuration) { var section = new TabSection("Key", "Value"); var availableVersion = TryGetVersionFromGithub(); section.AddRow() .Column("Latest version of Fluent Security").Strong() .Column(availableVersion).Strong() .Selected(); var loadedVersion = configuration.GetType().Assembly.FullName; section.AddRow() .Column("Loaded assembly") .Column(loadedVersion); section.AddRow() .Column("Website") .Column(@"<a href='http://fluentsecurity.net/'>http://fluentsecurity.net</a>").Raw(); section.AddRow() .Column("Documentation") .Column(@"<a href='http://fluentsecurity.net/wiki'>http://fluentsecurity.net/wiki</a>").Raw(); section.AddRow() .Column("Twitter") .Column(@"<a href='http://twitter.com/FluentSecurity'>@FluentSecurity</a>").Raw(); return section; }
public override TabSection Create() { var users = (LoggedInUser[])RequestData[DataKey.UserList]; if ((users == null) || (!users.Any())) return null; var section = new TabSection("Username", "Session ID", "Admin", "Created", "Last Request"); foreach (var user in users) { var row = section.AddRow() .Column(user.Name) .Column(user.SessionId) .Column(user.IsAdmin ? "Yes" : "No") .Column(user.Created) .Column(user.LastRequest); if (user.IsInactive()) { row.ApplyRowStyle("warn"); } } return section; }
public void Convert(TabSection section, OAEventLog eventLog) { section.AddRow() .Column(eventLog.DisplayName) .Column(this.GetMetricsValue(eventLog)) .Column(BaseMetricsConverter.GetDurationMetricValue(eventLog)) .Column(eventLog.Timestamp.ToString("HH:mm:ss.fff")); }
protected virtual void AddPluginRow(TabSection tabSection, Aspect.MethodInvocation methodInformation) { tabSection.AddRow() .Column(methodInformation.ClassName) .Column(methodInformation.MethodName) .Column(methodInformation.Parameters) .Column(methodInformation.InvocationTimeMilliseconds) .WarnIf(methodInformation.InvocationTimeMilliseconds >= this.warningThresholdMs); }
private static void AddPoliciesToPolicySection(TabSection policyRows, IEnumerable<Type> securityPolicies) { foreach (var securityPolicy in securityPolicies) { policyRows.AddRow() .Column(securityPolicy.Name.Replace("Policy", String.Empty)) .Column(securityPolicy.FullName) .WarnIf(securityPolicy == typeof(IgnorePolicy)); } }
public void ThrowWhenSectionNameIsNullOrEmpty() { var validSection = new TabSection(); Action<TabSection> validSectionAction = section => {}; Assert.Throws<ArgumentException>(() => Plugin.Section(null, validSection)); Assert.Throws<ArgumentException>(() => Plugin.Section("", validSection)); Assert.Throws<ArgumentException>(() => Plugin.Section(null, validSectionAction)); Assert.Throws<ArgumentException>(() => Plugin.Section("", validSectionAction)); }
public static TabSection Section(this TabSection current, string sectionName, Action<TabSection> section) { if (section == null) { throw new ArgumentNullException("section", "Section must not be null!"); } var tabSection = new TabSection(); section.Invoke(tabSection); return current.Section(sectionName, tabSection); }
private static void AddRowForEvent(ISecurityEvent @event, TabSection section) { var milliseconds = @event.CompletedInMilliseconds.HasValue ? (@event.CompletedInMilliseconds.Value.ToString("0.00") + " ms").Replace(",", ".") : null; section.AddRow() .Column(@event.CorrelationId.ToString().Substring(0,15)) .Column(@event.Message) .Column(milliseconds) .WarnIf(@event.CompletedInMilliseconds > 10); }
public static TabSection Section(this TabSection current, string sectionName, Action <TabSection> section) { if (section == null) { throw new ArgumentNullException("section", "Section must not be null!"); } var tabSection = new TabSection(); section.Invoke(tabSection); return(current.Section(sectionName, tabSection)); }
public void AddNewSection() { var innerSection = new TabSection(); Plugin.Section("SectionName1", innerSection); Assert.Equal(1, Plugin.Rows.Count()); Assert.Equal(2, Plugin.Rows.Single().Columns.Count()); Assert.Equal("*SectionName1*", Plugin.Rows.Single().Columns.First().Data); var buildResult = innerSection.Build() as IEnumerable<object>; Assert.Equal(0, buildResult.Count()); }
protected TabSection CreateSection(DataKey dataKey) { var fieldList = (FieldList)RequestData[dataKey]; if (fieldList == null) return null; var section = new TabSection("Property", "Value"); DisplayFields(fieldList.Fields, section); return section; }
private static void ParseQueryString(FieldList fieldList, TabSection section) { var queryStringFields = (FieldList) fieldList.Fields.SingleOrDefault(x => x.Key == QueryStringKey).Value; if (queryStringFields != null) { var queryStringSection = new TabSection("key", "value"); DisplayFields(queryStringFields.Fields, queryStringSection); section.Section(QueryStringKey, queryStringSection); } }
public override TabSection Create() { var fieldList = (FieldList) RequestData[DataKey.Request]; if (fieldList == null) return null; var section = new TabSection("Request Property", "Value"); DisplayFields(fieldList.Fields.Where(x => x.Key != QueryStringKey).ToArray(), section); ParseQueryString(fieldList, section); return section; }
public override TabSection Create() { var lastPages = (PageHolder[]) RequestData[DataKey.LastPages]; if ((lastPages == null) || (lastPages.Length == 0)) return null; var section = new TabSection("#","Id", "Timestamp", "Url"); foreach (var pageHolder in lastPages) { section.AddRow().Column(pageHolder.Num).Column(pageHolder.Id).Column(pageHolder.Date).Column(pageHolder.Url); } return section; }
public override TabSection Create() { var fields = (FieldList)RequestData[DataKey.License]; if ((fields == null) || (fields.Fields.Length == 0)) return null; var section = new TabSection("Property", "Value"); foreach (var field in fields.Fields) { section.AddRow().Column(field.Key).Column(field.Value); } return section; }
public override TabSection Create() { var goals = (Goal[]) RequestData[DataKey.Goals]; if ((goals == null) || (goals.Length == 0)) return null; var section = new TabSection("Timestamp", "Name"); foreach (var goal in goals) { section.AddRow().Column(goal.Timestamp).Column(goal.Name); } return section; }
public override object GetData(ITabContext context) { TabSection episerverTab = Plugin.Create("Section", "Content"); PageData currentPageData = EPiServerDataFactory.GetPageData(context.GetHttpContext().Request.RawUrl); TabSection pageData = new TabSection("Property", "Value"); pageData.AddRow().Column("Name").Column(currentPageData.Name); pageData.AddRow().Column("Page Name").Column(currentPageData.PageName); pageData.AddRow().Column("Page Type").Column(currentPageData.PageTypeName); pageData.AddRow() .Column("Start Publish") .Column(currentPageData.StartPublish.ToString(CultureInfo.InvariantCulture)); pageData.AddRow() .Column("Stop Publish") .Column(currentPageData.StopPublish.ToString(CultureInfo.InvariantCulture)); episerverTab.Section("Page Information", pageData); // Possible child page types? // version PageReference currentPageRef = EPiServerDataFactory.GetPageReference( context.GetHttpContext().Request.RawUrl); DynamicPropertyCollection dynprops = DynamicProperty.ListForPage(currentPageRef); TabSection dynpropData = new TabSection(); foreach (DynamicProperty dynprop in dynprops) { PropertyData prop = dynprop.PropertyValue; dynpropData.AddRow().Column(prop.Name).Column(prop.IsNull ? "null" : prop.Value.ToString()); } episerverTab.Section("Dynamic Properties", dynpropData); TabSection langData = new TabSection("Property", "Value"); langData.AddRow().Column("Page Language").Column(currentPageData.Language); langData.AddRow().Column("Is Master Language").Column(currentPageData.IsMasterLanguageBranch ? "Yes" : "No"); langData.AddRow().Column("Page Languages").Column(currentPageData.PageLanguages); episerverTab.Section("Languages", langData); return episerverTab; }
public override TabSection Create() { var section = new TabSection("Item", "Value"); var itemSection = CreateSection(DataKey.Item); if (itemSection != null) { section.AddRow().Column("Properties").Column(itemSection); } var itemTemplate = new ItemTemplateSection(RequestData).Create(); if (itemTemplate != null) section.AddRow().Column("Template").Column(itemTemplate); var itemVisualization = new ItemVisualizationSection(RequestData).Create(); if (itemVisualization != null) section.AddRow().Column("Visualization").Column(itemVisualization); return section; }
public static TabSection Section(this TabSection current, string sectionName, TabSection section) { if (string.IsNullOrEmpty(sectionName)) { throw new ArgumentException("Section name must not be null or empty!", "sectionName"); } if (section == null) { throw new ArgumentNullException("section", "Section must not be null!"); } current.AddRow() .Column(sectionName).Strong() .Column(section); return(current); }
public static TabSection Section(this TabSection current, string sectionName, TabSection section) { if (string.IsNullOrEmpty(sectionName)) { throw new ArgumentException("Section name must not be null or empty!", "sectionName"); } if (section == null) { throw new ArgumentNullException("section", "Section must not be null!"); } current.AddRow() .Column(sectionName).Strong() .Column(section); return current; }
public override TabSection Create() { var isNewVisitor = RequestData[DataKey.IsNewVisitor]; var engagementValue = RequestData[DataKey.EngagementValue]; var trafficType = RequestData[DataKey.TrafficType]; if ((isNewVisitor == null) || (engagementValue == null) || (trafficType == null)) return null; var section = new TabSection("Overview", "Value"); section.AddRow().Column("New vs. Returning").Column(isNewVisitor); section.AddRow().Column("Engagement Value").Column(engagementValue); section.AddRow().Column("Traffic Type").Column(trafficType); var campaign = RequestData[DataKey.Campaign]; if (campaign != null) section.AddRow().Column("Campaign").Column(campaign); return section; }
public override TabSection Create() { var profiles = (Profile[]) RequestData[DataKey.Profiles]; if ((profiles == null) || (profiles.Length == 0)) return null; var section = new TabSection(); section.AddRow().Column("Profile name").Column("Pattern Matched").Column("Values"); foreach (var profile in profiles) { section.AddRow() .Column(profile.Name) .Column(profile.PatternCard) .Column(profile.Values); } return section; }
public static TabSection Create(ISecurityConfiguration configuration) { var section = new TabSection("Controller", "Action", "Policies"); var sortedPolicyContainers = configuration.PolicyContainers.OrderBy(x => x.ActionName).OrderBy(x => x.ControllerName); foreach (var policyContainer in sortedPolicyContainers) { var policySectionData = new TabSection("Policy", "Type"); var securityPolicies = policyContainer.GetPolicies().OrderBy(x => x.GetType().FullName).Select(x => x.GetPolicyType()); AddPoliciesToPolicySection(policySectionData, securityPolicies); section.AddRow() .Column(policyContainer.ControllerName) .Column(policyContainer.ActionName) .Column(policySectionData); } return section; }
public override TabSection Create() { var controllers = (Controller[])RequestData[DataKey.Controllers]; if ((controllers == null) || (!controllers.Any())) return null; var section = new TabSection("Controller", "Type", "Authorise", "CSRF Protection", "Definition"); foreach (var controller in controllers) { section.AddRow() .Column(controller.Name) .Column(controller.ControllerType.ToString()) .Column(controller.Authorise ? "Yes" : "No") .Column(controller.CsrfProtection.ToString()) .Column(controller.Definition); } return section; }
public override TabSection Create() { var services = (SitecoreService[])RequestData[DataKey.Services]; if ((services == null) || (!services.Any())) return null; var section = new TabSection("Controller", "Url", "ES", "Authorise", "CSRF Protection", "Definition", "Metadata"); foreach (var service in services) { section.AddRow() .Column(service.Name) .Column(service.Url) .Column(service.IsEntityService ? "Yes" : "No") .Column(service.Authorise ? "Yes" : "No") .Column(service.CsrfProtection.ToString()) .Column(service.Definition) .Column(service.Metadata) .WarnIf(service.CorsEnabled); } return section; }
public override TabSection Create() { var section = new TabSection("Context", "Value"); var siteSection = new SiteSection(RequestData).Create(); if (siteSection != null) section.AddRow().Column("Site").Column(siteSection); var databaseSection = new DatabaseSection(RequestData).Create(); if (databaseSection != null) section.AddRow().Column("Database").Column(databaseSection); var deviceSection = new DeviceSection(RequestData).Create(); if (deviceSection != null) section.AddRow().Column("Device").Column(deviceSection); var domainSection = new DomainSection(RequestData).Create(); if (domainSection != null) section.AddRow().Column("Domain").Column(domainSection); var languageSection = new LanguageSection(RequestData).Create(); if (languageSection != null) section.AddRow().Column("Language").Column(languageSection); var cultureSection = new CultureSection(RequestData).Create(); if (cultureSection != null) section.AddRow().Column("Culture").Column(cultureSection); var userSection = new UserSection(RequestData).Create(); if (userSection != null) section.AddRow().Column("User").Column(userSection); var requestSection = new RequestSection(RequestData).Create(); if (requestSection != null) section.AddRow().Column("Request").Column(requestSection); var diagnosticsSection = new DiagnosticsSection(RequestData).Create(); if (diagnosticsSection != null) section.AddRow().Column("Diagnostics").Column(diagnosticsSection); var pageModeSection = new PageModeSection(RequestData).Create(); if (pageModeSection != null) section.AddRow().Column("PageMode").Column(pageModeSection); return section; }
/// <summary> /// Creates an TabSection from an event log. /// </summary> /// <param name="log">An EventLog.</param> /// <returns></returns> private static TabSection CreateEventLogSection(EventLog log) { TabSection section; section = new TabSection("Level", "Date", "Source", "Event ID", "Category", "Message"); int lastEntryIndex = log.Entries.Count > MaxEntries ? log.Entries.Count - MaxEntries : 0; for (int i = log.Entries.Count - 1; i >= lastEntryIndex; i--) { var entry = log.Entries[i]; var row = section.AddRow() .Column(entry.EntryType.ToString()) .Column(entry.TimeGenerated.ToString("G")) .Column(entry.Source) .Column(entry.InstanceId) .Column(entry.Category != "(0)" ? entry.Category : string.Empty) .Column(entry.Message); SetIndicator(row, entry.EntryType); } return section; }
public override object GetData(ITabContext context) { var connectionLifetimes = context.GetMessages<ConnectionLifetimeTimelineMessage>().ToArray(); var transactionLifetimes = context.GetMessages<TransactionLifetimeTimelineMessage>().ToArray(); var transactionEvents = context.GetMessages<TransactionEventTimelineMessage>().ToArray(); var commands = context.GetMessages<CommandTimelineMessage>().ToArray(); var statisticsSection = new TabSection("Database", "Queries", "Total Transaction Duration"); var eventSection = new TabSection("Database", "Events", "Queries", "IsCommited", "Total Duration"); // Statistics foreach (var transactionLifetime in transactionLifetimes.OrderBy(x => x.Offset).ToArray()) { statisticsSection.AddRow() .Column(connectionLifetimes.First(x => x.ConnectionId == transactionLifetime.ConnectionId).Database) .Column(commands.Count(x => x.TransactionId.HasValue && x.TransactionId.Value == transactionLifetime.TransactionId)) .Column(transactionLifetime.Duration); } // Events foreach (var transactionLifetime in transactionLifetimes.OrderBy(x => x.Offset).ToArray()) { var queries = commands .Where(x => x.TransactionId.HasValue && x.TransactionId.Value == transactionLifetime.TransactionId) .ToArray(); var events = transactionEvents .Where(x => x.TransactionId == transactionLifetime.TransactionId) .Select(x => new { EventType = "Transaction", EventName = x.TransactionEvent.ToString(), Duration = x.Duration, Offset = x.Offset }) .Concat(queries .Select(x => new { EventType = "Command", EventName = x.CommandText, Duration = x.Duration, Offset = x.Offset }) ) .OrderBy(x => x.Offset) .ToArray(); var eventDetailSection = new TabSection("EventType", "EventName", "Duration", "Offset"); var duplicatedKeys = new HashSet<string>(); foreach (var @event in events) { var row = eventDetailSection.AddRow() .Column(@event.EventType) .Column(@event.EventName) .Column(@event.Duration) .Column(@event.Offset); if (@event.EventType == "Command") { row.WarnIf(!duplicatedKeys.Add(@event.EventName)); } } eventSection.AddRow() .Column(transactionLifetime.Database) .Column(eventDetailSection) .Column(commands.Length) .Column(transactionLifetime.IsCommited) .Column(transactionLifetime.Duration); } var root = new TabObject(); root.AddRow().Key("Transaction Statistics").Value(statisticsSection); root.AddRow().Key("Transaction Events").Value(eventSection); return root.Build(); }
public override object GetData(ITabContext context) { var commands = context.GetMessages<CommandTimelineMessage>().ToArray(); if (!commands.Any()) { return null; } var ordinal = 1; var duplicationKeys = new HashSet<string>(); var duplicationCount = 0; var queries = new TabSection("Ordinal", "Database", "Command", "Parameters", "CommandType", "With Transaction", "Records", "IsError", "Duration", "Offset"); foreach (var command in commands) { var parameters = new TabSection("Name", "Value", "DbType", "Direction"); foreach (var parameter in command.Parameters) { parameters.AddRow() .Column(parameter.ParameterName) .Column(parameter.Value) .Column(parameter.DbType.ToString()) .Column(parameter.Direction.ToString()); } var row = queries.AddRow() .Column(ordinal) .Column(command.Database) .Column(command.CommandText) .Column(command.Parameters.Any() ? parameters : null) .Column(command.CommandType.ToString()) .Column(command.WithTransaction) .Column(command.Records ?? 0) .Column(command.IsError) .Column(command.Duration) .Column(command.Offset); var isDuplicated = !duplicationKeys.Add(command.CommandText); if (isDuplicated) { row.WarnIf(true); duplicationCount++; } ordinal++; } var sqlStatistics = new TabSection("Queries", "Duplication", "Total Query Duration"); sqlStatistics.AddRow() .Column(commands.Length) .Column(duplicationCount) .Column(commands.Select(x => x.Duration).Aggregate((x, y) => x.Add(y))); var root = new TabObject(); root.AddRow().Key("SQL Statistics").Value(sqlStatistics); root.AddRow().Key("Queries").Value(queries); return root.Build(); }
public PluginShould() { Plugin = Glimpse.Core.Tab.Assist.Plugin.Create(); }