Hello,
We are seeing an issue with the default Excel Exporter, for example within the Audit Logs section of the site.
This was working properly, however, now that we have switched to handle multiple timezones, it is causing an exception. Here is what we did...
We added the following code to the Startup.cs class:
Clock.Provider = ClockProviders.Utc;
Now, when we navigate to the Audit Logs section of the site, and click Export to excel, we get "An internal error occurred during your request". Then, digging into the logs we see the following
ERROR 2018-10-19 11:30:38,069 [12 ] Mvc.ExceptionHandling.AbpExceptionFilter - The conversion could not be completed because the supplied DateTime did not have the Kind property set correctly. For example, when the Kind property is DateTimeKind.Local, the source time zone must be TimeZoneInfo.Local. Parameter name: sourceTimeZone System.ArgumentException: The conversion could not be completed because the supplied DateTime did not have the Kind property set correctly. For example, when the Kind property is DateTimeKind.Local, the source time zone must be TimeZoneInfo.Local. Parameter name: sourceTimeZone at System.TimeZoneInfo.ConvertTime(DateTime dateTime, TimeZoneInfo sourceTimeZone, TimeZoneInfo destinationTimeZone, TimeZoneInfoOptions flags, CachedData cachedData) at Abp.Timing.Timezone.TimezoneHelper.Convert(Nullable
1 date, String fromTimeZoneId, String toTimeZoneId) at Abp.Timing.Timezone.TimeZoneConverter.Convert(Nullable
1 date, Nullable1 tenantId, Int64 userId) at xxx.xxx.Auditing.Exporting.AuditLogListExcelExporter.<>c__DisplayClass3_0.<ExportToFile>b__1(AuditLogListDto _) at xxx.xxx.DataExporting.Excel.EpPlus.EpPlusExcelExporterBase.AddObjects[T](ExcelWorksheet sheet, Int32 startRowIndex, IList
1 items, Func2[] propertySelectors) at xxx.xxx.Auditing.Exporting.AuditLogListExcelExporter.<>c__DisplayClass3_0.<ExportToFile>b__0(ExcelPackage excelPackage) at xxx.xxx.DataExporting.Excel.EpPlus.EpPlusExcelExporterBase.CreateExcelPackage(String fileName, Action
1 creator) at xxx.xxx.Auditing.Exporting.AuditLogListExcelExporter.ExportToFile(List`1 auditLogListDtos) at xxx.xxx.Auditing.AuditLogAppService.d__6.MoveNext()--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at lambda_method(Closure , Object ) at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__23.MoveNext()
If I debug the Exporter when this is happening, I can see that the Kind
of one of the dates is correctly (or at least I think it is correctly set) to Utc
.
Undoing the code change that was made above, and debugging again when the Exporter is working, I can see that the Kind
of one of the DateTime is set to Unspecified
.
Can you please advice on how to correct this? Having enabled multiple timezones, are there additional code changes that need to be made? If so, where can I find documentation for this?
Thanks
Gary
7 Answer(s)
-
0
Hi,
Are you using TimeZoneConverter 2.4.1 or above ?
-
0
Naive question...
How would I know that?
-
0
@ismcagdas Can you provide any additional information in order for me to answer your question? Thanks. I would really like to get to the bottom of this problem.
-
1
Are you using TimeZoneConverter 2.4.1 or above ?
How would I know that?
Check the NuGet packages in .Core project.
-
0
@aaron @ismcagdas thank you both for your help so far.
I can confirm that I am currently using TimeZoneConverter 2.3.1. Is the recommendation to be using 2.4.1? Is it as simple as updating this single package? Or are there other packages that I would also need to update?
Thanks
-
0
That should be sufficient.
-
0
@aaron Thank you very much. I am happy to confirm that updating to the latest TimeZoneConverter library (at the time of writing 2.4.2) corrected the problem that I was seeing.