Exemple #1
0
        public static void ExecuteModifyConfigurationFile(ISessionWrapper session)
        {
            //System.Diagnostics.Debugger.Launch();

            string customerName         = session.Get(CUSTOMER_NAME[0]);
            string groupName            = session.Get(GROUP_NAME[0]);
            string configFileUrl        = session.Get(CONFIG_FILE_URL[0]);
            string monitorWebServiceUrl = session.Get(MONITOR_WEBSERVICE_URL[0]);
            string monitorHost          = session.Get(MONITOR_HOST[0]);
            string connectionString     = session.Get(CONNECTION_STRING[0]);
            string installLocation      = session.Get("INSTALL_LOCATION");

            session.Log("CUSTOMER_NAME = " + customerName);
            session.Log("GROUP_NAME = " + groupName);
            session.Log("CONFIG_FILE_URL = " + configFileUrl);
            session.Log("MONITOR_WEBSERVICE_URL = " + monitorWebServiceUrl);
            session.Log("MONITOR_HOST = " + monitorHost);
            session.Log("CONNECTION_STRING = " + connectionString);
            session.Log("INSTALL_LOCATION" + installLocation);

            string configFilePath = Path.Combine(installLocation, "Cegeka.Updater.Service.exe.config");

            var doc         = XDocument.Load(configFilePath);
            var appSettings = doc.Descendants().FirstOrDefault(e => e.Name == "appSettings");

            replaceAppSettingAttributeValue(appSettings, CUSTOMER_NAME[1], customerName);
            replaceAppSettingAttributeValue(appSettings, GROUP_NAME[1], groupName);
            replaceAppSettingAttributeValue(appSettings, CONFIG_FILE_URL[1], configFileUrl);
            replaceAppSettingAttributeValue(appSettings, MONITOR_WEBSERVICE_URL[1], monitorWebServiceUrl);
            replaceAppSettingAttributeValue(appSettings, MONITOR_HOST[1], monitorHost);

            var connectionStringSection = doc.Descendants().FirstOrDefault(e => e.Name == "connectionStrings");

            replaceConnectionString(connectionStringSection, CONNECTION_STRING[1], connectionString);

            doc.Save(configFilePath);
        }