public async Task <IActionResult> ApplyRatingChanges( [FromServices] IConfigurationRegistry conf) { var rejudgingid = Contest.Settings.SystemTestRejudgingId; if (!CcsDefaults.SupportsRating || rejudgingid == null || Contest.Settings.RatingChangesApplied == true) { return(NotFound()); } if ((await conf.GetDateTimeOffsetAsync(CcsDefaults.ConfigurationLastRatingChangeTime)) > Contest.StartTime) { StatusMessage = "A later contest has done some rating changes. The history has been frozen."; return(RedirectToAction(nameof(Detail), new { rejudgingid })); } else if ((await Context.CountJudgingsAsync(j => j.RejudgingId == rejudgingid && (j.Status == Verdict.Pending || j.Status == Verdict.Running))) > 0) { StatusMessage = "System test is not finished. Please wait patiently."; return(RedirectToAction(nameof(Detail), new { rejudgingid })); } else { return(AskPost( title: "Finish system test", message: "Are you sure to apply rating?", type: BootstrapColor.warning)); } }
public async Task <IActionResult> Config( ConfigureEditModel models, [FromServices] IConfigurationRegistry registry) { var items = await registry.ListPublicAsync(); foreach (var item in items) { if (!models.Config.ContainsKey(item.Name) || models.Config[item.Name] == null) { continue; } var newVal = models.Config[item.Name]; if (item.Type == "string") { newVal = newVal.ToJson(); } if (newVal == item.Value) { continue; } await registry.UpdateValueAsync(item.Name, newVal); await HttpContext.AuditAsync("updated", item.Name, "from " + item.Value); } StatusMessage = "Configurations saved successfully."; return(RedirectToAction(nameof(Config))); }
internal static IDisposable Override(IConfigurationRegistry overrideRegistry) { IConfigurationRegistry current = registry; registry = overrideRegistry; return(new DisposableAction(() => registry = current)); }
public SignController(ISignInManager signInManager, IConfigurationRegistry registry, IEmailSender emailSender, IMediator mediator) { SignInManager = signInManager; UserManager = signInManager.UserManager; Configurations = registry; EmailSender = emailSender; Mediator = mediator; }
public ImportBase() { LoggingService = DependencyResolver.GetService <ILoggingService>(); CommandDispatcher = DependencyResolver.GetService <ICommandDispatcher>(); QueryDispatcher = DependencyResolver.GetService <IQueryDispatcher>(); Configuration = DependencyResolver.GetService <IConfigurationRegistry>(); SerializerService = new JsonSerializerService(); }
public static IConfigurationBuilder AddConfigurationRegistry (this IConfigurationBuilder self, IConfigurationRegistry registry) { var consul = new ConfigurationRegistrySource(registry); self.Add(consul); return(self); }
public ConfigServerClient(IHttpClientWrapper client, IClientCachingStrategy cache, IClientIdProvider clientIdProvider, IConfigurationRegistry collection, ConfigServerClientOptions options) { this.client = client; this.collection = collection; this.options = options; this.cache = cache; this.clientIdProvider = clientIdProvider; }
public static IConfigurationBuilder AddJsonConsul (this IConfigurationBuilder self, IConfigurationRegistry registry) { var consul = new ConsulSource(registry); registry.UpdateKeyParser(new JsonKeyValueParser()); self.Add(consul); return(self); }
public ImportBase() { LoggingService = DependencyResolver.Current.GetService <ILoggingService>(); CommandDispatcher = DependencyResolver.Current.GetService <ICommandDispatcher>(); QueryDispatcher = DependencyResolver.Current.GetService <IQueryDispatcher>(); Configuration = DependencyResolver.Current.GetService <IConfigurationRegistry>(); SerializerService = new JsonSerializerService(); SourceConnectionString = DependencyResolver.Current.GetService <IConfiguration>().GetConnectionString("StockTradingAnalysis_MSSQL_Migration_Source"); TargetConnectionString = DependencyResolver.Current.GetService <IConfiguration>().GetConnectionString("StockTradingAnalysis_MSSQL_Migration_Target"); }
/// <summary> /// Initializes this object /// </summary> /// <param name="connectionName">Name of the connection string</param> /// <param name="tableName">Name of the table</param> /// <param name="performanceMeasurementService">The performance measurement service.</param> /// <param name="configurationRegistry">The configuration registry.</param> public SnapShotDatastore( string connectionName, string tableName, IPerformanceMeasurementService performanceMeasurementService, IConfigurationRegistry configurationRegistry) : base(performanceMeasurementService) { _tableName = tableName; _connectionString = configurationRegistry.GetValue <string>(connectionName); _performanceMeasurementService = performanceMeasurementService; }
public void Configure(IApplicationBuilder app, IHostingEnvironment env , IConfigurationRegistry configRegistry, IServiceCollection services) { var config = new ConsulConfig { Setting = "Test" }; configRegistry.SetKeyJsonAsync($"{env.EnvironmentName}/ConsulConfig", config).Wait(); configRegistry.AddUpdatingPathAsync(env.EnvironmentName).Wait(); var configBuilder = new ConfigurationBuilder() .AddConfigurationRegistry(configRegistry).Build(); services.ConfigureReloadable <IConfigurationRegistry>(configBuilder, configRegistry); app.UseMvcWithDefaultRoute(); }
public async Task <IActionResult> Config(string name, [FromServices] IConfigurationRegistry configs) { var value = await configs.GetAsync(name); var result = new StringBuilder(); result.Append("{"); for (int i = 0; i < value.Count; i++) { result.Append(i != 0 ? ",\"" : "\"") .Append(value[i].Name) .Append("\":") .Append(value[i].Value); } result.Append("}"); return(Content(result.ToString(), "application/json")); }
public async Task <IActionResult> Config( ConfigureEditModel models, [FromServices] IConfigurationRegistry registry) { var items = (await registry.ListAsync()).SelectMany(a => a).ToList(); foreach (var item in items) { if (item.Type == "bool" && !models.Config.ContainsKey(item.Name)) { models.Config.Add(item.Name, "off"); } if (!models.Config.ContainsKey(item.Name) || models.Config[item.Name] == null) { continue; } var origVal = models.Config[item.Name]; var newVal = item.Type switch { "string" => origVal.ToJson(), "int" => origVal, "bool" => (origVal == "on" || origVal == "true" || origVal == "yes" || origVal == "1") ? "true" : "false", _ => throw new NotSupportedException(), }; if (newVal == item.Value) { continue; } await registry.UpdateAsync(item.Name, newVal); await HttpContext.AuditAsync("updated", item.Name, "from " + item.Value); } StatusMessage = "Configurations saved successfully."; return(RedirectToAction(nameof(Config))); }
public async Task <IActionResult> RollbackRatingChanges( [FromServices] IConfigurationRegistry conf) { if (!CcsDefaults.SupportsRating || Contest.Settings.RatingChangesApplied != true) { return(NotFound()); } if ((await conf.GetDateTimeOffsetAsync(CcsDefaults.ConfigurationLastRatingChangeTime)) > Contest.StartTime) { StatusMessage = "A later contest has done some rating changes. The history has been frozen."; return(RedirectToAction(nameof(Detail), new { rejudgingid = Contest.Settings.SystemTestRejudgingId })); } else { return(AskPost( title: "Finish system test", message: "Are you sure to rollback rating changes?", type: BootstrapColor.warning)); } }
internal static IDisposable Override(IConfigurationRegistry overrideRegistry) { IConfigurationRegistry current = registry; registry = overrideRegistry; return new DisposableAction(() => registry = current); }
public async Task <IActionResult> Config( [FromServices] IConfigurationRegistry registry) { return(View(await registry.ListAsync())); }
public ConfigurationRegistryProvider(IConfigurationRegistry configurationRegistry) { _configurationRegistry = configurationRegistry; _configurationRegistry.AddWatchOnEntireConfig(Load); }
public ForecastService(IConfigurationRegistry configuration) { Registry = configuration; }
public ConfigurationRegistrySource(IConfigurationRegistry configurationRegistry) => _configurationRegistry = configurationRegistry;
public static IServiceCollection ConfigureReloadable <TConfig>(this IServiceCollection self, IConfigurationRegistry registry, string sectionName) where TConfig : class => self.ConfigureReloadable <TConfig>(registry.Root, registry, sectionName);
public static IServiceCollection ConfigureReloadable <TConfig>(this IServiceCollection self, IConfiguration configuration, IConfigurationRegistry registry) where TConfig : class => self.ConfigureReloadable <TConfig>(configuration, registry, typeof(TConfig).Name);
public ConsulSource(IConfigurationRegistry configurationRegistry) { _configurationRegistry = configurationRegistry; }
public static IServiceCollection ConfigureReloadable <TConfig>(this IServiceCollection self, IConfiguration configuration, IConfigurationRegistry registry, string sectionName) where TConfig : class { var initialised = false; self.Configure <TConfig> (config => { void Bind() { var section = configuration.GetSection(sectionName); section.Bind(config); } if (!initialised) { registry.AddWatchOnEntireConfig(Bind); initialised = true; } Bind(); }); return(self); }
public static IServiceCollection ConfigureReloadable <TConfig>(this IServiceCollection self, IConfigurationRegistry registry) where TConfig : class { return(self.ConfigureReloadable <TConfig>(registry.Root, registry, typeof(TConfig).Name)); }
public Startup(IConfigurationRegistry registry) { _registry = registry; }
public ConfigurationProvider(IConfigurationRegistry registry) { this.registry = registry; }
public static Task <bool> SetKeyJsonAsync <T>(this IConfigurationRegistry self, string key, T value) { return(self.SetKeyAsync(key, JsonConvert.SerializeObject(value))); }
static ConfigurationRegistry() { registry = IoC.Resolve <IConfigurationRegistry>(); }
static ConfigurationRegistry() { registry = IoC.Resolve<IConfigurationRegistry>(); }