public string GetConfigurationContents(ClxApplication application, ConfigurationKey key)
        {
            string appConfigPath = GetSourceConfigPath(application);

            XmlDocument configDoc = new XmlDocument();

            configDoc.Load(appConfigPath);

            ConfigurationSettings settings = ConfigurationSettingsLoader.GetInstance().GetConfigurationSettings(application, key);

            string settingsNodeName = configDoc.SelectSingleNode("/configuration/configSections").FirstChild.FirstChild.Attributes["name"].Value;

            XmlNode appSettingsNode = configDoc.SelectSingleNode("/configuration/applicationSettings/" + settingsNodeName);

            foreach (XmlNode settingsNode in appSettingsNode.ChildNodes)
            {
                if (settingsNode.Attributes["name"].Value == "PawnSecDBHost")
                {
                    settingsNode.FirstChild.InnerText = settings.PawnSecDBHost;
                }
                else if (settingsNode.Attributes["name"].Value == "PawnSecDBPassword")
                {
                    settingsNode.FirstChild.InnerText = settings.PawnSecDBPassword;
                }
                else if (settingsNode.Attributes["name"].Value == "PawnSecDBPort")
                {
                    settingsNode.FirstChild.InnerText = settings.PawnSecDBPort;
                }
                else if (settingsNode.Attributes["name"].Value == "PawnSecDBSchema")
                {
                    settingsNode.FirstChild.InnerText = settings.PawnSecDBSchema;
                }
                else if (settingsNode.Attributes["name"].Value == "PawnSecDBService")
                {
                    settingsNode.FirstChild.InnerText = settings.PawnSecDBService;
                }
                else if (settingsNode.Attributes["name"].Value == "PawnSecDBUser")
                {
                    settingsNode.FirstChild.InnerText = settings.PawnSecDBUser;
                }
                else if (settingsNode.Attributes["name"].Value == "prodEnv")
                {
                    settingsNode.FirstChild.InnerText = settings.DstrProdEnv;
                }
            }

            StringBuilder sb = null;

            using (var stringWriter = new StringWriter())
                using (var xmlTextWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings()
                {
                    Indent = true
                }))
                {
                    configDoc.WriteTo(xmlTextWriter);
                    sb = stringWriter.GetStringBuilder();
                }

            return(sb.ToString());
        }
        public DatabaseConnectionStrings GetConnectionString(ClxApplication application, ConfigurationKey key)
        {
            DatabaseConnectionStrings connectionStrings = new DatabaseConnectionStrings();

            connectionStrings.PawnSecConnectionInfo  = GetPawnSecDatabaseConfigurationInfo(application, key);
            connectionStrings.CcsOwnerConnectionInfo = GetCcsOwnerDatabaseConfigurationInfo(connectionStrings.PawnSecConnectionInfo);

            return(connectionStrings);
        }
        private DatabaseConnectionInfo GetPawnSecDatabaseConfigurationInfo(ClxApplication application, ConfigurationKey key)
        {
            string configValue = ConfigurationReader.GetInstance().GetConfigurationContents(application, key);

            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(configValue);

            XmlNodeList list = xmlDocument.GetElementsByTagName("setting");

            DatabaseConnectionInfo info = new DatabaseConnectionInfo();

            foreach (XmlNode n in list)
            {
                string decryptedValue = EncryptionUtil.Decrypt(n.ChildNodes[0].InnerText, Resources.PrivateKey, true);

                switch (n.Attributes["name"].Value)
                {
                case "PawnSecDBUser":
                    info.UserId = decryptedValue;
                    break;

                case "PawnSecDBPassword":
                    info.Password = decryptedValue;
                    break;

                case "PawnSecDBSchema":
                    info.Schema = decryptedValue;
                    break;

                case "PawnSecDBPort":
                    info.Port = decryptedValue;
                    break;

                case "PawnSecDBHost":
                    info.Host = decryptedValue;
                    break;

                case "PawnSecDBService":
                    info.Service = decryptedValue;
                    break;
                }
            }

            return(info);
        }
        private string GetSourceConfigPath(ClxApplication application)
        {
            EnvironmentInfo env = EnvironmentInfo.GetInstance();

            switch (application)
            {
            case ClxApplication.Audit: return(Path.Combine(env.AuditProjectEnvironment.SourceDirectory, "app.config"));

            case ClxApplication.AuditQueries: return(Path.Combine(env.AuditQueriesProjectEnvironment.SourceDirectory, "app.config"));

            case ClxApplication.Cashlinx: return(Path.Combine(env.PawnProjectEnvironment.SourceDirectory, "app.config"));

            case ClxApplication.DSTRViewer: return(Path.Combine(env.DstrViewerProjectEnvironment.SourceDirectory, "app.config"));

            case ClxApplication.Support: return(Path.Combine(env.SupportProjectEnvironment.SourceDirectory, "app.config"));

            default:
                throw new BuildException("Application not supported: " + application);
            }
        }
        public ConfigurationSettings GetConfigurationSettings(ClxApplication application, ConfigurationKey key)
        {
            switch (key)
            {
            case ConfigurationKey.CLXD:
                return(new ConfigurationSettings()
                {
                    DstrProdEnv = key.ToString().ToUpper(),
                    PawnSecDBHost = "1xaOn6Ot6HRjXbIPl7E2WJ3Bs9SmWpEy",
                    PawnSecDBPassword = "******",
                    PawnSecDBPort = "c5oa+iWxTPs=",
                    PawnSecDBSchema = "Ny2VIxVYqnA=",
                    PawnSecDBService = "q7wvRn4eb3cRrLvSkAHG8w==",
                    PawnSecDBUser = "******"
                });

            case ConfigurationKey.CLXD2:
                return(new ConfigurationSettings()
                {
                    DstrProdEnv = key.ToString().ToUpper(),
                    PawnSecDBHost = "5HYH35IsmBLxuFKgDA0deV4cSI9w/aeE",
                    PawnSecDBPassword = "******",
                    PawnSecDBPort = "c5oa+iWxTPs=",
                    PawnSecDBSchema = "Ny2VIxVYqnA=",
                    PawnSecDBService = "zZCXW9Ci9FGVpj7+YIrMdxtI3uI0kDL1",
                    PawnSecDBUser = "******"
                });

            case ConfigurationKey.CLXD3:
                return(new ConfigurationSettings()
                {
                    DstrProdEnv = key.ToString().ToUpper(),
                    PawnSecDBHost = "5HYH35IsmBLxuFKgDA0deV4cSI9w/aeE",
                    PawnSecDBPassword = "******",
                    PawnSecDBPort = "c5oa+iWxTPs=",
                    PawnSecDBSchema = "Ny2VIxVYqnA=",
                    PawnSecDBService = "tN2vG1Y6pleVpj7+YIrMdxtI3uI0kDL1",
                    PawnSecDBUser = "******"
                });

            case ConfigurationKey.CLXI:
                return(new ConfigurationSettings()
                {
                    DstrProdEnv = key.ToString().ToUpper(),
                    PawnSecDBHost = "5HYH35IsmBLxuFKgDA0deV4cSI9w/aeE",
                    PawnSecDBPassword = "******",
                    PawnSecDBPort = "c5oa+iWxTPs=",
                    PawnSecDBSchema = "Ny2VIxVYqnA=",
                    PawnSecDBService = "7GS8RS4GC4MRrLvSkAHG8w==",
                    PawnSecDBUser = "******"
                });

            case ConfigurationKey.CLXP:
                return(new ConfigurationSettings()
                {
                    DstrProdEnv = key.ToString().ToUpper(),
                    PawnSecDBHost = "bIyV3M7QftbxuFKgDA0deV4cSI9w/aeE",
                    PawnSecDBPassword = "******",
                    PawnSecDBPort = "07s4aRvDFLs=",
                    PawnSecDBSchema = "Ny2VIxVYqnA=",
                    PawnSecDBService = "ZisF3qmLAEMRrLvSkAHG8w==",
                    PawnSecDBUser = "******"
                });

            case ConfigurationKey.CLXPG:
                return(new ConfigurationSettings()
                {
                    DstrProdEnv = key.ToString().ToUpper(),
                    PawnSecDBHost = "WTzPYAETxojxuFKgDA0deV4cSI9w/aeE",
                    PawnSecDBPassword = "******",
                    PawnSecDBPort = "c5oa+iWxTPs=",
                    PawnSecDBSchema = "Ny2VIxVYqnA=",
                    PawnSecDBService = "xWlbtRgC7x+Vpj7+YIrMdxtI3uI0kDL1",
                    PawnSecDBUser = "******"
                });

            case ConfigurationKey.CLXPP:
                return(new ConfigurationSettings()
                {
                    DstrProdEnv = key.ToString().ToUpper(),
                    PawnSecDBHost = "UzeafzXCKVFUiOK4kbZnXSPfSmxEso8X7kK+s12DlYA=",
                    PawnSecDBPassword = "******",
                    PawnSecDBPort = "qHuK02GJ/XY=",
                    PawnSecDBSchema = "Ny2VIxVYqnA=",
                    PawnSecDBService = "OFifF/KYo4eVpj7+YIrMdxtI3uI0kDL1",
                    PawnSecDBUser = "******"
                });

            case ConfigurationKey.CLXQ:
                return(new ConfigurationSettings()
                {
                    DstrProdEnv = key.ToString().ToUpper(),
                    PawnSecDBHost = "bYtNZ/PbgPkj30psRLKPF+5CvrNdg5WA",
                    PawnSecDBPassword = "******",
                    PawnSecDBPort = "07s4aRvDFLs=",
                    PawnSecDBSchema = "Ny2VIxVYqnA=",
                    PawnSecDBService = "7fOnJxxDY7oRrLvSkAHG8w==",
                    PawnSecDBUser = "******"
                });

            case ConfigurationKey.CLXR2:
                return(new ConfigurationSettings()
                {
                    DstrProdEnv = key.ToString().ToUpper(),
                    PawnSecDBHost = "O2krnbvpiHLxuFKgDA0deV4cSI9w/aeE",
                    PawnSecDBPassword = "******",
                    PawnSecDBPort = "c5oa+iWxTPs=",
                    PawnSecDBSchema = "Ny2VIxVYqnA=",
                    PawnSecDBService = "aEa/5aTGcl2Vpj7+YIrMdxtI3uI0kDL1",
                    PawnSecDBUser = "******"
                });

            case ConfigurationKey.CLXT:
                return(new ConfigurationSettings()
                {
                    DstrProdEnv = key.ToString().ToUpper(),
                    PawnSecDBHost = "bYtNZ/PbgPkj30psRLKPF+5CvrNdg5WA",
                    PawnSecDBPassword = "******",
                    PawnSecDBPort = "07s4aRvDFLs=",
                    PawnSecDBSchema = "Ny2VIxVYqnA=",
                    PawnSecDBService = "BBBxdZodCA0RrLvSkAHG8w==",
                    PawnSecDBUser = "******"
                });

            case ConfigurationKey.CLXT2:
                return(new ConfigurationSettings()
                {
                    DstrProdEnv = key.ToString().ToUpper(),
                    PawnSecDBHost = "bYtNZ/PbgPkj30psRLKPF+5CvrNdg5WA",
                    PawnSecDBPassword = "******",
                    PawnSecDBPort = "07s4aRvDFLs=",
                    PawnSecDBSchema = "Ny2VIxVYqnA=",
                    PawnSecDBService = "Ny/sG2mylyCVpj7+YIrMdxtI3uI0kDL1",
                    PawnSecDBUser = "******"
                });

            default: throw new BuildException("Configuration Settings not implemented: " + application + " - " + key);
            }
        }