Пример #1
0
        public void LoadChemistryItems(string filter)
        {
            string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";

            try
            {
                _initializing = true;
                ChemistryItems.Clear();
                var lib = new Database.Library();
                List <ChemistryDTO> dto = lib.GetAllChemistry(filter);
                foreach (var chemistry in dto)
                {
                    var mol = new Chemistry();
                    mol.Initializing = true;

                    mol.ID      = chemistry.Id;
                    mol.XML     = chemistry.Cml;
                    mol.Name    = chemistry.Name;
                    mol.Formula = chemistry.Formula;

                    ChemistryItems.Add(mol);
                    LoadOtherNames(mol);

                    mol.Initializing = false;
                }

                _initializing = false;
            }
            catch (Exception ex)
            {
                new ReportError(Globals.Chem4WordV3.Telemetry, Globals.Chem4WordV3.WordTopLeft, module, ex).ShowDialog();
            }
        }
Пример #2
0
        public void LoadChemistryItems(string filter)
        {
            string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";

            try
            {
                _initializing = true;
                ChemistryItems.Clear();
                SQLiteDataReader chemistry = LibraryModel.GetAllChemistry(filter);

                while (chemistry.Read())
                {
                    var mol = new Chemistry();

                    mol.Initializing = true;

                    mol.ID = (long)chemistry["ID"];
                    var byteArray = (Byte[])chemistry["Chemistry"];
                    mol.XML     = Encoding.UTF8.GetString(byteArray);
                    mol.Name    = chemistry["name"] as string;
                    mol.Formula = chemistry["formula"] as string;
                    ChemistryItems.Add(mol);
                    LoadOtherNames(mol);
                    mol.Initializing = false;
                }

                chemistry.Close();
                chemistry.Dispose();

                _initializing = false;
            }
            catch (Exception ex)
            {
                new ReportError(Globals.Chem4WordV3.Telemetry, Globals.Chem4WordV3.WordTopLeft, module, ex).ShowDialog();
            }
        }