Ejemplo n.º 1
0
        public DBQueryStatus(IDBConnection dbConnection,
                             IDBScriptsProvider dBScriptsProvider)
        {
            dbConnection.ThrowIfNull(nameof(dbConnection));

            _dbConnection      = dbConnection;
            _dBScriptsProvider = dBScriptsProvider;

            _dbConnection.Open();
        }
        public DBBackupRestoreCommands(IDBConnection dbConnection,
                                       IDBScriptsProvider dBScriptsProvider)
        {
            dbConnection.ThrowIfNull(nameof(dbConnection));

            _dbConnection      = dbConnection;
            _dBScriptsProvider = dBScriptsProvider;

            _dbConnection.Open();
        }
Ejemplo n.º 3
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            SearchBegin(this, new EventArgs());

            string QueryText = tbQuery.Text;

            QueryText = fmInvIndex.ClearText(QueryText);
            RussianStemmer RStemmer   = new RussianStemmer();
            List <string>  queryWords = QueryText.Split(' ').ToList().Select(t => RStemmer.Stem(t)).Where(t => t.Length > 2)
                                        .OrderBy(t => t).ToList();

            lblQueryForIIView.Text = queryWords.Aggregate((l, r) => l + " " + r);

            pnResponses.Controls.Clear();

            if (queryWords.Count == 0)
            {
                MessageBox.Show("По данному запросу ничего не найдено");
                return;
            }


            List <int> resultIDs = new List <int>();

            if (openFileDialog.SafeFileName.Split('.').Last() == "ii")
            {
                resultIDs = SearchInSimpleInvertedIndex(queryWords);
            }
            else
            {
                resultIDs = SearchInCompressedInvertedIndex(queryWords);
            }

            if (resultIDs == null || resultIDs.Count == 0)
            {
                MessageBox.Show("По данному запросу ничего не найдено");
                return;
            }

            string forQuery = "(" + resultIDs.Select(n => n.ToString()).Aggregate((l, r) => l + "," + r) + ")";


            string sql = "SELECT [u].[Text] [URL] FROM [dbo].[Urls] [u] inner join [dbo].[Pages] [p] on [u].[UrlId] = [p].[MainUrl_UrlId] WHERE [p].[Id] in " +
                         forQuery;

            Connection.Open();
            DataTable dt = Connection.ExecuteQuery(sql);

            Connection.Close();

            dgv.DataSource = new DataView(dt);
            pnResponses.Controls.Add(dgv);

            SearchEnd(this, new EventArgs());
        }
Ejemplo n.º 4
0
        private void LoadDataFromDB(bool ReconnectFlag = true)
        {
            if (ReconnectFlag || Connection == null)
            {
                if (Connection != null)
                {
                    Connection.Close();
                }
                Connection = DBConnection.GetInstance(GetConnectionString());
            }

            string sql = "SELECT [Id],[Content] FROM [dbo].[Pages];";

            Connection.Open();
            DataTable dt = Connection.ExecuteQuery(sql);

            Connection.Close();

            DocumentCorpus.Adapter(dt);
        }
        protected int FindAllCount()
        {
            try
            {
                if (!dbc.IsOpen)
                {
                    dbc.Open();
                }

                //Returns an object, not an int
                logger.LogInformation("FindAllCount complete.");
                return((int)dbc.Select <TEntity>().Count);
            }
            catch (Exception ex)
            {
                logger.LogError(ex.Message);
                return(0);
            }
        }
Ejemplo n.º 6
0
 public DBError Open()
 {
     return(sqlConnection.Open());
 }
Ejemplo n.º 7
0
 public DBError Open()
 {
     sqlConnection = factory.GetConnection();
     return(sqlConnection.Open());
 }