private void btnSaveSettings_Click(object sender, EventArgs e) { try { //biztalkAdminOperations.LogInfoInLogFile("Settings:Update Started"); appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); configFile = System.IO.Path.Combine(appPath, "MigrationSuite.exe.config"); ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap(); configFileMap.ExeConfigFilename = configFile; Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None); config.AppSettings.Settings["AppToRefer"].Value = txtAppToRefer.Text; config.AppSettings.Settings["RemoteRootFolder"].Value = txtTemporaryFolder.Text; // config.AppSettings.Settings["BamExePath"].Value = Environment.GetEnvironmentVariable("BTSINSTALLPATH") + @"Tracking\bm.exe"; config.AppSettings.Settings["CertPass"].Value = txtCertPass.Text; config.AppSettings.Settings["FoldersToCopyNoFiles"].Value = txtFoldersToCopyNoFiles.Text; config.AppSettings.Settings["FoldersToCopy"].Value = txtFoldersToCopy.Text; config.AppSettings.Settings["BizTalkAppToIgnore"].Value = txtBiztalkAppToIgnore.Text; config.AppSettings.Settings["CustomDllToInclude"].Value = txtCustomDllToInclude.Text; config.AppSettings.Settings["WindowsServiceToIgnore"].Value = txtWindowsServiceToIgnore.Text; config.AppSettings.Settings["WebSitesDriveDestination"].Value = txtWebSitesDrive.Text; config.AppSettings.Settings["FoldersDriveDestination"].Value = txtFoldersDrive.Text; config.AppSettings.Settings["ServicesDriveDestination"].Value = txtServicesDrive.Text; config.Save(); biztalkAdminOperations.UpdateSettings(); //added BizTalkAdminOperations goBack = new BizTalkAdminOperations(); loopback.Children.Clear(); loopback.Children.Add(goBack); //this.close(); } catch (Exception ex) { //changed BizTalkAdminOperations biztalkAdminOperations = new BizTalkAdminOperations(); biztalkAdminOperations.LogInfoInLogFile("Error while Updating Settings to ConfigFile " + ex.Message + ", " + ex.StackTrace); //added BizTalkAdminOperations goBack = new BizTalkAdminOperations(); loopback.Children.Clear(); loopback.Children.Add(goBack); // this.Close(); } }
private void btnSaveSettings_Click(object sender, EventArgs e) { try { //biztalkAdminOperations.LogInfoInLogFile("Settings:Update Started"); _appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); _configFile = Path.Combine(_appPath, "MigrationTool.exe.config"); ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap { ExeConfigFilename = _configFile }; Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None); config.AppSettings.Settings["AppToRefer"].Value = txtAppToRefer.Text; config.AppSettings.Settings["RemoteRootFolder"].Value = txtTemporaryFolder.Text; // config.AppSettings.Settings["BamExePath"].Value = Environment.GetEnvironmentVariable("BTSINSTALLPATH") + @"Tracking\bm.exe"; config.AppSettings.Settings["CertPass"].Value = txtCertPass.Text; config.AppSettings.Settings["FoldersToCopyNoFiles"].Value = txtFoldersToCopyNoFiles.Text; config.AppSettings.Settings["FoldersToCopy"].Value = txtFoldersToCopy.Text; config.AppSettings.Settings["BizTalkAppToIgnore"].Value = txtBiztalkAppToIgnore.Text; config.AppSettings.Settings["CustomDllToInclude"].Value = txtCustomDllToInclude.Text; config.AppSettings.Settings["WindowsServiceToIgnore"].Value = txtWindowsServiceToIgnore.Text; config.AppSettings.Settings["WebSitesDriveDestination"].Value = txtWebSitesDrive.Text; config.AppSettings.Settings["FoldersDriveDestination"].Value = txtFoldersDrive.Text; config.AppSettings.Settings["ServicesDriveDestination"].Value = txtServicesDrive.Text; config.Save(); _biztalkAdminOperations.UpdateSettings(); Close(); } catch (Exception ex) { using (BizTalkAdminOperations adminOperations = new BizTalkAdminOperations()) { adminOperations.LogInfoInLogFile("Error while Updating Settings to ConfigFile " + ex.Message + ", " + ex.StackTrace); } Close(); } }