public static DialogResult ShowWizard(Model model, ProviderDataSource source) { var dialog = new ImportTablesWizard(); //dialog.page1.Init(model); dialog.btnBack.Visible = false; dialog.btnNext.Visible = false; dialog.btnCancel.Left = 654; dialog.page2.RowLimitClause = source.GetRowLimitClause(); dialog.page2.IdentifierQuoting = source.GetIdentifierQuoting(); var tds = TypedDataSource.GetFromTabularDs(source); if (!dialog.page2.Init(tds)) { return(DialogResult.Cancel); } dialog.CurrentPage = 2; var res = dialog.ShowDialog(); if (res == DialogResult.OK) { DoImport(dialog.page1.Mode, model, dialog.page2.Source, dialog.page2.SelectedSchemas, dialog.page2.RowLimitClause, dialog.page2.IdentifierQuoting); } return(res); }
private void btnNext_Click(object sender, EventArgs e) { if (CurrentPage == 1) { switch (page1.Mode) { case Pages.ImportMode.UseExistingDs: if (page1.CurrentDataSource != null) { if (!page2.Init(TypedDataSource.GetFromTabularDs(page1.CurrentDataSource))) { return; } CurrentPage = 2; return; } break; case Pages.ImportMode.UseNewDs: var connectionDialog = ShowConnectionDialog(); if (connectionDialog == null) { return; } var source = TypedDataSource.GetFromConnectionUi(connectionDialog); var tabularDs = Model.AddDataSource(source.SuggestSourceName()); ConnectionUIHelper.ApplyToTabularDs(connectionDialog, tabularDs); source = TypedDataSource.GetFromTabularDs(tabularDs); page2.Init(source); CurrentPage = 2; return; case Pages.ImportMode.UseTempDs: connectionDialog = ShowConnectionDialog(); if (connectionDialog == null) { return; } source = TypedDataSource.GetFromConnectionUi(connectionDialog); source.TabularDsName = "(Temporary connection)"; page2.Init(source); CurrentPage = 2; return; case Pages.ImportMode.UseClipboard: page3.Visible = true; page3.BringToFront(); CurrentPage = 3; break; } } }
public object Edit(object instance, string property, object value, out bool cancel) { if (!(instance is TOMWrapper.ProviderDataSource)) { throw new NotSupportedException("This data source is not supported by Tabular Editor."); } cancel = true; var tabularDs = instance as TOMWrapper.ProviderDataSource; if (tabularDs is null) { return(value); } var ds = TypedDataSource.GetFromTabularDs(tabularDs); var dcd = new DataConnectionDialog(); DataSource.AddStandardDataSources(dcd); if (!string.IsNullOrEmpty(value as string)) { if (ds.ProviderType != ProviderType.Unknown) { dcd.SelectedDataSource = ds.DataSource; dcd.SelectedDataProvider = ds.DataProvider; dcd.ConnectionString = ds.ProviderString; } else { var mbResult = MessageBox.Show("The provider and/or connection string used by this data source, is not supported by Tabular Editor.", "Unknown provider", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (mbResult == DialogResult.Cancel) { return(value); } } } var res = DataConnectionDialog.Show(dcd); if (res == DialogResult.OK) { cancel = false; return(dcd.ApplyToTabularDs(tabularDs)); } return(value); }
public static DialogResult ShowWizard(Model model, ProviderDataSource source) { var dialog = new ImportTablesWizard(); dialog.page1.Init(model); var tds = TypedDataSource.GetFromTabularDs(source); if (!(tds is SqlDataSource) && int.TryParse(source.GetAnnotation("TabularEditor_RowLimitClause"), out int rlc)) { dialog.page2.RowLimitClause = (RowLimitClause)rlc; } dialog.page2.Init(tds); dialog.CurrentPage = 2; var res = dialog.ShowDialog(); if (res == DialogResult.OK) { DoImport(dialog.page1.Mode, model, dialog.page2.Source, dialog.page2.SelectedSchemas, dialog.page2.RowLimitClause); } return(res); }
public static DialogResult ShowWizard(Table table) { if (!(table.Partitions[0].DataSource is ProviderDataSource)) { MessageBox.Show("This feature currently only supports tables using Legacy Data Sources.", "Unsupported Data Source", MessageBoxButtons.OK, MessageBoxIcon.Information); return(DialogResult.Cancel); } var dialog = new ImportTablesWizard(); dialog.Model = table.Model; dialog._currentPage = 2; dialog.btnBack.Visible = false; dialog.btnNext.Visible = false; dialog.btnCancel.Left = 654; dialog.page2.lblHeader.Text = "Choose the table/view you want to use as a source for " + table.DaxObjectFullName + ":"; dialog.btnImport.Text = "OK"; dialog.page2.SingleSelection = true; dialog.page2.InitialSelection = table.GetTableSchema(); dialog.page2.RowLimitClause = table.GetRowLimitClause(); dialog.page2.IdentifierQuoting = table.GetIdentifierQuoting(); if (!dialog.page2.Init(TypedDataSource.GetFromTabularDs(table.Partitions[0].DataSource as ProviderDataSource))) { return(DialogResult.Cancel); } dialog.page2.Visible = true; // TODO: var res = dialog.ShowDialog(); if (res == DialogResult.OK) { DoUpdate(table, dialog.page2.Source, dialog.page2.SelectedSchemas.First(), dialog.page2.RowLimitClause, dialog.page2.IdentifierQuoting); } return(res); }