在servicestack响应中的ResponseStatus对象的stacktrace属性中,有一个时间戳,如下所示:
"StackTrace": [GetEmployee: 8/12/2015 9:09:35 PM]
然而,时间戳是UTC时间。我是否可以将servicestack配置为始终返回服务器(或本地)时间而不是UTC以进行堆栈跟踪错误?
答案 0 :(得分:1)
ServiceStack一致性使用DateTime.UtcNow
来提高整个代码库的性能和一致性。您无法直接更改DateTime.UtcNow
的硬编码使用情况,但您可以覆盖AppHost中的OnExceptionTypeFilter来修改/修饰返回的ResponseStatus
,这样您就可以替换现有的DateTime.Now
DateTime到public override void OnExceptionTypeFilter(
Exception ex, ResponseStatus responseStatus)
{
base.OnExceptionTypeFilter(ex, responseStatus);
var parts = (responseStatus.StackTrace ?? "").SplitOnFirst(']');
if (parts.Length != 2) return;
var requestName = parts[0].Substring(1).SplitOnFirst(':')[0];
responseStatus.StackTrace = "[{0}: {1}]{2}".Fmt(
requestName, DateTime.Now, parts[1]);
}
的内容如下:
Sub clearCells()
Dim ws As Worksheet
Dim lastrow As Long, currow As Long
Dim critvalue As String
Set ws = Sheets("Sheet1")
' Change A to a row with data in it
lastrow = ws.Range("A" & Rows.Count).End(xlUp).Offset(1).Row - 1
'Change 2 to the first row to check
For currow = 2 To lastrow
critvalue = "Attached Packaging"
' Change A to the row you are looking in
If ws.Range("A" & currow).Value = critvalue Then
' Use the currow to select the row and then create an offset
ws.Range("A" & currow).offset("B" & currow - 1).clear
ws.Range("A" & currow).offset("B" & currow + 1).clear
End If
Next currow
End Sub