public List <ChemistryDTO> GetAllChemistry(string filter) { List <ChemistryDTO> results = new List <ChemistryDTO>(); using (SQLiteConnection conn = LibraryConnection()) { SQLiteDataReader chemistry = GetAllChemistry(conn, filter); while (chemistry.Read()) { var dto = new ChemistryDTO(); dto.Id = (long)chemistry["ID"]; var byteArray = (Byte[])chemistry["Chemistry"]; dto.Cml = CmlFromBytes(byteArray, dto.Id); dto.Name = chemistry["name"] as string; dto.Formula = chemistry["formula"] as string; results.Add(dto); } chemistry.Close(); chemistry.Dispose(); } return(results); }
/// <summary> /// This is called via Microsoft.Office.Tools.CustomTaskPanel.OnVisibleChanged and Chem4Word.CustomRibbon.OnShowLibraryClick /// </summary> /// <param name="filter"></param> /// <returns></returns> public List <ChemistryDTO> GetAllChemistry(string filter) { string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}({filter})"; var results = new List <ChemistryDTO>(); Stopwatch sw = new Stopwatch(); sw.Start(); using (SQLiteConnection conn = LibraryConnection()) { SQLiteDataReader chemistry = GetAllChemistry(conn, filter); while (chemistry.Read()) { var dto = new ChemistryDTO(); dto.Id = (long)chemistry["ID"]; dto.Cml = CmlFromBytes(chemistry["Chemistry"] as Byte[]); dto.Name = chemistry["name"] as string; dto.Formula = chemistry["formula"] as string; results.Add(dto); } chemistry.Close(); chemistry.Dispose(); } sw.Stop(); Globals.Chem4WordV3.Telemetry.Write(module, "Timing", $"Reading {results.Count} structures took {SafeDouble.AsString(sw.ElapsedMilliseconds)}ms"); return(results); }
public List <ChemistryDTO> GetAllChemistry(string filter) { // This is called via Microsoft.Office.Tools.CustomTaskPaneImpl.OnVisibleChanged and Chem4Word.CustomRibbon.OnShowLibraryClick string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()"; var results = new List <ChemistryDTO>(); Stopwatch sw = new Stopwatch(); sw.Start(); using (SQLiteConnection conn = LibraryConnection()) { SQLiteDataReader chemistry = GetAllChemistry(conn, filter); while (chemistry.Read()) { var dto = new ChemistryDTO(); dto.Id = (long)chemistry["ID"]; dto.Cml = CmlFromBytes(chemistry["Chemistry"] as Byte[]); dto.Name = chemistry["name"] as string; dto.Formula = chemistry["formula"] as string; results.Add(dto); } chemistry.Close(); chemistry.Dispose(); } sw.Stop(); Globals.Chem4WordV3.Telemetry.Write(module, "Timing", $"Reading {results.Count} structures took {sw.ElapsedMilliseconds.ToString("#,##0", CultureInfo.InvariantCulture)}ms"); return(results); }