private string GetChemStructure(LiteEntity le) { using (new WaitCursor()) { var securityProtocol = ServicePointManager.SecurityProtocol; ServicePointManager.SecurityProtocol = securityProtocol | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; ChebiWebServiceService ws = new ChebiWebServiceService(); getCompleteEntityResponse results; ws.Url = UserOptions.ChEBIWebServiceUri; ws.UserAgent = "Chem4Word"; getCompleteEntity gce = new getCompleteEntity(); gce.chebiId = le.chebiId; results = ws.getCompleteEntity(gce); _allResults = results.@return; var chemStructure = _allResults?.ChemicalStructures?[0]?.structure; ServicePointManager.SecurityProtocol = securityProtocol; return(chemStructure); } }
private string GetChemStructure(LiteEntity le) { using (new WaitCursor()) { ChebiWebServiceService ws = new ChebiWebServiceService(); getCompleteEntityResponse results; ws.Url = UserOptions.ChEBIWebServiceUri; ws.UserAgent = "Chem4Word"; getCompleteEntity gce = new getCompleteEntity(); gce.chebiId = le.chebiId; results = ws.getCompleteEntity(gce); _allResults = results.@return; var chemStructure = _allResults?.ChemicalStructures?[0]?.structure; return(chemStructure); } }
private void ExecuteSearch() { string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()"; ErrorsAndWarnings.Text = ""; using (new WaitCursor()) { display1.Chemistry = null; if (!string.IsNullOrEmpty(SearchFor.Text)) { ChebiWebServiceService ws = new ChebiWebServiceService(); getLiteEntityResponse results; var securityProtocol = ServicePointManager.SecurityProtocol; ServicePointManager.SecurityProtocol = securityProtocol | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; ws.Url = UserOptions.ChEBIWebServiceUri; ws.UserAgent = "Chem4Word"; results = ws.getLiteEntity(new getLiteEntity { search = SearchFor.Text, maximumResults = UserOptions.MaximumResults, searchCategory = SearchCategory.ALL, stars = StarsCategory.ALL }); try { var allResults = results.@return; ResultsListView.Items.Clear(); ResultsListView.Enabled = true; if (allResults.Length > 0) { foreach (LiteEntity res in allResults) { var li = new ListViewItem(); li.Text = res.chebiId; li.Tag = res; ListViewItem.ListViewSubItem name = new ListViewItem.ListViewSubItem(li, res.chebiAsciiName); li.SubItems.Add(name); ListViewItem.ListViewSubItem score = new ListViewItem.ListViewSubItem(li, res.searchScore.ToString()); li.SubItems.Add(score); ResultsListView.Items.Add(li); } ResultsListView.Columns[0].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); } else { ErrorsAndWarnings.Text = "Sorry: No results found."; } } catch (Exception ex) { if (ex.Message.Equals("The operation has timed out")) { ErrorsAndWarnings.Text = "Please try again later - the service has timed out"; } else { ErrorsAndWarnings.Text = ex.Message; Telemetry.Write(module, "Exception", ex.Message); Telemetry.Write(module, "Exception", ex.StackTrace); } } finally { ServicePointManager.SecurityProtocol = securityProtocol; } } } EnableImport(); }
private void ExecuteSearch() { ErrorsAndWarnings.Text = ""; using (new WaitCursor()) { display1.Chemistry = null; if (!string.IsNullOrEmpty(SearchFor.Text)) { ChebiWebServiceService ws = new ChebiWebServiceService(); getLiteEntityResponse results; ws.Url = UserOptions.ChEBIWebServiceUri; ws.UserAgent = "Chem4Word"; results = ws.getLiteEntity(new getLiteEntity { search = SearchFor.Text, maximumResults = UserOptions.MaximumResults, searchCategory = SearchCategory.ALL, stars = StarsCategory.ALL }); try { var allResults = results.@return; ResultsListView.Items.Clear(); ResultsListView.Enabled = true; if (allResults.Length > 0) { foreach (LiteEntity res in allResults) { var li = new ListViewItem(); li.Text = res.chebiId; li.Tag = res; ListViewItem.ListViewSubItem name = new ListViewItem.ListViewSubItem(li, res.chebiAsciiName); li.SubItems.Add(name); ListViewItem.ListViewSubItem score = new ListViewItem.ListViewSubItem(li, res.searchScore.ToString()); li.SubItems.Add(score); ResultsListView.Items.Add(li); } ResultsListView.Columns[0].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); } else { ErrorsAndWarnings.Text = "Sorry: No results found."; } } catch (Exception ex) { ErrorsAndWarnings.Text = "The operation has timed out".Equals(ex.Message) ? "Please try again later - the service has timed out" : ex.Message; } finally { } } } EnableImport(); }