mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-24 10:11:35 +08:00
committed by
Sébastien Ros
parent
ec22a1150d
commit
575fb7413f
@@ -0,0 +1,19 @@
|
||||
using System.Web;
|
||||
using NHibernate.Connection;
|
||||
using NHibernate.Driver;
|
||||
|
||||
namespace Orchard.Glimpse.ADO {
|
||||
public class GlimpseConnectionProvider : DriverConnectionProvider, IConnectionProvider {
|
||||
public new IDriver Driver {
|
||||
get {
|
||||
var originalDriver = base.Driver;
|
||||
|
||||
if (HttpContext.Current == null || originalDriver is GlimpseDriver) {
|
||||
return originalDriver;
|
||||
}
|
||||
|
||||
return new GlimpseDriver(originalDriver);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
59
src/Orchard.Web/Modules/Orchard.Glimpse/ADO/GlimpseDriver.cs
Normal file
59
src/Orchard.Web/Modules/Orchard.Glimpse/ADO/GlimpseDriver.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using Glimpse.Ado.AlternateType;
|
||||
using NHibernate.Driver;
|
||||
using NHibernate.Engine;
|
||||
using NHibernate.SqlCommand;
|
||||
using NHibernate.SqlTypes;
|
||||
|
||||
namespace Orchard.Glimpse.ADO {
|
||||
public class GlimpseDriver : IDriver {
|
||||
private readonly IDriver _decoratedService;
|
||||
|
||||
public GlimpseDriver(IDriver decoratedService) {
|
||||
_decoratedService = decoratedService;
|
||||
}
|
||||
|
||||
public void Configure(IDictionary<string, string> settings) {
|
||||
_decoratedService.Configure(settings);
|
||||
}
|
||||
|
||||
public IDbConnection CreateConnection() {
|
||||
return new GlimpseDbConnection(_decoratedService.CreateConnection() as DbConnection);
|
||||
}
|
||||
|
||||
public IDbCommand GenerateCommand(CommandType type, SqlString sqlString, SqlType[] parameterTypes) {
|
||||
return new GlimpseDbCommand(_decoratedService.GenerateCommand(type, sqlString, parameterTypes) as DbCommand);
|
||||
}
|
||||
|
||||
public void PrepareCommand(IDbCommand command) {
|
||||
_decoratedService.PrepareCommand(command);
|
||||
}
|
||||
|
||||
public IDbDataParameter GenerateParameter(IDbCommand command, string name, SqlType sqlType) {
|
||||
return _decoratedService.GenerateParameter(command, name, sqlType);
|
||||
}
|
||||
|
||||
public void RemoveUnusedCommandParameters(IDbCommand cmd, SqlString sqlString) {
|
||||
_decoratedService.RemoveUnusedCommandParameters(cmd, sqlString);
|
||||
}
|
||||
|
||||
public void ExpandQueryParameters(IDbCommand cmd, SqlString sqlString) {
|
||||
_decoratedService.ExpandQueryParameters(cmd, sqlString);
|
||||
}
|
||||
|
||||
public IResultSetsCommand GetResultSetsCommand(ISessionImplementor session) {
|
||||
return _decoratedService.GetResultSetsCommand(session);
|
||||
}
|
||||
|
||||
public void AdjustCommand(IDbCommand command) {
|
||||
_decoratedService.AdjustCommand(command);
|
||||
}
|
||||
|
||||
public bool SupportsMultipleOpenReaders => _decoratedService.SupportsMultipleOpenReaders;
|
||||
|
||||
public bool SupportsMultipleQueries => _decoratedService.SupportsMultipleQueries;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using FluentNHibernate.Automapping;
|
||||
using FluentNHibernate.Cfg;
|
||||
using NHibernate.Cfg;
|
||||
using Orchard.Data;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Utility;
|
||||
|
||||
namespace Orchard.Glimpse.ADO {
|
||||
[OrchardFeature(FeatureNames.SQL)]
|
||||
public class GlimpseSessionConfigurationEvents : ISessionConfigurationEvents {
|
||||
public void Created(FluentConfiguration cfg, AutoPersistenceModel defaultModel) {}
|
||||
|
||||
public void Prepared(FluentConfiguration cfg) {}
|
||||
|
||||
public void Building(Configuration cfg) {}
|
||||
|
||||
public void Finished(Configuration cfg) {
|
||||
cfg.SetProperty("connection.provider", "Orchard.Glimpse.ADO.GlimpseConnectionProvider, Orchard.Glimpse");
|
||||
}
|
||||
|
||||
public void ComputingHash(Hash hash) {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Glimpse.Services;
|
||||
using Orchard.Glimpse.Tabs.Authorizer;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Security;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.Glimpse.AlternateImplementation {
|
||||
[OrchardFeature(FeatureNames.Authorizer)]
|
||||
public class GlimpseAuthorizerDecorator : IDecorator<IAuthorizer>, IAuthorizer {
|
||||
private readonly IAuthorizer _decoratedService;
|
||||
private readonly IGlimpseService _glimpseService;
|
||||
|
||||
public GlimpseAuthorizerDecorator(IAuthorizer decoratedService, IGlimpseService glimpseService) {
|
||||
_decoratedService = decoratedService;
|
||||
_glimpseService = glimpseService;
|
||||
}
|
||||
|
||||
public bool Authorize(Permission permission) {
|
||||
return _glimpseService.PublishTimedAction(() => _decoratedService.Authorize(permission),
|
||||
(r, t) => new AuthorizerMessage {
|
||||
Permission = permission,
|
||||
Result = r,
|
||||
Duration = t.Duration
|
||||
}, TimelineCategories.Authorizer, "Authorize", permission.Name).ActionResult;
|
||||
}
|
||||
|
||||
public bool Authorize(Permission permission, LocalizedString message) {
|
||||
return _glimpseService.PublishTimedAction(() => _decoratedService.Authorize(permission, message),
|
||||
(r, t) => new AuthorizerMessage {
|
||||
Permission = permission,
|
||||
Message = message.Text,
|
||||
Result = r,
|
||||
Duration = t.Duration
|
||||
}, TimelineCategories.Authorizer, "Authorize", permission.Name).ActionResult;
|
||||
}
|
||||
|
||||
public bool Authorize(Permission permission, IContent content) {
|
||||
return _glimpseService.PublishTimedAction(() => _decoratedService.Authorize(permission, content),
|
||||
(r, t) => new AuthorizerMessage {
|
||||
Permission = permission,
|
||||
Content = content,
|
||||
Result = r,
|
||||
Duration = t.Duration
|
||||
}, TimelineCategories.Authorizer, "Authorize", permission.Name).ActionResult;
|
||||
}
|
||||
|
||||
public bool Authorize(Permission permission, IContent content, LocalizedString message) {
|
||||
return _glimpseService.PublishTimedAction(() => _decoratedService.Authorize(permission, content, message),
|
||||
(r, t) => new AuthorizerMessage {
|
||||
Permission = permission,
|
||||
Content = content,
|
||||
Message = message.Text,
|
||||
Result = r,
|
||||
Duration = t.Duration
|
||||
}, TimelineCategories.Authorizer, "Authorize", permission.Name).ActionResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using Orchard.Caching.Services;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Glimpse.Services;
|
||||
using Orchard.Glimpse.Tabs.Cache;
|
||||
|
||||
namespace Orchard.Glimpse.AlternateImplementation {
|
||||
[OrchardFeature(FeatureNames.Cache)]
|
||||
public class GlimpseCacheServiceDecorator : IDecorator<ICacheService>, ICacheService {
|
||||
private readonly ICacheService _decoratedService;
|
||||
private readonly IGlimpseService _glimpseService;
|
||||
|
||||
public GlimpseCacheServiceDecorator(ICacheService decoratedService, IGlimpseService glimpseService) {
|
||||
_decoratedService = decoratedService;
|
||||
_glimpseService = glimpseService;
|
||||
}
|
||||
|
||||
public object GetObject<T>(string key) {
|
||||
return _glimpseService.PublishTimedAction(() => _decoratedService.GetObject<T>(key),
|
||||
(r, t) => new CacheMessage {
|
||||
Action = "Get",
|
||||
Duration = t.Duration,
|
||||
Key = key,
|
||||
Result = r == null ? "Miss" : "Hit",
|
||||
Value = r
|
||||
}, TimelineCategories.Cache, r => $"Get ({(r == null ? "Miss" : "Hit")})", r => key).ActionResult;
|
||||
}
|
||||
|
||||
public void Put<T>(string key, T value) {
|
||||
_glimpseService.PublishTimedAction(() => _decoratedService.Put(key, value),
|
||||
t => new CacheMessage {
|
||||
Action = "Put",
|
||||
Duration = t.Duration,
|
||||
Key = key,
|
||||
Value = value
|
||||
}, TimelineCategories.Cache, "Put", key);
|
||||
}
|
||||
|
||||
public void Put<T>(string key, T value, TimeSpan validFor) {
|
||||
_glimpseService.PublishTimedAction(() => _decoratedService.Put(key, value, validFor),
|
||||
t => new CacheMessage {
|
||||
Action = "Put",
|
||||
Duration = t.Duration,
|
||||
Key = key,
|
||||
Value = value,
|
||||
ValidFor = validFor
|
||||
}, TimelineCategories.Cache, "Put", key);
|
||||
}
|
||||
|
||||
public void Remove(string key) {
|
||||
_glimpseService.PublishTimedAction(() => _decoratedService.Remove(key),
|
||||
t => new CacheMessage {
|
||||
Action = "Remove",
|
||||
Duration = t.Duration,
|
||||
Key = key
|
||||
}, TimelineCategories.Cache, "Remove", key);
|
||||
}
|
||||
|
||||
public void Clear() {
|
||||
_glimpseService.PublishTimedAction(() => _decoratedService.Clear(),
|
||||
t => new CacheMessage {
|
||||
Action = "Clear",
|
||||
Duration = t.Duration
|
||||
}, TimelineCategories.Cache, "Clear");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Glimpse.Extensions;
|
||||
using Orchard.Glimpse.Services;
|
||||
using Orchard.Glimpse.Tabs.ContentManager;
|
||||
using Orchard.Indexing;
|
||||
|
||||
namespace Orchard.Glimpse.AlternateImplementation {
|
||||
[OrchardFeature(FeatureNames.ContentManager)]
|
||||
public class GlimpseContentManagerDecorator : IDecorator<IContentManager>, IContentManager {
|
||||
private readonly IContentManager _decoratedService;
|
||||
private readonly IGlimpseService _glimpseService;
|
||||
|
||||
public GlimpseContentManagerDecorator(IContentManager decoratedService, IGlimpseService glimpseService) {
|
||||
_decoratedService = decoratedService;
|
||||
_glimpseService = glimpseService;
|
||||
}
|
||||
|
||||
public IEnumerable<ContentTypeDefinition> GetContentTypeDefinitions() {
|
||||
return _decoratedService.GetContentTypeDefinitions();
|
||||
}
|
||||
|
||||
public ContentItem New(string contentType) {
|
||||
return _decoratedService.New(contentType);
|
||||
}
|
||||
|
||||
public void Create(ContentItem contentItem) {
|
||||
_decoratedService.Create(contentItem);
|
||||
}
|
||||
|
||||
public void Create(ContentItem contentItem, VersionOptions options) {
|
||||
_decoratedService.Create(contentItem, options);
|
||||
}
|
||||
|
||||
public ContentItem Clone(ContentItem contentItem) {
|
||||
return _decoratedService.Clone(contentItem);
|
||||
}
|
||||
|
||||
public ContentItem Restore(ContentItem contentItem, VersionOptions options) {
|
||||
return _decoratedService.Restore(contentItem, options);
|
||||
}
|
||||
|
||||
public ContentItem Get(int id) {
|
||||
return _glimpseService.PublishTimedAction(() => _decoratedService.Get(id), (r, t) => new ContentManagerGetMessage {
|
||||
ContentId = id,
|
||||
ContentType = GetContentType(id, r),
|
||||
Name = r.GetContentName(),
|
||||
Duration = t.Duration
|
||||
}, TimelineCategories.ContentManager, r => "Get: " + GetContentType(id, r), r => r.GetContentName()).ActionResult;
|
||||
}
|
||||
|
||||
public ContentItem Get(int id, VersionOptions options) {
|
||||
return _glimpseService.PublishTimedAction(() => _decoratedService.Get(id, options), (r, t) => new ContentManagerGetMessage {
|
||||
ContentId = id,
|
||||
ContentType = GetContentType(id, r),
|
||||
Name = r.GetContentName(),
|
||||
Duration = t.Duration,
|
||||
VersionOptions = options
|
||||
}, TimelineCategories.ContentManager, r => "Get: " + GetContentType(id, r), r => r.GetContentName()).ActionResult;
|
||||
}
|
||||
|
||||
public ContentItem Get(int id, VersionOptions options, QueryHints hints) {
|
||||
return _glimpseService.PublishTimedAction(() => _decoratedService.Get(id, options, hints), (r, t) => new ContentManagerGetMessage {
|
||||
ContentId = id,
|
||||
ContentType = GetContentType(id, r),
|
||||
Name = r.GetContentName(),
|
||||
Duration = t.Duration,
|
||||
VersionOptions = options
|
||||
}, TimelineCategories.ContentManager, r => "Get: " + GetContentType(id, r), r => r.GetContentName()).ActionResult;
|
||||
}
|
||||
|
||||
public IEnumerable<ContentItem> GetAllVersions(int id) {
|
||||
return _decoratedService.GetAllVersions(id);
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetMany<T>(IEnumerable<int> ids, VersionOptions options, QueryHints hints) where T : class, IContent {
|
||||
return _decoratedService.GetMany<T>(ids, options, hints);
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetManyByVersionId<T>(IEnumerable<int> versionRecordIds, QueryHints hints) where T : class, IContent {
|
||||
return _decoratedService.GetManyByVersionId<T>(versionRecordIds, hints);
|
||||
}
|
||||
|
||||
public IEnumerable<ContentItem> GetManyByVersionId(IEnumerable<int> versionRecordIds, QueryHints hints) {
|
||||
return _decoratedService.GetManyByVersionId(versionRecordIds, hints);
|
||||
}
|
||||
|
||||
public void Publish(ContentItem contentItem) {
|
||||
_decoratedService.Publish(contentItem);
|
||||
}
|
||||
|
||||
public void Unpublish(ContentItem contentItem) {
|
||||
_decoratedService.Unpublish(contentItem);
|
||||
}
|
||||
|
||||
public void Remove(ContentItem contentItem) {
|
||||
_decoratedService.Remove(contentItem);
|
||||
}
|
||||
|
||||
public void DiscardDraft(ContentItem contentItem) {
|
||||
_decoratedService.DiscardDraft(contentItem);
|
||||
}
|
||||
|
||||
public void Destroy(ContentItem contentItem) {
|
||||
_decoratedService.Destroy(contentItem);
|
||||
}
|
||||
|
||||
public void Index(ContentItem contentItem, IDocumentIndex documentIndex) {
|
||||
_decoratedService.Index(contentItem, documentIndex);
|
||||
}
|
||||
|
||||
public XElement Export(ContentItem contentItem) {
|
||||
return _decoratedService.Export(contentItem);
|
||||
}
|
||||
|
||||
public void Import(XElement element, ImportContentSession importContentSession) {
|
||||
_decoratedService.Import(element, importContentSession);
|
||||
}
|
||||
|
||||
public void Clear() {
|
||||
_decoratedService.Clear();
|
||||
}
|
||||
|
||||
public IContentQuery<ContentItem> Query() {
|
||||
return _decoratedService.Query();
|
||||
}
|
||||
|
||||
public IHqlQuery HqlQuery() {
|
||||
return _decoratedService.HqlQuery();
|
||||
}
|
||||
|
||||
public ContentItemMetadata GetItemMetadata(IContent contentItem) {
|
||||
return _decoratedService.GetItemMetadata(contentItem);
|
||||
}
|
||||
|
||||
public IEnumerable<GroupInfo> GetEditorGroupInfos(IContent contentItem) {
|
||||
return _decoratedService.GetEditorGroupInfos(contentItem);
|
||||
}
|
||||
|
||||
public IEnumerable<GroupInfo> GetDisplayGroupInfos(IContent contentItem) {
|
||||
return _decoratedService.GetDisplayGroupInfos(contentItem);
|
||||
}
|
||||
|
||||
public GroupInfo GetEditorGroupInfo(IContent contentItem, string groupInfoId) {
|
||||
return _decoratedService.GetEditorGroupInfo(contentItem, groupInfoId);
|
||||
}
|
||||
|
||||
public GroupInfo GetDisplayGroupInfo(IContent contentItem, string groupInfoId) {
|
||||
return _decoratedService.GetDisplayGroupInfo(contentItem, groupInfoId);
|
||||
}
|
||||
|
||||
public ContentItem ResolveIdentity(ContentIdentity contentIdentity) {
|
||||
return _decoratedService.ResolveIdentity(contentIdentity);
|
||||
}
|
||||
|
||||
public dynamic BuildDisplay(IContent content, string displayType = "", string groupId = "") {
|
||||
return _decoratedService.BuildDisplay(content, displayType, groupId);
|
||||
}
|
||||
|
||||
public dynamic BuildEditor(IContent content, string groupId = "") {
|
||||
return _decoratedService.BuildEditor(content, groupId);
|
||||
}
|
||||
|
||||
public dynamic UpdateEditor(IContent content, IUpdateModel updater, string groupId = "") {
|
||||
return _decoratedService.UpdateEditor(content, updater, groupId);
|
||||
}
|
||||
|
||||
private string GetContentType(int id, ContentItem item, VersionOptions options = null) {
|
||||
if (item != null) {
|
||||
return item.ContentType;
|
||||
}
|
||||
|
||||
if (options == null) {
|
||||
return "Unknown content type.";
|
||||
}
|
||||
|
||||
return options.VersionRecordId == 0 ? $"Content item: {id} is not published." : "Unknown content type.";
|
||||
}
|
||||
|
||||
public void CompleteImport(XElement element, ImportContentSession importContentSession) {
|
||||
_decoratedService.CompleteImport(element, importContentSession);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Glimpse.Models;
|
||||
using Orchard.Glimpse.Services;
|
||||
|
||||
namespace Orchard.Glimpse.AlternateImplementation {
|
||||
[OrchardFeature(FeatureNames.Parts)]
|
||||
public class GlimpseContentPartDriver : IDecorator<IContentPartDriver>, IContentPartDriver {
|
||||
private readonly IContentPartDriver _decoratedService;
|
||||
private readonly IGlimpseService _glimpseService;
|
||||
|
||||
public GlimpseContentPartDriver(IContentPartDriver decoratedService, IGlimpseService glimpseService) {
|
||||
_decoratedService = decoratedService;
|
||||
_glimpseService = glimpseService;
|
||||
}
|
||||
|
||||
public DriverResult BuildDisplay(BuildDisplayContext context) {
|
||||
var driverResult = _decoratedService.BuildDisplay(context);
|
||||
|
||||
return driverResult == null ? null : new GlimpseDriverResult(driverResult, _glimpseService);
|
||||
}
|
||||
|
||||
public DriverResult BuildEditor(BuildEditorContext context) {
|
||||
return _decoratedService.BuildEditor(context);
|
||||
}
|
||||
|
||||
public void Exported(ExportContentContext context) {
|
||||
_decoratedService.Exported(context);
|
||||
}
|
||||
|
||||
public void Cloning(CloneContentContext context) {
|
||||
_decoratedService.Cloning(context);
|
||||
}
|
||||
|
||||
public void Cloned(CloneContentContext context) {
|
||||
_decoratedService.Cloned(context);
|
||||
}
|
||||
|
||||
public void Exporting(ExportContentContext context) {
|
||||
_decoratedService.Exporting(context);
|
||||
}
|
||||
|
||||
public void GetContentItemMetadata(GetContentItemMetadataContext context) {
|
||||
_decoratedService.GetContentItemMetadata(context);
|
||||
}
|
||||
|
||||
public IEnumerable<ContentPartInfo> GetPartInfo() {
|
||||
return _decoratedService.GetPartInfo();
|
||||
}
|
||||
|
||||
public void ImportCompleted(ImportContentContext context) {
|
||||
_decoratedService.ImportCompleted(context);
|
||||
}
|
||||
|
||||
public void Imported(ImportContentContext context) {
|
||||
_decoratedService.Imported(context);
|
||||
}
|
||||
|
||||
public void Importing(ImportContentContext context) {
|
||||
_decoratedService.Importing(context);
|
||||
}
|
||||
|
||||
public DriverResult UpdateEditor(UpdateEditorContext context) {
|
||||
return _decoratedService.UpdateEditor(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Web;
|
||||
using Microsoft.CSharp.RuntimeBinder;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.DisplayManagement.Shapes;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Glimpse.Services;
|
||||
using Orchard.Glimpse.Tabs.Shapes;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
|
||||
namespace Orchard.Glimpse.AlternateImplementation {
|
||||
[OrchardFeature(FeatureNames.Shapes)]
|
||||
[OrchardSuppressDependency("Orchard.DisplayManagement.Implementation.DefaultDisplayManager")]
|
||||
public class GlimpseDisplayManager : IDisplayManager {
|
||||
private readonly Lazy<IShapeTableLocator> _shapeTableLocator;
|
||||
private readonly IGlimpseService _glimpseService;
|
||||
private readonly IWorkContextAccessor _workContextAccessor;
|
||||
private readonly IEnumerable<IShapeDisplayEvents> _shapeDisplayEvents;
|
||||
|
||||
// this need to be Shape instead of IShape - cast to interface throws error on clr types like HtmlString
|
||||
private static readonly CallSite<Func<CallSite, object, Shape>> _convertAsShapeCallsite = CallSite<Func<CallSite, object, Shape>>.Create(
|
||||
new ForgivingConvertBinder(
|
||||
(ConvertBinder) Binder.Convert(
|
||||
CSharpBinderFlags.ConvertExplicit,
|
||||
typeof (Shape),
|
||||
null /*typeof(DefaultDisplayManager)*/)));
|
||||
|
||||
public GlimpseDisplayManager(
|
||||
IWorkContextAccessor workContextAccessor,
|
||||
IEnumerable<IShapeDisplayEvents> shapeDisplayEvents,
|
||||
Lazy<IShapeTableLocator> shapeTableLocator,
|
||||
IGlimpseService glimpseService) {
|
||||
_shapeTableLocator = shapeTableLocator;
|
||||
_glimpseService = glimpseService;
|
||||
_workContextAccessor = workContextAccessor;
|
||||
_shapeDisplayEvents = shapeDisplayEvents;
|
||||
T = NullLocalizer.Instance;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public IHtmlString Execute(DisplayContext context) {
|
||||
var shape = _convertAsShapeCallsite.Target(_convertAsShapeCallsite, context.Value);
|
||||
|
||||
// non-shape arguments are returned as a no-op
|
||||
if (shape == null) {
|
||||
return CoerceHtmlString(context.Value);
|
||||
}
|
||||
|
||||
var shapeMetadata = shape.Metadata;
|
||||
// can't really cope with a shape that has no type information
|
||||
if (shapeMetadata == null || string.IsNullOrEmpty(shapeMetadata.Type)) {
|
||||
return CoerceHtmlString(context.Value);
|
||||
}
|
||||
|
||||
var result = _glimpseService.PublishTimedAction(() => {
|
||||
var workContext = _workContextAccessor.GetContext(context.ViewContext);
|
||||
var shapeTable = _shapeTableLocator.Value.Lookup(workContext.CurrentTheme.Id);
|
||||
|
||||
var displayingContext = new ShapeDisplayingContext {
|
||||
Shape = shape,
|
||||
ShapeMetadata = shapeMetadata
|
||||
};
|
||||
_shapeDisplayEvents.Invoke(sde => sde.Displaying(displayingContext), Logger);
|
||||
|
||||
// find base shape association using only the fundamental shape type.
|
||||
// alternates that may already be registered do not affect the "displaying" event calls
|
||||
ShapeBinding shapeBinding;
|
||||
if (TryGetDescriptorBinding(shapeMetadata.Type, Enumerable.Empty<string>(), shapeTable, out shapeBinding)) {
|
||||
shapeBinding.ShapeDescriptor.Displaying.Invoke(action => action(displayingContext), Logger);
|
||||
|
||||
// copy all binding sources (all templates for this shape) in order to use them as Localization scopes
|
||||
shapeMetadata.BindingSources = shapeBinding.ShapeDescriptor.BindingSources.Where(x => x != null).ToList();
|
||||
if (!shapeMetadata.BindingSources.Any()) {
|
||||
shapeMetadata.BindingSources.Add(shapeBinding.ShapeDescriptor.BindingSource);
|
||||
}
|
||||
}
|
||||
|
||||
// invoking ShapeMetadata displaying events
|
||||
shapeMetadata.Displaying.Invoke(action => action(displayingContext), Logger);
|
||||
|
||||
// use pre-fectched content if available (e.g. coming from specific cache implmentation)
|
||||
if (displayingContext.ChildContent != null) {
|
||||
shape.Metadata.ChildContent = displayingContext.ChildContent;
|
||||
}
|
||||
else {
|
||||
// now find the actual binding to render, taking alternates into account
|
||||
ShapeBinding actualBinding;
|
||||
if (TryGetDescriptorBinding(shapeMetadata.Type, shapeMetadata.Alternates, shapeTable, out actualBinding)) {
|
||||
shape.Metadata.ChildContent = Process(actualBinding, shape, context);
|
||||
}
|
||||
else {
|
||||
throw new OrchardException(T("Shape type {0} not found", shapeMetadata.Type));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var frameType in shape.Metadata.Wrappers) {
|
||||
ShapeBinding frameBinding;
|
||||
if (TryGetDescriptorBinding(frameType, Enumerable.Empty<string>(), shapeTable, out frameBinding)) {
|
||||
shape.Metadata.ChildContent = Process(frameBinding, shape, context);
|
||||
}
|
||||
}
|
||||
|
||||
var displayedContext = new ShapeDisplayedContext {
|
||||
Shape = shape,
|
||||
ShapeMetadata = shape.Metadata,
|
||||
ChildContent = shape.Metadata.ChildContent,
|
||||
};
|
||||
|
||||
_shapeDisplayEvents.Invoke(sde => {
|
||||
var prior = displayedContext.ChildContent = displayedContext.ShapeMetadata.ChildContent;
|
||||
sde.Displayed(displayedContext);
|
||||
// update the child content if the context variable has been reassigned
|
||||
if (prior != displayedContext.ChildContent) {
|
||||
displayedContext.ShapeMetadata.ChildContent = displayedContext.ChildContent;
|
||||
}
|
||||
}, Logger);
|
||||
|
||||
if (shapeBinding != null) {
|
||||
shapeBinding.ShapeDescriptor.Displayed.Invoke(action => {
|
||||
var prior = displayedContext.ChildContent = displayedContext.ShapeMetadata.ChildContent;
|
||||
action(displayedContext);
|
||||
// update the child content if the context variable has been reassigned
|
||||
if (prior != displayedContext.ChildContent) {
|
||||
displayedContext.ShapeMetadata.ChildContent = displayedContext.ChildContent;
|
||||
}
|
||||
}, Logger);
|
||||
}
|
||||
|
||||
// invoking ShapeMetadata displayed events
|
||||
shapeMetadata.Displayed.Invoke(action => action(displayedContext), Logger);
|
||||
|
||||
return shapeBinding;
|
||||
}, (r, t) => new ShapeMessage(shape.Metadata) {
|
||||
Duration = t.Duration,
|
||||
BindingName = r.BindingName,
|
||||
BindingSource = r.BindingSource
|
||||
}, TimelineCategories.Shapes, r => "Shape Displaying", r => r.BindingSource);
|
||||
|
||||
return shape.Metadata.ChildContent;
|
||||
}
|
||||
|
||||
private static bool TryGetDescriptorBinding(string shapeType, IEnumerable<string> shapeAlternates, ShapeTable shapeTable, out ShapeBinding shapeBinding) {
|
||||
// shape alternates are optional, fully qualified binding names
|
||||
// the earliest added alternates have the lowest priority
|
||||
// the descriptor returned is based on the binding that is matched, so it may be an entirely
|
||||
// different descriptor if the alternate has a different base name
|
||||
foreach (var shapeAlternate in shapeAlternates.Reverse()) {
|
||||
if (shapeTable.Bindings.TryGetValue(shapeAlternate, out shapeBinding)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// when no alternates match, the shapeType is used to find the longest matching binding
|
||||
// the shapetype name can break itself into shorter fallbacks at double-underscore marks
|
||||
// so the shapetype itself may contain a longer alternate forms that falls back to a shorter one
|
||||
var shapeTypeScan = shapeType;
|
||||
for (;;) {
|
||||
if (shapeTable.Bindings.TryGetValue(shapeTypeScan, out shapeBinding)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var delimiterIndex = shapeTypeScan.LastIndexOf("__");
|
||||
if (delimiterIndex < 0) {
|
||||
shapeBinding = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
shapeTypeScan = shapeTypeScan.Substring(0, delimiterIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private static IHtmlString CoerceHtmlString(object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var result = value as IHtmlString;
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return new HtmlString(HttpUtility.HtmlEncode(value));
|
||||
}
|
||||
|
||||
private static IHtmlString Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context) {
|
||||
if (shapeBinding == null || shapeBinding.Binding == null) {
|
||||
// todo: create result from all child shapes
|
||||
return shape.Metadata.ChildContent ?? new HtmlString("");
|
||||
}
|
||||
return CoerceHtmlString(shapeBinding.Binding(context));
|
||||
}
|
||||
|
||||
private class ForgivingConvertBinder : ConvertBinder {
|
||||
private readonly ConvertBinder _innerBinder;
|
||||
|
||||
public ForgivingConvertBinder(ConvertBinder innerBinder)
|
||||
: base(innerBinder.ReturnType, innerBinder.Explicit) {
|
||||
_innerBinder = innerBinder;
|
||||
}
|
||||
|
||||
public override DynamicMetaObject FallbackConvert(DynamicMetaObject target, DynamicMetaObject errorSuggestion) {
|
||||
// adjust the normal csharp convert binder to allow failure to become null.
|
||||
// this causes the same net effect as the "as" keyword, but may be applied to dynamic objects
|
||||
var result = _innerBinder.FallbackConvert(
|
||||
target,
|
||||
errorSuggestion ?? new DynamicMetaObject(Expression.Default(_innerBinder.ReturnType), GetTypeRestriction(target)));
|
||||
return result;
|
||||
}
|
||||
|
||||
private static BindingRestrictions GetTypeRestriction(DynamicMetaObject obj) {
|
||||
if ((obj.Value == null) && obj.HasValue) {
|
||||
return BindingRestrictions.GetInstanceRestriction(obj.Expression, null);
|
||||
}
|
||||
return BindingRestrictions.GetTypeRestriction(obj.Expression, obj.LimitType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Conditions.Services;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Utilities;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Glimpse.Services;
|
||||
using Orchard.Glimpse.Tabs.Layers;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Mvc.Html;
|
||||
using Orchard.Widgets.Models;
|
||||
using Orchard.Widgets.Services;
|
||||
|
||||
namespace Orchard.Glimpse.AlternateImplementation {
|
||||
[OrchardFeature(FeatureNames.Layers)]
|
||||
[OrchardSuppressDependency("Orchard.Widgets.Services.DefaultLayerEvaluationService")]
|
||||
public class GlimpseLayerEvaluationService : ILayerEvaluationService {
|
||||
private readonly IGlimpseService _glimpseService;
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
private readonly UrlHelper _urlHelper;
|
||||
private readonly IConditionManager _conditionManager;
|
||||
|
||||
private readonly LazyField<int[]> _activeLayerIDs;
|
||||
|
||||
public GlimpseLayerEvaluationService(IGlimpseService glimpseService, IOrchardServices orchardServices, UrlHelper urlHelper, IConditionManager conditionManager) {
|
||||
_glimpseService = glimpseService;
|
||||
_orchardServices = orchardServices;
|
||||
_urlHelper = urlHelper;
|
||||
_conditionManager = conditionManager;
|
||||
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
|
||||
_activeLayerIDs = new LazyField<int[]>();
|
||||
_activeLayerIDs.Loader(PopulateActiveLayers);
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves every Layer from the Content Manager and evaluates each one.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A collection of integers that represents the Ids of each active Layer
|
||||
/// </returns>
|
||||
public int[] GetActiveLayerIds() {
|
||||
return _activeLayerIDs.Value;
|
||||
}
|
||||
|
||||
private int[] PopulateActiveLayers() {
|
||||
// Once the Rule Engine is done:
|
||||
// Get Layers and filter by zone and rule
|
||||
// NOTE: .ForType("Layer") is faster than .Query<LayerPart, LayerPartRecord>()
|
||||
var activeLayers = _orchardServices.ContentManager.Query<LayerPart>().WithQueryHints(new QueryHints().ExpandParts<LayerPart>()).ForType("Layer").List();
|
||||
|
||||
var activeLayerIds = new List<int>();
|
||||
foreach (var activeLayer in activeLayers) {
|
||||
// ignore the rule if it fails to execute
|
||||
try {
|
||||
var currentLayer = activeLayer;
|
||||
var layerRuleMatches = _glimpseService.PublishTimedAction(() => _conditionManager.Matches(currentLayer.Record.LayerRule), (r, t) => new LayerMessage {
|
||||
Active = r,
|
||||
Name = currentLayer.Record.Name,
|
||||
Rule = currentLayer.Record.LayerRule,
|
||||
EditUrl = GlimpseHelpers.AppendReturnUrl(_urlHelper.ItemAdminUrl(activeLayer), _urlHelper),
|
||||
Duration = t.Duration
|
||||
}, TimelineCategories.Layers, "Layer Evaluation", currentLayer.Record.Name).ActionResult;
|
||||
|
||||
if (layerRuleMatches) {
|
||||
activeLayerIds.Add(activeLayer.ContentItem.Id);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
Logger.Warning(e, T("An error occurred during layer evaluation on: {0}", activeLayer.Name).Text);
|
||||
}
|
||||
}
|
||||
|
||||
return activeLayerIds.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Mvc;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Glimpse.Services;
|
||||
using Orchard.Glimpse.Tabs.Widgets;
|
||||
using Orchard.Indexing;
|
||||
using Orchard.Mvc.Html;
|
||||
using Orchard.Widgets.Models;
|
||||
|
||||
namespace Orchard.Glimpse.AlternateImplementation {
|
||||
[OrchardFeature(FeatureNames.Widgets)]
|
||||
public class GlimpseWidgetContentManagerDecorator : IDecorator<IContentManager>, IContentManager {
|
||||
private readonly IContentManager _decoratedService;
|
||||
private readonly IGlimpseService _glimpseService;
|
||||
private readonly UrlHelper _urlHelper;
|
||||
|
||||
public GlimpseWidgetContentManagerDecorator(IContentManager decoratedService, IGlimpseService glimpseService, UrlHelper urlHelper) {
|
||||
_decoratedService = decoratedService;
|
||||
_glimpseService = glimpseService;
|
||||
_urlHelper = urlHelper;
|
||||
}
|
||||
|
||||
public IEnumerable<ContentTypeDefinition> GetContentTypeDefinitions() {
|
||||
return _decoratedService.GetContentTypeDefinitions();
|
||||
}
|
||||
|
||||
public ContentItem New(string contentType) {
|
||||
return _decoratedService.New(contentType);
|
||||
}
|
||||
|
||||
public void Create(ContentItem contentItem) {
|
||||
_decoratedService.Create(contentItem);
|
||||
}
|
||||
|
||||
public void Create(ContentItem contentItem, VersionOptions options) {
|
||||
_decoratedService.Create(contentItem, options);
|
||||
}
|
||||
|
||||
public ContentItem Clone(ContentItem contentItem) {
|
||||
return _decoratedService.Clone(contentItem);
|
||||
}
|
||||
|
||||
public ContentItem Restore(ContentItem contentItem, VersionOptions options) {
|
||||
return _decoratedService.Restore(contentItem, options);
|
||||
}
|
||||
|
||||
public ContentItem Get(int id) {
|
||||
return _decoratedService.Get(id);
|
||||
}
|
||||
|
||||
public ContentItem Get(int id, VersionOptions options) {
|
||||
return _decoratedService.Get(id, options);
|
||||
}
|
||||
|
||||
public ContentItem Get(int id, VersionOptions options, QueryHints hints) {
|
||||
return _decoratedService.Get(id, options, hints);
|
||||
}
|
||||
|
||||
public IEnumerable<ContentItem> GetAllVersions(int id) {
|
||||
return _decoratedService.GetAllVersions(id);
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetMany<T>(IEnumerable<int> ids, VersionOptions options, QueryHints hints) where T : class, IContent {
|
||||
return _decoratedService.GetMany<T>(ids, options, hints);
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetManyByVersionId<T>(IEnumerable<int> versionRecordIds, QueryHints hints) where T : class, IContent {
|
||||
return _decoratedService.GetManyByVersionId<T>(versionRecordIds, hints);
|
||||
}
|
||||
|
||||
public IEnumerable<ContentItem> GetManyByVersionId(IEnumerable<int> versionRecordIds, QueryHints hints) {
|
||||
return _decoratedService.GetManyByVersionId(versionRecordIds, hints);
|
||||
}
|
||||
|
||||
public void Publish(ContentItem contentItem) {
|
||||
_decoratedService.Publish(contentItem);
|
||||
}
|
||||
|
||||
public void Unpublish(ContentItem contentItem) {
|
||||
_decoratedService.Unpublish(contentItem);
|
||||
}
|
||||
|
||||
public void Remove(ContentItem contentItem) {
|
||||
_decoratedService.Remove(contentItem);
|
||||
}
|
||||
|
||||
public void DiscardDraft(ContentItem contentItem) {
|
||||
_decoratedService.DiscardDraft(contentItem);
|
||||
}
|
||||
|
||||
public void Destroy(ContentItem contentItem) {
|
||||
_decoratedService.Destroy(contentItem);
|
||||
}
|
||||
|
||||
public void Index(ContentItem contentItem, IDocumentIndex documentIndex) {
|
||||
_decoratedService.Index(contentItem, documentIndex);
|
||||
}
|
||||
|
||||
public XElement Export(ContentItem contentItem) {
|
||||
return _decoratedService.Export(contentItem);
|
||||
}
|
||||
|
||||
public void Import(XElement element, ImportContentSession importContentSession) {
|
||||
_decoratedService.Import(element, importContentSession);
|
||||
}
|
||||
|
||||
public void Clear() {
|
||||
_decoratedService.Clear();
|
||||
}
|
||||
|
||||
public IContentQuery<ContentItem> Query() {
|
||||
return _decoratedService.Query();
|
||||
}
|
||||
|
||||
public IHqlQuery HqlQuery() {
|
||||
return _decoratedService.HqlQuery();
|
||||
}
|
||||
|
||||
public ContentItemMetadata GetItemMetadata(IContent contentItem) {
|
||||
return _decoratedService.GetItemMetadata(contentItem);
|
||||
}
|
||||
|
||||
public IEnumerable<GroupInfo> GetEditorGroupInfos(IContent contentItem) {
|
||||
return _decoratedService.GetEditorGroupInfos(contentItem);
|
||||
}
|
||||
|
||||
public IEnumerable<GroupInfo> GetDisplayGroupInfos(IContent contentItem) {
|
||||
return _decoratedService.GetDisplayGroupInfos(contentItem);
|
||||
}
|
||||
|
||||
public GroupInfo GetEditorGroupInfo(IContent contentItem, string groupInfoId) {
|
||||
return _decoratedService.GetEditorGroupInfo(contentItem, groupInfoId);
|
||||
}
|
||||
|
||||
public GroupInfo GetDisplayGroupInfo(IContent contentItem, string groupInfoId) {
|
||||
return _decoratedService.GetDisplayGroupInfo(contentItem, groupInfoId);
|
||||
}
|
||||
|
||||
public ContentItem ResolveIdentity(ContentIdentity contentIdentity) {
|
||||
return _decoratedService.ResolveIdentity(contentIdentity);
|
||||
}
|
||||
|
||||
public dynamic BuildDisplay(IContent content, string displayType = "", string groupId = "") {
|
||||
var widgetPart = content.As<WidgetPart>();
|
||||
|
||||
if (widgetPart == null) {
|
||||
return _decoratedService.BuildDisplay(content, displayType, groupId);
|
||||
}
|
||||
|
||||
return _glimpseService.PublishTimedAction(() => _decoratedService.BuildDisplay(content, displayType, groupId),
|
||||
(r, t) => new WidgetMessage {
|
||||
ContentId = content.Id,
|
||||
Title = widgetPart.Title,
|
||||
Type = widgetPart.ContentItem.ContentType,
|
||||
Zone = widgetPart.Zone,
|
||||
Layer = widgetPart.LayerPart,
|
||||
Position = widgetPart.Position,
|
||||
TechnicalName = widgetPart.Name,
|
||||
EditUrl = GlimpseHelpers.AppendReturnUrl(_urlHelper.ItemAdminUrl(content), _urlHelper),
|
||||
Duration = t.Duration
|
||||
}, TimelineCategories.Widgets, $"Build Display: {widgetPart.ContentItem.ContentType}", widgetPart.Title).ActionResult;
|
||||
}
|
||||
|
||||
public dynamic BuildEditor(IContent content, string groupId = "") {
|
||||
return _decoratedService.BuildEditor(content, groupId);
|
||||
}
|
||||
|
||||
public dynamic UpdateEditor(IContent content, IUpdateModel updater, string groupId = "") {
|
||||
return _decoratedService.UpdateEditor(content, updater, groupId);
|
||||
}
|
||||
|
||||
public void CompleteImport(XElement element, ImportContentSession importContentSession) {
|
||||
_decoratedService.CompleteImport(element, importContentSession);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Title.Models;
|
||||
using Orchard.Users.Models;
|
||||
using Orchard.Widgets.Models;
|
||||
|
||||
namespace Orchard.Glimpse.Extensions {
|
||||
public static class ContentExtensions {
|
||||
public static string GetContentName(this IContent content) {
|
||||
if (content.Has<TitlePart>()) {
|
||||
return content.As<TitlePart>().Title;
|
||||
}
|
||||
if (content.Has<WidgetPart>()) {
|
||||
return content.As<WidgetPart>().Title;
|
||||
}
|
||||
if (content.Has<UserPart>()) {
|
||||
return content.As<UserPart>().UserName;
|
||||
}
|
||||
if (content.Has<LayerPart>()) {
|
||||
return content.As<LayerPart>().Name;
|
||||
}
|
||||
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Glimpse.Core.Tab.Assist;
|
||||
using Orchard.Glimpse.Models;
|
||||
|
||||
namespace Orchard.Glimpse.Extensions {
|
||||
public static class TabSectionExtensions {
|
||||
public static void AddTimingSummary(this TabSection section, IEnumerable<IDurationMessage> messages) {
|
||||
if (!section.Rows.Any()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var columnCount = section.Rows.First().Columns.Count();
|
||||
|
||||
var row = section.AddRow();
|
||||
|
||||
var itemCount = messages.Count();
|
||||
row.Column($"{itemCount} item{(itemCount == 1 ? "" : "s")}");
|
||||
|
||||
for (int i = 0; i < columnCount - 3; i++) {
|
||||
row.Column("");
|
||||
}
|
||||
|
||||
row.Column("Total time:");
|
||||
row.Column(messages.Sum(m => m.Duration.TotalMilliseconds).ToTimingString());
|
||||
row.Selected();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Orchard.Glimpse.Extensions {
|
||||
public static class TimespanExtensions {
|
||||
public static string ToTimingString(this TimeSpan timespan) {
|
||||
return timespan.TotalMilliseconds.ToTimingString();
|
||||
}
|
||||
|
||||
public static string ToTimingString(this double milliseconds) {
|
||||
return $"{milliseconds:0,0.00} ms";
|
||||
}
|
||||
|
||||
public static string ToReadableString(this TimeSpan span) {
|
||||
var segments = new[] {
|
||||
GetTimeSpanSegment(span.Duration().Days, "day"),
|
||||
GetTimeSpanSegment(span.Duration().Hours, "hour"),
|
||||
GetTimeSpanSegment(span.Duration().Minutes, "minute"),
|
||||
GetTimeSpanSegment(span.Duration().Seconds, "second")
|
||||
};
|
||||
|
||||
return string.Join(", ", segments.Where(s => s != null));
|
||||
}
|
||||
|
||||
private static string GetTimeSpanSegment(int value, string unit) {
|
||||
return value > 0 ? $"{value:0} {unit}{(value == 1 ? string.Empty : "s")}" : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
src/Orchard.Web/Modules/Orchard.Glimpse/FeatureNames.cs
Normal file
12
src/Orchard.Web/Modules/Orchard.Glimpse/FeatureNames.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Orchard.Glimpse {
|
||||
internal static class FeatureNames {
|
||||
internal const string Authorizer = "Orchard.Glimpse.Authorizer";
|
||||
internal const string Cache = "Orchard.Glimpse.Cache";
|
||||
internal const string ContentManager = "Orchard.Glimpse.ContentManager";
|
||||
internal const string Layers = "Orchard.Glimpse.Layers";
|
||||
internal const string Parts = "Orchard.Glimpse.Parts";
|
||||
internal const string Shapes = "Orchard.Glimpse.Shapes";
|
||||
internal const string SQL = "Orchard.Glimpse.SQL";
|
||||
internal const string Widgets = "Orchard.Glimpse.Widgets";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Glimpse.Core.Extensibility;
|
||||
|
||||
namespace Orchard.Glimpse.GlimpseExtensions {
|
||||
public class WhitelistedIpAddressesSecurityPolicy : IRuntimePolicy {
|
||||
public RuntimePolicy Execute(IRuntimePolicyContext policyContext) {
|
||||
var request = HttpContext.Current.Request;
|
||||
var whitelistedIpAddressesValue = ConfigurationManager.AppSettings["Orchard.Glimpse:WhitelistedIpAddresses"] ?? string.Empty;
|
||||
var whitelistedIpAddresses = whitelistedIpAddressesValue.Split(new[] {";"}, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (request.IsLocal || !whitelistedIpAddresses.Any()) {
|
||||
return RuntimePolicy.On;
|
||||
}
|
||||
|
||||
return whitelistedIpAddresses.Contains(request.UserHostAddress) ? RuntimePolicy.On : RuntimePolicy.Off;
|
||||
}
|
||||
|
||||
public RuntimeEvent ExecuteOn => RuntimeEvent.EndRequest | RuntimeEvent.ExecuteResource;
|
||||
}
|
||||
}
|
||||
24
src/Orchard.Web/Modules/Orchard.Glimpse/GlimpseHelpers.cs
Normal file
24
src/Orchard.Web/Modules/Orchard.Glimpse/GlimpseHelpers.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Orchard.Glimpse {
|
||||
public static class GlimpseHelpers {
|
||||
public static string AppendReturnUrl(string path, UrlHelper urlHelper) {
|
||||
var requestUrl = urlHelper.RequestContext.HttpContext.Request.Url;
|
||||
|
||||
if (requestUrl == null) {
|
||||
return path;
|
||||
}
|
||||
|
||||
var uriBuilder = new UriBuilder(requestUrl.AbsoluteUri) { Path = path };
|
||||
var query = HttpUtility.ParseQueryString(uriBuilder.Query);
|
||||
|
||||
query["returnUrl"] = requestUrl.AbsolutePath;
|
||||
uriBuilder.Query = query.ToString();
|
||||
path = uriBuilder.ToString();
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace Orchard.Glimpse.Interceptors {
|
||||
public abstract class GlimpseMessageInterceptor<T> : IGlimpseMessageInterceptor where T : class {
|
||||
public void MessageReceived<TMessage>(TMessage message) where TMessage : class {
|
||||
var typedMessage = message as T;
|
||||
|
||||
if (typedMessage != null) {
|
||||
ProcessMessage(typedMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void ProcessMessage(T message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace Orchard.Glimpse.Interceptors {
|
||||
public interface IGlimpseMessageInterceptor : IDependency {
|
||||
void MessageReceived<TMessage>(TMessage message) where TMessage : class;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Glimpse.Extensions;
|
||||
using Orchard.Glimpse.Services;
|
||||
using Orchard.Glimpse.Tabs.Parts;
|
||||
|
||||
namespace Orchard.Glimpse.Models {
|
||||
public class GlimpseDriverResult : DriverResult {
|
||||
private readonly IGlimpseService _glimpseService;
|
||||
|
||||
public GlimpseDriverResult(DriverResult originalDriverResult, IGlimpseService glimpseService) {
|
||||
_glimpseService = glimpseService;
|
||||
OriginalDriverResult = originalDriverResult;
|
||||
|
||||
ContentField = originalDriverResult?.ContentField;
|
||||
ContentPart = originalDriverResult?.ContentPart;
|
||||
}
|
||||
public DriverResult OriginalDriverResult { get; set; }
|
||||
|
||||
public override void Apply(BuildDisplayContext context) {
|
||||
_glimpseService.PublishTimedAction(() => OriginalDriverResult.Apply(context), t => new PartMessage {
|
||||
ContentId = context.ContentItem.Id,
|
||||
ContentName = context.ContentItem.GetContentName(),
|
||||
ContentType = context.ContentItem.ContentType,
|
||||
DisplayType = context.DisplayType,
|
||||
PartDefinition = context.ContentPart?.PartDefinition,
|
||||
Duration = t.Duration
|
||||
}, TimelineCategories.Parts, "Display Part: " + (ContentPart == null ? context.ContentItem.ContentType : ContentPart.PartDefinition.Name), context.ContentItem.GetContentName());
|
||||
}
|
||||
|
||||
public override void Apply(BuildEditorContext context) {
|
||||
OriginalDriverResult.Apply(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using System;
|
||||
|
||||
namespace Orchard.Glimpse.Models {
|
||||
public interface IDurationMessage {
|
||||
TimeSpan Duration { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using Glimpse.Core.Extensibility;
|
||||
|
||||
namespace Orchard.Glimpse.Models {
|
||||
public class TimedActionResult<T> {
|
||||
public TimedActionResult() {
|
||||
TimerResult = new TimerResult(); // Glimpse fails if it is ever passed a null TimerResult
|
||||
}
|
||||
|
||||
public TimerResult TimerResult { get; set; }
|
||||
public T ActionResult { get; set; }
|
||||
}
|
||||
}
|
||||
53
src/Orchard.Web/Modules/Orchard.Glimpse/Module.txt
Normal file
53
src/Orchard.Web/Modules/Orchard.Glimpse/Module.txt
Normal file
@@ -0,0 +1,53 @@
|
||||
Name: Orchard.Glimpse
|
||||
AntiForgery: enabled
|
||||
Author: The Orchard Team
|
||||
Website: http://orchardproject.net
|
||||
Version: 1.0
|
||||
OrchardVersion: 1.10.1
|
||||
Description: Brings Orchard specific tabs to the Glimpse panel.
|
||||
Path: Glimpse
|
||||
Features:
|
||||
Orchard.Glimpse:
|
||||
Name: Glimpse for Orchard
|
||||
Description: Brings Orchard specific tabs to the Glimpse panel.
|
||||
Category: Diagnostics
|
||||
Orchard.Glimpse.Authorizer:
|
||||
Name: Glimpse for Orchard Authorizer
|
||||
Description: Adds Glimpse instrumentation to your Authorizer service.
|
||||
Category: Diagnostics
|
||||
Dependencies: Orchard.Glimpse
|
||||
Orchard.Glimpse.Cache:
|
||||
Name: Glimpse for Orchard Cache Service
|
||||
Description: Adds Glimpse instrumentation to your current Cache Service.
|
||||
Category: Diagnostics
|
||||
Dependencies: Orchard.Glimpse, Orchard.Caching
|
||||
Orchard.Glimpse.ContentManager:
|
||||
Name: Glimpse for Orchard Content Manager
|
||||
Description: Adds Glimpse instrumentation to your current Content Manager.
|
||||
Category: Diagnostics
|
||||
Dependencies: Orchard.Glimpse
|
||||
Orchard.Glimpse.Layers:
|
||||
Name: Glimpse for Orchard Layers
|
||||
Description: Adds Glimpse instrumentation to your current Layer Rule evalution.
|
||||
Category: Diagnostics
|
||||
Dependencies: Orchard.Glimpse, Orchard.Widgets
|
||||
Orchard.Glimpse.Parts:
|
||||
Name: Glimpse for Orchard Content Parts
|
||||
Description: Adds Glimpse instrumentation to the Build Display events of each of your Content Part Drivers.
|
||||
Category: Diagnostics
|
||||
Dependencies: Orchard.Glimpse
|
||||
Orchard.Glimpse.Shapes:
|
||||
Name: Glimpse for Orchard Shapes
|
||||
Description: Adds Glimpse instrumentation to your Shapes.
|
||||
Category: Diagnostics
|
||||
Dependencies: Orchard.Glimpse
|
||||
Orchard.Glimpse.SQL:
|
||||
Name: Glimpse for Orchard SQL
|
||||
Description: Adds Glimpse instrumentation to your database calls.
|
||||
Category: Diagnostics
|
||||
Dependencies: Orchard.Glimpse
|
||||
Orchard.Glimpse.Widgets:
|
||||
Name: Glimpse for Orchard Widgets
|
||||
Description: Adds Glimpse instrumentation to your Widgets.
|
||||
Category: Diagnostics
|
||||
Dependencies: Orchard.Glimpse, Orchard.Widgets
|
||||
252
src/Orchard.Web/Modules/Orchard.Glimpse/Orchard.Glimpse.csproj
Normal file
252
src/Orchard.Web/Modules/Orchard.Glimpse/Orchard.Glimpse.csproj
Normal file
@@ -0,0 +1,252 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{71E17466-D937-49D7-8C7D-77CCBAB8CCF4}</ProjectGuid>
|
||||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Orchard.Glimpse</RootNamespace>
|
||||
<AssemblyName>Orchard.Glimpse</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<MvcBuildViews>false</MvcBuildViews>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>4.0</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
<TargetFrameworkProfile />
|
||||
<UseIISExpress>false</UseIISExpress>
|
||||
<IISExpressSSLPort />
|
||||
<IISExpressAnonymousAuthentication />
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
<UseGlobalApplicationHostFile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Autofac, Version=3.5.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Autofac.3.5.2\lib\net40\Autofac.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="FluentNHibernate, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\FluentNHibernate.2.0.3.0\lib\net40\FluentNHibernate.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Glimpse.Ado, Version=1.7.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Glimpse.Ado.1.7.3\lib\net45\Glimpse.Ado.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Glimpse.AspNet, Version=1.9.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Glimpse.AspNet.1.9.2\lib\net45\Glimpse.AspNet.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Glimpse.Core, Version=1.8.6.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Glimpse.1.8.6\lib\net45\Glimpse.Core.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Glimpse.Mvc5, Version=1.5.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Glimpse.Mvc5.1.5.3\lib\net45\Glimpse.Mvc5.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Iesi.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Iesi.Collections.4.0.1.4000\lib\net40\Iesi.Collections.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate, Version=4.0.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\NHibernate.4.0.1.4000\lib\net40\NHibernate.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.XML" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Properties\AssemblyInfo.cs" />
|
||||
<Content Include="Module.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
|
||||
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
|
||||
<Name>Orchard.Framework</Name>
|
||||
<Private>false</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
|
||||
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
|
||||
<Name>Orchard.Core</Name>
|
||||
<Private>false</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Caching\Orchard.Caching.csproj">
|
||||
<Project>{7528BF74-25C7-4ABE-883A-443B4EEC4776}</Project>
|
||||
<Name>Orchard.Caching</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Conditions\Orchard.Conditions.csproj">
|
||||
<Project>{98251eae-a41b-47b2-aa91-e28b8482da70}</Project>
|
||||
<Name>Orchard.Conditions</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Tokens\Orchard.Tokens.csproj">
|
||||
<Project>{6f759635-13d7-4e94-bcc9-80445d63f117}</Project>
|
||||
<Name>Orchard.Tokens</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Users\Orchard.Users.csproj">
|
||||
<Project>{79AED36E-ABD0-4747-93D3-8722B042454B}</Project>
|
||||
<Name>Orchard.Users</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Widgets\Orchard.Widgets.csproj">
|
||||
<Project>{194D3CCC-1153-474D-8176-FDE8D7D0D0BD}</Project>
|
||||
<Name>Orchard.Widgets</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AlternateImplementation\GlimpseContentPartDriver.cs" />
|
||||
<Compile Include="AlternateImplementation\GlimpseLayerEvaluationService.cs" />
|
||||
<Compile Include="GlimpseHelpers.cs" />
|
||||
<Compile Include="Interceptors\IGlimpseMessageInterceptor.cs" />
|
||||
<Compile Include="Models\GlimpseDriverResult.cs" />
|
||||
<Compile Include="Interceptors\GlimpseMessageInterceptor.cs" />
|
||||
<Compile Include="Tabs\Parts\PartMessage.cs" />
|
||||
<Compile Include="Tabs\Parts\PartMessagesConverter.cs" />
|
||||
<Compile Include="Tabs\Parts\PartTab.cs" />
|
||||
<Compile Include="GlimpseExtensions\WhitelistedIpAddressesSecurityPolicy.cs" />
|
||||
<Compile Include="ADO\GlimpseSessionConfigurationEvents.cs" />
|
||||
<Compile Include="ADO\GlimpseConnectionProvider.cs" />
|
||||
<Compile Include="ADO\GlimpseDriver.cs" />
|
||||
<Compile Include="AlternateImplementation\GlimpseWidgetContentManagerDecorator.cs" />
|
||||
<Compile Include="AlternateImplementation\GlimpseDisplayManager.cs" />
|
||||
<Compile Include="AlternateImplementation\GlimpseAuthorizerDecorator.cs" />
|
||||
<Compile Include="AlternateImplementation\GlimpseCacheServiceDecorator.cs" />
|
||||
<Compile Include="AlternateImplementation\GlimpseContentManagerDecorator.cs" />
|
||||
<Compile Include="FeatureNames.cs" />
|
||||
<Compile Include="Extensions\ContentExtensions.cs" />
|
||||
<Compile Include="Extensions\TimespanExtensions.cs" />
|
||||
<Compile Include="Models\IDurationMessage.cs" />
|
||||
<Compile Include="Extensions\TabSectionExtensions.cs" />
|
||||
<Compile Include="Tabs\Layers\LayerMessage.cs" />
|
||||
<Compile Include="Tabs\Layers\LayerMessagesConverter.cs" />
|
||||
<Compile Include="Tabs\Layers\LayerTab.cs" />
|
||||
<Compile Include="Tabs\Widgets\WidgetTab.cs" />
|
||||
<Compile Include="Tabs\Widgets\WidgetMessage.cs" />
|
||||
<Compile Include="Tabs\Widgets\WidgetMessagesConverter.cs" />
|
||||
<Compile Include="Tabs\Shapes\ShapesMessage.cs" />
|
||||
<Compile Include="Tabs\Shapes\ShapesMessagesConverter.cs" />
|
||||
<Compile Include="Tabs\Shapes\ShapesTab.cs" />
|
||||
<Compile Include="Tabs\ContentManager\ContentManagerGetMessage.cs" />
|
||||
<Compile Include="Tabs\ContentManager\ContentManagerGetMessagesConverter.cs" />
|
||||
<Compile Include="Tabs\ContentManager\ContentManagerTab.cs" />
|
||||
<Compile Include="Tabs\Authorizer\AuthorizerMessage.cs" />
|
||||
<Compile Include="Tabs\Authorizer\AuthorizerMessagesConverter.cs" />
|
||||
<Compile Include="Tabs\Authorizer\AuthorizerTab.cs" />
|
||||
<Compile Include="Tabs\Cache\CacheMessage.cs" />
|
||||
<Compile Include="Tabs\Cache\CacheTab.cs" />
|
||||
<Compile Include="Tabs\TimelineMessage.cs" />
|
||||
<Compile Include="Services\DefaultGlimpseService.cs" />
|
||||
<Compile Include="Services\IGlimpseService.cs" />
|
||||
<Compile Include="Models\TimedActionResult.cs" />
|
||||
<Compile Include="Tabs\Cache\CacheMessagesConverter.cs" />
|
||||
<Compile Include="TimelineCategories.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<Content Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target> -->
|
||||
<Target Name="AfterBuild" DependsOnTargets="AfterBuildCompiler">
|
||||
<PropertyGroup>
|
||||
<AreasManifestDir>$(ProjectDir)\..\Manifests</AreasManifestDir>
|
||||
</PropertyGroup>
|
||||
<!-- If this is an area child project, uncomment the following line:
|
||||
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Child" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
|
||||
-->
|
||||
<!-- If this is an area parent project, uncomment the following lines:
|
||||
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Parent" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
|
||||
<CopyAreaManifests ManifestPath="$(AreasManifestDir)" CrossCopy="false" RenameViews="true" />
|
||||
-->
|
||||
</Target>
|
||||
<Target Name="AfterBuildCompiler" Condition="'$(MvcBuildViews)'=='true'">
|
||||
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
|
||||
</Target>
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
<WebProjectProperties>
|
||||
<UseIIS>False</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>45979</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>
|
||||
</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>True</UseCustomServer>
|
||||
<CustomServerUrl>http://orchard.codeplex.com</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Orchard.Glimpse")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyProduct("Orchard")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("3025a79f-1d30-467b-9bf9-94274b3aea28")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using Glimpse.Core.Extensibility;
|
||||
using Glimpse.Core.Framework;
|
||||
using Glimpse.Core.Message;
|
||||
using Orchard.Glimpse.Interceptors;
|
||||
using Orchard.Glimpse.Models;
|
||||
using Orchard.Glimpse.Tabs;
|
||||
using Orchard.Localization;
|
||||
using ILogger = Orchard.Logging.ILogger;
|
||||
using NullLogger = Orchard.Logging.NullLogger;
|
||||
|
||||
namespace Orchard.Glimpse.Services {
|
||||
public class DefaultGlimpseService : IGlimpseService {
|
||||
private readonly IEnumerable<IGlimpseMessageInterceptor> _messageInterceptors;
|
||||
|
||||
public DefaultGlimpseService(IEnumerable<IGlimpseMessageInterceptor> messageInterceptors) {
|
||||
_messageInterceptors = messageInterceptors;
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
public Localizer T { get; private set; }
|
||||
|
||||
public TimerResult Time(Action action) {
|
||||
var executionTimer = GetTimer();
|
||||
|
||||
if (executionTimer == null) {
|
||||
action();
|
||||
return new TimerResult();
|
||||
}
|
||||
|
||||
return executionTimer.Time(action);
|
||||
}
|
||||
|
||||
public TimedActionResult<T> Time<T>(Func<T> action) {
|
||||
var result = default(T);
|
||||
|
||||
var executionTimer = GetTimer();
|
||||
|
||||
if (executionTimer == null) {
|
||||
return new TimedActionResult<T> {ActionResult = action() };
|
||||
}
|
||||
|
||||
var duration = executionTimer.Time(() => { result = action(); });
|
||||
|
||||
return new TimedActionResult<T> {
|
||||
ActionResult = result,
|
||||
TimerResult = duration
|
||||
};
|
||||
}
|
||||
|
||||
public TimerResult PublishTimedAction(Action action, TimelineCategoryItem category, string eventName, string eventSubText = null) {
|
||||
var timedResult = Time(action);
|
||||
PublishMessage(new TimelineMessage {EventName = eventName, EventCategory = category, EventSubText = eventSubText}.AsTimedMessage(timedResult));
|
||||
|
||||
return timedResult;
|
||||
}
|
||||
|
||||
public TimerResult PublishTimedAction<TMessage>(Action action, Func<TMessage> messageFactory, TimelineCategoryItem category, string eventName, string eventSubText = null) where TMessage : class {
|
||||
var timedResult = PublishTimedAction(action, category, eventName, eventSubText);
|
||||
PublishMessage(messageFactory());
|
||||
|
||||
return timedResult;
|
||||
}
|
||||
|
||||
public TimerResult PublishTimedAction<TMessage>(Action action, Func<TimerResult, TMessage> messageFactory, TimelineCategoryItem category, string eventName, string eventSubText = null) where TMessage : class {
|
||||
var timedResult = PublishTimedAction(action, category, eventName, eventSubText);
|
||||
PublishMessage(messageFactory(timedResult));
|
||||
|
||||
return timedResult;
|
||||
}
|
||||
|
||||
public TimedActionResult<T> PublishTimedAction<T>(Func<T> action, TimelineCategoryItem category, string eventName, string eventSubText = null, Func<T, bool> publishCondition = null) {
|
||||
var timedResult = Time(action);
|
||||
|
||||
if (publishCondition==null || publishCondition(timedResult.ActionResult)) {
|
||||
PublishMessage(new TimelineMessage {EventName = eventName, EventCategory = category, EventSubText = eventSubText}.AsTimedMessage(timedResult.TimerResult));
|
||||
}
|
||||
|
||||
return timedResult;
|
||||
}
|
||||
|
||||
public TimedActionResult<T> PublishTimedAction<T>(Func<T> action, TimelineCategoryItem category, Func<T, string> eventNameFactory, Func<T, string> eventSubTextFactory = null, Func<T, bool> publishCondition = null) {
|
||||
var timedResult = Time(action);
|
||||
|
||||
string eventSubText = null;
|
||||
if (eventSubTextFactory != null) {
|
||||
eventSubText = eventSubTextFactory(timedResult.ActionResult);
|
||||
}
|
||||
|
||||
if (publishCondition == null || publishCondition(timedResult.ActionResult)) {
|
||||
PublishMessage(new TimelineMessage {EventName = eventNameFactory(timedResult.ActionResult), EventCategory = category, EventSubText = eventSubText}.AsTimedMessage(timedResult.TimerResult));
|
||||
}
|
||||
|
||||
return timedResult;
|
||||
}
|
||||
|
||||
public TimedActionResult<T> PublishTimedAction<T, TMessage>(Func<T> action, Func<T, TimerResult, TMessage> messageFactory, TimelineCategoryItem category, string eventName, string eventSubText = null, Func<T, bool> publishCondition = null) where TMessage : class {
|
||||
var actionResult = PublishTimedAction(action, category, eventName, eventSubText);
|
||||
|
||||
if (publishCondition == null || publishCondition(actionResult.ActionResult)) {
|
||||
PublishMessage(messageFactory(actionResult.ActionResult, actionResult.TimerResult));
|
||||
}
|
||||
|
||||
return actionResult;
|
||||
}
|
||||
|
||||
public TimedActionResult<T> PublishTimedAction<T, TMessage>(Func<T> action, Func<T, TimerResult, TMessage> messageFactory, TimelineCategoryItem category, Func<T, string> eventNameFactory, Func<T, string> eventSubTextFactory = null, Func<T, bool> publishCondition = null) where TMessage : class {
|
||||
var actionResult = PublishTimedAction(action, category, eventNameFactory, eventSubTextFactory);
|
||||
|
||||
if (publishCondition == null || publishCondition(actionResult.ActionResult)) {
|
||||
PublishMessage(messageFactory(actionResult.ActionResult, actionResult.TimerResult));
|
||||
}
|
||||
|
||||
return actionResult;
|
||||
}
|
||||
|
||||
public void PublishMessage<T>(T message) where T : class {
|
||||
var broker = GetMessageBroker();
|
||||
|
||||
_messageInterceptors.Invoke(i => i.MessageReceived(message), Logger);
|
||||
|
||||
broker?.Publish(message);
|
||||
}
|
||||
|
||||
private IExecutionTimer GetTimer() {
|
||||
var context = HttpContext.Current;
|
||||
|
||||
return ((GlimpseRuntime) context?.Application.Get("__GlimpseRuntime"))?.Configuration.TimerStrategy.Invoke();
|
||||
}
|
||||
|
||||
private IMessageBroker GetMessageBroker() {
|
||||
var context = HttpContext.Current;
|
||||
|
||||
return ((GlimpseRuntime) context?.Application.Get("__GlimpseRuntime"))?.Configuration.MessageBroker;
|
||||
}
|
||||
}
|
||||
|
||||
public class NullMessageBroker : IMessageBroker {
|
||||
public void Publish<T>(T message) { }
|
||||
|
||||
public Guid Subscribe<T>(Action<T> action) {
|
||||
return Guid.NewGuid();
|
||||
}
|
||||
|
||||
public void Unsubscribe<T>(Guid subscriptionId) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using Glimpse.Core.Extensibility;
|
||||
using Glimpse.Core.Message;
|
||||
using Orchard.Glimpse.Models;
|
||||
|
||||
namespace Orchard.Glimpse.Services {
|
||||
public interface IGlimpseService : IDependency {
|
||||
/// <summary>
|
||||
/// Executes an action, and times how long the execution takes
|
||||
/// </summary>
|
||||
/// <param name="action">The action to execute</param>
|
||||
/// <returns>An instance of TimerResult which contains the measured time taken to execute the action</returns>
|
||||
TimerResult Time(Action action);
|
||||
|
||||
/// <summary>
|
||||
/// Executes an expression, times how long the execution takes, and returns the result of the timer and the result of the expression
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The return type of the expression to execute</typeparam>
|
||||
/// <param name="action">The expression to execute</param>
|
||||
/// <returns>A TimedActionResult containing an instance of TimerResult depicting the measured time taken to execute the action, and the result of the action that was executed</returns>
|
||||
TimedActionResult<T> Time<T>(Func<T> action);
|
||||
|
||||
/// <summary>
|
||||
/// Executes an action, times how long the action takes, and adds the result of the timed action to the Glimpse Timeline
|
||||
/// </summary>
|
||||
/// <param name="action">The action to execute</param>
|
||||
/// <param name="category">The <see cref="TimelineCategoryItem"/> that describes the way the action should be displayed on the Glimpse Timeline</param>
|
||||
/// <param name="eventName">The name of the event to be displayed on the Glimpse Timeline</param>
|
||||
/// <param name="eventSubText">Optional. A sub header to be displayed on the Glimpse Timeline that provides additional information about the action</param>
|
||||
/// <returns>A TimerResult depicting the measured time taken to execute the action</returns>
|
||||
TimerResult PublishTimedAction(Action action, TimelineCategoryItem category, string eventName, string eventSubText = null);
|
||||
|
||||
/// <summary>
|
||||
/// Executes an action, times how long the action takes, adds the result of the timed action to the Glimpse Timeline, and adds an additional message to the Glimpse broker
|
||||
/// </summary>
|
||||
/// <typeparam name="TMessage">The type of the message to be added to the Glimpse broker</typeparam>
|
||||
/// <param name="action">The action to execute</param>
|
||||
/// <param name="messageFactory">An expression that returns the message to be added to the Glimpse broker</param>
|
||||
/// <param name="category">The <see cref="TimelineCategoryItem"/> that describes the way the action should be displayed on the Glimpse Timeline</param>
|
||||
/// <param name="eventName">The name of the event to be displayed on the Glimpse Timeline</param>
|
||||
/// <param name="eventSubText">Optional. A sub header to be displayed on the Glimpse Timeline that provides additional information about the action</param>
|
||||
/// <returns>A TimerResult depicting the measured time taken to execute the action</returns>
|
||||
TimerResult PublishTimedAction<TMessage>(Action action, Func<TMessage> messageFactory, TimelineCategoryItem category, string eventName, string eventSubText = null) where TMessage : class;
|
||||
|
||||
/// <summary>
|
||||
/// Executes an action, times how long the action takes, adds the result of the timed action to the Glimpse Timeline, and adds an additional message to the Glimpse broker
|
||||
/// </summary>
|
||||
/// <typeparam name="TMessage">The type of the message to be added to the Glimpse broker</typeparam>
|
||||
/// <param name="action">The action to execute</param>
|
||||
/// <param name="messageFactory">An expression that returns the message to be added to the Glimpse broker. The expression will be passed an instance of <see cref="TimerResult"/> that contains data about the time take to execute <paramref name="action"/></param>
|
||||
/// <param name="category">The <see cref="TimelineCategoryItem"/> that describes the way the action should be displayed on the Glimpse Timeline</param>
|
||||
/// <param name="eventName">The name of the event to be displayed on the Glimpse Timeline</param>
|
||||
/// <param name="eventSubText">Optional. A sub header to be displayed on the Glimpse Timeline that provides additional information about the action</param>
|
||||
/// <returns>A TimerResult depicting the measured time taken to execute the action</returns>
|
||||
TimerResult PublishTimedAction<TMessage>(Action action, Func<TimerResult, TMessage> messageFactory, TimelineCategoryItem category, string eventName, string eventSubText = null) where TMessage : class;
|
||||
|
||||
/// <summary>
|
||||
/// Executes an expression, times how long the expression takes, and adds the result of the timed expression to the Glimpse Timeline
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The return type of the expression to execute</typeparam>
|
||||
/// <param name="action">The expression to execute</param>
|
||||
/// <param name="category">The <see cref="TimelineCategoryItem"/> that describes the way the action should be displayed on the Glimpse Timeline</param>
|
||||
/// <param name="eventName">The name of the event to be displayed on the Glimpse Timeline</param>
|
||||
/// <param name="eventSubText">Optional. A sub header to be displayed on the Glimpse Timeline that provides additional information about the expression</param>
|
||||
/// <returns>A TimedActionResult containing an instance of TimerResult depicting the measured time taken to execute the expression, and the result of the expression that was executed</returns>
|
||||
TimedActionResult<T> PublishTimedAction<T>(Func<T> action, TimelineCategoryItem category, string eventName, string eventSubText = null, Func<T, bool> publishCondition = null);
|
||||
|
||||
TimedActionResult<T> PublishTimedAction<T>(Func<T> action, TimelineCategoryItem category, Func<T, string> eventNameFactory, Func<T, string> eventSubTextFactory = null, Func<T, bool> publishCondition = null);
|
||||
|
||||
TimedActionResult<T> PublishTimedAction<T, TMessage>(Func<T> action, Func<T, TimerResult, TMessage> messageFactory, TimelineCategoryItem category, string eventName, string eventSubText = null, Func<T, bool> publishCondition = null) where TMessage : class;
|
||||
|
||||
TimedActionResult<T> PublishTimedAction<T, TMessage>(Func<T> action, Func<T, TimerResult, TMessage> messageFactory, TimelineCategoryItem category, Func<T, string> eventNameFactory, Func<T, string> eventSubTextFactory = null, Func<T, bool> publishCondition = null) where TMessage : class;
|
||||
|
||||
/// <summary>
|
||||
/// Places a message into the Glimpse Broker
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the message to be published</typeparam>
|
||||
/// <param name="message">The message to be published</param>
|
||||
void PublishMessage<T>(T message) where T : class;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using Glimpse.Core.Message;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Glimpse.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.Authorizer {
|
||||
public class AuthorizerMessage : MessageBase, IDurationMessage {
|
||||
public string Message { get; set; }
|
||||
public IContent Content { get; set; }
|
||||
public Permission Permission { get; set; }
|
||||
public bool Result { get; set; }
|
||||
public TimeSpan Duration { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
using Glimpse.Core.Extensibility;
|
||||
using Glimpse.Core.Tab.Assist;
|
||||
using Orchard.Glimpse.Extensions;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.Authorizer {
|
||||
public class AuthorizerMessagesConverter : SerializationConverter<IEnumerable<AuthorizerMessage>> {
|
||||
public override object Convert(IEnumerable<AuthorizerMessage> messages) {
|
||||
var root = new TabSection("Permission", "Content Id", "Content Type", "Content Name", "User Is Authorized?", "Message", "Time Taken");
|
||||
foreach (var message in messages) {
|
||||
root.AddRow()
|
||||
.Column(message.Permission)
|
||||
.Column(message.Content?.Id.ToString())
|
||||
.Column(message.Content?.ContentItem.ContentType)
|
||||
.Column(message.Content?.ContentItem.GetContentName())
|
||||
.Column(message.Result ? "Yes" : "No")
|
||||
.Column(message.Result ? null : message.Message)
|
||||
.Column(message.Duration.ToTimingString());
|
||||
}
|
||||
|
||||
root.AddTimingSummary(messages);
|
||||
|
||||
return root.Build();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Linq;
|
||||
using Glimpse.Core.Extensibility;
|
||||
using Glimpse.Core.Extensions;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.Authorizer {
|
||||
public class AuthorizerTab : TabBase, ITabSetup, IKey, ILayoutControl {
|
||||
public override object GetData(ITabContext context) {
|
||||
var messages = context.GetMessages<AuthorizerMessage>().ToList();
|
||||
|
||||
if (!messages.Any()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
public override string Name => "Authorizer";
|
||||
|
||||
public void Setup(ITabSetupContext context) {
|
||||
context.PersistMessages<AuthorizerMessage>();
|
||||
}
|
||||
|
||||
public string Key => "glimpse_orchard_authorizer";
|
||||
|
||||
public bool KeysHeadings => false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using Glimpse.Core.Message;
|
||||
using Orchard.Glimpse.Models;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.Cache {
|
||||
public class CacheMessage : MessageBase, IDurationMessage {
|
||||
public string Action { get; set; }
|
||||
public string Key { get; set; }
|
||||
public object Value { get; set; }
|
||||
public string Result { get; set; }
|
||||
public TimeSpan? ValidFor { get; set; }
|
||||
public TimeSpan Duration { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
using Glimpse.Core.Extensibility;
|
||||
using Glimpse.Core.Tab.Assist;
|
||||
using Orchard.Glimpse.Extensions;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.Cache {
|
||||
public class CacheMessagesConverter : SerializationConverter<IEnumerable<CacheMessage>> {
|
||||
public override object Convert(IEnumerable<CacheMessage> messages) {
|
||||
var root = new TabSection("Action", "Valid For", "Key", "Result", "Value", "Time Taken");
|
||||
foreach (var message in messages) {
|
||||
root.AddRow()
|
||||
.Column(message.Action)
|
||||
.Column(message.ValidFor?.ToReadableString())
|
||||
.Column(message.Key)
|
||||
.Column(message.Result)
|
||||
.Column(message.Value)
|
||||
.Column(message.Duration.ToTimingString())
|
||||
.QuietIf(message.Result == "Miss");
|
||||
}
|
||||
|
||||
root.AddTimingSummary(messages);
|
||||
|
||||
return root.Build();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Linq;
|
||||
using Glimpse.Core.Extensibility;
|
||||
using Glimpse.Core.Extensions;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.Cache {
|
||||
public class CacheTab : TabBase, ITabSetup, IKey, ILayoutControl {
|
||||
public override object GetData(ITabContext context) {
|
||||
var messages = context.GetMessages<CacheMessage>().ToList();
|
||||
|
||||
if (!messages.Any()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
public override string Name => "Cache Service";
|
||||
|
||||
public void Setup(ITabSetupContext context) {
|
||||
context.PersistMessages<CacheMessage>();
|
||||
}
|
||||
|
||||
public string Key => "glimpse_orchard_cache";
|
||||
|
||||
public bool KeysHeadings => false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using Glimpse.Core.Message;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Glimpse.Models;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.ContentManager {
|
||||
public class ContentManagerGetMessage : MessageBase, IDurationMessage {
|
||||
public int ContentId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ContentType { get; set; }
|
||||
public VersionOptions VersionOptions { get; set; }
|
||||
public TimeSpan Duration { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Glimpse.Core.Extensibility;
|
||||
using Glimpse.Core.Tab.Assist;
|
||||
using Orchard.Glimpse.Extensions;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.ContentManager {
|
||||
public class ContentManagerGetMessagesConverter : SerializationConverter<IEnumerable<ContentManagerGetMessage>> {
|
||||
public override object Convert(IEnumerable<ContentManagerGetMessage> messages) {
|
||||
var root = new TabSection("Content Id", "Content Type", "Name", "Version Options", "Duration");
|
||||
foreach (var message in messages.OrderByDescending(m => m.Duration)) {
|
||||
root.AddRow()
|
||||
.Column(message.ContentId)
|
||||
.Column(message.ContentType)
|
||||
.Column(message.Name)
|
||||
.Column(message.VersionOptions)
|
||||
.Column(message.Duration.ToTimingString());
|
||||
}
|
||||
|
||||
root.AddTimingSummary(messages);
|
||||
|
||||
return root.Build();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using Glimpse.Core.Extensibility;
|
||||
using Glimpse.Core.Extensions;
|
||||
using System.Linq;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.ContentManager {
|
||||
public class ContentManagerTab : TabBase, ITabSetup, IKey, ILayoutControl {
|
||||
public override object GetData(ITabContext context) {
|
||||
var messages = context.GetMessages<ContentManagerGetMessage>().ToList();
|
||||
|
||||
if (!messages.Any()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
public override string Name => "Content Manager";
|
||||
|
||||
public void Setup(ITabSetupContext context) {
|
||||
context.PersistMessages<ContentManagerGetMessage>();
|
||||
}
|
||||
|
||||
public string Key => "glimpse_orchard_contentmanager";
|
||||
|
||||
public bool KeysHeadings => false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using Glimpse.Core.Message;
|
||||
using Orchard.Glimpse.Models;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.Layers {
|
||||
public class LayerMessage : MessageBase, IDurationMessage {
|
||||
public string Name { get; set; }
|
||||
public string Rule { get; set; }
|
||||
public bool Active { get; set; }
|
||||
public string EditUrl { get; set; }
|
||||
public TimeSpan Duration { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Glimpse.Core.Extensibility;
|
||||
using Glimpse.Core.Tab.Assist;
|
||||
using Orchard.Glimpse.Extensions;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.Layers {
|
||||
public class LayerMessagesConverter : SerializationConverter<IEnumerable<LayerMessage>> {
|
||||
public override object Convert(IEnumerable<LayerMessage> messages) {
|
||||
var root = new TabSection("Layer Name", "Layer Rule", "Active", "Actions", "Evaluation Time");
|
||||
foreach (var message in messages.OrderByDescending(m => m.Duration)) {
|
||||
root.AddRow()
|
||||
.Column(message.Name)
|
||||
.Column(message.Rule)
|
||||
.Column(message.Active ? "Yes" : "No")
|
||||
.Column(@"<a href='" + message.EditUrl + "'>Edit</a>").Raw()
|
||||
.Column(message.Duration.ToTimingString())
|
||||
.QuietIf(!message.Active);
|
||||
}
|
||||
|
||||
root.AddTimingSummary(messages);
|
||||
|
||||
return root.Build();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Linq;
|
||||
using Glimpse.Core.Extensibility;
|
||||
using Glimpse.Core.Extensions;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.Layers {
|
||||
public class LayerTab : TabBase, ITabSetup, IKey {
|
||||
public override object GetData(ITabContext context) {
|
||||
var messages = context.GetMessages<LayerMessage>().ToList();
|
||||
|
||||
if (!messages.Any()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
public override string Name => "Layers";
|
||||
|
||||
public void Setup(ITabSetupContext context) {
|
||||
context.PersistMessages<LayerMessage>();
|
||||
}
|
||||
|
||||
public string Key => "glimpse_orchard_layers";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using Glimpse.Core.Message;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.Glimpse.Models;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.Parts {
|
||||
public class PartMessage : MessageBase, IDurationMessage {
|
||||
public int ContentId { get; set; }
|
||||
public ContentPartDefinition PartDefinition { get; set; }
|
||||
public string DisplayType { get; set; }
|
||||
public string ContentName { get; set; }
|
||||
public string ContentType { get; set; }
|
||||
public TimeSpan Duration { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
using Glimpse.Core.Extensibility;
|
||||
using Glimpse.Core.Tab.Assist;
|
||||
using Orchard.Glimpse.Extensions;
|
||||
using Orchard.Utility.Extensions;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.Parts {
|
||||
public class PartMessagesConverter : SerializationConverter<IEnumerable<PartMessage>> {
|
||||
public override object Convert(IEnumerable<PartMessage> messages) {
|
||||
var root = new TabSection("Content Id", "Content Name", "Content Type", "Part", "Display Type", "Duration");
|
||||
foreach (var message in messages) {
|
||||
root.AddRow()
|
||||
.Column(message.ContentId)
|
||||
.Column(message.ContentName)
|
||||
.Column(message.ContentType.CamelFriendly())
|
||||
.Column(message.PartDefinition?.Name.CamelFriendly())
|
||||
.Column(message.DisplayType)
|
||||
.Column(message.Duration.ToTimingString());
|
||||
}
|
||||
|
||||
root.AddTimingSummary(messages);
|
||||
|
||||
return root.Build();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Glimpse.Core.Extensibility;
|
||||
using Glimpse.Core.Extensions;
|
||||
using System.Linq;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.Parts {
|
||||
public class PartTab : TabBase, ITabSetup, IKey {
|
||||
public override object GetData(ITabContext context) {
|
||||
var messages = context.GetMessages<PartMessage>().ToList();
|
||||
|
||||
if (!messages.Any()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
public override string Name => "Parts";
|
||||
|
||||
public void Setup(ITabSetupContext context) {
|
||||
context.PersistMessages<PartMessage>();
|
||||
}
|
||||
|
||||
public string Key => "glimpse_orchard_parts";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Glimpse.Core.Message;
|
||||
using Orchard.DisplayManagement.Shapes;
|
||||
using Orchard.Glimpse.Models;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.Shapes {
|
||||
public class ShapeMessage : MessageBase, IDurationMessage {
|
||||
private readonly ShapeMetadata _metaData;
|
||||
|
||||
public ShapeMessage(ShapeMetadata metaData) {
|
||||
_metaData = metaData;
|
||||
}
|
||||
|
||||
public string BindingName { get; set; }
|
||||
public string BindingSource { get; set; }
|
||||
|
||||
public string Type => _metaData.Type;
|
||||
|
||||
public string DisplayType => _metaData.DisplayType;
|
||||
|
||||
public string Position => _metaData.Position;
|
||||
|
||||
public string PlacementSource => _metaData.PlacementSource;
|
||||
|
||||
public string Prefix => _metaData.Prefix;
|
||||
|
||||
public IList<string> Wrappers => _metaData.Wrappers.Any() ? _metaData.Wrappers : null;
|
||||
|
||||
public IList<string> Alternates => _metaData.Alternates.Any() ? _metaData.Alternates : null;
|
||||
|
||||
public IList<string> BindingSources => _metaData.BindingSources.Any() ? _metaData.BindingSources : null;
|
||||
|
||||
public TimeSpan Duration { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Collections.Generic;
|
||||
using Glimpse.Core.Extensibility;
|
||||
using Glimpse.Core.Tab.Assist;
|
||||
using Orchard.Glimpse.Extensions;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.Shapes {
|
||||
public class ShapesMessagesConverter : SerializationConverter<IEnumerable<ShapeMessage>> {
|
||||
public override object Convert(IEnumerable<ShapeMessage> messages) {
|
||||
var root = new TabSection("Type", "Display Type", "Position", "Placement Source", "Prefix", "Binding Source", "Available Binding Sources", "Wrappers", "Alternates", "Build Display Duration");
|
||||
foreach (var message in messages) {
|
||||
root.AddRow()
|
||||
.Column(message.Type)
|
||||
.Column(message.DisplayType)
|
||||
.Column(message.Position)
|
||||
.Column(message.PlacementSource)
|
||||
.Column(message.Prefix)
|
||||
.Column(message.BindingSource)
|
||||
.Column(message.BindingSources)
|
||||
.Column(message.Wrappers)
|
||||
.Column(message.Alternates)
|
||||
.Column(message.Duration.ToTimingString());
|
||||
}
|
||||
|
||||
return root.Build();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Linq;
|
||||
using Glimpse.Core.Extensibility;
|
||||
using Glimpse.Core.Extensions;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.Shapes {
|
||||
public class ShapesTab : TabBase, ITabSetup, IKey, ILayoutControl {
|
||||
public override object GetData(ITabContext context) {
|
||||
var messages = context.GetMessages<ShapeMessage>().ToList();
|
||||
|
||||
if (!messages.Any()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
public override string Name => "Shapes";
|
||||
|
||||
public void Setup(ITabSetupContext context) {
|
||||
context.PersistMessages<ShapeMessage>();
|
||||
}
|
||||
|
||||
public string Key => "glimpse_orchard_shapes";
|
||||
|
||||
public bool KeysHeadings => false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using Glimpse.Core.Message;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs {
|
||||
public class TimelineMessage : MessageBase, ITimelineMessage {
|
||||
public TimeSpan Offset { get; set; }
|
||||
public TimeSpan Duration { get; set; }
|
||||
public DateTime StartTime { get; set; }
|
||||
public string EventName { get; set; }
|
||||
public TimelineCategoryItem EventCategory { get; set; }
|
||||
public string EventSubText { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using Glimpse.Core.Message;
|
||||
using Orchard.Glimpse.Models;
|
||||
using Orchard.Widgets.Models;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.Widgets {
|
||||
public class WidgetMessage : MessageBase, IDurationMessage {
|
||||
public int ContentId { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Zone { get; set; }
|
||||
public string Position { get; set; }
|
||||
public string TechnicalName { get; set; }
|
||||
public string EditUrl { get; set; }
|
||||
public LayerPart Layer { get; set; }
|
||||
public TimeSpan Duration { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Glimpse.Core.Extensibility;
|
||||
using Glimpse.Core.Tab.Assist;
|
||||
using Orchard.Glimpse.Extensions;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.Widgets {
|
||||
public class WidgetMessagesConverter : SerializationConverter<IEnumerable<WidgetMessage>> {
|
||||
public override object Convert(IEnumerable<WidgetMessage> messages) {
|
||||
var root = new TabSection("Id", "Widget Title", "Widget Type", "Layer", "Layer Rule", "Zone", "Position", "Technical Name", "Actions", "Build Display Duration");
|
||||
foreach (var message in messages.OrderByDescending(m => m.Duration)) {
|
||||
root.AddRow()
|
||||
.Column(message.ContentId)
|
||||
.Column(message.Title)
|
||||
.Column(message.Type)
|
||||
.Column(message.Layer.Name)
|
||||
.Column(message.Layer.LayerRule)
|
||||
.Column(message.Zone)
|
||||
.Column(message.Position)
|
||||
.Column(message.TechnicalName)
|
||||
.Column(@"<a href='" + message.EditUrl + "'>Edit</a>").Raw()
|
||||
.Column(message.Duration.ToTimingString());
|
||||
}
|
||||
|
||||
root.AddTimingSummary(messages);
|
||||
|
||||
return root.Build();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Glimpse.Core.Extensibility;
|
||||
using Glimpse.Core.Extensions;
|
||||
using System.Linq;
|
||||
|
||||
namespace Orchard.Glimpse.Tabs.Widgets {
|
||||
public class WidgetTab : TabBase, ITabSetup, IKey {
|
||||
public override object GetData(ITabContext context) {
|
||||
var messages = context.GetMessages<WidgetMessage>().ToList();
|
||||
|
||||
if (!messages.Any()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
public override string Name => "Widgets";
|
||||
|
||||
public void Setup(ITabSetupContext context) {
|
||||
context.PersistMessages<WidgetMessage>();
|
||||
}
|
||||
|
||||
public string Key => "glimpse_orchard_widgets";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Glimpse.Core.Message;
|
||||
|
||||
namespace Orchard.Glimpse {
|
||||
public class TimelineCategories {
|
||||
public static TimelineCategoryItem Cache => new TimelineCategoryItem("Cache", "#154B87", "#154B87");
|
||||
public static TimelineCategoryItem Layers => new TimelineCategoryItem("Layers", "#E6261D", "#E6261D");
|
||||
public static TimelineCategoryItem Parts => new TimelineCategoryItem("Parts", "#169871", "#169871");
|
||||
public static TimelineCategoryItem ContentManager => new TimelineCategoryItem("Content Manager", "#603182", "#603182");
|
||||
public static TimelineCategoryItem Shapes => new TimelineCategoryItem("Shapes", "#bcbb27", "#bcbb27");
|
||||
public static TimelineCategoryItem Authorizer => new TimelineCategoryItem("Authorizer", "#da7520", "#da7520");
|
||||
public static TimelineCategoryItem Widgets => new TimelineCategoryItem("Widgets", "#84DCC6", "#84DCC6");
|
||||
}
|
||||
}
|
||||
102
src/Orchard.Web/Modules/Orchard.Glimpse/Web.config
Normal file
102
src/Orchard.Web/Modules/Orchard.Glimpse/Web.config
Normal file
@@ -0,0 +1,102 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||
<remove name="host" />
|
||||
<remove name="pages" />
|
||||
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
|
||||
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<system.web.webPages.razor>
|
||||
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<pages pageBaseType="Orchard.Mvc.ViewEngines.Razor.WebViewPage">
|
||||
<namespaces>
|
||||
<add namespace="System.Web.Mvc" />
|
||||
<add namespace="System.Web.Mvc.Ajax" />
|
||||
<add namespace="System.Web.Mvc.Html" />
|
||||
<add namespace="System.Web.Routing" />
|
||||
<add namespace="System.Web.WebPages" />
|
||||
<add namespace="System.Linq" />
|
||||
<add namespace="System.Collections.Generic" />
|
||||
<add namespace="Orchard.Mvc.Html" />
|
||||
</namespaces>
|
||||
</pages>
|
||||
</system.web.webPages.razor>
|
||||
<!--
|
||||
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
|
||||
|
||||
The following attributes can be set on the <httpRuntime> tag.
|
||||
<system.Web>
|
||||
<httpRuntime targetFramework="4.5.2" />
|
||||
</system.Web>
|
||||
-->
|
||||
<system.web>
|
||||
<compilation targetFramework="4.5.2">
|
||||
<assemblies>
|
||||
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
|
||||
<add assembly="System.Web.Mvc, Version=5.2.3, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<add assembly="Orchard.Framework,Culture=neutral, PublicKeyToken=null" />
|
||||
<add assembly="Orchard.Core,Culture=neutral, PublicKeyToken=null" />
|
||||
</assemblies>
|
||||
</compilation>
|
||||
</system.web>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.5.0.0" newVersion="3.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.4000" newVersion="4.0.0.4000" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false" />
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
15
src/Orchard.Web/Modules/Orchard.Glimpse/packages.config
Normal file
15
src/Orchard.Web/Modules/Orchard.Glimpse/packages.config
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Autofac" version="3.5.2" targetFramework="net452" />
|
||||
<package id="FluentNHibernate" version="2.0.3.0" targetFramework="net452" />
|
||||
<package id="Glimpse" version="1.8.6" targetFramework="net452" />
|
||||
<package id="Glimpse.Ado" version="1.7.3" targetFramework="net452" />
|
||||
<package id="Glimpse.AspNet" version="1.9.2" targetFramework="net452" />
|
||||
<package id="Glimpse.Mvc5" version="1.5.3" targetFramework="net452" />
|
||||
<package id="Iesi.Collections" version="4.0.1.4000" targetFramework="net452" />
|
||||
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net452" />
|
||||
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net452" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net452" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net452" />
|
||||
<package id="NHibernate" version="4.0.1.4000" targetFramework="net452" />
|
||||
</packages>
|
||||
@@ -54,6 +54,18 @@
|
||||
<HintPath>..\packages\Autofac.3.5.2\lib\net40\Autofac.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Glimpse.AspNet, Version=1.9.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Glimpse.AspNet.1.9.2\lib\net45\Glimpse.AspNet.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Glimpse.Core, Version=1.8.6.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Glimpse.1.8.6\lib\net45\Glimpse.Core.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Glimpse.Mvc5, Version=1.5.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Glimpse.Mvc5.1.5.3\lib\net45\Glimpse.Mvc5.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@@ -173,6 +185,10 @@
|
||||
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
|
||||
<Name>Orchard.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="Modules\Orchard.Glimpse\Orchard.Glimpse.csproj">
|
||||
<Project>{71e17466-d937-49d7-8c7d-77ccbab8ccf4}</Project>
|
||||
<Name>Orchard.Glimpse</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Config\Host.config" />
|
||||
|
||||
@@ -9,4 +9,6 @@
|
||||
<customErrors mode="RemoteOnly" xdt:Transform="SetAttributes(mode)" />
|
||||
<machineKey validationKey="AutoGenerate" decryptionKey="AutoGenerate" xdt:Transform="SetAttributes(validationKey,decryptionKey)" />
|
||||
</system.web>
|
||||
|
||||
<glimpse xdt:Transform="SetAttributes(defaultRuntimePolicy)" defaultRuntimePolicy="Off" />
|
||||
</configuration>
|
||||
@@ -6,6 +6,7 @@
|
||||
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
|
||||
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
<section name="glimpse" type="Glimpse.Core.Configuration.Section, Glimpse.Core" />
|
||||
</configSections>
|
||||
|
||||
<appSettings>
|
||||
@@ -98,19 +99,30 @@
|
||||
<add namespace="Orchard.Mvc.Html" />
|
||||
</namespaces>
|
||||
</pages>
|
||||
|
||||
<httpModules>
|
||||
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" />
|
||||
</httpModules>
|
||||
<httpHandlers>
|
||||
<add path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" />
|
||||
</httpHandlers>
|
||||
</system.web>
|
||||
|
||||
<system.webServer>
|
||||
<!-- Prevent IIS from only allowing integrated mode configuration. -->
|
||||
<validation validateIntegratedModeConfiguration="false" />
|
||||
|
||||
<modules runAllManagedModulesForAllRequests="false">
|
||||
<remove name="OutputCache" />
|
||||
<remove name="WarmupHttpModule" />
|
||||
<add name="WarmupHttpModule" type="Orchard.WarmupStarter.WarmupHttpModule, Orchard.WarmupStarter, Version=1.10, Culture=neutral" />
|
||||
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" preCondition="integratedMode" />
|
||||
</modules>
|
||||
<handlers accessPolicy="Script">
|
||||
<!-- Clear all handlers, prevents executing code file extensions or returning any file contents. -->
|
||||
<clear />
|
||||
<!-- Ensure the Glimpse handlers is added before the 404 catch all handler. -->
|
||||
<add name="Glimpse" path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" preCondition="integratedMode" />
|
||||
<!-- Return 404 for all requests via a managed handler. The URL routing handler will substitute the MVC request handler when routes match. -->
|
||||
<add name="NotFound" path="*" verb="*" type="System.Web.HttpNotFoundHandler" preCondition="integratedMode" requireAccess="Script" />
|
||||
<!-- WebApi -->
|
||||
@@ -255,4 +267,34 @@
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
||||
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
|
||||
<logging level="Error" logLocation="App_data/Logs/Glimpse.log" />
|
||||
<tabs>
|
||||
<ignoredTypes>
|
||||
<add type="Glimpse.Mvc.Tab.Views, Glimpse.Mvc5" />
|
||||
<add type="Glimpse.Mvc.Tab.ModelBinding, Glimpse.Mvc5" />
|
||||
<add type="Glimpse.Mvc.Tab.Metadata, Glimpse.Mvc5" />
|
||||
<add type="Glimpse.AspNet.Tab.Cache, Glimpse.AspNet" />
|
||||
<add type="Glimpse.AspNet.Tab.Routes, Glimpse.AspNet" />
|
||||
<add type="Glimpse.AspNet.Tab.Session, Glimpse.AspNet" />
|
||||
</ignoredTypes>
|
||||
</tabs>
|
||||
<inspectors>
|
||||
<ignoredTypes>
|
||||
<add type="Glimpse.Mvc.Inspector.ViewEngineInspector, Glimpse.Mvc5" />
|
||||
<add type="Glimpse.Mvc.Inspector.DependencyInjectionInspector, Glimpse.Mvc5" />
|
||||
<add type="Glimpse.Mvc.Inspector.ModelBinderInspector, Glimpse.Mvc5" />
|
||||
<add type="Glimpse.AspNet.Inspector.RoutesInspector, Glimpse.AspNet" />
|
||||
</ignoredTypes>
|
||||
</inspectors>
|
||||
<runtimePolicies>
|
||||
<ignoredTypes>
|
||||
<!-- Uncomment the line below to allow Glimpse to be enabled for remote requests -->
|
||||
<!-- NOTE: If you uncomment this line, you can still restrict access to a set of whitelisted IP Address by adding the app setting `Orchard.Glimpse:WhitelistedIpAddresses` with a value of a semi colon separated IP Addresses to allow into the `appSettings` section of this file -->
|
||||
<!--<add type="Glimpse.AspNet.Policy.LocalPolicy, Glimpse.AspNet" />-->
|
||||
</ignoredTypes>
|
||||
</runtimePolicies>
|
||||
<!--For more information on how to configure Glimpse, please visit http://getglimpse.com/Help/Configuration or access {your site}/Glimpse.axd for even more details and a Configuration Tool to support you.-->
|
||||
</glimpse>
|
||||
</configuration>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Autofac" version="3.5.2" targetFramework="net452" />
|
||||
<package id="Glimpse" version="1.8.6" targetFramework="net452" />
|
||||
<package id="Glimpse.AspNet" version="1.9.2" targetFramework="net452" />
|
||||
<package id="Glimpse.Mvc5" version="1.5.3" targetFramework="net452" />
|
||||
<package id="log4net" version="2.0.3" targetFramework="net452" />
|
||||
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net452" />
|
||||
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net452" />
|
||||
|
||||
@@ -281,6 +281,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Azure.Tests", "Orch
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.OpenId", "Orchard.Web\Modules\Orchard.OpenId\Orchard.OpenId.csproj", "{42E217C1-E163-4B6B-9E8F-42BEE21B6896}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Glimpse", "Orchard.Web\Modules\Orchard.Glimpse\Orchard.Glimpse.csproj", "{71E17466-D937-49D7-8C7D-77CCBAB8CCF4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
CodeCoverage|Any CPU = CodeCoverage|Any CPU
|
||||
@@ -1124,6 +1126,16 @@ Global
|
||||
{42E217C1-E163-4B6B-9E8F-42BEE21B6896}.FxCop|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{42E217C1-E163-4B6B-9E8F-42BEE21B6896}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{42E217C1-E163-4B6B-9E8F-42BEE21B6896}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{71E17466-D937-49D7-8C7D-77CCBAB8CCF4}.CodeCoverage|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{71E17466-D937-49D7-8C7D-77CCBAB8CCF4}.CodeCoverage|Any CPU.Build.0 = Release|Any CPU
|
||||
{71E17466-D937-49D7-8C7D-77CCBAB8CCF4}.Coverage|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{71E17466-D937-49D7-8C7D-77CCBAB8CCF4}.Coverage|Any CPU.Build.0 = Release|Any CPU
|
||||
{71E17466-D937-49D7-8C7D-77CCBAB8CCF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{71E17466-D937-49D7-8C7D-77CCBAB8CCF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{71E17466-D937-49D7-8C7D-77CCBAB8CCF4}.FxCop|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{71E17466-D937-49D7-8C7D-77CCBAB8CCF4}.FxCop|Any CPU.Build.0 = Release|Any CPU
|
||||
{71E17466-D937-49D7-8C7D-77CCBAB8CCF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{71E17466-D937-49D7-8C7D-77CCBAB8CCF4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -1213,6 +1225,7 @@ Global
|
||||
{D4E8F7C8-2DB2-4C50-A422-DA1DF1E3CC73} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
|
||||
{1CC62F45-E6FF-43D5-84BF-509A1085D994} = {74E681ED-FECC-4034-B9BD-01B0BB1BDECA}
|
||||
{42E217C1-E163-4B6B-9E8F-42BEE21B6896} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
|
||||
{71E17466-D937-49D7-8C7D-77CCBAB8CCF4} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EnterpriseLibraryConfigurationToolBinariesPath = packages\TransientFaultHandling.Core.5.1.1209.1\lib\NET4
|
||||
|
||||
Reference in New Issue
Block a user