TimeSpan and Nullable
TimeSpan and Nullable
This is driving me nuts. I have a report with a datasource containing a TimeSpan.
At design-time the datasource contains some sample data and everything works just fine.
When printing this report with an empty datasource, I get an exception complaining about
System.Nullable not containing an Hours property.
http://pastie.org/2417798
(I'm setting StiOptions.Dictionary.UseNullableTimeSpan = false; !!!)
But if I call _stiReport.Design(); just before _stiReport.Render(); (without doing any modifications to the report) it works just fine.
Unfortunately I haven't been able to reproduce this outside of my application yet.
What's going wrong here? Where's the Nullable coming from?
At design-time the datasource contains some sample data and everything works just fine.
When printing this report with an empty datasource, I get an exception complaining about
System.Nullable not containing an Hours property.
http://pastie.org/2417798
(I'm setting StiOptions.Dictionary.UseNullableTimeSpan = false; !!!)
But if I call _stiReport.Design(); just before _stiReport.Render(); (without doing any modifications to the report) it works just fine.
Unfortunately I haven't been able to reproduce this outside of my application yet.
What's going wrong here? Where's the Nullable coming from?
TimeSpan and Nullable
Just figured out, that calling _stiReport.Dictionary.Synchronize(); before _stiReport.Render() makes this work.
Is it required to call this after RegData before rendering the report?
Is it required to call this after RegData before rendering the report?
TimeSpan and Nullable
Hello.
Synchronize() is recommended to use before Render().
If you could send us sample project to reproduce the issue we'll try to find out a reason.
Thank you.
We couldn't reproduce this bug.Tobias wrote:Just figured out, that calling _stiReport.Dictionary.Synchronize(); before _stiReport.Render() makes this work.
Is it required to call this after RegData before rendering the report?
Synchronize() is recommended to use before Render().
If you could send us sample project to reproduce the issue we'll try to find out a reason.
Thank you.
TimeSpan and Nullable
It's hard to create a sample project to reproduces this, because the data generated from POCO's is kinda complex.
Right now I must even do:
_stiReport.Dictionary.Synchronize();
_stiReport.Dictionary.Synchronize();
(two times - this is not a typo), otherwise I get an error in the designer because my TimeSpans are wrapped into Nullable.
Is there a way to export the data registered with a report in a way, that it can easily be loaded again?
Tobias
Right now I must even do:
_stiReport.Dictionary.Synchronize();
_stiReport.Dictionary.Synchronize();
(two times - this is not a typo), otherwise I get an error in the designer because my TimeSpans are wrapped into Nullable.
Is there a way to export the data registered with a report in a way, that it can easily be loaded again?
Tobias
TimeSpan and Nullable
Hello.
Thank you.
Unfortunately, we can't give you any advice, because we can't reproduce your issue. If you could send us a sample project, we'll try to find out the cause.Tobias wrote:It's hard to create a sample project to reproduces this, because the data generated from POCO's is kinda complex.
Right now I must even do:
_stiReport.Dictionary.Synchronize();
_stiReport.Dictionary.Synchronize();
(two times - this is not a typo), otherwise I get an error in the designer because my TimeSpans are wrapped into Nullable.
Is there a way to export the data registered with a report in a way, that it can easily be loaded again?
Tobias
Thank you.
Re: TimeSpan and Nullable
Please see the code below and the attached sample. I've tested this with 2013.1.
1. If I call report.Dictionary.Synchronize() once, it works fine.
2. If I call report.Dictionary.Synchronize() twice, I will get an error in the designers preview, because the TimeSpan-Field now is Nullable<TimeSpan>
3. If I add a third call to report.Dictionary.Synchronize(), it works fine again.
The obvious workaround is to make sure, report.Dictionary.Synchronize() is called only once, but I think this should also work when called multiple times and the TimeSpan field should not suddenly become Nullable<>
Tobias
1. If I call report.Dictionary.Synchronize() once, it works fine.
2. If I call report.Dictionary.Synchronize() twice, I will get an error in the designers preview, because the TimeSpan-Field now is Nullable<TimeSpan>
3. If I add a third call to report.Dictionary.Synchronize(), it works fine again.
The obvious workaround is to make sure, report.Dictionary.Synchronize() is called only once, but I think this should also work when called multiple times and the TimeSpan field should not suddenly become Nullable<>
Tobias
Code: Select all
var report = new StiReport();
report.Load("sample.mrt");
report.Dictionary.Variables.Clear();
foreach (var dataSource in report.DataSources)
{
report.RegData(((StiDataSource)dataSource).Alias, new object[] { });
}
report.RegData("Data", new List<Foo>
{
new Foo {Something = "Something 1", TimeSpan = TimeSpan.FromHours(1)},
new Foo {Something = "Something 2", TimeSpan = TimeSpan.FromHours(2)},
new Foo {Something = "Something 3", TimeSpan = TimeSpan.FromHours(3)},
new Foo {Something = "Something 4", TimeSpan = TimeSpan.FromHours(4)},
new Foo {Something = "Something 5", TimeSpan = TimeSpan.FromHours(5)},
});
report.Dictionary.Synchronize();
report.Dictionary.Synchronize();
report.Design();
- Attachments
-
- sample.mrt
- Sample report
- (5.51 KiB) Downloaded 254 times
Re: TimeSpan and Nullable
Hello,
Thank you for the sent code.
We need some additional time for check the issue.
Thank you.
Thank you for the sent code.
We need some additional time for check the issue.
Thank you.
Re: TimeSpan and Nullable
Any news on that?
It's even more weird. When doing Render() instead of Design() I MUST call Sychronize() TWICE, otherwise TimeSpans will get wrapped as Nullable and I get an exception.
So this throws:
But this doesn't:
And this throws (On Preview):
But this doesn't:
Tobias
It's even more weird. When doing Render() instead of Design() I MUST call Sychronize() TWICE, otherwise TimeSpans will get wrapped as Nullable and I get an exception.
So this throws:
Code: Select all
report.Dictionary.Synchronize();
report.Render();
Code: Select all
report.Dictionary.Synchronize();
report.Dictionary.Synchronize();
report.Render();
Code: Select all
report.Dictionary.Synchronize();
report.Dictionary.Synchronize();
report.Design();
Code: Select all
report.Dictionary.Synchronize();
report.Design();
Re: TimeSpan and Nullable
Hello.
We are still working on the issue.
We will let you know about the results.
Thank you.
We are still working on the issue.
We will let you know about the results.
Thank you.
Re: TimeSpan and Nullable
Hello,
The problem is solved.
The patch will be available in the next prerelease build.
Thank you.
The problem is solved.
The patch will be available in the next prerelease build.
Thank you.