public ExecuteCommandViewData(IBasicActivateItems activator, [DemandsInitialization("The ColumnInfo, TableInfo or ExtractionInformation you want to view a sample of")] IMapsDirectlyToDatabaseTable obj, [DemandsInitialization("Optional. The view mode you want to see. Options include 'TOP_100', 'Aggregate' and 'Distribution'", DefaultValue = ViewType.TOP_100)] ViewType viewType = ViewType.TOP_100, [DemandsInitialization("Optional. A file to write the records to instead of the console")] FileInfo toFile = null) : base(activator) { _viewType = viewType; ToFile = toFile; if (obj is TableInfo ti) { _collection = new ViewTableInfoExtractUICollection(ti, _viewType); if (_viewType != ViewType.TOP_100) { throw new ArgumentException($"Only '{nameof(ViewType.TOP_100)}' can be used for TableInfos"); } } else if (obj is ColumnInfo col) { _collection = CreateCollection(col); } else if (obj is ExtractionInformation ei) { _collection = CreateCollection(ei); } else { throw new ArgumentException($"Object '{obj}' was not a table or column compatible with this command"); } }
public override void ShowData(IViewSQLAndResultsCollection collection) { var point = collection.GetDataAccessPoint(); var db = DataAccessPortal.GetInstance().ExpectDatabase(point, DataAccessContext.InternalDataProcessing); var toRun = new ExtractTableVerbatim(db.Server, collection.GetSql(), Console.OpenStandardOutput(), ",", null); toRun.DoExtraction(); }
public override void ShowData(IViewSQLAndResultsCollection collection) { var view = new ConsoleGuiSqlEditor(this, collection) { Modal = true }; Application.Run(view); }
/// <summary> /// Fetches the <paramref name="viewType"/> of the data in <see cref="ColumnInfo"/> <paramref name="c"/> /// </summary> /// <param name="activator"></param> /// <param name="viewType"></param> /// <param name="c"></param> public ExecuteCommandViewData(IActivateItems activator, ViewType viewType, ColumnInfo c) : base(activator) { _collection = new ViewColumnInfoExtractUICollection(c, viewType); _viewType = viewType; if (!c.IsNumerical() && viewType == ViewType.Distribution) { SetImpossible("Column is not numerical"); } }
/// <summary> /// Runs the query described in <paramref name="collection"/> and extracts the data into <paramref name="toFile"/> /// </summary> /// <param name="collection"></param> /// <param name="toFile"></param> /// <param name="context">Determines which access credentials (if any) are used to run the query</param> public static void ExtractDataToFile(IViewSQLAndResultsCollection collection, FileInfo toFile, DataAccessContext context = DataAccessContext.InternalDataProcessing) { var point = collection.GetDataAccessPoint(); var db = DataAccessPortal.GetInstance().ExpectDatabase(point, context); using (var fs = File.OpenWrite(toFile.FullName)) { var toRun = new ExtractTableVerbatim(db.Server, collection.GetSql(), fs, ",", null); toRun.DoExtraction(); } }
public void SetCollection(IActivateItems activator, IPersistableObjectCollection collection) { _collection = (IViewSQLAndResultsCollection)collection; CommonFunctionality.ClearToolStrip(); btnExecuteSql.Image = activator.CoreIconProvider.GetImage(RDMPConcept.SQL, OverlayKind.Execute); var overlayer = new IconOverlayProvider(); btnResetSql.Image = overlayer.GetOverlay(FamFamFamIcons.text_align_left, OverlayKind.Problem); if (_autoComplete == null) { _autoComplete = new AutoCompleteProviderFactory(activator).Create(_collection.GetQuerySyntaxHelper()); _collection.AdjustAutocomplete(_autoComplete); _autoComplete.RegisterForEvents(_scintilla); } SetItemActivator(activator); CommonFunctionality.Add(btnExecuteSql); CommonFunctionality.Add(btnResetSql); foreach (var c in _timeoutControls.GetControls()) { CommonFunctionality.Add(c); } foreach (DatabaseEntity d in _collection.GetToolStripObjects()) { CommonFunctionality.AddToMenu(new ExecuteCommandShow(activator, d, 0, true)); } CommonFunctionality.Add(new ToolStripSeparator()); CommonFunctionality.Add(_serverHeader); try { var dap = _collection.GetDataAccessPoint(); _serverHeader.Text = $"Server: {dap.Server} Database: {dap.Database}"; _serverHeader.Image = _databaseTypeIconProvider.GetImage(dap.DatabaseType); } catch (Exception) { _serverHeader.Text = "Server:Unknown"; } RefreshUIFromDatabase(); }
public ExecuteCommandViewData(IActivateItems activator, TableInfo tableInfo) : base(activator) { _viewType = ViewType.TOP_100; _collection = new ViewTableInfoExtractUICollection(tableInfo, _viewType); }
public ExecuteCommandViewData(IBasicActivateItems activator, ViewType viewType, ExtractionInformation ei) : base(activator) { _viewType = viewType; _collection = CreateCollection(ei); }
/// <summary> /// Fetches the <paramref name="viewType"/> of the data in <see cref="ColumnInfo"/> <paramref name="c"/> /// </summary> /// <param name="activator"></param> /// <param name="viewType"></param> /// <param name="c"></param> public ExecuteCommandViewData(IBasicActivateItems activator, ViewType viewType, ColumnInfo c) : base(activator) { _viewType = viewType; _collection = CreateCollection(c); }
public override void ShowData(IViewSQLAndResultsCollection collection) { Activate <ViewSQLAndResultsWithDataGridUI>(collection); }
public override void ShowData(IViewSQLAndResultsCollection collection) { throw new NotImplementedException(); }
public abstract void ShowData(IViewSQLAndResultsCollection collection);
public void SetCollection(IActivateItems activator, IPersistableObjectCollection collection) { _collection = (IViewSQLAndResultsCollection)collection; CommonFunctionality.ClearToolStrip(); btnExecuteSql.Image = activator.CoreIconProvider.GetImage(RDMPConcept.SQL, OverlayKind.Execute); var overlayer = new IconOverlayProvider(); btnResetSql.Image = overlayer.GetOverlay(FamFamFamIcons.text_align_left, OverlayKind.Problem); if (_scintilla == null) { // figure out what DBMS we are targetting var syntax = _collection.GetQuerySyntaxHelper(); // Create the SQL editor for that language ScintillaTextEditorFactory factory = new ScintillaTextEditorFactory(); _scintilla = factory.Create(null, SyntaxLanguage.SQL, syntax); splitContainer1.Panel1.Controls.Add(_scintilla); _scintilla.TextChanged += _scintilla_TextChanged; _scintilla.KeyUp += ScintillaOnKeyUp; // Setup autocomplete menu for the DBMS language _autoComplete = new AutoCompleteProviderWin(syntax); _collection.AdjustAutocomplete(_autoComplete); _autoComplete.RegisterForEvents(_scintilla); } SetItemActivator(activator); CommonFunctionality.Add(btnExecuteSql); CommonFunctionality.Add(btnResetSql); foreach (var c in _timeoutControls.GetControls()) { CommonFunctionality.Add(c); } foreach (DatabaseEntity d in _collection.GetToolStripObjects()) { CommonFunctionality.AddToMenu(new ExecuteCommandShow(activator, d, 0, true)); } CommonFunctionality.Add(new ToolStripSeparator()); CommonFunctionality.Add(_serverHeader); try { var dap = _collection.GetDataAccessPoint(); _serverHeader.Text = $"Server: {dap.Server} Database: {dap.Database}"; _serverHeader.Image = _databaseTypeIconProvider.GetImage(dap.DatabaseType); } catch (Exception) { _serverHeader.Text = "Server:Unknown"; } RefreshUIFromDatabase(); }
public ConsoleGuiSqlEditor(IBasicActivateItems activator, IViewSQLAndResultsCollection collection) { this.Activator = activator; this._collection = collection; Modal = true; ColorScheme = ConsoleMainWindow.ColorScheme; // Tabs (query and results) TabView = new TabView() { Width = Dim.Fill(), Height = Dim.Fill(), Y = 1 }; textView = new SqlTextView() { X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill(), Text = _orignalSql = collection.GetSql().Replace("\r\n", "\n").Replace("\t", " ") }; textView.AllowsTab = false; TabView.AddTab(queryTab = new Tab("Query", textView), true); tableView = new TableView() { X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill() }; tableView.Style.AlwaysShowHeaders = true; tableView.CellActivated += TableView_CellActivated; TabView.AddTab(resultTab = new Tab("Results", tableView), false); Add(TabView); // Buttons on top of control _btnRunOrCancel = new Button("Run") { X = 0, Y = 0, }; _btnRunOrCancel.Clicked += () => RunOrCancel(); Add(_btnRunOrCancel); var resetSql = new Button("Reset Sq_l") { X = Pos.Right(_btnRunOrCancel) + 1 }; resetSql.Clicked += () => ResetSql(); Add(resetSql); var clearSql = new Button("Clear S_ql") { X = Pos.Right(resetSql) + 1, }; clearSql.Clicked += () => ClearSql(); Add(clearSql); var lblTimeout = new Label("Timeout:") { X = Pos.Right(clearSql) + 1, }; Add(lblTimeout); var tbTimeout = new TextField(_timeout.ToString()) { X = Pos.Right(lblTimeout), Width = 5 }; tbTimeout.TextChanged += TbTimeout_TextChanged; Add(tbTimeout); var btnSave = new Button("Save") { X = Pos.Right(tbTimeout) + 1, }; btnSave.Clicked += () => Save(); Add(btnSave); var btnClose = new Button("Clos_e") { X = Pos.Right(btnSave) + 1, }; btnClose.Clicked += () => { Application.RequestStop(); }; Add(btnClose); var auto = new AutoCompleteProvider(collection.GetQuerySyntaxHelper()); collection.AdjustAutocomplete(auto); var bits = auto.Items.SelectMany(auto.GetBits).OrderBy(a => a).Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList(); textView.Autocomplete.AllSuggestions = bits; textView.Autocomplete.MaxWidth = 40; }