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);
 }
Пример #2
0
 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);
 }
Пример #3
0
 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);
 }
        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());
        }
Пример #5
0
 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());
 }
Пример #6
0
        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);
        }