Page 1 of 2

SynchronizeBusinessObjects

Posted: Mon Oct 07, 2013 9:06 pm
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.

Re: SynchronizeBusinessObjects

Posted: Wed Oct 09, 2013 11:41 am
by HighAley
Hello.

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

Thank you.

Re: SynchronizeBusinessObjects

Posted: Tue Oct 15, 2013 2:24 pm
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.

Re: SynchronizeBusinessObjects

Posted: Tue Oct 15, 2013 3:03 pm
by Daniel Schmitz
Hello,

In which version is this implemented?

Thanks.

Re: SynchronizeBusinessObjects

Posted: Wed Oct 16, 2013 2:18 pm
by HighAley
Hello, Daniel.

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

Thank you.

Re: SynchronizeBusinessObjects

Posted: Tue Oct 22, 2013 7:54 pm
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.

Re: SynchronizeBusinessObjects

Posted: Wed Oct 23, 2013 9:41 am
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.

Re: SynchronizeBusinessObjects

Posted: Wed Oct 23, 2013 1:19 pm
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.

Re: SynchronizeBusinessObjects

Posted: Thu Oct 24, 2013 12:50 pm
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.

Re: SynchronizeBusinessObjects

Posted: Thu Oct 24, 2013 1:50 pm
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.