mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Storing EventData as XML instead of CData.
This commit is contained in:
@@ -1,11 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using Orchard.AuditTrail.Models;
|
using Orchard.AuditTrail.Models;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
using Orchard.Environment.Extensions;
|
using Orchard.Environment.Extensions;
|
||||||
using Orchard.Events;
|
|
||||||
using Orchard.ImportExport.Services;
|
using Orchard.ImportExport.Services;
|
||||||
|
|
||||||
namespace Orchard.AuditTrail.ImportExport {
|
namespace Orchard.AuditTrail.ImportExport {
|
||||||
@@ -22,7 +20,7 @@ namespace Orchard.AuditTrail.ImportExport {
|
|||||||
|
|
||||||
public void Exported(ExportContext context) {
|
public void Exported(ExportContext context) {
|
||||||
|
|
||||||
if (!((IEnumerable<string>)context.ExportOptions.CustomSteps).Contains("AuditTrail")) {
|
if (!context.ExportOptions.CustomSteps.Contains("AuditTrail")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,14 +35,14 @@ namespace Orchard.AuditTrail.ImportExport {
|
|||||||
|
|
||||||
foreach (var record in records) {
|
foreach (var record in records) {
|
||||||
root.Add(new XElement("Event",
|
root.Add(new XElement("Event",
|
||||||
new XAttribute("Name", record.Event),
|
CreateAttribute("Name", record.Event),
|
||||||
new XAttribute("Category", record.Category),
|
CreateAttribute("Category", record.Category),
|
||||||
new XAttribute("User", record.UserName),
|
CreateAttribute("User", record.UserName),
|
||||||
new XAttribute("CreatedUtc", record.CreatedUtc),
|
CreateAttribute("CreatedUtc", record.CreatedUtc),
|
||||||
new XAttribute("EventFilterKey", record.EventFilterKey),
|
CreateAttribute("EventFilterKey", record.EventFilterKey),
|
||||||
new XAttribute("EventFilterData", record.EventFilterData),
|
CreateAttribute("EventFilterData", record.EventFilterData),
|
||||||
CreateElement("Comment", record.Comment),
|
CreateElement("Comment", record.Comment),
|
||||||
CreateCDataElement("EventData", record.EventData)));
|
ParseEventData(record.EventData)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,8 +50,19 @@ namespace Orchard.AuditTrail.ImportExport {
|
|||||||
return !String.IsNullOrWhiteSpace(value) ? new XElement(name, value) : null;
|
return !String.IsNullOrWhiteSpace(value) ? new XElement(name, value) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static XElement CreateCDataElement(string name, string value) {
|
private static XAttribute CreateAttribute(string name, string value) {
|
||||||
return !String.IsNullOrWhiteSpace(value) ? new XElement(name, new XCData(value)) : null;
|
return !String.IsNullOrWhiteSpace(value) ? new XAttribute(name, value) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static XAttribute CreateAttribute(string name, object value) {
|
||||||
|
return new XAttribute(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static XElement ParseEventData(string eventData) {
|
||||||
|
if(String.IsNullOrWhiteSpace(eventData))
|
||||||
|
return new XElement("EventData");
|
||||||
|
|
||||||
|
return XElement.Parse(eventData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Orchard.Environment.Extensions;
|
using Orchard.Environment.Extensions;
|
||||||
using Orchard.Events;
|
|
||||||
using Orchard.ImportExport.Services;
|
using Orchard.ImportExport.Services;
|
||||||
|
|
||||||
namespace Orchard.AuditTrail.ImportExport {
|
namespace Orchard.AuditTrail.ImportExport {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace Orchard.AuditTrail.ImportExport {
|
|||||||
EventFilterKey = eventElement.Attr<string>("EventFilterKey"),
|
EventFilterKey = eventElement.Attr<string>("EventFilterKey"),
|
||||||
EventFilterData = eventElement.Attr<string>("EventFilterData"),
|
EventFilterData = eventElement.Attr<string>("EventFilterData"),
|
||||||
Comment = eventElement.El("Comment"),
|
Comment = eventElement.El("Comment"),
|
||||||
EventData = eventElement.El("EventData"),
|
EventData = eventElement.Element("EventData").ToString(),
|
||||||
};
|
};
|
||||||
|
|
||||||
_auditTrailEventRepository.Create(record);
|
_auditTrailEventRepository.Create(record);
|
||||||
|
|||||||
Reference in New Issue
Block a user