Пример #1
0
        public BaseContext CreateDbContext(LoginModel model)
        {
            String      primaryConnectionString;
            BaseContext primaryDBContext;

            switch (model.PrimaryServerType)
            {
            case DatabaseConstants.SQL_SERVER:
                primaryConnectionString = SQLConnectionString.Replace("{server}", model.PrimaryServerName).Replace("{database}", model.PrimaryDatabaseName).Replace("{user id}", model.PrimaryUserName).Replace("{password}", model.PrimaryPassword);
                primaryDBContext        = new SQLContext(primaryConnectionString);
                break;

            case DatabaseConstants.MY_SQL:
                primaryConnectionString = MySQLConnectionString.Replace("{server}", model.PrimaryServerName).Replace("{database}", model.PrimaryDatabaseName).Replace("{user id}", model.PrimaryUserName).Replace("{password}", model.PrimaryPassword);
                primaryDBContext        = new MySQLContext(primaryConnectionString);
                break;

            default:
                throw new ArgumentOutOfRangeException("PrimaryServerName", null, "Could not establish connection to Primary Database Server");
                // primaryConnectionString = SQLConnectionString.Replace("{server}", model.PrimaryServerName).Replace("{database}", model.PrimaryDatabaseName).Replace("{user id}", model.PrimaryUserName).Replace("{password}", model.PrimaryPassword);
                // primaryDBContext = new SQLContext(primaryConnectionString);
                // break;
            }
            return(primaryDBContext);
        }
 public override bool Execute()
 {
     try
     {
         Log.LogMessageFromText(String.Format("PnPSqlAppConfigGeneratorTask: Reading information for configuration {0} to generate app.config in {1}", Configuration, AppConfigFolder), MessageImportance.Normal);
         PnPAppConfigManager appConfigManager = new PnPAppConfigManager(SQLConnectionString.Replace(""", "\""), Configuration);
         appConfigManager.GenerateAppConfig(AppConfigFolder);
         return(true);
     }
     catch (Exception ex)
     {
         Log.LogErrorFromException(ex);
         return(false);
     }
 }
 public override bool Execute()
 {
     try
     {
         //Log.LogMessageFromText(String.Format("PnPAppConfigReaderTask: Reading information for configuration {0}", Configuration), MessageImportance.Normal);
         PnPAppConfigManager appConfigManager = new PnPAppConfigManager(SQLConnectionString.Replace(""", "\""), Configuration);
         PnPBuildConfiguration = appConfigManager.GetConfigurationElement("PnPBuild");
         PnPBranch             = appConfigManager.GetConfigurationElement("PnPBranch");
         return(true);
     }
     catch (Exception ex)
     {
         Log.LogErrorFromException(ex);
         return(false);
     }
 }
Пример #4
0
        public BaseContext CreateReplicaDbContext(LoginModel model)
        {
            String      replicaConnectionString;
            BaseContext replicaDBContext;

            switch (model.ReplicaServerType)
            {
            case DatabaseConstants.SQL_SERVER:
                replicaConnectionString = SQLConnectionString.Replace("{server}", model.ReplicaServerName).Replace("{database}", model.ReplicaDatabaseName).Replace("{user id}", model.ReplicaUserName).Replace("{password}", model.ReplicaPassword);
                replicaDBContext        = new SQLContext(replicaConnectionString);
                break;

            case DatabaseConstants.MY_SQL:
                replicaConnectionString = MySQLConnectionString.Replace("{server}", model.ReplicaServerName).Replace("{database}", model.ReplicaDatabaseName).Replace("{user id}", model.ReplicaUserName).Replace("{password}", model.ReplicaPassword);
                replicaDBContext        = new MySQLContext(replicaConnectionString);
                break;

            default:
                replicaConnectionString = SQLConnectionString.Replace("{server}", model.ReplicaServerName).Replace("{database}", model.ReplicaDatabaseName).Replace("{user id}", model.ReplicaUserName).Replace("{password}", model.ReplicaPassword);
                replicaDBContext        = new SQLContext(replicaConnectionString);
                break;
            }
            return(replicaDBContext);
        }
Пример #5
0
        public BaseContext CreateDbContext(LoginModel model)
        {
            String      primaryConnectionString;
            BaseContext primaryDBContext;

            switch (model.PrimaryServerType)
            {
            case DatabaseConstants.SQL_SERVER:
                primaryConnectionString = SQLConnectionString.Replace("{server}", model.PrimaryServerName).Replace("{database}", model.PrimaryDatabaseName).Replace("{user id}", model.PrimaryUserName).Replace("{password}", model.PrimaryPassword);
                primaryDBContext        = new SQLContext(primaryConnectionString);
                break;

            case DatabaseConstants.MY_SQL:
                primaryConnectionString = MySQLConnectionString.Replace("{server}", model.PrimaryServerName).Replace("{database}", model.PrimaryDatabaseName).Replace("{user id}", model.PrimaryUserName).Replace("{password}", model.PrimaryPassword);
                primaryDBContext        = new MySQLContext(primaryConnectionString);
                break;

            default:
                primaryConnectionString = SQLConnectionString.Replace("{server}", model.PrimaryServerName).Replace("{database}", model.PrimaryDatabaseName).Replace("{user id}", model.PrimaryUserName).Replace("{password}", model.PrimaryPassword);
                primaryDBContext        = new SQLContext(primaryConnectionString);
                break;
            }
            return(primaryDBContext);
        }