void WriteFiles() { var writing = Stopwatch.StartNew(); var dataUpdate = new UpdatePackage("data"); var jsout = new JsOutput(dataUpdate); jsout.Write(); // Has to be after everything else because partials are modified here. var searchUpdate = new UpdatePackage("search"); var sqlout = new SearchOutput(jsout, searchUpdate); sqlout.Write(); if (dataUpdate.RowCount > 0) { DatabaseBuilder.PrintLine($"Updating {dataUpdate.RowCount} data rows."); dataUpdate.Write(); } if (searchUpdate.RowCount > 0) { DatabaseBuilder.PrintLine($"Updating {searchUpdate.RowCount} data rows."); searchUpdate.Write(); } writing.Stop(); DatabaseBuilder.PrintLine($"Writing elapsed: {writing.Elapsed}"); }
public async Task <IActionResult> Suggest([FromBody] SearchInput input) { string gitHubAuthToken = HttpContext.Session .GetString(Constants.GIT_HUB_AUTH_TOKEN_SESSION_KEY); string gitHubLogin = HttpContext.Session .GetString(Constants.GIT_HUB_LOGIN_KEY); if (CanSearch(gitHubAuthToken, gitHubLogin)) { if (string.IsNullOrWhiteSpace(input.Query)) { return(BadRequest()); } IUserRepoSearchActor userRepoSearchActor = ServiceProvider .GetUserRepoSearchActor(_context, gitHubLogin); SearchOutput output = await userRepoSearchActor .GetSuggestionsAsync(input); return(Ok(output)); } else { return(Unauthorized()); } }
public static RowCollection GetVisibleResults() { SearchPage searchPage = Program.MainWindow.SearchPage; SearchOutput searchOutput = (SearchOutput)searchPage.GetType().GetField("OutputPanel", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(searchPage); return(new RowCollection(GetVisibleResults(searchOutput.QueryPanel.Rows))); }
public override DocsPaIntegration.Search.SearchOutput Search(DocsPaIntegration.Search.SearchInfo searchInfo) { try { List <SearchOutputRow> rows = new List <SearchOutputRow>(); ExternalWSSoapClient soap = getWSClient(); SearchInfoWS search = new SearchInfoWS(); search.Descrizione = searchInfo.Descrizione; search.Codice = searchInfo.Codice; search.PageSize = searchInfo.PageSize; search.RequestedPage = searchInfo.RequestedPage; SearchOutputWS outputWS = soap.Search(search); if (outputWS.Code == SearchOutputCode.KO) { throw new SearchException(SearchExceptionCode.SERVER_ERROR, outputWS.ErrorMessage); } for (int i = 0; i < outputWS.Rows.Length; i++) { SearchOutputRow row = new SearchOutputRow(); row.Codice = outputWS.Rows[i].Codice; row.Descrizione = outputWS.Rows[i].Descrizione; rows.Add(row); } SearchOutput res = new SearchOutput(rows, outputWS.NumTotResults); return(res); } catch (SearchException se) { throw se; } catch (Exception e) { throw new SearchException(SearchExceptionCode.SERVICE_UNAVAILABLE); } }
private void btn_ric_Click(Object sender, EventArgs arg) { SearchInfo searchInfo = new SearchInfo(); searchInfo.RequestedPage = 1; searchInfo.PageSize = 10; searchInfo.Descrizione = this.txt_descr.Text; searchInfo.Codice = this.txt_codice.Text; SearchInfo = searchInfo; SearchOutput res = null; try { res = IntegrationAdapter.Search(searchInfo); bindDataGrid(res, 0); } catch (SearchException e) { if (e.Code == SearchExceptionCode.SERVICE_UNAVAILABLE) { handleDisservizio(); } if (e.Code == SearchExceptionCode.SERVER_ERROR) { Response.Write("<script language='javascript'>alert('" + e.Message + "')</script>"); } } catch (Exception e) { handleDisservizio(); } }
protected void Show_All_Click(object sender, EventArgs e) { int selectedIndex = SearchDropDown.SelectedIndex; String tableName = "health_profile"; if (selectedIndex == 1) { tableName = "diet"; } else if (selectedIndex == 2) { tableName = "enum_health_condition"; } else if (selectedIndex == 3) { tableName = "health_profile"; } else if (selectedIndex == 4) { tableName = "enum_medication"; } else if (selectedIndex == 5) { tableName = "prescription"; } else if (selectedIndex == 6) { tableName = "animal"; } using (MySqlConnection conn = new MySqlConnection(CONNECTION_STR)) { try { // Connect to Azure MySQL server System.Diagnostics.Debug.WriteLine("Connecting to server..."); conn.Open(); string query = "SELECT * FROM " + tableName; MySqlCommand cmd = new MySqlCommand(query, conn); MySqlDataAdapter adapter = new MySqlDataAdapter(); adapter.SelectCommand = cmd; DataTable table = new DataTable(); adapter.Fill(table); SearchOutput.DataSource = table; SearchOutput.DataBind(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } }
private static async Task SaveToCache( string query, IReliableDictionary <string, CachedItem <SearchOutput> > cache, SearchOutput output, ITransaction tx) { await cache.AddAsync(tx, query, new CachedItem <SearchOutput> { CachedAt = DateTime.UtcNow, Data = output }); }
private void bindDataGrid(SearchOutput res, int numPage) { dg_OggEst.VirtualItemCount = res.NumTotResults; dg_OggEst.CurrentPageIndex = numPage; SearchOutput = res; if (res.NumTotResults == 0) { this.lbl_noResult.Visible = true; this.dg_OggEst.Visible = false; } else { this.lbl_noResult.Visible = false; this.dg_OggEst.Visible = true; this.dg_OggEst.DataSource = res.Rows; this.dg_OggEst.DataBind(); } }
private void dg_OggEst_PageIndexChanged(Object sender, EventArgs arg) { DataGridPageChangedEventArgs ev = (DataGridPageChangedEventArgs)arg; SearchInfo searchInfo = SearchInfo; searchInfo.RequestedPage = ev.NewPageIndex + 1; SearchInfo = searchInfo; SearchOutput res = null; try { res = IntegrationAdapter.Search(searchInfo); bindDataGrid(res, ev.NewPageIndex); } catch (Exception e) { handleDisservizio(); } }
public static readonly TimeSpan CACHE_LIFESPAN = new TimeSpan(3, 0, 0); // 3 hours public async static Task <Result <SearchOutput> > SearchAsync( SearchInput input, IReliableDictionary <string, CachedItem <SearchOutput> > cache, ITransaction tx, IGitHubClient gitHubClient) { if (string.IsNullOrWhiteSpace(input.Query)) { return new Result <SearchOutput> { Success = false } } ; input.Query = input.Query.ToLowerInvariant(); SearchOutput searchOutput = await FindInCache(input.Query, cache, tx); if (searchOutput == null) { var result = await SearchOverAPI(input, gitHubClient); if (result.Success) { searchOutput = result.Data; await SaveToCache(input.Query, cache, searchOutput, tx); await tx.CommitAsync(); } } return(new Result <SearchOutput> { Success = searchOutput != null, Data = searchOutput }); }
protected void SearchBtn_Click(object sender, EventArgs e) { // Get user input int keyID = Convert.ToInt32(SearchInput.Text.Trim()); int selectedIndex = SearchDropDown.SelectedIndex; String tableName = "health_profile"; String primaryKey = "profile_id"; if (selectedIndex == 1) { tableName = "diet"; primaryKey = "diet_id"; } else if (selectedIndex == 2) { tableName = "enum_health_condition"; primaryKey = "condition_id"; } else if (selectedIndex == 3) { tableName = "health_profile"; primaryKey = "profile_id"; } else if (selectedIndex == 4) { tableName = "enum_medication"; primaryKey = "med_id"; } else if (selectedIndex == 5) { tableName = "prescription"; primaryKey = "prescription_id"; } else if (selectedIndex == 6) { tableName = "animal"; primaryKey = "animal_id"; } using (MySqlConnection conn = new MySqlConnection(CONNECTION_STR)) { try { // Connect to Azure MySQL server System.Diagnostics.Debug.WriteLine("Connecting to server..."); conn.Open(); string query = "SELECT * FROM " + tableName + " WHERE " + primaryKey + " = @key_id;"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@key_id", keyID); MySqlDataAdapter adapter = new MySqlDataAdapter(); adapter.SelectCommand = cmd; DataTable table = new DataTable(); adapter.Fill(table); SearchOutput.DataSource = table; SearchOutput.DataBind(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } }
public override DocsPaIntegration.Search.SearchOutput Search(DocsPaIntegration.Search.SearchInfo searchInfo) { try { //Client del webservice ArcaWS.ArcaIntraWSService wsArca = new ArcaIntraWSService(); wsArca.Url = WSUrl; //Imposta il profilo per invocare il webservice di Arca ArcaWS.tProfilo profilo = new tProfilo(); SetProfilo(ref profilo); //Istanzia l'oggetto per il risultato della ricerca ArcaWS.DatiRisposta datiRisposta = new DatiRisposta(); //Ricerca per codice fiscale if (searchInfo.OtherParam.ContainsKey("CF")) { //Istanzia l'oggetto per la ricerca per codice fiscale ArcaWS.RichiestaPerCodiceFiscale ricercaCF = new RichiestaPerCodiceFiscale(); ricercaCF.Profilo = profilo; //Istanzia l'oggetto per i dati codice fiscale ArcaWS.tCodiceFiscale cfRichiesta = new tCodiceFiscale(); //Imposta i dati del codice fiscale SetCodiceFiscale(ref cfRichiesta, searchInfo.OtherParam["CF"].ToString()); ricercaCF.CodiceFiscale = cfRichiesta; datiRisposta = wsArca.ricercaPerCodiceFiscale(ricercaCF); } else //Ricerca per dati anagrafici { //Istanzia l'oggetto per la ricerca per dati anagrafici ArcaWS.RichiestaPerDatiAnagraficiParziali ricercaDA = new RichiestaPerDatiAnagraficiParziali(); ricercaDA.Profilo = profilo; //Istanzia l'oggetto per i data anagrafici parziali ArcaWS.tDatiPersonaliParziali2 dpRichiesta = new tDatiPersonaliParziali2(); //Imposta i dati anagrafici parziali if (searchInfo.OtherParam.ContainsKey("COGNOME")) { dpRichiesta.Cognome = searchInfo.OtherParam["COGNOME"].ToString(); } if (searchInfo.OtherParam.ContainsKey("NOME")) { dpRichiesta.Cognome = searchInfo.OtherParam["NOME"].ToString(); } if (searchInfo.OtherParam.ContainsKey("DATA_NASCITA")) { ArcaWS.tData2 dataNascita = new tData2(); dataNascita.Anno = searchInfo.OtherParam["DATA_NASCITA"].ToString().Substring(4, 4); dataNascita.Mese = searchInfo.OtherParam["DATA_NASCITA"].ToString().Substring(2, 2); dataNascita.Giorno = searchInfo.OtherParam["DATA_NASCITA"].ToString().Substring(0, 2); dpRichiesta.DataNascita = dataNascita; } if (searchInfo.OtherParam.ContainsKey("SESSO")) { dpRichiesta.Sesso = searchInfo.OtherParam["SESSO"].ToString(); } if (searchInfo.OtherParam.ContainsKey("COMUNE_NASCITA") || searchInfo.OtherParam.ContainsKey("PROVINCIA_NASCITA")) { ArcaWS.tLuogo2 comuneNascita = new tLuogo2(); if (searchInfo.OtherParam.ContainsKey("COMUNE_NASCITA")) { comuneNascita.Nome = searchInfo.OtherParam["COMUNE_NASCITA"].ToString(); } if (searchInfo.OtherParam.ContainsKey("PROVINCIA_NASCITA")) { comuneNascita.Provincia = searchInfo.OtherParam["PROVINCIA_NASCITA"].ToString(); } dpRichiesta.ComuneNascita = comuneNascita; } ricercaDA.DatiPersonali = dpRichiesta; datiRisposta = wsArca.ricercaPerDatiPersonaliParziali(ricercaDA); } //Se il webservice di Arca è andato in errore lancia un'eccezione con il dettaglio dell'errore if (datiRisposta.Esito.ReturnCode != "WS-OK") { throw new SearchException(SearchExceptionCode.SERVER_ERROR, datiRisposta.Esito.Descrizione); } else { List <SearchOutputRow> rows = new List <SearchOutputRow>(); if (datiRisposta.Esito.TotaleSinonimiRestituiti == 1) { SearchOutputRow row = new SearchOutputRow(); ArcaWS.tCodiceFiscale cfRisposta = datiRisposta.Dettaglio.HighProfile.CodiceFiscale; row.Codice = cfRisposta.Cognome + cfRisposta.Nome + cfRisposta.Anno + cfRisposta.Mese + cfRisposta.Giorno + cfRisposta.Comune + cfRisposta.CodControllo; row.Descrizione = datiRisposta.Dettaglio.HighProfile.DatiPersonali.Cognome + " " + datiRisposta.Dettaglio.HighProfile.DatiPersonali.Nome; rows.Add(row); } else { for (int i = 0; i <= datiRisposta.Esito.TotaleSinonimiRestituiti; i++) { SearchOutputRow row = new SearchOutputRow(); ArcaWS.tCodiceFiscale cfRisposta = datiRisposta.Sinonimi[i].LowProfile.CodiceFiscale; row.Codice = cfRisposta.Cognome + cfRisposta.Nome + cfRisposta.Anno + cfRisposta.Mese + cfRisposta.Giorno + cfRisposta.Comune + cfRisposta.CodControllo; row.Descrizione = datiRisposta.Sinonimi[i].LowProfile.DatiPersonali.Cognome + " " + datiRisposta.Sinonimi[i].LowProfile.DatiPersonali.Nome; rows.Add(row); } } SearchOutput res = new SearchOutput(rows, datiRisposta.Esito.TotaleSinonimiRestituiti); return(res); } } catch (Exception e) { throw new SearchException(SearchExceptionCode.SERVICE_UNAVAILABLE); } }
public IActionResult Report([FromBody] SearchFromTo <TypeLogEnum> requestDto) { SearchOutput data = _logService.Search(requestDto, GetCurrentUser()); return(Json(data)); }
public void SearchByAuthor() { SearchOutput searchOutput = new SearchOutput(); _view.OutputText = searchOutput.SearchResultsOutput(_view.EnteredAuthor, _model.GetAllPolygraphicItems()); }