/// <summary> /// Read the configuration file (*.exe.config). /// </summary> /// <param name="extensions">Extensions to load.</param> public static void ReadConfiguration(StringCollection extensions) { if (null == extensions) { throw new ArgumentNullException("extensions"); } // Don't use the default AppSettings reader because // the tool may be called from within another process. // Instead, read the .exe.config file from the tool location. string toolPath = Assembly.GetCallingAssembly().Location; Configuration config = ConfigurationManager.OpenExeConfiguration(toolPath); if (config.HasFile) { KeyValueConfigurationElement configVal = config.AppSettings.Settings["extensions"]; if (configVal != null) { string extensionTypes = configVal.Value; foreach (string extensionType in extensionTypes.Split(";".ToCharArray())) { extensions.Add(extensionType); } } } }
public static void Set(string key, string value) { try { Configuration config = GetConfig(); if (config == null) { return; } KeyValueConfigurationElement element = config.AppSettings.Settings[key]; if (element != null) { element.Value = value; } else { config.AppSettings.Settings.Add(key, value); } config.Save(ConfigurationSaveMode.Modified); } catch (System.Exception ex1) { MessageBox.Show("exception: " + ex1); } }
public static string Get(string key) { try { //used to switch the hardcoded server to CASE's or ARUP based on the existence of a file on disk or not if (key == "jiraserver") { string serverfile = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CASE", "ARUP Issue Tracker", "usecaseserver"); if (System.IO.File.Exists(serverfile)) { return(System.IO.File.ReadAllText(serverfile).Replace(" ", "")); } else { return(_jiraserverskanska); } } if (key == "guidfield") { string guidfile = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CASE", "ARUP Issue Tracker", "guidfieldid"); if (System.IO.File.Exists(guidfile)) { return(System.IO.File.ReadAllText(guidfile).Replace(" ", "")); } else { return("customfield_10104"); } //return "customfield_10900"; } Configuration config = GetConfig(); if (config == null) { return(string.Empty); } KeyValueConfigurationElement element = config.AppSettings.Settings[key]; if (element != null) { string value = element.Value; if (!string.IsNullOrEmpty(value)) { return(value); } } else { config.AppSettings.Settings.Add(key, ""); config.Save(ConfigurationSaveMode.Modified); } } catch (System.Exception ex1) { MessageBox.Show("exception: " + ex1); } return(string.Empty); }
// Token: 0x06000050 RID: 80 RVA: 0x00002F6C File Offset: 0x0000116C private static string GetConfigurationValue(string key) { object settings = Configuration.Settings; if (settings != null) { KeyValueConfigurationCollection keyValueConfigurationCollection = settings as KeyValueConfigurationCollection; if (keyValueConfigurationCollection != null) { KeyValueConfigurationElement keyValueConfigurationElement = keyValueConfigurationCollection[key]; if (keyValueConfigurationElement == null) { return(null); } return(keyValueConfigurationElement.Value); } else { NameValueCollection nameValueCollection = settings as NameValueCollection; if (nameValueCollection != null) { return(nameValueCollection[key]); } } } return(null); }
//public string GetWindowName() //{ // if (Session["WindowName"] == null) // Session["WindowName"] = Guid.NewGuid().ToString().Replace("-", ""); // return Session["WindowName"].ToString(); //} private bool UsuarioValido(string id, string pwd, out int perfil) { // Comprobación puerta atrás. if (id == "*CD40*" && pwd == "*NUCLEOCC*") { perfil = 3; return(true); } else { Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~"); KeyValueConfigurationElement s = config.AppSettings.Settings["Sistema"]; perfil = 0; ServiciosCD40.Operadores operador = new ServiciosCD40.Operadores(); operador.IdSistema = s.Value; operador.IdOperador = Login1.UserName; operador.Clave = Login1.Password; ServiciosCD40.Tablas[] validado = ServiceServiciosCD40.ListSelectSQL(operador); if (validado.Length > 0) { perfil = (int)((ServiciosCD40.Operadores)validado[0]).NivelAcceso; } return(validado.Length > 0); } }
private void GuardarCambios(string strSistema) { try { ServiciosCD40.Emplazamientos n = new ServiciosCD40.Emplazamientos(); n.IdSistema = strSistema; n.IdEmplazamiento = TextBox1.Text; NewItem = TextBox1.Text; if (ServicioCD40.InsertSQL(n) < 0) { logDebugView.Warn("(Emplazamientos-GuardarElemento): no se ha guardado el emplazamiento."); cMsg.alert(String.Format((string)GetGlobalResourceObject("Espaniol", "ErrorGuardarEmplazamiento"), n.IdEmplazamiento)); } else { Configuration config = WebConfigurationManager.OpenWebConfiguration("~"); KeyValueConfigurationElement sincronizar = config.AppSettings.Settings["SincronizaCD30"]; if ((sincronizar != null) && (Int32.Parse(sincronizar.Value) == 1)) { SincronizaCD30.SincronizaCD30 sincro = new SincronizaCD30.SincronizaCD30(); switch (sincro.AltaEmplazamiento(n.IdEmplazamiento)) { case 108: cMsg.alert(String.Format((string)GetGlobalResourceObject("Espaniol", "Cod108"), n.IdEmplazamiento)); break; case 109: cMsg.alert(String.Format((string)GetGlobalResourceObject("Espaniol", "Cod109"), n.IdEmplazamiento)); break; default: break; } } ActualizaWebPadre(true); } BtAceptar.Visible = false; BtCancelar.Visible = false; Label2.Visible = false; TextBox1.Visible = false; ListBox1.Enabled = true; BtNuevo.Visible = PermisoSegunPerfil; //BtEliminar.Visible = ListBox1.Items.Count > 0 && PermisoSegunPerfil; ListBox1.Items.Clear(); MuestraDatos(DameDatos()); ValidationSummary1.Visible = false; RequiredFieldValidator1.Visible = false; Panel1.Enabled = false; } catch (Exception e) { logDebugView.Error("(Emplazamientos-GuardarCambios):", e); } }
private void EliminarElemento() { try { ServiciosCD40.Nucleos n = new ServiciosCD40.Nucleos(); n.IdSistema = (string)Session["idsistema"]; n.IdNucleo = (string)Session["elemento"]; if (ServicioCD40.DeleteSQL(n) < 0) { logDebugView.Warn("(Nucleos-EliminarElemento): No se ha borrado el elemento"); cMsg.alert(String.Format((string)GetGlobalResourceObject("Espaniol", "ErrorEliminarNucleo"), n.IdNucleo)); } else { Configuration config = WebConfigurationManager.OpenWebConfiguration("~"); KeyValueConfigurationElement sincronizar = config.AppSettings.Settings["SincronizaCD30"]; if ((sincronizar != null) && (Int32.Parse(sincronizar.Value) == 1)) { SincronizaCD30.SincronizaCD30 sincro = new SincronizaCD30.SincronizaCD30(); switch (sincro.BajaNucleo(n.IdNucleo)) { case 102: string s = (string)GetGlobalResourceObject("Espaniol", "ElementoEliminado") + "\\n\\n" + String.Format((string)GetGlobalResourceObject("Espaniol", "Cod102"), n.IdNucleo); cMsg.alert(s); break; case 103: string s1 = (string)GetGlobalResourceObject("Espaniol", "ElementoEliminado") + "\\n\\n" + String.Format((string)GetGlobalResourceObject("Espaniol", "Cod103"), n.IdNucleo); cMsg.alert(s1); break; default: break; } } else { cMsg.alert((string)GetGlobalResourceObject("Espaniol", "ElementoEliminado")); } } } catch (Exception e) { logDebugView.Error("(Nucleos-EliminarElemento): ", e); } ListBox1.Items.Clear(); MuestraDatos(DameDatos()); //MVO 2017/08/04: Sólo se permite configurar un Nucleo en el sistema. BtNuevo.Visible = PermisoSegunPerfil && ListBox1.Items.Count < 1; //if (ListBox1.SelectedIndex >= 0) //{ // BtEliminar.Visible = PermisoSegunPerfil; // MostrarSectores(); //} }
/// <summary> /// Load all the necessary values from the config file. /// </summary> /// <param name="configFile">The config file that contains the configuration settings</param> /// <returns>The base folder</returns> private string loadConfigValues(string configFile) { //String baseConfig = null; KeyValueConfigurationElement baseConfig; if (configFile.Substring(configFile.Length - 7).Equals(".config")) { configFile = configFile.Substring(0, configFile.Length - 7); } try { Configuration configFig = ConfigurationManager.OpenExeConfiguration(configFile); KeyValueConfigurationCollection config = ConfigurationManager.OpenExeConfiguration(configFile).AppSettings.Settings; baseConfig = config[Config.Scripts.BaseFolder]; KeyValueConfigurationElement restartConfig = config[Config.Scripts.RestartStr]; KeyValueConfigurationElement startConfig = config[Config.Scripts.StartStr]; KeyValueConfigurationElement shutdownConfig = config[Config.Scripts.ShutdownStr]; KeyValueConfigurationElement clearConfig = config[Config.Scripts.ClearStr]; KeyValueConfigurationElement cleanConfig = config[Config.Scripts.Clean]; KeyValueConfigurationElement debugConfig = config[Config.Common.DebugFile]; if (baseConfig != null && debugConfig != null) { DB.File = Path.Combine(baseConfig.Value, debugConfig.Value); } if (startConfig != null) { startString = startConfig.Value; } if (restartConfig != null) { restartString = restartConfig.Value; } if (shutdownConfig != null) { shutdownString = shutdownConfig.Value; } if (clearConfig != null) { clearString = clearConfig.Value; } if (cleanConfig != null) { bool parsed = bool.TryParse(cleanConfig.Value, out clean); clean = parsed && clean; } } catch (ConfigurationErrorsException e) { DB.Exception(e, "Unable to load config from " + configFile, Levels.SCRIPTS); DB.Print("Stopping startup", Levels.EXCEPTIONS, Levels.SCRIPTS); return(null); } if (baseConfig == null) { DB.Print("Unable to load base folder from config file, shutting down", Levels.DEBUG, Levels.SCRIPTS); return(null); } return(baseConfig.Value); }
/// <summary> /// Method to look up service implementation based upon service interface name. /// </summary> /// <param name="servName"> Incoming parameter that specifies the name of the service interface to retrieve. </param> /// <returns> Returns a string representing name of the service implementation. </returns> private String GetImplName(string servName) { //Configuration webConfig = WebConfigurationManager.OpenWebConfiguration("/"); Configuration webConfig = WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath); KeyValueConfigurationElement setting = webConfig.AppSettings.Settings[servName]; return(setting.Value); }
public string getAppSetting(string key) { Configuration config = ConfigurationManager.OpenExeConfiguration( System.Reflection.Assembly.GetExecutingAssembly().Location); KeyValueConfigurationElement e = config.AppSettings.Settings[key]; return(e != null ? e.Value : null); }
public static string GetValueFromConfiguration(string key) { string exePath = Application.ResourceAssembly.Location; Configuration config = ConfigurationManager.OpenExeConfiguration(exePath); KeyValueConfigurationElement categoryList = config.AppSettings.Settings[key]; return(categoryList.Value); }
static public string ReadConfigurationElement(string key) { KeyValueConfigurationElement element = null; element = config.AppSettings.Settings[key]; return(null == element ? string.Empty : element.Value); }
/// <summary> /// Returns a setting value from the application configuration settings by its key name. /// </summary> /// <param name="key">The value containing the setting's key name.</param> /// <returns>The setting's value or a null reference if the specified key was not found.</returns> public string GetSetting(string key) { Guard.ArgumentNotNullOrEmptyString(key, "key"); KeyValueConfigurationElement value = Settings[GetNormalizedKey(key)]; return(value != null ? value.Value : null); }
/// <summary> /// Returns a setting value from the application configuration settings by its key name casting the return value to the specified type <typeparamref name="T"/>. /// </summary> /// <typeparam name="T">The type of the configuration setting.</typeparam> /// <param name="key">The value containing the setting's key name.</param> /// <param name="defaultValue">The default value to be used when configuration setting's value is null or the setting was not found.</param> /// <returns>The setting's value or the specified default value if the specified key was not found.</returns> public T GetSetting <T>(string key, T defaultValue) { Guard.ArgumentNotNullOrEmptyString(key, "key"); KeyValueConfigurationElement value = Settings[GetNormalizedKey(key)]; return(value != null?FrameworkUtility.ConvertTo <T>(value.Value) : defaultValue); }
public static string GetConfig(string key, string defaultValue) { Log.Debug(string.Format("Try get value {0} from app config", key)); Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); KeyValueConfigurationElement keyElement = configuration.AppSettings.Settings[key]; return(keyElement != null ? keyElement.Value : defaultValue); }
public string GetSettingValue(ConfigurationUserLevel userLevel, string key) { global::System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(userLevel); KeyValueConfigurationElement value = config.AppSettings.Settings [key]; return(value != null ? value.Value : null); }
public static void AssignValues(string key, Form form, Point defPos, Size defSize) { int iX = 0; int iY = 0; int iW, iH; KeyValueConfigurationElement key1 = Config.AppSettings.Settings[key + "_X"]; KeyValueConfigurationElement key2 = Config.AppSettings.Settings[key + "_Y"]; if (key1 != null && key2 != null) { if (int.TryParse(key1.Value, out iX) && int.TryParse(key2.Value, out iY)) { if (iX > 0 && iY > 0) // т.к. однажды записалось -32000 { form.Location = new Point(iX, iY); } else { form.StartPosition = FormStartPosition.CenterScreen; } } } else if (!CF.WasHadConfig) { form.Location = defPos; } else // значит просто настройки слетели { form.StartPosition = FormStartPosition.CenterScreen; } key1 = Config.AppSettings.Settings[key + "_Width"]; key2 = Config.AppSettings.Settings[key + "_Height"]; if (key1 != null && key2 != null) { if (int.TryParse(key1.Value, out iW) && int.TryParse(key2.Value, out iH)) { if (iW > 0 && iH > 0) { // при минусовых значениях размеры формы не восcтанавливаем, значение -32000 при FormWindowState.Minimized if (iX != -32000 && iY != -32000) { form.Size = new Size(iW, iH); } } else { form.WindowState = FormWindowState.Maximized; return; } } } else if (!CF.WasHadConfig) { form.Size = defSize; } }
/// <summary> /// Gets a setting from the environment scoped configuration first. /// If it does not exist there, get's the setting from the app or machine configs. /// </summary> /// <param name="settingName">The name of the setting.</param> /// <returns>The setting or an empty string if the setting doesn't exist.</returns> public string GetAppSetting(string settingName) { KeyValueConfigurationElement returnSettingObject = _environmentSpecificConfig.AppSettings.Settings[settingName]; var returnSetting = (returnSettingObject == null || string.IsNullOrEmpty(returnSettingObject.Value) ? ConfigurationManager.AppSettings[settingName] : returnSettingObject.Value); return(returnSetting); }
private ISetting WriteAppSetting() { var el = new KeyValueConfigurationElement("Test", "Test"); Isolate.WhenCalled(() => el.Key).WillReturn("Test"); var setting = SettingFactory.CreateSecureSetting(el); _configSettingSource.Add(setting); return(setting); }
public string GetConfigString(string label, string defaultValue) { KeyValueConfigurationElement keyValueConfigurationElement = this.config.AppSettings.Settings[label]; if (keyValueConfigurationElement != null) { return(keyValueConfigurationElement.Value ?? defaultValue); } return(defaultValue); }
/// <summary> /// The full path of the CSharp external backend worker process. /// </summary> internal override string GetCSharpWorkerExePath() { KeyValueConfigurationElement workerPathConfig = appSettings.Settings[CSharpWorkerPathSettingKey]; if (workerPathConfig != null) { return(workerPathConfig.Value); } return(GetSparkCLRArtifactsPath("bin", ProcFileName)); }
//this function is to get the active directory group string from web config file. And this value is tokenized in udepoly. public string getADRoleString(string roleType) { if (rootWebConfig.AppSettings.Settings.Count == 0) { //try diffrent path rootWebConfig = WebConfigurationManager.OpenWebConfiguration("/"); } roleTypeInConfig = rootWebConfig.AppSettings.Settings[roleType]; return(roleTypeInConfig.Value.ToString()); }
public static string GetSetting(string name) { KeyValueConfigurationElement element = Config.AppSettings.Settings[name]; if (element != null) { return(element.Value); } return(null); }
private string getConfigValue(string key, string defaultVal) { KeyValueConfigurationElement setting = programSettings.Settings[key]; if (setting == null) { return(defaultVal); } return(setting.Value); }
// returns a non-null value public static string GetNonNullConfigurationOption(Configuration conf, string key) { KeyValueConfigurationElement elm = conf.AppSettings.Settings[key]; if (elm == null) { return(""); } return(elm.Value); }
private void RecuperaSectoresSectorizacion(string idSectorizacion) { Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~"); KeyValueConfigurationElement s = config.AppSettings.Settings["Sistema"]; System.Data.DataSet ds = ServiceServiciosCD40.ControladoresRecuperaSectoresSectorizacion(s.Value, idSectorizacion); MuestraSectores(ds); MuestraEstadoSectorizacion(); }
public PlayerTypesController() { rootWebConfig1 = WebConfigurationManager.OpenWebConfiguration(null); configRealTimeChessUri = rootWebConfig1.AppSettings.Settings["RealTimeChessUri"]; string strRealTimeChessUri = configRealTimeChessUri.Value; baseUri = new Uri(strRealTimeChessUri); authCredsBasic = new BasicAuthenticationCredentials(); apiChess = new RealTimeChessAPI(baseUri, authCredsBasic); }
protected void Page_Load(object sender, EventArgs e) { //base.Page_Load(sender, e); //cMsg = (Mensajes.msgBox)this.Master.FindControl("MsgBox1"); if (Context.Request.IsAuthenticated) { // retrieve user's identity from httpcontext user FormsIdentity ident = (FormsIdentity)Context.User.Identity; string perfil = ident.Ticket.UserData; if (perfil != "0") { Response.Redirect("~/Configuracion/Inicio.aspx?Permiso=NO"); return; } } else if (!IsPostBack) { Response.Redirect("~/Login.aspx"); return; } if (CallbackCompletado == null) { CallbackCompletado = new AsyncCallback(OnCallBackCompleted); } if (ServiceServiciosCD40 == null) { ServiceServiciosCD40 = new ServiciosCD40.ServiciosCD40(); } string cbReference = ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "context", "ClientCallbackError", true); string callbackScript = "function CallServer(arg, context) {" + cbReference + "; }"; ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer", callbackScript, true); if (!IsPostBack) { Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~"); KeyValueConfigurationElement s = config.AppSettings.Settings["Sistema"]; RecuperaIdSectorizacionActiva(s.Value); RecuperaTops(s.Value); RecuperaSectoresActiva(s.Value); RecuperaSectorizaciones(s.Value); RecuperaSectoresSectorizaciones(s.Value); MuestraEstadoSectorizacion(); } else { EliminaFilas(); } }
private string GetStringFromConfigFile(string key) { string result = string.Empty; KeyValueConfigurationElement keyValueConfigurationElement = this.configurationFromFile.AppSettings.Settings[key]; if (keyValueConfigurationElement != null && !string.IsNullOrEmpty(keyValueConfigurationElement.Value)) { result = keyValueConfigurationElement.Value; } return(result); }
/// <summary> /// 获取WDM查询字符串 /// </summary> /// <param name="queryName"></param> /// <returns></returns> public static string getWDMDBQueryName(string queryName) { Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); KeyValueConfigurationElement element = config.AppSettings.Settings[queryName]; if (element == null) { return(""); } return(element.Value); }
// Methods public void Add(KeyValueConfigurationElement keyValue) {}