Exemplo n.º 1
0
        private void RefreshUIFromDatabase()
        {
            try
            {
                _server = DataAccessPortal.GetInstance()
                          .ExpectServer(_collection.GetDataAccessPoint(), DataAccessContext.InternalDataProcessing);

                string sql = _collection.GetSql();
                _originalSql = sql;
                //update the editor to show the user the SQL
                _scintilla.Text = sql;

                _server.TestConnection();

                LoadDataTableAsync(_server, sql);
            }
            catch (QueryBuildingException ex)
            {
                ragSmiley1.SetVisible(true);
                ragSmiley1.Fatal(ex);
            }
            catch (Exception ex)
            {
                ragSmiley1.SetVisible(true);
                ragSmiley1.Fatal(ex);
            }
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        /// <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();
            }
        }
Exemplo n.º 4
0
        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 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();
        }