예제 #1
0
        public ScimoreDb()
        {
            try
            {
                IPathManager pathManager   = ServiceRegistration.Get <IPathManager>();
                string       dataDirectory = pathManager.GetPath("<DATA>");
                string       databasePath  = Path.Combine(dataDirectory, DEFAULT_DATABASE_FILE);

                const string DATABASE_NAME = "MediaPortal";
                _connectionString = "Initial Catalog=" + DATABASE_NAME;

                _db.Create(databasePath);
                _db.Open(databasePath);
                using (ScimoreConnection conn = _db.CreateConnection(_connectionString))
                {
                    using (IDbCommand command = conn.CreateCommand())
                    {
                        command.CommandText = "CREATE DATABASE IF NOT EXISTS " + DATABASE_NAME;
                        command.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception e)
            {
                ServiceRegistration.Get <ILogger>().Critical("Error establishing database connection", e);
                throw;
            }
        }
예제 #2
0
        private IDbConnection GetConnection()
        {
            IDbConnection conn = scimore.CreateConnection();

            conn.Open();

            return(conn);
        }