【问题标题】:How to convert StartDate and EndDate to DateTimeZone in Event Audit .Net?如何在 Event Audit .Net 中将 StartDate 和 EndDate 转换为 DateTimeZone?
【发布时间】:2021-05-16 14:22:54
【问题描述】:

{ "EventType": "订单:更新", “环境”: { "用户名": "费德里科", "机器名": "HP", "域名": "HP", "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

}

【问题讨论】:

    标签: audit.net


    【解决方案1】:

    您无法更改AuditEvent 属性的类型,但您可以使用custom actions 将custom fields 添加到审计事件中。

    例如:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-19
      • 2016-08-20
      • 1970-01-01
      • 2013-08-14
      • 1970-01-01
      相关资源
      最近更新 更多