Page 1 of 2
TimeSpan and Nullable
Posted: Tue Aug 23, 2011 12:39 pm
by Tobias
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?
TimeSpan and Nullable
Posted: Tue Aug 23, 2011 12:48 pm
by Tobias
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?
TimeSpan and Nullable
Posted: Wed Aug 24, 2011 3:14 am
by HighAley
Hello.
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?
We couldn't reproduce this bug.
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
Posted: Thu Sep 01, 2011 9:12 am
by Tobias
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
TimeSpan and Nullable
Posted: Fri Sep 02, 2011 3:20 am
by HighAley
Hello.
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
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.
Thank you.
Re: TimeSpan and Nullable
Posted: Fri Apr 12, 2013 4:26 pm
by Tobias
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
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();
Re: TimeSpan and Nullable
Posted: Mon Apr 15, 2013 1:15 pm
by Alex K.
Hello,
Thank you for the sent code.
We need some additional time for check the issue.
Thank you.
Re: TimeSpan and Nullable
Posted: Fri Apr 19, 2013 10:25 am
by Tobias
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:
Code: Select all
report.Dictionary.Synchronize();
report.Render();
But this doesn't:
Code: Select all
report.Dictionary.Synchronize();
report.Dictionary.Synchronize();
report.Render();
And this throws (On Preview):
Code: Select all
report.Dictionary.Synchronize();
report.Dictionary.Synchronize();
report.Design();
But this doesn't:
Code: Select all
report.Dictionary.Synchronize();
report.Design();
Tobias
Re: TimeSpan and Nullable
Posted: Fri Apr 19, 2013 2:01 pm
by HighAley
Hello.
We are still working on the issue.
We will let you know about the results.
Thank you.
Re: TimeSpan and Nullable
Posted: Sun Jul 28, 2013 7:43 pm
by Ivan
Hello,
The problem is solved.
The patch will be available in the next prerelease build.
Thank you.