如何在 Event Audit .Net 中将 StartDate 和 EndDate 转换为 DateTimeZone?

How to convert StartDate and EndDate to DateTimeZone in Event Audit .Net?

{ "EventType": "订单:更新", “环境”: { “用户名”:“费德里科”, "机器名": "惠普", "域名": "惠普", "CallingMethodName": "Audit.UnitTest.AuditTests.TestUpdate()", “异常”:空, “文化”:“en-GB” }, “目标”: { “类型”:“订单”, “老的”: { "OrderId": "39dc0d86-d5fc-4d2e-b918-fb1a97710c99", “状态”:2,

    },
    "New": {
        "OrderId": "39dc0d86-d5fc-4d2e-b918-fb1a97710c99",
        "Status": -1,
        
    }
},
"ReferenceId": "39dc0d86-d5fc-4d2e-b918-fb1a97710c99",           // <-- Custom Field
"Comments": ["Status Updated to Cancelled"],                     // <-- Comments
"StartDate": "2016-08-23T11:34:44.656101-05:00",
"EndDate": "2016-08-23T11:34:55.1810821-05:00",
"Duration": 8531

}

您无法更改 AuditEvent 属性的类型,但可以添加 custom fields to the audit event with custom actions.

例如:

Audit.Core.Configuration.AddCustomAction(ActionType.OnScopeCreated, scope =>
{
    scope.SetCustomField("StartDateTimeZone", GetCurrentDate());
});

Audit.Core.Configuration.AddCustomAction(ActionType.OnEventSaving, scope =>
{
    scope.SetCustomField("EndDateTimeZone", GetCurrentDate());
});