Page 1 of 1

Restrict New Datasource Dialog

Posted: Tue Jan 23, 2018 1:46 am
by johnham
Our designer (embedded into our software) used to have new connection and new dataset. New connection was disabled in the designer and we provided only one connection to our users (the database that runs our software). We noticed recently, upon updating Stimulsoft Reports.net that we could no longer add datasets. This is because the dataset/connections options were merged together into a single process. After removing the AddConnection restriction, I can now see the option to add a datasource but it but my predefined connection ("added with Report.RegData") is not showing up and instead there are many datasource types I DO NOT want showing up.

Attached is a picture. As you can see my SQL Connection is showing in the Dictionary Panel but it is not showing as part of the NewDataSources dialog.

Here is a code snippet for my designer init:

Code: Select all

//Designer Configuration              
            StiDesigner.SavingReport += new StiSavingObjectEventHandler(StiDesigner_SavingReport);
            StiDesigner.LoadingReport += new StiLoadingObjectEventHandler(StiDesigner_LoadingReport);
            StiOptions.Engine.GlobalEvents.OpenRecentFileInDesigner += new StiOpenRecentFileObjectEventHandler(GlobalEvents_OpenRecentFileInDesigner);
            StiDesigner.CreatingReport += new StiCreatingObjectEventHandler(StiDesigner_CreatingReport);

            //StiSelectGuiHelper.IsRibbonGui = true;  //Replaced by next line.
            StiOptions.Windows.GlobalGuiStyle = StiGlobalGuiStyle.Office2007Blue;
            StiOptions.Designer.IgnoreOptionReportNeverSaved = true;
            DictionaryPanel = StiDictionaryPanelService.GetService();            
            //DictionaryPanel.ShowDataSourceNewMenuItem = true;
            //DictionaryPanel.ShowDataSourcesNewMenuItem = true;

            if (_IsDeveloper)
            {
                StiOptions.Designer.CodeTabVisible = true;
                //DictionaryPanel.ShowConnectionNewMenuItem = true;
            }
            else
            {
                StiOptions.Designer.CodeTabVisible = false;
                //DictionaryPanel.ShowConnectionNewMenuItem = false;
            }

And one for my Report Init:

Code: Select all

private StiReport PrepReport()
        {
            StiReport TheReport;
            SqlConnection TheConnection;
            StiServiceContainer RegisteredDataAdapters;

            //Init Report            
            SetEnvironmentParameters(_ReportParams);
            TheReport = LoadReport();         

            //Init Data Connection                        
            TheConnection = new SqlConnection(_ConnectString);

            RegisteredDataAdapters = StiConfig.Services.GetServices(typeof(StiDataAdapterService));
            foreach (StiDataAdapterService dataAdapter in RegisteredDataAdapters)
            {
                if (dataAdapter.GetDataSourceType() != typeof(StiSqlSource))
                {
                    dataAdapter.ServiceEnabled = false;
                }
            }


            //Register Data                                   
            TheReport.RegData("POSitive Retail Manager", TheConnection);
            //TheReport.Dictionary.DataStore["POSitive Retail Manager"].IsReportData = true;
            TheReport.Dictionary.Connect();
            

            //Register Parameters
            MakeParameters(_ReportParams, TheReport);

            //Register Custom Functions
            RegisterCustomFunctions();

            _ReportObject = TheReport;

            return TheReport;
        }
Screen Shot 2018-01-22 at 5.35.12 PM.png
Screen Shot 2018-01-22 at 5.35.12 PM.png (133.44 KiB) Viewed 3531 times

Re: Restrict New Datasource Dialog

Posted: Tue Jan 23, 2018 2:05 am
by johnham
Here is a quick picture of a simulation in the demo version of the designer. Notice the Report Connections section of the New Datasource Dialog. I would like to see ONLY that section and the other sections hidden from view. I would also like to provide an alternative ICON for my Connection on this dialog if possible.
Screen Shot 2018-01-22 at 6.02.08 PM.png
Screen Shot 2018-01-22 at 6.02.08 PM.png (109.97 KiB) Viewed 3530 times

Re: Restrict New Datasource Dialog

Posted: Wed Jan 24, 2018 9:24 pm
by johnham
Any update on this?

Re: Restrict New Datasource Dialog

Posted: Fri Jan 26, 2018 10:14 am
by Alex K.
Hello,

You can disable all unnecessary connection:

Code: Select all

foreach (var service in StiOptions.Services.Databases)
{
    service.ServiceEnabled = false;
}
Thank you.

Re: Restrict New Datasource Dialog

Posted: Thu Feb 01, 2018 9:50 pm
by johnham
Worked great! I plopped this code in and then changed my "default" database connection registration code from

Code: Select all

TheReport.RegData("POSitive Retail Manager", TheConnection);

Code: Select all

TheReport.Dictionary.Databases.Add(TheDB);
It took me a bit of poking around but I got it!

Re: Restrict New Datasource Dialog

Posted: Thu Feb 01, 2018 10:14 pm
by Alex K.
Hello

We are always glad to help you!
Please let us know if you need any additional help.

Thank you.