public void Should_Change_Setting_Values() { var session = new MyChangableSession(); var settingManager = new SettingManager(CreateMockSettingDefinitionManager(), new ObjectThreadSafeCacheFactoryService()); settingManager.SettingStore = new MemorySettingStore(); settingManager.Session = session; //Application level changes settingManager.ChangeSettingForApplication(MyAppLevelSetting, "53"); settingManager.ChangeSettingForApplication(MyAppLevelSetting, "54"); settingManager.ChangeSettingForApplication(MyAllLevelsSetting, "application level changed value"); settingManager.SettingStore.GetSettingOrNull(null, null, MyAppLevelSetting).Value.ShouldBe("54"); settingManager.GetSettingValue <int>(MyAppLevelSetting).ShouldBe(54); settingManager.GetSettingValue(MyAllLevelsSetting).ShouldBe("application level changed value"); //Tenant level changes session.TenantId = Guid.NewGuid(); settingManager.ChangeSettingForTenant(session.TenantId.Value, MyAllLevelsSetting, "tenant 1 changed value"); settingManager.GetSettingValue(MyAllLevelsSetting).ShouldBe("tenant 1 changed value"); //User level changes session.UserId = Guid.NewGuid(); settingManager.ChangeSettingForUser(session.UserId.Value, MyAllLevelsSetting, "user 1 changed value"); settingManager.GetSettingValue(MyAllLevelsSetting).ShouldBe("user 1 changed value"); }
public void Should_Change_Setting_Values() { var session = new MyChangableSession(); var settingManager = new SettingManager(CreateMockSettingDefinitionManager()); settingManager.SettingStore = new MemorySettingStore(); settingManager.Session = session; //Application level changes settingManager.ChangeSettingForApplication(MyAppLevelSetting, "53"); settingManager.ChangeSettingForApplication(MyAllLevelsSetting, "application level changed value"); settingManager.GetSettingValue <int>(MyAppLevelSetting).ShouldBe(53); settingManager.GetSettingValue(MyAllLevelsSetting).ShouldBe("application level changed value"); //Tenant level changes session.TenantId = 1; settingManager.ChangeSettingForTenant(1, MyAllLevelsSetting, "tenant 1 changed value"); settingManager.GetSettingValue(MyAllLevelsSetting).ShouldBe("tenant 1 changed value"); //User level changes session.UserId = 1; settingManager.ChangeSettingForUser(1, MyAllLevelsSetting, "user 1 changed value"); settingManager.GetSettingValue(MyAllLevelsSetting).ShouldBe("user 1 changed value"); }
public Guid GetDevice() { string device = SettingManager.GetSettingValue(AppSettingNames.CentrastageDeviceId); if (string.IsNullOrEmpty(device)) { Logger.Info("Account identifier not found in the local database."); Guid deviceFromRegistry = GetDeviceFromRegistry(); SettingManager.ChangeSettingForApplication(AppSettingNames.CentrastageDeviceId, deviceFromRegistry.ToString()); return(deviceFromRegistry); } if (Guid.TryParse(device, out Guid deviceId)) { if (deviceId != default(Guid)) { return(deviceId); } } Guid id = GetDeviceFromRegistry(); SettingManager.ChangeSettingForApplication(AppSettingNames.CentrastageDeviceId, id.ToString()); return(id); }
public long GetAccount(Guid device) { string account = SettingManager.GetSettingValue(AppSettingNames.AutotaskAccountId); if (string.IsNullOrEmpty(account)) { Logger.Info("Account number not found in the local database."); long idFromService = GetAccountFromService(device); SettingManager.ChangeSettingForApplication(AppSettingNames.AutotaskAccountId, idFromService.ToString()); return(idFromService); } if (long.TryParse(account, out long accountId)) { if (accountId != default(long)) { return(accountId); } } var id = GetAccountFromService(device); SettingManager.ChangeSettingForApplication(AppSettingNames.AutotaskAccountId, id.ToString()); return(id); }
public bool Init(PerformContext performContext) { Logger.Log(LogSeverity.Info, performContext, "Running startup process"); try { bool monUsers = ShouldMonitorUsers(performContext); SettingManager.ChangeSettingForApplication(AppSettingNames.MonitorUsers, monUsers.ToString()); Logger.Log(LogSeverity.Info, performContext, monUsers ? "Monitoring Users" : "Not Monitoring Users"); } catch (Exception ex) { Logger.Log(LogSeverity.Error, performContext, ex.Message); } try { bool monVeeam = MonitorVeeam(performContext); SettingManager.ChangeSettingForApplication(AppSettingNames.MonitorVeeam, monVeeam.ToString()); Logger.Log(LogSeverity.Info, performContext, monVeeam ? "Monitoring Veeam" : "Not Monitoring Veeam"); } catch (Exception ex) { Logger.Log(LogSeverity.Error, performContext, ex.Message); } Logger.Log(LogSeverity.Info, performContext, "************ Initialisation Successful ************"); return(true); }
public void SetPlayWayAuto() { #region 切换为 自动播放 SettingManager.ChangeSettingForApplication(AppSettings.General.PlayWay, "1"); #endregion }
public JsonResult UpdateGeneralSettings([FromBody] SettingViewModel viewModel) { //Change general settings SettingManager.ChangeSettingForApplication(AppSettingNames.StopTopUpSaving, viewModel.StopTopUpSaving.ToString()); SettingManager.ChangeSettingForApplication(AppSettingNames.StopSignUp, viewModel.StopSignUp.ToString()); return(Json(new { })); }
public void PlayText(string filePath, string topPorts, List <string> devices) { #region 自动切换为 手动播放 SettingManager.ChangeSettingForApplication(AppSettings.General.PlayWay, "2"); #endregion _wavCombine.Art_PlayerTxt(filePath, "", topPorts); }
public void UpdateSettings(AppSettingsDto input) { SettingManager.ChangeSettingForApplication(SettingNames.HoldTime, input.HoldTime.ToString()); SettingManager.ChangeSettingForApplication(SettingNames.MaxHoldTime, input.MaxHoldTime.ToString()); SettingManager.ChangeSettingForApplication(SettingNames.DaysInAdvance, input.DaysInAdvance.ToString()); SettingManager.ChangeSettingForApplication(SettingNames.AvailableColor, input.AvailableColor); SettingManager.ChangeSettingForApplication(SettingNames.WithheldColor, input.WitheldColor); SettingManager.ChangeSettingForApplication(SettingNames.BookedColor, input.BookedColor); SettingManager.ChangeSettingForApplication(SettingNames.NotAvailableColor, input.NotAvailableColor); }
public virtual void SetSetting(T input) { typeof(T).GetProperties().ToList().ForEach(n => { var name = n.GetCustomAttributes <KeyAttribute>().FirstOrDefault()?.Value; if (!string.IsNullOrEmpty(name)) { var value = n.GetValue(input).ToString(); if (n.PropertyType.Name == typeof(bool).Name) { value = value.ToLower(); } SettingManager.ChangeSettingForApplication(name, value); } }); }
public string GetVersion() { if (File.Exists(VeeamFilePath)) { FileVersionInfo version = FileVersionInfo.GetVersionInfo(VeeamFilePath); SettingManager.ChangeSettingForApplication(AppSettingNames.VeeamVersion, version.FileVersion); return(version.FileVersion); } if (File.Exists(Veeam90FilePath)) { FileVersionInfo version = FileVersionInfo.GetVersionInfo(Veeam90FilePath); SettingManager.ChangeSettingForApplication(AppSettingNames.VeeamVersion, version.FileVersion); return(version.FileVersion); } SettingManager.ChangeSettingForApplication(AppSettingNames.VeeamVersion, string.Empty); return(null); }
public void Should_Delete_Setting_Values_On_Default_Value() { var session = new MyChangableSession(); var store = new MemorySettingStore(); var settingManager = new SettingManager(CreateMockSettingDefinitionManager(), new ObjectThreadSafeCacheFactoryService()); settingManager.SettingStore = store; settingManager.Session = session; session.TenantId = Guid.NewGuid(); session.UserId = Guid.NewGuid(); //We can get user's personal stored value store.GetSettingOrNull(null, session.UserId, MyAllLevelsSetting).ShouldNotBe(null); settingManager.GetSettingValue(MyAllLevelsSetting).ShouldBe("user 1 stored value"); //This will delete setting for the user since it's same as tenant's setting value settingManager.ChangeSettingForUser(session.UserId.Value, MyAllLevelsSetting, "tenant 1 stored value"); store.GetSettingOrNull(null, session.UserId, MyAllLevelsSetting).ShouldBe(null); //We can get tenant's setting value store.GetSettingOrNull(session.TenantId, null, MyAllLevelsSetting).ShouldNotBe(null); settingManager.GetSettingValue(MyAllLevelsSetting).ShouldBe("tenant 1 stored value"); //This will delete setting for tenant since it's same as application's setting value settingManager.ChangeSettingForTenant(session.TenantId.Value, MyAllLevelsSetting, "application level stored value"); store.GetSettingOrNull(null, session.UserId, MyAllLevelsSetting).ShouldBe(null); //We can get application's value store.GetSettingOrNull(null, null, MyAllLevelsSetting).ShouldNotBe(null); settingManager.GetSettingValue(MyAllLevelsSetting).ShouldBe("application level stored value"); //This will delete setting for application since it's same as the default value of the setting settingManager.ChangeSettingForApplication(MyAllLevelsSetting, "application level default value"); store.GetSettingOrNull(null, null, MyAllLevelsSetting).ShouldBe(null); //Now, there is no setting value, default value should return settingManager.GetSettingValue(MyAllLevelsSetting).ShouldBe("application level default value"); }
public override void SetSetting(SecuritySettingDto input) { base.SetSetting(input); SettingManager.ChangeSettingForApplication(AppSettingNames.Security.PasswordComplexity, JsonConvert.SerializeObject(input.PasswordComplexity)); }
public void _04_Should_Change_Application_Setting_With_Repository() { _settingManager.ChangeSettingForApplication("SiteTitle", "My Test Site v2"); Assert.AreEqual("My Test Site v2", _settingManager.GetSettingValue("SiteTitle")); Assert.AreEqual("My Test Site v2", _repository.Single(sv => sv.Name == "SiteTitle").Value); }