/// <summary> /// Formats the filter values. /// </summary> /// <param name="configurationValues">The configuration values.</param> /// <param name="filterValues">The filter values.</param> /// <returns></returns> public virtual string FormatFilterValues(Dictionary <string, ConfigurationValue> configurationValues, List <string> filterValues) { if (filterValues != null && filterValues.Any()) { // If just one value, then it is likely just a value if (filterValues.Count == 1) { string filterValue = FormatFilterValueValue(configurationValues, filterValues[0]); if (!string.IsNullOrWhiteSpace(filterValue)) { return("is " + filterValue); } } // If two more values, then it is a comparison and a value else if (filterValues.Count >= 2) { string comparisonValue = filterValues[0]; if (comparisonValue != "0") { ComparisonType comparisonType = comparisonValue.ConvertToEnum <ComparisonType>(ComparisonType.StartsWith); if (comparisonType == ComparisonType.IsBlank || comparisonType == ComparisonType.IsNotBlank) { return(comparisonType.ConvertToString()); } else { return(string.Format("{0} {1}", comparisonType.ConvertToString(), FormatFilterValueValue(configurationValues, filterValues[1]))); } } } } return(string.Empty); }
/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public override string FormatSelection(Type entityType, string selection) { var values = selection.Split('|'); if (values.Length == 1) { return(string.Format("{0} is {1}", GetGlobalGradeLabel(), values[0])); } else if (values.Length >= 2) { var gradeNameValue = DefinedValueCache.Read(values[1].AsGuid()); string gradeDescription = gradeNameValue != null ? gradeNameValue.Description : "??"; ComparisonType comparisonType = values[0].ConvertToEnum <ComparisonType>(ComparisonType.StartsWith); if (comparisonType == ComparisonType.IsBlank || comparisonType == ComparisonType.IsNotBlank) { return(string.Format("{0} {1}", GetGlobalGradeLabel(), comparisonType.ConvertToString())); } else { return(string.Format("{0} {1} '{2}'", GetGlobalGradeLabel(), comparisonType.ConvertToString(), gradeDescription)); } } else { return(GetGlobalGradeLabel() + " Filter"); } }
/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public override string FormatSelection(Type entityType, string selection) { var values = selection.Split('|'); if (values.Length == 1) { return(string.Format("Total Amount is {0}", values[0])); } else if (values.Length >= 2) { ComparisonType comparisonType = values[0].ConvertToEnum <ComparisonType>(ComparisonType.StartsWith); if (comparisonType == ComparisonType.IsBlank || comparisonType == ComparisonType.IsNotBlank) { return(string.Format("Total Amount {0}", comparisonType.ConvertToString())); } else { return(string.Format("Total Amount {0} '{1}'", comparisonType.ConvertToString(), values[1])); } } else { return("Total Amount Filter"); } }
/// <summary> /// Formats the filter values. /// </summary> /// <param name="configurationValues">The configuration values.</param> /// <param name="filterValues">The filter values.</param> /// <returns></returns> public virtual string FormatFilterValues(Dictionary <string, ConfigurationValue> configurationValues, List <string> filterValues) { if (filterValues != null && filterValues.Any()) { if (filterValues.Count == 1) { // If just one value, then it is likely just a value string filterValue = FormatFilterValueValue(configurationValues, filterValues[0]); if (!string.IsNullOrWhiteSpace(filterValue)) { return("Is " + filterValue); } } else if (filterValues.Count >= 2) { // If two more values, then it is a comparison and a value string comparisonValue = filterValues[0]; if (comparisonValue != "0") { ComparisonType comparisonType = comparisonValue.ConvertToEnum <ComparisonType>(ComparisonType.StartsWith); if (comparisonType == ComparisonType.IsBlank || comparisonType == ComparisonType.IsNotBlank) { return(comparisonType.ConvertToString()); } else { var filterValueValue = FormatFilterValueValue(configurationValues, filterValues[1]); if (string.IsNullOrEmpty(filterValueValue)) { if (this.FilterComparisonType.HasFlag(ComparisonType.IsBlank) && comparisonType == ComparisonType.EqualTo || comparisonType == ComparisonType.NotEqualTo) { // if IsBlank is one of the allowed FilterComparisonTypes, and if EqualTo or NotEqualTo specified with blank value, this will get converted is IsBlank/IsNotBlank // so we can render this as "Equal To ''" or '"Not Equal To ''" return(string.Format("{0} {1}", comparisonType.ConvertToString(), filterValueValue)); } // if there is no value specified, just return String.Empty return(string.Empty); } else { return(string.Format("{0} {1}", comparisonType.ConvertToString(), filterValueValue)); } } } } } return(string.Empty); }
/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType"></param> /// <param name="selection">The selection.</param> /// <returns></returns> public override string FormatSelection(Type entityType, string selection) { var values = JsonConvert.DeserializeObject <List <string> >(selection); if (values.Count > 0) { // First value in array is always the name of the entity field being filtered string entityFieldName = values[0]; var entityField = GetEntityFields(entityType).Where(p => p.Name == entityFieldName).FirstOrDefault(); if (entityField != null) { // If there is just one additional value then there's no comparison value if (values.Count == 2) { if (entityField.FilterFieldType == SystemGuid.FieldType.MULTI_SELECT) { var selectedValues = JsonConvert.DeserializeObject <List <string> >(values[1]); var selectedTexts = new List <string>(); if (entityField.DefinedTypeId.HasValue) { foreach (string selectedValue in selectedValues) { int valueId = int.MinValue; if (int.TryParse(selectedValue, out valueId)) { var definedValue = DefinedValueCache.Read(valueId); if (definedValue != null) { selectedTexts.Add(definedValue.Name); } } } } else { selectedTexts = selectedValues.ToList(); } return(string.Format("{0} is {1}", entityField.Title, selectedTexts.Select(v => "'" + v + "'").ToList().AsDelimited(" or "))); } else { return(string.Format("{0} is {1}", entityField.Title, values[1])); } } // If two more values, then it is a comparison and a value else if (values.Count == 3) { ComparisonType comparisonType = values[1].ConvertToEnum <ComparisonType>(ComparisonType.StartsWith); return(string.Format("{0} {1} '{2}'", entityField.Title, comparisonType.ConvertToString(), values[2])); } } } return(entityType.Name.SplitCase() + " Property"); }
/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public override string FormatSelection(Type entityType, string selection) { string s = "Attendance"; string[] options = selection.Split('|'); if (options.Length >= 4) { var groupsList = new GroupService(new RockContext()).GetByGuids(options[0].Split(',').AsGuidList()) .Select(a => a.Name).ToList().AsDelimited(", ", " or "); ComparisonType comparisonType = options[1].ConvertToEnum <ComparisonType>(ComparisonType.GreaterThanOrEqualTo); bool includeChildGroups = options.Length > 4 ? options[4].AsBoolean() : false; string dateRangeText = SlidingDateRangePicker.FormatDelimitedValues(options[3].Replace(',', '|')); s = string.Format( "Attended '{0}'{4} {1} {2} times. Date Range: {3}", groupsList != null ? groupsList : "?", comparisonType.ConvertToString(), options[2], dateRangeText, includeChildGroups ? " (or child groups) " : string.Empty); } return(s); }
/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public override string FormatSelection(Type entityType, string selection) { string s = "Group Type Attendance"; string[] options = selection.Split('|'); if (options.Length >= 4) { var groupType = Rock.Web.Cache.GroupTypeCache.Read(options[0].AsGuid()); ComparisonType comparisonType = options[1].ConvertToEnum <ComparisonType>(ComparisonType.GreaterThanOrEqualTo); bool includeChildGroups = options.Length > 4 ? options[4].AsBoolean() : false; string dateRangeText; int? lastXWeeks = options[3].AsIntegerOrNull(); if (lastXWeeks.HasValue) { dateRangeText = " in last " + (lastXWeeks.Value * 7).ToString() + " days"; } else { dateRangeText = SlidingDateRangePicker.FormatDelimitedValues(options[3].Replace(',', '|')); } s = string.Format( "Attended '{0}'{4} {1} {2} times. Date Range: {3}", groupType != null ? groupType.Name : "?", comparisonType.ConvertToString(), options[2], dateRangeText, includeChildGroups ? " (or child group types) " : string.Empty); } return(s); }
/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public override string FormatSelection(Type entityType, string selection) { var values = selection.Split('|'); string result = "Member Count"; if (values.Length == 4) { ComparisonType comparisonType = values[0].ConvertToEnum <ComparisonType>(ComparisonType.EqualTo); int? memberCountValue = values[1].AsIntegerOrNull(); bool? isLeader = values[2].AsBooleanOrNull(); GroupMemberStatus?memberStatusValue = (GroupMemberStatus?)values[3].AsIntegerOrNull(); result = "Number of"; if (memberStatusValue.HasValue) { result += " " + memberStatusValue.Value.ConvertToString(); } if (isLeader.HasValue) { result += isLeader.Value ? " Leader" : " Not Leader"; } if (result.Trim() == "Number of") { result = "Number of members"; } string countText = (comparisonType == ComparisonType.IsBlank || comparisonType == ComparisonType.IsNotBlank) ? string.Empty : memberCountValue.ToString(); result += " " + comparisonType.ConvertToString() + " " + countText; } return(result); }
/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public override string FormatSelection(Type entityType, string selection) { string result = "Giving Amount"; string[] selectionValues = selection.Split('|'); if (selectionValues.Length >= 4) { ComparisonType comparisonType = selectionValues[0].ConvertToEnum <ComparisonType>(ComparisonType.GreaterThanOrEqualTo); decimal amount = selectionValues[1].AsDecimalOrNull() ?? 0.00M; string accountNames = string.Empty; if (selectionValues.Length >= 5) { var accountGuids = selectionValues[4].Split(',').Select(a => a.AsGuid()).ToList(); accountNames = new FinancialAccountService(new RockContext()).GetByGuids(accountGuids).Select(a => a.Name).ToList().AsDelimited(","); } bool combineGiving = false; if (selectionValues.Length >= 6) { combineGiving = selectionValues[5].AsBooleanOrNull() ?? false; } SlidingDateRangePicker fakeSlidingDateRangePicker = new SlidingDateRangePicker(); if (selectionValues.Length >= 7) { // convert comma delimited to pipe fakeSlidingDateRangePicker.DelimitedValues = selectionValues[6].Replace(',', '|'); } else { // if converting from a previous version of the selection var lowerValue = selectionValues[2].AsDateTime(); var upperValue = selectionValues[3].AsDateTime(); fakeSlidingDateRangePicker.SlidingDateRangeMode = SlidingDateRangePicker.SlidingDateRangeType.DateRange; fakeSlidingDateRangePicker.SetDateRangeModeValue(new DateRange(lowerValue, upperValue)); } result = string.Format( "{4}Giving amount total {0} {1} {2}. Date Range: {3}", comparisonType.ConvertToString().ToLower(), amount.ToString("C"), !string.IsNullOrWhiteSpace(accountNames) ? " to accounts:" + accountNames : string.Empty, SlidingDateRangePicker.FormatDelimitedValues(fakeSlidingDateRangePicker.DelimitedValues), combineGiving ? "Combined " : string.Empty); } return(result); }
/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public override string FormatSelection(Type entityType, string selection) { var values = selection.Split('|'); if (values.Length >= 2) { string locationType = ""; if (values.Length >= 3 && values[0].AsInteger() != 0) { var groupLocationType = DefinedTypeCache.Get(SystemGuid.DefinedType.GROUP_LOCATION_TYPE.AsGuid()) .DefinedValues.FirstOrDefault(dv => dv.Id == values[2].AsInteger()); if (groupLocationType != null) { locationType = groupLocationType.Value; } } ComparisonType comparisonType = values[0].ConvertToEnum <ComparisonType>(ComparisonType.EqualTo); switch (comparisonType) { case ComparisonType.EqualTo: case ComparisonType.NotEqualTo: case ComparisonType.StartsWith: case ComparisonType.Contains: case ComparisonType.DoesNotContain: case ComparisonType.EndsWith: return(string.Format("{0} Postal Code {1} {2}", locationType, comparisonType.ConvertToString(), values[1])); case ComparisonType.IsBlank: case ComparisonType.IsNotBlank: return(string.Format("{0} Postal Code {1}", locationType, comparisonType.ConvertToString())); default: break; } } return("Postal code filter"); }
/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public override string FormatSelection(Type entityType, string selection) { var values = selection.Split('|'); string result = "Available Capacity"; if (values.Length == 2) { ComparisonType comparisonType = values[0].ConvertToEnum <ComparisonType>(ComparisonType.EqualTo); int? capacityCountValue = values[1].AsIntegerOrNull(); string countText = (comparisonType == ComparisonType.IsBlank || comparisonType == ComparisonType.IsNotBlank) ? string.Empty : capacityCountValue.ToString(); result += " " + comparisonType.ConvertToString() + " " + countText; } return(result); }
/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public virtual string FormatSelection(Type entityType, string selection) { ComparisonType comparisonType = ComparisonType.StartsWith; string value = string.Empty; string[] options = selection.Split('|'); if (options.Length > 0) { comparisonType = options[0].ConvertToEnum <ComparisonType>(ComparisonType.StartsWith); } if (options.Length > 1) { value = options[1]; } return(string.Format("{0} {1} '{2}'", GetTitle(entityType), comparisonType.ConvertToString(), value)); }
/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public override string FormatSelection(Type entityType, string selection) { string result = "Giving Amount"; var selectionConfig = SelectionConfig.Parse(selection); ComparisonType comparisonType = selectionConfig.ComparisonType; decimal amount = selectionConfig.Amount ?? 0.00M; string accountNames = string.Empty; var accountGuids = selectionConfig.AccountGuids; if (selectionConfig.AccountGuids != null && selectionConfig.AccountGuids.Any()) { accountNames = new FinancialAccountService(new RockContext()).GetByGuids(accountGuids).Select(a => a.Name).ToList().AsDelimited(", ", " and "); } bool combineGiving = selectionConfig.CombineGiving; string toAccountsDescription; if (!accountNames.IsNullOrWhiteSpace()) { toAccountsDescription = " to accounts: " + accountNames; if (selectionConfig.IncludeChildAccounts) { toAccountsDescription += " including child accounts"; } } else { toAccountsDescription = string.Empty; } result = $@" {( combineGiving ? "Combined " : string.Empty ) }Giving amount total {comparisonType.ConvertToString().ToLower()} {amount.FormatAsCurrency()} {toAccountsDescription}. Date Range: {SlidingDateRangePicker.FormatDelimitedValues( selectionConfig.SlidingDateRangePickerDelimitedValues )}"; if (selectionConfig.UseAnalyticsModels) { result += " using analytics models"; } return(result); }
/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public override string FormatSelection(Type entityType, string selection) { string s = "Group Type Attendance"; string[] options = selection.Split('|'); if (options.Length >= 4) { var groupType = Rock.Web.Cache.GroupTypeCache.Read(int.Parse(options[0])); ComparisonType comparisonType = options[0].ConvertToEnum <ComparisonType>(ComparisonType.GreaterThanOrEqualTo); s = string.Format("Attended '{0}' {1} {2} times in the last {3} week(s)", groupType != null ? groupType.Name : "?", comparisonType.ConvertToString(), options[2], options[3]); } return(s); }
/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public override string FormatSelection(Type entityType, string selection) { string result = "Attendance at Campuses"; string[] options = selection.Split('|'); if (options.Length >= 4) { var campusGuidList = options[0].Split(',').AsGuidList(); List <string> campusNames = new List <string>(); foreach (var campusGuid in campusGuidList) { var campus = CampusCache.Get(campusGuid); if (campus != null) { campusNames.Add(campus.Name); } } ComparisonType comparisonType = options[1].ConvertToEnum <ComparisonType>(ComparisonType.GreaterThanOrEqualTo); string dateRangeText; int? lastXWeeks = options[3].AsIntegerOrNull(); if (lastXWeeks.HasValue) { dateRangeText = " in last " + (lastXWeeks.Value * 7).ToString() + " days"; } else { dateRangeText = SlidingDateRangePicker.FormatDelimitedValues(options[3].Replace(',', '|')); } result = string.Format( "Attended '{0}' {1} {2} times. Date Range: {3}", campusNames.Any() ? "Campuses: " + campusNames.AsDelimited(", ") : "?", comparisonType.ConvertToString(), options[2], dateRangeText); } return(result); }
/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public override string FormatSelection(Type entityType, string selection) { string result = "Giving Amount"; string[] selectionValues = selection.Split('|'); if (selectionValues.Length >= 4) { ComparisonType comparisonType = selectionValues[0].ConvertToEnum <ComparisonType>(ComparisonType.GreaterThanOrEqualTo); decimal amount = selectionValues[1].AsDecimalOrNull() ?? 0.00M; DateTime startDate = selectionValues[2].AsDateTime() ?? DateTime.MinValue; DateTime endDate = selectionValues[3].AsDateTime() ?? DateTime.MaxValue; string accountNames = string.Empty; if (selectionValues.Length >= 5) { var accountGuids = selectionValues[4].Split(',').Select(a => a.AsGuid()).ToList(); accountNames = new FinancialAccountService(new RockContext()).GetByGuids(accountGuids).Select(a => a.Name).ToList().AsDelimited(","); } bool combineGiving = false; if (selectionValues.Length >= 6) { combineGiving = selectionValues[5].AsBooleanOrNull() ?? false; } result = string.Format( "{5}Giving amount total {0} {1} {2} between {3} and {4}", comparisonType.ConvertToString().ToLower(), amount.ToString("C"), !string.IsNullOrWhiteSpace(accountNames) ? " to accounts:" + accountNames : string.Empty, startDate.ToShortDateString(), endDate.ToShortDateString(), combineGiving ? "Combined " : string.Empty); } return(result); }
/// <summary> /// Formats the selection. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="selection">The selection.</param> /// <returns></returns> public override string FormatSelection(Type entityType, string selection) { string result = "Giving Amount"; string[] selectionValues = selection.Split('|'); if (selectionValues.Length >= 4) { ComparisonType comparisonType = selectionValues[0].ConvertToEnum <ComparisonType>(ComparisonType.GreaterThanOrEqualTo); decimal amount = selectionValues[1].AsDecimal() ?? 0.00M; DateTime startDate = selectionValues[2].AsDateTime() ?? DateTime.MinValue; DateTime endDate = selectionValues[3].AsDateTime() ?? DateTime.MaxValue; result = string.Format("Giving amount total {0} {1} between {2} and {3}", comparisonType.ConvertToString().ToLower(), amount.ToString("C"), startDate.ToShortDateString(), endDate.ToShortDateString()); } return(result); }