Restrict New Datasource Dialog

Stimulsoft Reports.NET discussion
Post Reply
johnham
Posts: 98
Joined: Fri Sep 19, 2008 2:27 pm
Location: Richland, WA, USA

Restrict New Datasource Dialog

Post 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 2958 times
Thanks,
John Hamilton
Hamilton & Company, LLC
johnham
Posts: 98
Joined: Fri Sep 19, 2008 2:27 pm
Location: Richland, WA, USA

Re: Restrict New Datasource Dialog

Post 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 2957 times
Thanks,
John Hamilton
Hamilton & Company, LLC
johnham
Posts: 98
Joined: Fri Sep 19, 2008 2:27 pm
Location: Richland, WA, USA

Re: Restrict New Datasource Dialog

Post by johnham »

Any update on this?
Thanks,
John Hamilton
Hamilton & Company, LLC
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Restrict New Datasource Dialog

Post 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.
johnham
Posts: 98
Joined: Fri Sep 19, 2008 2:27 pm
Location: Richland, WA, USA

Re: Restrict New Datasource Dialog

Post 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!
Thanks,
John Hamilton
Hamilton & Company, LLC
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Restrict New Datasource Dialog

Post by Alex K. »

Hello

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

Thank you.
Post Reply