Exemplo n.º 1
0
        public static void Init(HttpServerUtility server)
        {
            string configPath = Path.Combine(PARENT_CONFIG_PATH, DefaultConfigName);
            DefaultConfigPath = server.MapPath(configPath);

            //By default if there's no config let's create a sqlite db.
            string defaultConfigPath = DefaultConfigPath;

            string sqlitePath = Path.Combine(DATA_FOLDER, DEFAULT_SQLITE_NAME);
            sqlitePath = server.MapPath(sqlitePath);

            if (!File.Exists(defaultConfigPath))
            {
                ConfigFile file = new ConfigFile(defaultConfigPath);

                file.Set(DbConstants.KEY_DB_TYPE, DbConstants.DB_TYPE_SQLITE);
                file.Set(DbConstants.KEY_FILE_NAME, sqlitePath);
                file.Save();

                CurrentConfigFile = file;
            }
            else
            {
                CurrentConfigFile = new ConfigFile(defaultConfigPath);
                CurrentConfigFile.Load();
            }

            CurrentDbProvider = DbProviderFactory.Create(CurrentConfigFile);
        }
Exemplo n.º 2
0
        public static void Init(HttpServerUtility server)
        {
            lock (_lock)
            {
                if (Debugger.IsAttached)
                {
                    BasicConfigurator.Configure();
                }
                else
                {
                    XmlConfigurator.Configure();
                }

                string configPath = Path.Combine(PARENT_CONFIG_PATH, DefaultConfigName);
                DefaultConfigPath = server.MapPath(configPath);

                RootDir = server.MapPath(".");

                log.Debug("DYLD_FALLBACK_LIBRARY_PATH: " + Environment.GetEnvironmentVariable("DYLD_FALLBACK_LIBRARY_PATH"));
                log.Debug("PWD: " + Environment.CurrentDirectory);

                //Check if we are running as an Azure App Service with a MySQL In App database
                string mysql = Environment.GetEnvironmentVariable("MYSQLCONNSTR_localdb");
                if (mysql != null)
                {
                    log.Debug("Loading config from env var MYSQLCONNSTR_localdb: " + mysql);
                    CurrentConfigFile = new MySqlConnStringConfig(mysql);
                    CurrentConfigFile.Load();
                }
                else
                {
                    log.Debug("No env var detected for MYSQLCONNSTR_localdb");

                    //By default if there's no config let's create a sqlite db.
                    string defaultConfigPath = DefaultConfigPath;

                    string sqlitePath = Path.Combine(DATA_FOLDER, DEFAULT_SQLITE_NAME);
                    sqlitePath = server.MapPath(sqlitePath);

                    if (!File.Exists(defaultConfigPath))
                    {
                        ConfigFile file = new ConfigFile(defaultConfigPath);

                        file.Set(DbConstants.KEY_DB_TYPE, DbConstants.DB_TYPE_SQLITE);
                        file.Set(DbConstants.KEY_FILE_NAME, sqlitePath);
                        file.Save();

                        CurrentConfigFile = file;
                    }
                    else
                    {
                        CurrentConfigFile = new ConfigFile(defaultConfigPath);
                        CurrentConfigFile.Load();
                    }
                }

                CurrentDbProvider = DbProviderFactory.Create(CurrentConfigFile);
                _inited           = true;
            }
        }
Exemplo n.º 3
0
        public static void Init(HttpServerUtility server)
        {
            string configPath = Path.Combine(PARENT_CONFIG_PATH, DefaultConfigName);

            DefaultConfigPath = server.MapPath(configPath);

            //By default if there's no config let's create a sqlite db.
            string defaultConfigPath = DefaultConfigPath;

            string sqlitePath = Path.Combine(DATA_FOLDER, DEFAULT_SQLITE_NAME);

            sqlitePath = server.MapPath(sqlitePath);

            if (!File.Exists(defaultConfigPath))
            {
                ConfigFile file = new ConfigFile(defaultConfigPath);

                file.Set(DbConstants.KEY_DB_TYPE, DbConstants.DB_TYPE_SQLITE);
                file.Set(DbConstants.KEY_FILE_NAME, sqlitePath);
                file.Save();

                CurrentConfigFile = file;
            }
            else
            {
                CurrentConfigFile = new ConfigFile(defaultConfigPath);
                CurrentConfigFile.Load();
            }

            CurrentDbProvider = DbProviderFactory.Create(CurrentConfigFile);
        }
