SynchronizeBusinessObjects

Stimulsoft Reports.WEB discussion
Daniel Schmitz
Posts: 32
Joined: Tue Jul 03, 2012 2:16 pm

SynchronizeBusinessObjects

Post by Daniel Schmitz »

Hello.

We are using reports with Business Objects, where the data comes from a customized data source.
The objects are build in memory, and then are registered as the following:

myReport.RegBusinessObject(dataSourceName, myData);
myReport.Dictionary.SynchronizeBusinessObjects(50);
myReport.Dictionary.BusinessObjects.Sort(StiSortOrder.Asc, true);

Generally, it Works fine.
But sometimes occurs of the data source changes, and when I'm editing na already existing report, it loads the new data source, but also keeps the old ones.
The only way I found to solve this, was calling "myReport.Dictionary.BusinessObjects.Clear();" right before I register my data.
Ok, It works fine.
But the bands in my report lose their configs.
I debugged the code, and found out that the bind are made by the BusinessObject's ID, and not by it's name, and doing that was giving it a new ID, what makes sense.

So, I wanted to know two things:
1) Why SynchronizeBusinessObjects() are just adding new objects and properties, but not removing the old ones?
2) What could I do to solve that?

Thanks.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: SynchronizeBusinessObjects

Post by HighAley »

Hello.

We are considering the issue now.
We will let you know when the solution will be available.

Thank you.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: SynchronizeBusinessObjects

Post by HighAley »

Hello, Daniel.

If you register new Business Object and there is already one, the new business object will be created. Now we have added a new option:

Code: Select all

StiOptions.Dictionary.ReplaceExistingDataAtRegistrationOfNewData
By default, it will be true. And the new Business Object with the same name as the existed will replace the last.
You don't have to clear dictionary and synchronize business objects now.
Let us know if you have any different problems using business objects.

Thank you.
Daniel Schmitz
Posts: 32
Joined: Tue Jul 03, 2012 2:16 pm

Re: SynchronizeBusinessObjects

Post by Daniel Schmitz »

Hello,

In which version is this implemented?

Thanks.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: SynchronizeBusinessObjects

Post by HighAley »

Hello, Daniel.

This feature will be available in our next prerelease build from October 18.

Thank you.
Daniel Schmitz
Posts: 32
Joined: Tue Jul 03, 2012 2:16 pm

Re: SynchronizeBusinessObjects

Post by Daniel Schmitz »

Hello.

I downloaded the prerelease build, but I did not find this property.
Was It released? If not, when will it be?

Thanks.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: SynchronizeBusinessObjects

Post by HighAley »

Hello.

Please, check the version of assemblies that you use.
The version of assemblies should be 2013.3.1701.
You should update assemblies in GAC.
You could read more in our Knowledge Base.

Thank you.
Daniel Schmitz
Posts: 32
Joined: Tue Jul 03, 2012 2:16 pm

Re: SynchronizeBusinessObjects

Post by Daniel Schmitz »

Hello.

Yes, you are right.
Maybe I had some references problem, I don't know. But I found it now!
BUT, it still didn't work. Nothing has changed.

Debugging the code, I found out that the code of RegBussinessObject verify the property ReplaceExistingDataAtRegistrationOfNewData, and iterates the StiReport.BusinessObjectsStore property.
But when my code gets the report from the request:

Code: Select all

StiReport report  = StiMvcDesigner.GetReportObject(this.Request);
This property comes empty, so it never runs the code of update the bussiness objects, and ends up always adding them.
Only property StiReport.Dictionary.BusinessObjects have data.
Is this right?

Thanks.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: SynchronizeBusinessObjects

Post by Alex K. »

Hello,

> This property comes empty, so it never runs the code of update the bussiness objects, and ends up always adding them.
> Only property StiReport.Dictionary.BusinessObjects have data.
> Is this right?

Yes.
Most probably we do not exactly understand your questions in first post.
Lets try answer again:

> So, I wanted to know two things:
> 1) Why SynchronizeBusinessObjects() are just adding new objects and properties, but not removing the old ones?

It's by design, only refresh and adding new.
It is possible to directly register new data during report execution. So there are cases when before running the report, not all data are registered, but corresponding business objects are needed.

Please clarify what goes wrong with old Business Objects.

> 2) What could I do to solve that?

For DataSources there is a report.Dictionary.RemoveUnusedDataSourcesV2() method.
We can try to add the similar method and for business objects.

Thank you.
Daniel Schmitz
Posts: 32
Joined: Tue Jul 03, 2012 2:16 pm

Re: SynchronizeBusinessObjects

Post by Daniel Schmitz »

Hello.

Maybe I did not undestand your answer. I will explain better what is the problem.

Given my bussiness object:

Code: Select all

public class Person
{
    public int Id;
    public string Name;
    public int Age;
}
When the report designer is called, this code register the bussiness objects for it to use:

Code: Select all

myReport.RegBusinessObject(dataSourceName, new List<Person>());
myReport.Dictionary.SynchronizeBusinessObjects(50);
myReport.Dictionary.BusinessObjects.Sort(StiSortOrder.Asc, true);
But, if my object changes:

Code: Select all

public class Person
{
    public int Id;
    public string Name;
    public DateTime BirthDate;
}
In the dictionary of the Report Designer (while editing the report created previously), I will see the following:

Code: Select all

Person
{
    Age
    BirthDate
    Id
    Name
}
But the Age property does not exist anymore.
So, what I need, is to know what can I do to remove this property from the dictionary of old reports.

Thanks.
Post Reply