private async Task RecordAuditTrailEventAsync(string eventName, IContent content)
        {
            var buildingAuditTrailEventContext = new BuildingAuditTrailEventContext(content.ContentItem, eventName);

            await _auditTrailEvents.InvokeAsync((provider, context) =>
                                                provider.BuildingAuditTrailEventAsync(context), buildingAuditTrailEventContext, Logger);

            // -1 is a unique contentItem.Id that only Preview is using such that another stored document can't have
            // the same one in the IContentManagerSession index.
            if (buildingAuditTrailEventContext.IsCanceled || content.ContentItem.Id == -1)
            {
                return;
            }

            var versionNumber = await _session.Query <ContentItem, ContentItemIndex>()
                                .Where(contentItemIndex => contentItemIndex.ContentItemId == content.ContentItem.ContentItemId)
                                .CountAsync();

            var eventData = new Dictionary <string, object>
            {
                { "ContentItem", content.ContentItem },
                { "VersionNumber", versionNumber }
            };

            await _auditTrailManager.AddAuditTrailEventAsync <ContentAuditTrailEventProvider>(
                new AuditTrailContext(eventName, _hca.GetCurrentUserName(), eventData, "content", content.ContentItem.ContentItemId));
        }
示例#2
0
        public async Task BuildingAuditTrailEventAsync(BuildingAuditTrailEventContext buildingAuditTrailEventContext)
        {
            var siteSettings = await _siteService.GetSiteSettingsAsync();

            var auditTrailSettings = siteSettings.As <AuditTrailSettings>();
            var contentType        = buildingAuditTrailEventContext.ContentItem.ContentType;

            if (auditTrailSettings.BlacklistedContentTypeNames.Contains(contentType))
            {
                buildingAuditTrailEventContext.IsCanceled = true;
            }
        }