Exemplo n.º 4
0
        public static void Init(HttpServerUtility server)
        {
            lock (_lock)
            {
                if (Debugger.IsAttached)
                {
                    BasicConfigurator.Configure();
                }
                else
                {
                    XmlConfigurator.Configure();
                }

                string configPath = Path.Combine(PARENT_CONFIG_PATH, DefaultConfigName);
                DefaultConfigPath = server.MapPath(configPath);

                RootDir = server.MapPath(".");

                log.Debug("DYLD_FALLBACK_LIBRARY_PATH: " + Environment.GetEnvironmentVariable("DYLD_FALLBACK_LIBRARY_PATH"));
                log.Debug("PWD: " + Environment.CurrentDirectory);

                //By default if there's no config let's create a sqlite db.
                string defaultConfigPath = DefaultConfigPath;

                string sqlitePath = Path.Combine(DATA_FOLDER, DEFAULT_SQLITE_NAME);
                sqlitePath = server.MapPath(sqlitePath);

                if (!File.Exists(defaultConfigPath))
                {
                    ConfigFile file = new ConfigFile(defaultConfigPath);

                    file.Set(DbConstants.KEY_DB_TYPE, DbConstants.DB_TYPE_SQLITE);
                    file.Set(DbConstants.KEY_FILE_NAME, sqlitePath);
                    file.Save();

                    CurrentConfigFile = file;
                }
                else
                {
                    CurrentConfigFile = new ConfigFile(defaultConfigPath);
                    CurrentConfigFile.Load();
                }

                CurrentDbProvider = DbProviderFactory.Create(CurrentConfigFile);
                _inited           = true;
            }
        }
Exemplo n.º 5
0
        public static void Init(HttpServerUtility server)
        {
            lock (_lock)
            {
                if (Debugger.IsAttached)
                    BasicConfigurator.Configure();
                else
                    XmlConfigurator.Configure();

                string configPath = Path.Combine(PARENT_CONFIG_PATH, DefaultConfigName);
                DefaultConfigPath = server.MapPath(configPath);

                RootDir = server.MapPath(".");

                log.Debug("DYLD_FALLBACK_LIBRARY_PATH: " + Environment.GetEnvironmentVariable("DYLD_FALLBACK_LIBRARY_PATH"));
                log.Debug("PWD: " + Environment.CurrentDirectory);

                //By default if there's no config let's create a sqlite db.
                string defaultConfigPath = DefaultConfigPath;

                string sqlitePath = Path.Combine(DATA_FOLDER, DEFAULT_SQLITE_NAME);
                sqlitePath = server.MapPath(sqlitePath);

                if (!File.Exists(defaultConfigPath))
                {
                    ConfigFile file = new ConfigFile(defaultConfigPath);

                    file.Set(DbConstants.KEY_DB_TYPE, DbConstants.DB_TYPE_SQLITE);
                    file.Set(DbConstants.KEY_FILE_NAME, sqlitePath);
                    file.Save();

                    CurrentConfigFile = file;
                }
                else
                {
                    CurrentConfigFile = new ConfigFile(defaultConfigPath);
                    CurrentConfigFile.Load();
                }

                CurrentDbProvider = DbProviderFactory.Create(CurrentConfigFile);
                _inited = true;
            }

        }
Exemplo n.º 6
0
        private void UpdateConfigFile(ConfigFile configFile)
        {
           if (string.IsNullOrEmpty(txtServer.Text))
                configFile.Remove(DbConstants.KEY_HOST);
            else
                configFile.Set(DbConstants.KEY_HOST, txtServer.Text);

            if (string.IsNullOrEmpty(txtFilePath.Text))
                configFile.Remove(DbConstants.KEY_FILE_NAME);
            else
                configFile.Set(DbConstants.KEY_FILE_NAME, txtFilePath.Text);

            if (string.IsNullOrEmpty(dropDownDataProvider.Text))
                configFile.Remove(DbConstants.KEY_DB_TYPE);
            else
                configFile.Set(DbConstants.KEY_DB_TYPE, dropDownDataProvider.Text);

            if (string.IsNullOrEmpty(txtPort.Text))
                configFile.Remove(DbConstants.KEY_PORT);
            else
                configFile.Set(DbConstants.KEY_PORT, txtPort.Text);

            if (string.IsNullOrEmpty(txtClientExecutable.Text))
                configFile.Remove(DbConstants.KEY_CLIENT_EXEC);
            else
                configFile.Set(DbConstants.KEY_CLIENT_EXEC, txtClientExecutable.Text);

            if (string.IsNullOrEmpty(txtDatabase.Text))
                configFile.Remove(DbConstants.KEY_DATABASE);
            else
                configFile.Set(DbConstants.KEY_DATABASE, txtDatabase.Text);
            
            if (string.IsNullOrEmpty(txtUserName.Text))
                configFile.Remove(DbConstants.KEY_UID);
            else
                configFile.Set(DbConstants.KEY_UID, txtUserName.Text);

            if (string.IsNullOrEmpty(txtPassword.Text))
                configFile.Remove(DbConstants.KEY_PWD);
            else
                configFile.Set(DbConstants.KEY_PWD, txtPassword.Text);
            
            configFile.Save();
        }