Exemplo n.º 1
0
 public ArasSetupConfig(IArasConnectionConfig connectionConfig)
 {
     Name         = connectionConfig.Name;
     ArasAddress  = connectionConfig.ArasAddress;
     ArasDBName   = connectionConfig.ArasDBName;
     ArasUser     = connectionConfig.ArasUser;
     ArasPassword = connectionConfig.ArasPassword;
 }
        public IArasSetupConfig GetConfig(string env)
        {
            IArasConnectionConfig connectionConfig = GetArasConnectionConfig(env);
            IArasSetupConfig      config           = new ArasSetupConfig(connectionConfig)
            {
                DatabaseName = EnvNode.SelectSingleNode(XPATH_DATABASE_NAME).InnerText,
                SqlServer    = EnvNode.SelectSingleNode(XPATH_DB_SERVER).InnerText,
                SqlCmd       = EnvNode.SelectSingleNode(XPATH_SQLCMD).InnerText,
                BackupDir    = EnvNode.SelectSingleNode(XPATH_BACKUP_DIR).InnerText
            };

            return(config);
        }
        private string GetDefaultDBName(IArasConnectionConfig config, string address)
        {
            Console.WriteLine("Getting databases");
            string[] dbs           = Interfaces.Aras.ArasConnection.GetDBList(address);
            string   defaultDBName = config.ArasDBName;
            string   extistingDB   = dbs.FirstOrDefault(s => s.Equals(defaultDBName, StringComparison.Ordinal));

            if (String.IsNullOrEmpty(extistingDB))
            {
                defaultDBName = (dbs.Length > 0) ? dbs[0] : defaultDBName; // Get first db in list
            }
            return(defaultDBName);
        }
        public IArasSetupConfig Setup(string env)
        {
            IArasConnectionConfig connectionConfig = SetupConnection(env);
            IArasSetupConfig      config           = new ArasSetupConfig(connectionConfig);

            config.DatabaseName = EnvNode.SelectSingleNode(XPATH_DATABASE_NAME).InnerText;
            config.SqlServer    = EnvNode.SelectSingleNode(XPATH_DB_SERVER).InnerText;
            config.SqlCmd       = EnvNode.SelectSingleNode(XPATH_SQLCMD).InnerText;
            config.BackupDir    = EnvNode.SelectSingleNode(XPATH_BACKUP_DIR).InnerText;

            string configValue;

            configValue = GetValueFromUserInput($"Set Database Name ({config.ArasDBName}):", config.ArasDBName);
            SaveToFile(EnvNode, Setting.DataBaseName, configValue);
            configValue = GetValueFromUserInput($"Set sqlcmd ({config.SqlCmd}):", config.SqlCmd);
            SaveToFile(EnvNode, Setting.SqlCmd, configValue);
            configValue = GetValueFromUserInput($"Set SQL Server ({config.SqlServer}):", config.SqlServer);
            SaveToFile(EnvNode, Setting.SqlServer, configValue);
            configValue = GetValueFromUserInput($"Set Backup Dir ({config.BackupDir}):", config.BackupDir);
            SaveToFile(EnvNode, Setting.DBBackupDir, configValue);
            config = this.GetConfig(env);
            return(config);
        }