public HttpResponseMessage SendAspenTicket(string from, string message) { var json = string.Empty; try { var to = new AppSettingsRepository().GetByKey("HELPDESK_EMAIL").Value; //ConfigurationManager.AppSettings.Get("email_to"); var subject = new AppSettingsRepository().GetByKey("HELPDESK_EMAIL_SUBJ").Value; //ConfigurationManager.AppSettings.Get("email_subject"); var smtp = new SmtpClient(); var arguments = new EmailArg { From = from, Tos = string.Join(",", to, from), Subject = subject, Body = message, Host = smtp.Host, EnableSsl = smtp.EnableSsl, Port = smtp.Port, DeliveryMethod = smtp.DeliveryMethod }; SendEmail(arguments); json = JsonConvert.SerializeObject(arguments); } catch (Exception ex) { json = "{'result': 0, 'error':'" + ex.Message + "'}"; } return(new HttpResponseMessage { Content = new StringContent(json, Encoding.UTF8, "application/json") }); }
private string CreatorsHubLogin(string login, string password) { var creatorshubUrl = new AppSettingsRepository().GetByKey("CREATORSHUB_LOGIN_URL").Value; var creatorshubApiKey = new AppSettingsRepository().GetByKey("CREATORSHUB_LOGIN_API_KEY").Value; string result; try { using (var client = new WebClient()) { byte[] response = client.UploadValues(creatorshubUrl, new NameValueCollection() { { "api_key", creatorshubApiKey }, { "login", login }, { "password", password } }); result = Encoding.UTF8.GetString(response); } } catch (Exception ex) { result = "{'result': 0, 'error':'" + ex.Message + "'}"; } return(result); }
/// <summary> /// Initializes a new instance of the <see cref="StartPageConfiguratorViewModel"/> class. /// </summary> public StartPageConfiguratorViewModel() { _repository = new AppSettingsRepository(); this.AppSettings = _repository.LoadSettings(); this.SaveConfigurationCommand = new RelayCommand<ICloseable>(null, this.SaveConfiguration); }
public void LoadAppSettingsFromDisk() { // instantiate default memory model var model = AppSettingsRepository.GetDefaultApplicationSettings(); model.ImageFormatExtension = ".webp"; model.InputDirectory = GlobalUnitTestConfig.TestDataInputPath; model.OutputDirectory = GlobalUnitTestConfig.TempDataPath; Assert.IsNotNull(model.FormStateModels, "AppSettingsRepository failed to create valied default config", nameof(model.FormStateModels)); Assert.IsTrue(_repository.SaveSettings(model), "Failed to Save default Settings"); var loadedSettings = _repository.LoadSettings(); Assert.IsNotNull(loadedSettings, "Loaded Settings where null."); // Do not compare form state dictionaries. model.FormStateModels = loadedSettings.FormStateModels; // Test each property bool modelEquals = model.Equals(loadedSettings); Assert.IsTrue(modelEquals, "model.Equals(loadedSettings) The loaded model where not identical to the saved model"); }
public void GetExcludedChildTypes_Returns_Expected_List_Count(string configFileName, int expectedCount) { var stagingConfigurationSettingsOptions = OptionsFactory.CreateOptions <StagingConfigurationSettings>(configFileName); var appSettingsRepository = new AppSettingsRepository(stagingConfigurationSettingsOptions); var childTypePairs = appSettingsRepository.GetExcludedChildTypes(); Assert.AreEqual(expectedCount, childTypePairs.Count); }
public void GetExcludedMediaLibraries_Returns_Trimmed_Name() { var stagingConfigurationSettingsOptions = OptionsFactory.CreateOptions <StagingConfigurationSettings>(AppConfigFileName.Untrimmed); var appSettingsRepository = new AppSettingsRepository(stagingConfigurationSettingsOptions); var excludedMediaLibraries = appSettingsRepository.GetExcludedMediaLibraries(); Assert.AreEqual("emailimages", excludedMediaLibraries.FirstOrDefault()); }
public ImageConverterService(ILifetimeScope scope, IMapper mapper, AppSettingsRepository appSettingsRepository) { _scope = scope; _mapper = mapper; _appSettingsRepository = appSettingsRepository; _batchItems = new List <BatchItemModel>(); _cancellationTokenSource = new CancellationTokenSource(); IsRunningBatch = false; }
public async Task <IActionResult> GetOEmbedInfo() { AppSettings appSettings = await AppSettingsRepository.CreateDefault(_serviceProvider).GetAppSettings(); return(new ContentResult() { Content = appSettings.GetEmbedData(_config.GetBaseUrl()), ContentType = "text/html" }); }
public void GetExcludedChildTypes_Returns_Trimmed_Name() { var stagingConfigurationSettingsOptions = OptionsFactory.CreateOptions <StagingConfigurationSettings>(AppConfigFileName.Untrimmed); var appSettingsRepository = new AppSettingsRepository(stagingConfigurationSettingsOptions); var childTypePairs = appSettingsRepository.GetExcludedChildTypes(); var childTypePair = childTypePairs.FirstOrDefault(); Assert.AreEqual("cms.role", childTypePair?.ParentType); Assert.AreEqual("cms.userrole", childTypePair?.ChildType); }
public HttpResponseMessage GetByKey(string key) { var repo = new AppSettingsRepository(); var entity = repo.GetByKey(key); var json = JsonConvert.SerializeObject(entity); return(new HttpResponseMessage { Content = new StringContent(json, Encoding.UTF8, "application/json") }); }
public HttpResponseMessage List() { var repo = new AppSettingsRepository(); var entities = repo.List(); var json = JsonConvert.SerializeObject(entities); return(new HttpResponseMessage { Content = new StringContent(json, Encoding.UTF8, "application/json") }); }
public async Task <IActionResult> UpdateAppSettings([FromBody] EmbedAppSettingsForPutDto newSettings) { await RequireSiteAdmin(); AppSettingsRepository repo = AppSettingsRepository.CreateDefault(_serviceProvider); AppSettings current = await repo.GetAppSettings(); current.EmbedTitle = newSettings.EmbedTitle; current.EmbedContent = newSettings.EmbedContent; return(Ok(await repo.UpdateAppSettings(current))); }
public async Task <IActionResult> UpdateAppSettings([FromBody] SettingsAppSettingsForPutDto newSettings) { await RequireSiteAdmin(); AppSettingsRepository repo = AppSettingsRepository.CreateDefault(_serviceProvider); AppSettings current = await repo.GetAppSettings(); current.DefaultLanguage = newSettings.DefaultLanguage; current.AuditLogWebhookURL = newSettings.AuditLogWebhookURL ?? string.Empty; current.PublicFileMode = newSettings.PublicFileMode; return(Ok(await repo.UpdateAppSettings(current))); }
public void SaveAppSettingsToDisk() { var model = AppSettingsRepository.GetDefaultApplicationSettings(); model.InputDirectory = GlobalUnitTestConfig.TestDataInputPath; model.OutputDirectory = GlobalUnitTestConfig.TempDataPath; var result = _repository.SaveSettings(model); Assert.IsTrue(result, "Save AppSettingsFailed"); var fi = new FileInfo(Path.Combine(model.OutputDirectory, GlobalUnitTestConfig.AppSettingsFilename)); Log.Information("Saving App settings in: " + Path.GetFullPath(fi.FullName)); Assert.IsTrue(fi.Exists, "Could not find ImageConverterSettings.bin at: " + fi.FullName); }
public async Task <IActionResult> SettingsAsync([Bind("ConnectionString", "CheckForConnection")] AppSettings model) { try { if (ModelState.IsValid) { await AppSettingsRepository.GetInstance().SaveAsync(model); return(Redirect(nameof(Settings))); } } catch (Exception e) { log4net.Error($"\n{e.GetType()}\n{e.InnerException?.GetType()}\n{e.Message}\n{e.StackTrace}\n", e); return(NotFound(e)); } return(View(model)); }
public async Task <GoalOptions> GetGoalOptions() { var settings = (await AppSettingsRepository.Get(1).ConfigureAwait(false)).First(); var oneDay = 1000 * 60 * 60 * 24; var session = settings.SessionSettings.SessionDuration; var shortBreak = settings.SessionSettings.ShortBreakDuration; var longBreak = settings.SessionSettings.LongBreakDuration; var pairDuration = session + shortBreak; var seriesDuration = pairDuration * 4 + longBreak; var totalSeries = oneDay / seriesDuration; var remainingPairs = (oneDay - totalSeries * seriesDuration) / pairDuration; return(new GoalOptions { Sessions = new Range <int> { Min = 1, Max = totalSeries * 4 + remainingPairs }, SessionDuration = session }); }
public ApplicationSettingsService(AppSettingsRepository appSettingsRepository) { _appSettingsRepository = appSettingsRepository; try { _applicationSettings = _appSettingsRepository.LoadSettings(); if (_applicationSettings == null) { _applicationSettings = AppSettingsRepository.GetDefaultApplicationSettings(); _appSettingsRepository.SaveSettings(_applicationSettings); } } catch (Exception ex) { Log.Error(ex, "Fatal error encountered when accessing the registry settings"); throw new IOException("Application Settings could not be loaded and could not be set to default and saved"); } _appSettingsRepository.LoadSettingsCompleted += _appSettingsFileRepository_LoadSettingsCompleted; }
public AppSettings() { try { var memoryCacheProvider = MemoryCacheProvider.GetInstance(); var declaringTypeFullName = MethodBase.GetCurrentMethod()?.DeclaringType?.FullName; var filePathKey = $"{declaringTypeFullName}{@".FilePath"}"; var filePath = (object)memoryCacheProvider.Get(filePathKey); if (null == filePath) { AppSettingsRepository?.MergeAndCopyToUserDirectory(this); memoryCacheProvider.Put(filePathKey, FilePath, TimeSpan.FromDays(1)); } if (null != FileName && null != UserProfileDirectory) { FilePath = (string)(filePath ?? Path.Combine(UserProfileDirectory, FileName)); } var useGlobalDatabaseConnectionSettingsKey = $"{declaringTypeFullName}{@".UseGlobalDatabaseConnectionSettings"}"; var useGlobalDatabaseConnectionSettings = (object)memoryCacheProvider.Get(useGlobalDatabaseConnectionSettingsKey); if (null == useGlobalDatabaseConnectionSettings) { memoryCacheProvider.Put(useGlobalDatabaseConnectionSettingsKey, UseGlobalDatabaseConnectionSettings, TimeSpan.FromDays(1)); if (UseGlobalDatabaseConnectionSettings) { var appSettingsModel = new NetAppCommon.AppSettings.Models.AppSettings(); ConnectionString = appSettingsModel.ConnectionString; AppSettingsRepository?.MergeAndSave(this); } } } catch (Exception e) { _log4Net.Error($"\n{e.GetType()}\n{e.InnerException?.GetType()}\n{e.Message}\n{e.StackTrace}\n", e); } }
public EmailSenderRepository() { teamMemberRepo = new TeamMemberRepository(); appSettingsRepo = new AppSettingsRepository(); initializeEmailService(); }
public AppSettingsService(AppSettingsRepository appSettingsRepository) { AppSettingsRepository = appSettingsRepository; }
public AppSettings() { try { var memoryCacheProvider = MemoryCacheProvider.GetInstance(); var filePathKey = $"{MethodBase.GetCurrentMethod()?.DeclaringType?.FullName}.FilePath"; var filePath = (object)memoryCacheProvider.Get(filePathKey); if (null == filePath) { var appSettingsSetupFilePath = Path.Combine(BaseDirectory !, SetupFileName !); var appSettingsUserFilePath = Path.Combine(UserProfileDirectory !, FileName !); var appSettingsFilePath = FilePath; var appSettingsSetupConnectionString = new AppSettings(appSettingsSetupFilePath !).GetConnectionString(); var appSettingsUserConnectionString = new AppSettings(appSettingsUserFilePath !).GetConnectionString(); var appSettingsConnectionString = new AppSettings(appSettingsFilePath !).GetConnectionString(); if (!string.IsNullOrWhiteSpace(appSettingsUserFilePath) && !File.Exists(appSettingsUserFilePath)) { AppSettingsRepository?.CopyToUserDirectory(this); } try { AppSettingsRepository?.MergeAndSave(appSettingsSetupFilePath, appSettingsUserFilePath); } catch (Exception e) { _log4Net.Error($"\n{e.GetType()}\n{e.InnerException?.GetType()}\n{e.Message}\n{e.StackTrace}\n", e); } try { if (File.Exists(appSettingsSetupFilePath)) { File.Delete(appSettingsSetupFilePath); } } catch (Exception e) { _log4Net.Error($"\n{e.GetType()}\n{e.InnerException?.GetType()}\n{e.Message}\n{e.StackTrace}\n", e); } try { AppSettingsRepository?.MergeAndSave(appSettingsUserFilePath, appSettingsFilePath); } catch (Exception e) { _log4Net.Error($"\n{e.GetType()}\n{e.InnerException?.GetType()}\n{e.Message}\n{e.StackTrace}\n", e); } try { AppSettingsRepository?.MergeAndSave(appSettingsFilePath, appSettingsUserFilePath); } catch (Exception e) { _log4Net.Error($"\n{e.GetType()}\n{e.InnerException?.GetType()}\n{e.Message}\n{e.StackTrace}\n", e); } FilePath = File.Exists(appSettingsUserFilePath) ? appSettingsUserFilePath : FilePath; if (null != AppSettingsRepository) { if (!string.IsNullOrWhiteSpace(appSettingsSetupConnectionString) && AppSettingsRepository.MssqlCheckConnectionString(appSettingsSetupConnectionString)) { ConnectionString = appSettingsSetupConnectionString; AppSettingsRepository?.SaveAsync(this); } else if (!string.IsNullOrWhiteSpace(appSettingsUserConnectionString) && AppSettingsRepository.MssqlCheckConnectionString(appSettingsUserConnectionString)) { ConnectionString = appSettingsUserConnectionString; AppSettingsRepository?.SaveAsync(this); } else if (!string.IsNullOrWhiteSpace(appSettingsConnectionString) && AppSettingsRepository.MssqlCheckConnectionString(appSettingsConnectionString)) { ConnectionString = appSettingsConnectionString; AppSettingsRepository?.SaveAsync(this); } } memoryCacheProvider.Put(filePathKey, FilePath, TimeSpan.FromDays(1)); } if (null != UserProfileDirectory && null != FileName) { FilePath = (string)(filePath ?? Path.Combine(UserProfileDirectory !, FileName !)); } } catch (Exception e) { _log4Net.Error($"\n{e.GetType()}\n{e.InnerException?.GetType()}\n{e.Message}\n{e.StackTrace}\n", e); } }
public DailyPlanService(AppSettingsRepository appSettingsRepository, DailyPlanRepository dailyPlanRepository) { AppSettingsRepository = appSettingsRepository; DailyPlanRepository = dailyPlanRepository; }
public async Task <IActionResult> GetAppSettings([FromRoute] ulong guildId) { await RequireSiteAdmin(); return(Ok(await AppSettingsRepository.CreateDefault(_serviceProvider).GetAppSettings())); }
public AppSettingsController() { repo = new AppSettingsRepository(); }
public AppSettingsService() { _appSettingsRepository = new AppSettingsRepository(); }
protected override void CommitEdit() { var appSettingsCurrentItem = (AppSettings)DataForm.CurrentItem; if (null != appSettingsCurrentItem) { if (appSettingsCurrentItem.CheckForUpdateAndMigrate) { _mainWindow.Opacity = 50; _mainWindow.IsEnabled = false; var message = new StringBuilder(); var task = Task.Run(() => { var erpSerwisDbContext = new Core.Data.ErpSerwisDbContext(); var isCheckForUpdateAndCreateMssqlMdf = erpSerwisDbContext.CheckForUpdateAndCreateMssqlMdf(appSettingsCurrentItem); var isCheckForUpdateAndMigrate = erpSerwisDbContext.CheckForUpdateAndMigrate(appSettingsCurrentItem); if (isCheckForUpdateAndCreateMssqlMdf) { message.Append($"Sprawdziłem i utworzyłem bazę danych w formacie Ms SQL MDF w dniu: { appSettingsCurrentItem.LastMigrateDateTime }").Append(Environment.NewLine); } else { message.Append($"Błąd tworzenia bazy danych w formacie Ms SQL MDF!").Append(Environment.NewLine); } if (isCheckForUpdateAndMigrate) { message.Append($"Sprawdziłem i przeprowadziłem migrację w dniu: { appSettingsCurrentItem.LastMigrateDateTime }").Append(Environment.NewLine); } else { message.Append($"Błąd migracji bazy danych!").Append(Environment.NewLine); } }); task.GetAwaiter().OnCompleted(() => { MessageBox.Show(message.ToString(), "Status operacji"); _mainWindow.Opacity = 100; _mainWindow.IsEnabled = true; }); } if (DataForm != null && DataForm.ValidateItem()) { var saveResult = false; _mainWindow.Opacity = 50; _mainWindow.IsEnabled = false; Task task = Task.Run(async() => { saveResult = await AppSettingsRepository.GetInstance().SaveAsync(appSettingsCurrentItem); return(saveResult); }); task.GetAwaiter().OnCompleted(() => { if (saveResult) { MessageBox.Show($"Zapisano ustawienia w lokalizacji { appSettingsCurrentItem.GetFilePath() }", "Operacja zakończona."); } else { MessageBox.Show($"Nie można zapisać ustawień w lokalizacji { appSettingsCurrentItem.GetFilePath() }!", "Błąd!"); } _mainWindow.Opacity = 100; _mainWindow.IsEnabled = true; }); } } }