diff --git a/src/Orchard.Web/Modules/Orchard.AuditTrail/Models/AuditTrailEventRecord.cs b/src/Orchard.Web/Modules/Orchard.AuditTrail/Models/AuditTrailEventRecord.cs index 9b9dbcedb..81a9350bf 100644 --- a/src/Orchard.Web/Modules/Orchard.AuditTrail/Models/AuditTrailEventRecord.cs +++ b/src/Orchard.Web/Modules/Orchard.AuditTrail/Models/AuditTrailEventRecord.cs @@ -2,21 +2,63 @@ using Orchard.Data.Conventions; namespace Orchard.AuditTrail.Models { + + /// + /// Audit Trail Event Record in the database. + /// public class AuditTrailEventRecord { public virtual int Id { get; set; } + + /// + /// The time when the event occurred. + /// public virtual DateTime CreatedUtc { get; set; } + + /// + /// The user name of the user who caused the event to occur. + /// public virtual string UserName { get; set; } + + /// + /// The name of the event. + /// public virtual string EventName { get; set; } + + /// + /// The full name of the event. + /// public virtual string FullEventName { get; set; } + + /// + /// The category the event belongs to. + /// public virtual string Category { get; set; } - + + /// + /// The data of the event. + /// [StringLengthMax] public virtual string EventData { get; set; } + + /// + /// The filter key of the event. + /// public virtual string EventFilterKey { get; set; } + + /// + /// The filter data of the event. + /// public virtual string EventFilterData { get; set; } + /// + /// The comment of the event. + /// [StringLengthMax] public virtual string Comment { get; set; } + + /// + /// The IP address of the user who caused the event to occur. + /// public virtual string ClientIpAddress { get; set; } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.AuditTrail/Models/AuditTrailEventRecordResult.cs b/src/Orchard.Web/Modules/Orchard.AuditTrail/Models/AuditTrailEventRecordResult.cs index 4480a7471..92db483a0 100644 --- a/src/Orchard.Web/Modules/Orchard.AuditTrail/Models/AuditTrailEventRecordResult.cs +++ b/src/Orchard.Web/Modules/Orchard.AuditTrail/Models/AuditTrailEventRecordResult.cs @@ -1,6 +1,18 @@ namespace Orchard.AuditTrail.Models { + + /// + /// The created audit trail event result + /// public class AuditTrailEventRecordResult { + + /// + /// The created + /// public AuditTrailEventRecord Record { get; set; } + + /// + /// Determines whether AuditTrailEventRecordResult is disabled for . + /// public bool IsDisabled { get; set; } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.AuditTrail/Services/AuditTrailManager.cs b/src/Orchard.Web/Modules/Orchard.AuditTrail/Services/AuditTrailManager.cs index 441c08c62..0b7377db0 100644 --- a/src/Orchard.Web/Modules/Orchard.AuditTrail/Services/AuditTrailManager.cs +++ b/src/Orchard.Web/Modules/Orchard.AuditTrail/Services/AuditTrailManager.cs @@ -16,6 +16,10 @@ using Orchard.Services; using Orchard.Settings; namespace Orchard.AuditTrail.Services { + + /// + /// Manage the audit trail. + /// public class AuditTrailManager : Component, IAuditTrailManager { private readonly IRepository _auditTrailRepository; private readonly IAuditTrailEventProvider _providers; @@ -52,6 +56,14 @@ namespace Orchard.AuditTrail.Services { _clientHostAddressAccessor = clientHostAddressAccessor; } + /// + /// Gets a page of event records from the audit trail. + /// + /// The page number to get records from. + /// The number of records to get. + /// The value to order by. + /// Optional. An object to filter the records on. + /// A page of event records. public IPageOfItems GetRecords( int page, int pageSize, @@ -102,10 +114,20 @@ namespace Orchard.AuditTrail.Services { }; } + /// + /// Gets a single event record from the audit trail by ID. + /// + /// The event record ID. + /// A single event record. public AuditTrailEventRecord GetRecord(int id) { return _auditTrailRepository.Get(id); } + /// + /// Builds a shape tree of filter displays. + /// + /// Input for each filter builder. + /// A tree of shapes. public dynamic BuildFilterDisplay(Filters filters) { var filterDisplay = (dynamic)_shapeFactory.Create("AuditTrailFilter"); var filterDisplayContext = new DisplayFilterContext(_shapeFactory, filters, filterDisplay); @@ -123,6 +145,17 @@ namespace Orchard.AuditTrail.Services { return filterDisplay; } + /// + /// Records an audit trail event. + /// + /// The audit trail event provider type to determine the scope of the event name. + /// The shorthand name of the event + /// The user to associate with the event. This is typically the currently loggedin user. + /// A property bag of custom event data that could be useful for implementations. These values aren't stored. Use the eventData parameter to persist additional data with the event. + /// A property bag of custom event data that will be stored with the event record. + /// The name of a custom key to use when filtering events. + /// The value of a custom filter key to filter on. + /// The created audit trail event record if the specified event was not disabled. public AuditTrailEventRecordResult CreateRecord(string eventName, IUser user, IDictionary properties = null, IDictionary eventData = null, string eventFilterKey = null, string eventFilterData = null) where T : IAuditTrailEventProvider { var eventDescriptor = DescribeEvent(eventName); if (!IsEventEnabled(eventDescriptor)) @@ -165,26 +198,49 @@ namespace Orchard.AuditTrail.Services { }; } + /// + /// Describes all audit trail events provided by the system. + /// + /// A list of audit trail category descriptors. public IEnumerable DescribeCategories() { var context = DescribeProviders(); return context.Describe(); } + /// + /// Describes all audit trail event providers. + /// public DescribeContext DescribeProviders() { var context = new DescribeContext(); _providers.Describe(context); return context; } + /// + /// Describes a single audit trail event. + /// + /// The audit trail event record for which to find its descriptor. + /// A single audit trail event descriptor. public AuditTrailEventDescriptor DescribeEvent(AuditTrailEventRecord record) { return DescribeEvent(record.FullEventName) ?? AuditTrailEventDescriptor.Basic(record); } + /// + /// Describes a single audit trail event. + /// + /// The scope of the specified event name. + /// The shorthand name of the event. + /// A single audit trail event descriptor. public AuditTrailEventDescriptor DescribeEvent(string eventName) where T : IAuditTrailEventProvider { var fullyQualifiedEventName = EventNameExtensions.GetFullyQualifiedEventName(eventName); return DescribeEvent(fullyQualifiedEventName); } + /// + /// Describes a single audit trail event. + /// + /// The fully qualified event name to describe. + /// A single audit trail event descriptor. public AuditTrailEventDescriptor DescribeEvent(string fullyQualifiedEventName) { var categoryDescriptors = DescribeCategories(); var eventDescriptorQuery = diff --git a/src/Orchard.Web/Modules/Orchard.AuditTrail/Services/EventDataSerializer.cs b/src/Orchard.Web/Modules/Orchard.AuditTrail/Services/EventDataSerializer.cs index a9192ab16..0285f2078 100644 --- a/src/Orchard.Web/Modules/Orchard.AuditTrail/Services/EventDataSerializer.cs +++ b/src/Orchard.Web/Modules/Orchard.AuditTrail/Services/EventDataSerializer.cs @@ -5,7 +5,17 @@ using Newtonsoft.Json; using Orchard.Logging; namespace Orchard.AuditTrail.Services { + + /// + /// A service responsible for serializing and deserializing audit trail event data. + /// public class EventDataSerializer : Component, IEventDataSerializer { + + /// + /// Serialize event data. + /// + /// eventData to be serialized. + /// The serialized data. public string Serialize(IDictionary eventData) { try { var json = JsonConvert.SerializeObject(eventData, Formatting.None); @@ -18,6 +28,11 @@ namespace Orchard.AuditTrail.Services { return null; } + /// + /// Deserialize event data. + /// + /// eventData to be deserialized. + /// The deserialized generic dictionary public IDictionary Deserialize(string eventData) { if (String.IsNullOrWhiteSpace(eventData)) return new Dictionary(); diff --git a/src/Orchard.Web/Modules/Orchard.AuditTrail/Services/IAuditTrailManager.cs b/src/Orchard.Web/Modules/Orchard.AuditTrail/Services/IAuditTrailManager.cs index 9e06e2da8..944cdc299 100644 --- a/src/Orchard.Web/Modules/Orchard.AuditTrail/Services/IAuditTrailManager.cs +++ b/src/Orchard.Web/Modules/Orchard.AuditTrail/Services/IAuditTrailManager.cs @@ -6,7 +6,12 @@ using Orchard.Collections; using Orchard.Security; namespace Orchard.AuditTrail.Services { + + /// + /// Manage the audit trail. + /// public interface IAuditTrailManager : IDependency { + /// /// Gets a page of event records from the audit trail. /// diff --git a/src/Orchard.Web/Modules/Orchard.AuditTrail/Services/IEventDataSerializer.cs b/src/Orchard.Web/Modules/Orchard.AuditTrail/Services/IEventDataSerializer.cs index 3fef8e8c4..c38fe5144 100644 --- a/src/Orchard.Web/Modules/Orchard.AuditTrail/Services/IEventDataSerializer.cs +++ b/src/Orchard.Web/Modules/Orchard.AuditTrail/Services/IEventDataSerializer.cs @@ -1,8 +1,24 @@ using System.Collections.Generic; namespace Orchard.AuditTrail.Services { + + /// + /// A service responsible for serializing and deserializing audit trail event data. + /// public interface IEventDataSerializer : IDependency { + + /// + /// Serialize event data. + /// + /// eventData to be serialized. + /// The serialized data. string Serialize(IDictionary eventData); + + /// + /// Deserialize event data. + /// + /// eventData to be deserialized. + /// The deserialized generic dictionary IDictionary Deserialize(string eventData); } } \ No newline at end of file