public void ValidValue(string value, int expected) { var setting = CleanDbSetting.Create(VALID_KEY_SAMPLE, value, VALID_REPOSITORYNAMEFORMAT_SAMPLE); Assert.IsNotNull(setting); Assert.AreEqual(expected, setting.RetentionPeriodMonth); }
public void ValidKey(string key, string expectedRepositoryFullName) { var setting = CleanDbSetting.Create(key, VALID_VALUE_SAMPLE, VALID_REPOSITORYNAMEFORMAT_SAMPLE); Assert.IsNotNull(setting); Assert.AreEqual(expectedRepositoryFullName, setting.RepositoryFullName); }
/// <summary> /// 不要データの削除 /// </summary> public void Clean() { try { OutputLogEnter(_logger); // 削除設定を取得する var targetSettings = _settings.GetConfigs(CleanDbSetting.KeyPrefix); // 正常設定されているデータ群の取得 IEnumerable <CleanDbSetting> settings = targetSettings.Select(x => { try { return(CleanDbSetting.Create(x.Key, x.Value, RepositoryNameFormat)); } catch (RmsInvalidAppSettingException e) { OutputLog002(_logger, e, new object[] { e.Message }); return(null); } }) .Where(x => x != null); foreach (var setting in settings) { CleanStatus status = CleanStatus.GetType; try { // 処理リポジトリがあるかチェック Type repoType = Type.GetType(setting.RepositoryFullName); if (repoType == null) { // 存在しないクラス指定なので処理しない throw new RmsInvalidAppSettingException(string.Format("{0} is not supported.", CleanDbSetting.KeyPrefix + setting.ModelName)); } ICleanRepository repository = _serviceProvider.GetService(repoType) as ICleanRepository; if (repository == null) { // 削除対象のクラスでないので処理しない throw new RmsInvalidAppSettingException(string.Format("{0} is not supported.", CleanDbSetting.KeyPrefix + setting.ModelName)); } // DBから指定月数を超過しているデータの削除を依頼する status = CleanStatus.DeleteExceedsMonthsAllData; if (repository.DeleteExceedsMonthsAllData(CreateThreshold(setting)) > 0) { OutputLog004(_logger, new object[] { setting.RepositoryFullName }); } } catch (RmsInvalidAppSettingException e) { OutputLog002(_logger, e, new object[] { e.Message }); } catch (Exception e) { switch (status) { case CleanStatus.DeleteExceedsMonthsAllData: OutputLog003(_logger, e, new object[] { setting.RepositoryFullName }); break; case CleanStatus.GetType: default: // GetTypeがnullを返さずにExceptionを投げた場合は、 // RmsInvalidAppSettingException発生時と同じ処理とする OutputLog002(_logger, e, new object[] { e.Message }); break; } } } return; } catch (Exception ex) { OutputLog001(_logger, ex); } finally { OutputLogLeave(_logger); } }
public void InvalidValue(string value) { var setting = CleanDbSetting.Create(VALID_KEY_SAMPLE, value, VALID_REPOSITORYNAMEFORMAT_SAMPLE); Assert.IsNull(setting); }
public void InvalidKey(string key) { var setting = CleanDbSetting.Create(key, VALID_VALUE_SAMPLE, VALID_REPOSITORYNAMEFORMAT_SAMPLE); Assert.IsNull(setting); }