private static IValidationRuleSet GetValidationRules() { // ensure that not both the procedure type and procedure type groups filters are being applied var procedureTypeRule = new ValidationRule <Worklist>( delegate(Worklist w) { var filterByBothProcedureTypeAndProcedureTypeGroup = w.ProcedureTypeFilter.IsEnabled && w.ProcedureTypeGroupFilter.IsEnabled; return(new TestResult(!filterByBothProcedureTypeAndProcedureTypeGroup, SR.MessageValidateWorklistProcedureTypeAndGroupFilters)); }); // ensure time filter meets constraints specified in settings var timeFilterRule = new ValidationRule <Worklist>( delegate(Worklist w) { var settings = new WorklistSettings(); var maxDays = settings.TimeWindowMaxSpanDays; if (settings.TimeWindowRequired && maxDays > 0) { return(new TestResult(w.CheckTimeFilterSpan(TimeSpan.FromDays(maxDays)), string.Format(SR.MessageValidateWorklistTimeFilter, maxDays))); } return(new TestResult(true)); }); return(new ValidationRuleSet(new[] { procedureTypeRule, timeFilterRule })); }
public static int CurrentServerConfigurationMaxSpanDays() { var settings = new WorklistSettings(); return(settings.TimeWindowMaxSpanDays); }
public static bool CurrentServerConfigurationRequiresTimeFilter() { var settings = new WorklistSettings(); return(settings.TimeWindowRequired); }
private static IValidationRuleSet GetValidationRules() { // ensure that not both the procedure type and procedure type groups filters are being applied var procedureTypeRule = new ValidationRule<Worklist>( delegate(Worklist w) { var filterByBothProcedureTypeAndProcedureTypeGroup = w.ProcedureTypeFilter.IsEnabled && w.ProcedureTypeGroupFilter.IsEnabled; return new TestResult(!filterByBothProcedureTypeAndProcedureTypeGroup, SR.MessageValidateWorklistProcedureTypeAndGroupFilters); }); // ensure time filter meets constraints specified in settings var timeFilterRule = new ValidationRule<Worklist>( delegate(Worklist w) { var settings = new WorklistSettings(); var maxDays = settings.TimeWindowMaxSpanDays; if (settings.TimeWindowRequired && maxDays > 0) { return new TestResult(w.CheckTimeFilterSpan(TimeSpan.FromDays(maxDays)), string.Format(SR.MessageValidateWorklistTimeFilter, maxDays)); } return new TestResult(true); }); return new ValidationRuleSet(new[] { procedureTypeRule, timeFilterRule }); }
public static int CurrentServerConfigurationMaxSpanDays() { var settings = new WorklistSettings(); return settings.TimeWindowMaxSpanDays; }
public static bool CurrentServerConfigurationRequiresTimeFilter() { var settings = new WorklistSettings(); return settings.TimeWindowRequired; }
/// <summary> /// Checks whether the current user has access to worklists owned by the specified worklist owner. /// </summary> /// <param name="owner"></param> /// <remarks>Throws a RequestValidationException if the worklist count exceed the configured maximum.</remarks> private void CheckWorklistCountRestriction(WorklistOwner owner) { // admin can have unlimited worklists if (owner.IsAdminOwner) return; var worklistCount = PersistenceContext.GetBroker<IWorklistBroker>().Count(owner); var settings = new WorklistSettings(); if (owner.IsStaffOwner) { if (worklistCount >= settings.MaxPersonalOwnedWorklists) throw new RequestValidationException(SR.ExceptionMaximumWorklistsReachedForStaff); } else if (owner.IsGroupOwner) { if (worklistCount >= settings.MaxGroupOwnedWorklists) throw new RequestValidationException(SR.ExceptionMaximumWorklistsReachedForStaffGroup); } }