Restrict New Datasource Dialog
Posted: Tue Jan 23, 2018 1:46 am
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:
And one for my Report Init:
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;
}