public void ExecutePendingQueries() { IQuery query; while (GetSafeQueueCount() > 0) { query = null; lock (queue) { if (queue.Count > 0) { query = queue.Dequeue(); } } if (query != null) { if (db.ExecuteQuery(query)) { // query прошло, дать потребителю знать OutputMessage("Выполненный запрос #0x" + query.GetHashCode().ToString("X")); } else { // если запрос не выполнился, покажи сообщение из СУБД OutputMessage(db.GetLastResponse()); } } } }
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()); }
public EmployeeResponse RetrieveEmployeeMetrics(string email) { using (IServiceScope scope = ServiceProvider.CreateScope()) { IDBConnection dbConnection = scope.ServiceProvider.GetRequiredService <IDBConnection>(); dbConnection.Connect(); var result = dbConnection.ExecuteQuery <EmployeeMetrics>(QueryGenerator.GetEmployeeMetricsHeader() + QueryGenerator.WhereEmail(email)); return(result.Any() ? new EmployeeResponse(result.First()) : null); } }
public EttEmployee RetrieveEmployeeInfo(string email) { using (IServiceScope scope = ServiceProvider.CreateScope()) { IDBConnection dbConnection = scope.ServiceProvider.GetRequiredService <IDBConnection>(); dbConnection.Connect(); var query = QueryGenerator.GetEmployeeInfo(email); var result = dbConnection.ExecuteQuery <EttEmployee>(query); return(result.Any() ? result.First() : null); } }
public List <EmployeeResponse> RetrieveAllEmployeeMetrics() { using (IServiceScope scope = ServiceProvider.CreateScope()) { IDBConnection dbConnection = scope.ServiceProvider.GetRequiredService <IDBConnection>(); dbConnection.Connect(); var results = dbConnection.ExecuteQuery <EmployeeMetrics>(QueryGenerator.GetEmployeeMetricsHeader() + QueryGenerator.WhereRole("Developer")); var castedResults = new List <EmployeeResponse>(); foreach (var res in results) { castedResults.Add(new EmployeeResponse(res)); } return(castedResults.Any() ? castedResults : null); } }
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); }