Beispiel #1
0
        /// <summary>
        /// Sets up the obd database and config.
        /// </summary>
        private void InitializeDatabase()
        {
            OBDSql = new OBDSql(ConfigurationManager.ConnectionStrings["OBDConnectionString"].ConnectionString);

            try
            {
                OBDConfig = OBDSql.GetConfiguration();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Updates the database.
        /// </summary>
        private void UpdateDatabase()
        {
            // Exit. Application doesn't have a valid OBD device.
            if (ELM327Manager.RequestType != RequestType.DataStream)
            {
                return;
            }

            // Create storage.
            if (ELM327Manager.Storage == null)
            {
                int sessionId = OBDSql.GetSession(OBDConfig.CarId);                 // Do not use try/catch. Let the program crash if it fails to retrieve session id.
                ELM327Manager.SetStorage(sessionId);
            }

            // Insert to database when the threshold is reached.
            if (ELM327Manager.Storage.Rows.Count >= OBDSql.StorageThreshold)
            {
                OBDSql.Insert(ELM327Manager.Storage);
            }
        }