Page 1 of 1

Registering Business Object / Connections

Posted: Wed Aug 17, 2011 8:34 am
by edusfleck
Hi Guys,

We are evaluating your solution on our Silverlight Application.
What we want is add Data (as Business Object or Data Source) and then let the user build its report.

We run into some issues and will be great if we have some clarification:
(We have a SL Application running with RIA Services, MVVM pattern and Stimulsoft Reports.Ultimate 2011.1 Trial libraries)

How to register Data and it appears on Business Objects?
If we register like this, doesn't appears

Code: Select all

  
            StiReport report = new StiReport();
            report.CalculationMode = StiCalculationMode.Interpretation;
            report.RegBusinessObject(FonteSelecionada.Nome, FonteSelecionada.Nome, DataTable);
            designer.Report = report;
            designer.InvokeRebuildDesigner();
If we register like this, appears, but the report opens another design in another window

Code: Select all

            StiReport report = new StiReport();
            report.CalculationMode = StiCalculationMode.Interpretation;
            report.RegBusinessObject(FonteSelecionada.Nome, FonteSelecionada.Nome, DataTable);
            report.Design();
How to register Data in Design time and viewer time?
Because, we registered a DataTable (our dataTable, not the System.Data.DataTable) and it worked well, but when the designer tries to render it, the Data goes away.
(On the "WCF Render Method" I need to register the Data Again?)

Code: Select all

        void WCFService_WCFRenderReport(object sender, Stimulsoft.Report.Events.StiWCFEventArgs e)
        {
            designer.StartProgressInformation("WCF Service", StiLocalization.Get("DesignerFx", "CompilingReport"), System.Windows.Visibility.Visible, true);

            InvokeOperation invoke = domain.RenderReport(e.Xml);
            invoke.Completed += new EventHandler(invoke_Completed);
        }

        void invoke_Completed(object sender, EventArgs e)
        {
            InvokeOperation invoke = sender as InvokeOperation;
            if (!invoke.HasError)
                designer.ApplyRenderedReport(invoke.Value);

            designer.CloseProgressInformation();
        }

/////WCF (RIA Method)
        [Invoke]
        public string RequestFromUserRenderReport(string xml)
        {
            StiReport report = EncodingHelper.DecodeXmlRequestFromUser(xml, ds);

            if (report.CompilerResults.Errors.Count > 0)
            {
                return RenderingReportHelper.GetErrorListXml(report);
            }

            bool error = false;
            try
            {
                report.Render(false);
            }
            catch
            {
                error = true;
            }

            if (!error)
            {
                return RenderingReportHelper.CheckReportOnInteractions(report, true);
            }
            return null;
        }
There's an example, on those that come with the trial version, that handle with connections?
If not, can u show me (or indicate me a thread/how-to what does) a way to register a Connection programmatically and add a DataSource?

Thank in advance,
Eduardo Fleck

Registering Business Object / Connections

Posted: Fri Aug 19, 2011 2:25 am
by Alex K.
Hello,

For register Data you can use the following code:

Code: Select all

report.RegBusinessObject();
report.Dictionary.SynchronizeBusinessObjects(level);
For add connections and data sources you can use the following code.
New connection string:

Code: Select all

report.Dictionary.Databases.Clear();
report.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", newConnectionString));
Add DataSources:

Code: Select all

StiSqlSource DS1 = new StiSqlSource("Connection", "DS1", "DS1", "SELECT * FROM DS1", true, false);
report.Dictionary.DataSources.Add(DS1);
Add Columns:

Code: Select all

foreach (DataColumn col in dataTableDS1.Columns)
{
     DS1.Columns.Add(col.ColumnName, col.DataType);
}
Add Relations:

Code: Select all

StiDataRelation dataRelation = new StiDataRelation("MyRelation", parentDS, childDS, new string[] { "Field" }, new string[] { "Field" });
report.Dictionary.RegRelations();
report.Dictionary.Relations.Add(dataRelation);
Thank you.

Registering Business Object / Connections

Posted: Fri Aug 19, 2011 2:57 pm
by edusfleck
Thanks Aleksey!

Everything worked fine, but my report still not rendering.

I'm getting this error on Report.Render(false); at WCF (Ria Services)

"Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application."

Really odd because this looks like a client error, not a WCF error.

Any thoughts?

Code: Select all


//ADD DATA SOURCES AND CONNETIONS

                Fontes.AddRange(domainFonte.Fontes);
                ViewDataSourceRelatorio2 view = this.View as ViewDataSourceRelatorio2;
                view.designer.Report.Dictionary.Databases.Clear();
                foreach (Conexao con in Conexoes)
                {
                    view.designer.Report.Dictionary.Databases.Add(new StiSqlDatabase(con.Nome, con.Nome, con.ConnectionString, true));   

                    foreach(Fonte f in Fontes.Where(x => x.Cd_Conexao == con.Codigo))
                    {
                        StiSqlSource DS = new StiSqlSource(con.Nome, f.Descricao, f.Descricao, f.TSQL, true, false);
                        view.designer.Report.Dictionary.DataSources.Add(DS);

                        if (f.Tipos != null)
                        {
                            Dictionary tipos = Lib.LibPaineis.DeserializaJson>(f.Tipos);

                            foreach (var tipo in tipos)
                            {
                                DS.Columns.Add(tipo.Key, Type.GetType(tipo.Value));
                            }
                        }
                    }
                }

                view.designer.Report.Dictionary.SynchronizeBusinessObjects();

