Exemplo n.º 1
0
//        public string SerializeProviderConfiguration(IEnumerable<AuditTrailEventSetting> settings) {
//            var doc = new XDocument(
//                new XElement("Events",
//                    settings.Select(x =>
//                        new XElement("Event",
//                            new XAttribute("Name", x.EventName),
//                            new XAttribute("IsEnabled", x.IsEnabled)))));
//
//            return doc.ToString(SaveOptions.DisableFormatting);
//        }
//
//        public IEnumerable<AuditTrailEventSetting> DeserializeProviderConfiguration(string data) {
//            if (String.IsNullOrWhiteSpace(data))
//                return Enumerable.Empty<AuditTrailEventSetting>();
//
//            try {
//                var doc = XDocument.Parse(data);
//                return doc.Element("Events").Elements("Event").Select(x => new AuditTrailEventSetting {
//                    EventName = x.Attr<string>("Name"),
//                    IsEnabled = x.Attr<bool>("IsEnabled")
//                }).ToArray();
//
//            }
//            catch (Exception ex) {
//                Logger.LogError(ex, "Error occurred during deserialization of audit trail settings.");
//            }
//            return Enumerable.Empty<AuditTrailEventSetting>();
//        }
//
//        private async Task<string> GetClientAddress()
//        {
//            var _siteService =   _serviceProvider.GetRequiredService<ISiteService>();
//            var settings = (await _siteService.GetSiteSettingsAsync()).As<AuditTrailSettings>();
//
//            if (!settings.EnableClientIpAddressLogging)
//                return null;
//
//            return _clientHostAddressAccessor.GetClientAddress();
//        }

        private bool  IsEventEnabled(ActivityStreamEventDescriptor eventDescriptor)
        {
            //todo
            return(true);

            /*if (eventDescriptor.IsMandatory)
             * return true;
             *
             * //  var settingsDictionary = _cacheManager.Get("AuditTrail.EventSettings", context => {
             * //  context.Monitor(_signals.When("AuditTrail.EventSettings"));
             *
             *
             *
             *
             * //   return await _siteService.GetSiteSettingsAsync().As<AuditTrailPartSettings>().EventSettings.ToDictionary(x => x.EventName);
             * //});
             * var settingsDictionary = await GetAuditTrailEventSettings();
             * var setting = settingsDictionary.ContainsKey(eventDescriptor.Event) ? settingsDictionary[eventDescriptor.Event] : default(AuditTrailEventSetting);
             * return setting?.IsEnabled ?? eventDescriptor.IsEnabledByDefault;*/
        }
Exemplo n.º 2
0
 /// <summary>
 /// Describes a single audit trail event.
 /// </summary>
 /// <param name="record">The audit trail event record for which to find its descriptor.</param>
 /// <returns>A single audit trail event descriptor.</returns>
 public ActivityStreamEventDescriptor DescribeEvent(ActivityStreamItem record)
 {
     return(DescribeEvent(record.FullEventName) ?? ActivityStreamEventDescriptor.Basic(record));
 }