Ejemplo n.º 1
0
        private EntityConnectionStringBuilder UpdateConnectionParameters(
            DatabaseAccessConfiguration accessConfigurations)
        {
            var connection = new EntityConnectionStringBuilder(
                ConfigurationManager.ConnectionStrings[nameof(DragonflyEntities)].ConnectionString);
            var builder = new SqlConnectionStringBuilder(connection.ProviderConnectionString)
            {
                ApplicationName = "Dragonfly server"
            };

            if (!string.IsNullOrWhiteSpace(accessConfigurations.ServerName))
            {
                builder.DataSource = accessConfigurations.ServerName;
            }
            if (!string.IsNullOrWhiteSpace(accessConfigurations.DbName))
            {
                builder.InitialCatalog = accessConfigurations.DbName;
            }
            if (!string.IsNullOrWhiteSpace(accessConfigurations.UserName))
            {
                builder.UserID = accessConfigurations.UserName;
            }
            if (!string.IsNullOrWhiteSpace(accessConfigurations.Password))
            {
                builder.Password = accessConfigurations.Password;
            }

            connection.ProviderConnectionString = builder.ToString();
            return(connection);
        }
Ejemplo n.º 2
0
        public void ReadDbConfigurationTest()
        {
            Assert.IsNotNull(_LibManager, "Library settings manager can't be null, but it is.");

            DragonflyConfig currentConfig = null;

            currentConfig = ReadCurrentConfiguration();
            Assert.IsNotNull(
                currentConfig,
                "Return empty configuration after reading.");
            Assert.IsNotNull(
                currentConfig.DbConfiguration,
                "Return empty DB configuration after reading.");

            try
            {
                DatabaseAccessConfiguration accessConfig = _Raader.GetDbAccessSettings();
                Assert.IsNotNull(accessConfig, "Reader was returned an empty db config.");
                Assert.AreEqual(currentConfig.DbConfiguration.DbAddress, accessConfig.ServerName);
                Assert.AreEqual(currentConfig.DbConfiguration.DbName, accessConfig.DbName);
                Assert.AreEqual(currentConfig.DbConfiguration.DefaultUserName, accessConfig.UserName);
                Assert.AreEqual(currentConfig.DbConfiguration.DefaultUserPassword, accessConfig.Password);
            }
            finally
            {
            }
        }
Ejemplo n.º 3
0
 public DBContextGenerator(DatabaseAccessConfiguration accessConfigurations)
 {
     if (accessConfigurations == null)
     {
         throw new ArgumentNullException(nameof(accessConfigurations));
     }
     _DbConfig = Clone(accessConfigurations);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Base constructor of the MS MQL factory.
 /// </summary>
 public MsSqlFactory(DatabaseAccessConfiguration dbConfig)
 {
     if (dbConfig == null)
     {
         throw new ArgumentNullException(nameof(dbConfig));
     }
     _ContextGenerator  = new DBContextGenerator(dbConfig);
     _UserDBDataManager = new UserDBDataManager();
 }
Ejemplo n.º 5
0
 static Common()
 {
     Connectionconfig = new SettingsLibReader().GetDbAccessSettings(_DefaultPath);
 }