Code: Select all

//WCF RIA SERVICES METHOD
        [Invoke]
        public string RenderReport(string xml)
        {
            if (!string.IsNullOrEmpty(xml))
            {
                StiReport report = new StiReport();
                report.LoadFromString(WCFHelper.EncodingHelper.Decode(xml));

                if (!report.IsRendered)
                {
                    try
                    {
                        report.Compile();
                    }
                    catch
                    {
                    }

                    if (report.CompilerResults != null && report.CompilerResults.Errors.Count > 0)
                    {
                        return RenderingReportHelper.GetErrorListXml(report);
                    }
                }

                bool error = false;
                try
                {
                    report.Render(false);
                }
                catch
                {
                    error = true;
                }

                if (!error)
                {
                    return RenderingReportHelper.CheckReportOnInteractions(report, true);
                }
            }
            return null;
        }

Code: Select all

//SILVERLIGHT CODE

   void WCFService_WCFRenderReport(object sender, Stimulsoft.Report.Events.StiWCFEventArgs e)
        {
            designer.StartProgressInformation("WCF Service", StiLocalization.Get("DesignerFx", "CompilingReport"), System.Windows.Visibility.Visible, true);

            InvokeOperation invoke = domain.RenderReport(e.Xml);
            invoke.Completed += new EventHandler(invoke_Completed);
        }

        void invoke_Completed(object sender, EventArgs e)
        {
            InvokeOperation invoke = sender as InvokeOperation;
            if (!invoke.HasError)
            {
                designer.ApplyRenderedReport(invoke.Value);
            }

            designer.CloseProgressInformation();
        }



Registering Business Object / Connections

Posted: Mon Aug 22, 2011 1:59 am
by Alex K.
Hello,

Could you explain your issue in more details and, if possible, send us a step-by-step guide or video how to reproduce the issue?
Also please check the last version of WCF on our site
http://www.stimulsoft.com/Downloads/WCF ... es.WCF.zip

Thank you.

Registering Business Object / Connections

Posted: Mon Aug 22, 2011 6:27 am
by edusfleck
I Found something:

This is the complete excpetion that occuors on the LoadReport:



22/08/2011 08:11:10 Teste Report Mensagem de erro tratada: System.InvalidOperationException: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
at Stimulsoft.Report.Dictionary.Design.StiDataEditors.PromptUserNameAndPassword()
at Stimulsoft.Report.Dictionary.StiSqlAdapterService.OpenConnection(IDbConnection connection, StiData data, StiDictionary dictionary)
at Stimulsoft.Report.Dictionary.StiSqlAdapterService.ConnectDataSourceToData(StiDictionary dictionary, StiDataSource dataSource, Boolean loadData)
at Stimulsoft.Report.Dictionary.StiDataSource.Connect(StiDataCollection datas, Boolean loadData)
at Stimulsoft.Report.Dictionary.StiDataSourcesCollection.Connect(StiDataCollection datas, Boolean loadData)
at Stimulsoft.Report.Dictionary.StiDictionary.Connect(Boolean loadData)
at Stimulsoft.Report.Engine.StiRenderProviderV2.ConnectToData(StiReport report)
at Stimulsoft.Report.Engine.StiRenderProviderV2.Render(StiReport report, StiRenderState state)
at Stimulsoft.Report.Engine.StiReportV2Builder.RenderSingleReport(StiReport masterReport, StiRenderState renderState)
at Stimulsoft.Report.StiReport.RenderReport(StiRenderState renderState)
at Stimulsoft.Report.StiReport.Render(StiRenderState renderState, StiGuiMode guiMode)
at Stimulsoft.Report.StiReport.Render(Boolean showProgress)
at Prowise.DistributedServices.Core.PWDomainRelatorio2.RenderReport(String xml) in C:\PaineisGerenciais\Prowise.DistributedServices.Core\PWDomainRelatorio2.cs:line 49 Erro=Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
[File:C:\PaineisGerenciais\Prowise.DistributedServices.Core\PWDomainRelatorio2.cs Metodo:RenderReport(Linha:49 Coluna:21)]


I did this:

Code: Select all

                    
view.designer.Report.Dictionary.Databases.Add(new StiSqlDatabase(con.Nome, con.Nome, con.ConnectionString, false)); 
unlike this

Code: Select all

                    
view.designer.Report.Dictionary.Databases.Add(new StiSqlDatabase(con.Nome, con.Nome, con.ConnectionString, true)); 
And worked

Registering Business Object / Connections

Posted: Tue Aug 23, 2011 1:04 am
by HighAley
Hello.

When you wrote this code:

Code: Select all

view.designer.Report.Dictionary.Databases.Add(new StiSqlDatabase(con.Nome, con.Nome, con.ConnectionString, true)); 
You service on server side tried to create a window requesting a password. Thus the error appeared.
When you wrote 'false' in last parameter, the window is not created and there is no error.

We are always glad to help you.
Let us know if you need any additional help.

Thank you.