/// <summary> /// Gets the display value for a filter field. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected void fFees_DisplayFilterValue(object sender, GridFilter.DisplayFilterValueArgs e) { switch (e.Key) { case "FeeDateRange": e.Value = SlidingDateRangePicker.FormatDelimitedValues(e.Value); break; case "FeeName": break; case "FeeOptions": var values = new List <string>(); foreach (string value in e.Value.Split(';')) { var item = cblFeeOptions.Items.FindByValue(value); if (item != null) { values.Add(item.Text); } } e.Value = values.AsDelimited(", "); break; default: e.Value = string.Empty; break; } }
/// <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> /// Rs the filter_ display filter value. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected void rFilter_DisplayFilterValue(object sender, GridFilter.DisplayFilterValueArgs e) { switch (e.Key) { case FilterKey.DateRange: var formattedValue = SlidingDateRangePicker.FormatDelimitedValues(e.Value); e.Value = formattedValue.IsNullOrWhiteSpace() ? e.Value : formattedValue; e.Value = e.Value == "All||||" ? string.Empty : e.Value; break; case FilterKey.Severity: e.Value = ((WebFarmNodeLog.SeverityLevel)e.Value.AsInteger()).ToString(); break; case FilterKey.EventType: case FilterKey.Text: case FilterKey.NodeName: case FilterKey.WriterNodeName: break; default: e.Value = string.Empty; break; } }
/// <summary> /// Formats the filter values. /// </summary> /// <param name="configurationValues">The configuration values.</param> /// <param name="filterValues">The filter values.</param> /// <returns></returns> public override string FormatFilterValues(Dictionary <string, ConfigurationValue> configurationValues, List <string> filterValues) { if (filterValues.Count >= 2) { // uses Tab Delimited since slidingDateRangePicker is | delimited var filterValueValues = filterValues[1].Split(new string[] { "\t" }, StringSplitOptions.None); string comparisonValue = filterValues[0]; if (comparisonValue != "0") { ComparisonType comparisonType = comparisonValue.ConvertToEnum <ComparisonType>(ComparisonType.EqualTo); if (comparisonType == ComparisonType.Between && filterValueValues.Length > 1) { var dateRangeText = SlidingDateRangePicker.FormatDelimitedValues(filterValueValues[1]); return(dateRangeText.IsNotNullOrWhiteSpace() ? string.Format("During '{0}'", dateRangeText) : null); } else { List <string> filterValuesForFormat = new List <string>(); filterValuesForFormat.Add(filterValues[0]); filterValuesForFormat.Add(filterValueValues[0]); return(base.FormatFilterValues(configurationValues, filterValuesForFormat)); } } } return(null); }
/// <summary> /// Gets the display value for a filter field. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected void fDiscounts_DisplayFilterValue(object sender, GridFilter.DisplayFilterValueArgs e) { switch (e.Key) { case "DiscountDateRange": e.Value = SlidingDateRangePicker.FormatDelimitedValues(e.Value); break; case "DiscountCode": // If that discount code is not in the list, don't show it anymore. if (ddlDiscountCode.Items.FindByText(e.Value) == null) { e.Value = string.Empty; } break; case "DiscountCodeSearch": break; default: e.Value = string.Empty; break; } }
/// <summary> /// Handles displaying the stored filter values. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e as DisplayFilterValueArgs (hint: e.Key and e.Value).</param> protected void gfInteractions_DisplayFilterValue(object sender, GridFilter.DisplayFilterValueArgs e) { switch (e.Key) { case "Date Range": e.Value = SlidingDateRangePicker.FormatDelimitedValues(e.Value); break; case "Show Unassigned Devices": var showUnassignedDevices = e.Value.AsBooleanOrNull(); if (showUnassignedDevices.HasValue && showUnassignedDevices.Value) { e.Value = showUnassignedDevices.Value.ToYesNo(); } else { e.Value = string.Empty; } break; case "Present Devices": var presentDevices = e.Value.AsBooleanOrNull(); if (presentDevices.HasValue && presentDevices.Value) { e.Value = presentDevices.Value.ToYesNo(); } else { e.Value = string.Empty; } break; } }
/// <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) { string s = "Activity"; var selectionConfig = SelectionConfig.Parse(selection); if (selectionConfig != null && selectionConfig.ConnectionActivityTypeGuid.HasValue) { var activityType = new ConnectionActivityTypeService(new RockContext()).Get(selectionConfig.ConnectionActivityTypeGuid.Value); var activityName = GetActivityName(activityType); var dateRangeString = string.Empty; if (selectionConfig.SlidingDateRangeDelimitedValues.IsNotNullOrWhiteSpace()) { var dateRange = SlidingDateRangePicker.FormatDelimitedValues(selectionConfig.SlidingDateRangeDelimitedValues); if (dateRangeString.IsNotNullOrWhiteSpace()) { dateRangeString += $" Date Range: {dateRangeString}"; } } s = string.Format( "Activity '{0}' {1} {2} times. {3}", activityName, selectionConfig.IntegerCompare.ConvertToString(), selectionConfig.MinimumCount, dateRangeString); } return(s); }
/// <summary> /// Gfs the group members display filter value. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected void gfGroupMembers_DisplayFilterValue(object sender, GridFilter.DisplayFilterValueArgs e) { int groupId = hfGroupId.Value.AsInteger(); if (e.Key == "Group Role") { List <int> selectedGroupRoleIds = e.Value.FromJsonOrNull <List <int> >() ?? new List <int>(); e.Value = cblRole.Items.OfType <ListItem>().Where(a => selectedGroupRoleIds.Contains(a.Value.AsInteger())).Select(a => a.Text).ToList().AsDelimited(", ", " or "); } else if (e.Key == "Group Member Status") { List <int> selectedGroupMemberStatuses = e.Value.FromJsonOrNull <List <int> >() ?? new List <int>(); e.Value = cblGroupMemberStatus.Items.OfType <ListItem>().Where(a => selectedGroupMemberStatuses.Contains(a.Value.AsInteger())).Select(a => a.Text).ToList().AsDelimited(", ", " or "); } else if (e.Key == "Date Added" || e.Key == "Date Removed") { e.Value = SlidingDateRangePicker.FormatDelimitedValues(e.Value); } else if (e.Key == "First Name" || e.Key == "Last Name") { // let the value go thru unchanged } else { // unexpected key or a key for another GroupId e.Value = string.Empty; } }
/// <summary> /// Renders the specified writer. /// </summary> /// <param name="badge">The badge.</param> /// <param name="writer">The writer.</param> public override void Render(PersonBadgeCache badge, System.Web.UI.HtmlTextWriter writer) { Guid?groupTypeGuid = GetAttributeValue(badge, "GroupType").AsGuidOrNull(); if (groupTypeGuid.HasValue) { var lavaTemplate = this.GetAttributeValue(badge, "LavaTemplate"); var slidingDateRangeDelimitedValues = this.GetAttributeValue(badge, "DateRange"); var dateRange = SlidingDateRangePicker.CalculateDateRangeFromDelimitedValues(slidingDateRangeDelimitedValues); var dateRangeSummary = SlidingDateRangePicker.FormatDelimitedValues(slidingDateRangeDelimitedValues); var mergeFields = Lava.LavaHelper.GetCommonMergeFields(null, null, new Lava.CommonMergeFieldsOptions { GetLegacyGlobalMergeFields = false }); mergeFields.Add("Person", this.Person); using (var rockContext = new RockContext()) { var groupType = GroupTypeCache.Read(groupTypeGuid.Value); int groupTypeId = groupType?.Id ?? 0; mergeFields.Add("GroupType", groupType); mergeFields.Add("Badge", badge); mergeFields.Add("DateRange", new { Dates = dateRange, Summary = dateRangeSummary }); var personAliasIds = Person.Aliases.Select(a => a.Id).ToList(); var attendanceQuery = new AttendanceService(rockContext).Queryable().Where(a => a.Group.GroupTypeId == groupTypeId && a.DidAttend == true && personAliasIds.Contains(a.PersonAliasId.Value)); if (dateRange.Start.HasValue) { attendanceQuery = attendanceQuery.Where(a => a.StartDateTime >= dateRange.Start.Value); } if (dateRange.End.HasValue) { attendanceQuery = attendanceQuery.Where(a => a.StartDateTime < dateRange.End.Value); } var attendanceDateTimes = attendanceQuery.Select(a => a.StartDateTime).ToList(); if (attendanceDateTimes.Any()) { var attendanceResult = new { Count = attendanceDateTimes.Count(), LastDateTime = attendanceDateTimes.Max() }; mergeFields.Add("Attendance", attendanceResult); } string output = lavaTemplate.ResolveMergeFields(mergeFields); writer.Write(output); } } }
/// <summary> /// Build filter values/summary with user friendly data from filters /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected void fExceptionList_DisplayFilterValue(object sender, GridFilter.DisplayFilterValueArgs e) { switch (e.Key) { case "Site": int siteId; if (int.TryParse(e.Value, out siteId)) { var site = SiteCache.Get(siteId); if (site != null) { e.Value = site.Name; } } break; case "Page": int pageId; if (int.TryParse(e.Value, out pageId)) { var page = PageCache.Get(pageId); if (page != null) { e.Value = page.InternalName; } } break; case "User": int userPersonId; if (int.TryParse(e.Value, out userPersonId)) { PersonService personService = new PersonService(new RockContext()); var user = personService.Get(userPersonId); if (user != null) { e.Value = user.FullName; } } break; // ignore old filter parameters case "Start Date": case "End Date": e.Value = null; break; case "Date Range": e.Value = SlidingDateRangePicker.FormatDelimitedValues(e.Value); break; } }
/// <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> /// Gets the user-friendly description for a filter field setting. /// </summary> /// <param name="filterName"></param> /// <returns></returns> private string OnFormatFilterValueDescription(string filterName, string value) { if (filterName == FilterSettingName.Site) { int siteId; if (int.TryParse(value, out siteId)) { var site = SiteCache.Get(siteId); if (site != null) { value = site.Name; } } } else if (filterName == FilterSettingName.Page) { int pageId; if (int.TryParse(value, out pageId)) { var page = PageCache.Get(pageId); if (page != null) { value = page.InternalName; } } } else if (filterName == FilterSettingName.User) { int userPersonId; if (int.TryParse(value, out userPersonId)) { var personService = new PersonService(_dataContext); var user = personService.Get(userPersonId); if (user != null) { value = user.FullName; } } } else if (filterName == FilterSettingName.DateRange) { value = SlidingDateRangePicker.FormatDelimitedValues(value); } return(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 = "First Contribution Date"; string[] selectionValues = selection.Split('|'); if (selectionValues.Length >= 3) { SlidingDateRangePicker fakeSlidingDateRangePicker = new SlidingDateRangePicker(); if (selectionValues.Length >= 5) { // convert comma delimited to pipe fakeSlidingDateRangePicker.DelimitedValues = selectionValues[4].Replace(',', '|'); } else { // if converting from a previous version of the selection var lowerValue = selectionValues[0].AsDateTime(); var upperValue = selectionValues[1].AsDateTime(); fakeSlidingDateRangePicker.SlidingDateRangeMode = SlidingDateRangePicker.SlidingDateRangeType.DateRange; fakeSlidingDateRangePicker.SetDateRangeModeValue(new DateRange(lowerValue, upperValue)); } string accountNames = string.Empty; var accountGuids = selectionValues[2].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 >= 4) { combineGiving = selectionValues[3].AsBooleanOrNull() ?? false; } result = string.Format( "{2}First contribution date{0}. Date Range: {1}", !string.IsNullOrWhiteSpace(accountNames) ? " to accounts:" + accountNames : string.Empty, SlidingDateRangePicker.FormatDelimitedValues(fakeSlidingDateRangePicker.DelimitedValues), combineGiving ? "Giving Group " : 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"; 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) { SelectionConfig selectionConfig = SelectionConfig.Parse(selection); string accountNames = string.Empty; if (selectionConfig.AccountGuids != null && selectionConfig.AccountGuids.Any()) { accountNames = new FinancialAccountService(new RockContext()).GetByGuids(selectionConfig.AccountGuids).Select(a => a.Name).ToList().AsDelimited(","); } string sundayDateString = selectionConfig.UseSundayDate == true ? "Sunday " : string.Empty; string accountsString = accountNames.IsNullOrWhiteSpace() ? string.Empty : " to accounts: " + accountNames; string dateRangeString = $" Date Range: {SlidingDateRangePicker.FormatDelimitedValues( selectionConfig.DelimitedValues )}"; return($"First contribution {sundayDateString}date{accountsString}.{dateRangeString}"); }
/// <summary> /// Gets the display value for a filter field. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected void fPayments_DisplayFilterValue(object sender, GridFilter.DisplayFilterValueArgs e) { switch (e.Key) { case "Payments Date Range": { e.Value = SlidingDateRangePicker.FormatDelimitedValues(e.Value); break; } default: { e.Value = string.Empty; break; } } }
/// <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 selectionOutput = "Attendance"; var groupAttendanceFilterSelection = GetGroupAttendanceFilterSelection(selection); var groupsList = ""; var selectedSchedules = ""; using (var rockContext = new RockContext()) { groupsList = new GroupService(rockContext) .GetByGuids(groupAttendanceFilterSelection.GroupGuids) .Select(a => a.Name) .ToList() .AsDelimited(", ", " or "); selectedSchedules = new ScheduleService(rockContext) .GetByIds(groupAttendanceFilterSelection.Schedules) .Select(x => x.Name) .ToList() .AsDelimited(", ", " or "); } if (groupsList.IsNullOrWhiteSpace()) { groupsList = "?"; } else if (groupAttendanceFilterSelection.IncludeChildGroups) { groupsList += " (or child groups)"; } if (selectedSchedules.IsNotNullOrWhiteSpace()) { selectedSchedules = $"on {selectedSchedules} "; } var comparisonType = groupAttendanceFilterSelection.IntegerCompare.ConvertToEnum <ComparisonType>(ComparisonType.GreaterThanOrEqualTo); string dateRangeText = SlidingDateRangePicker.FormatDelimitedValues(groupAttendanceFilterSelection.SlidingDateRange); selectionOutput = $"Attended '{groupsList}' {selectedSchedules}{comparisonType.ConvertToString()} {groupAttendanceFilterSelection.AttendedCount} times. Date Range: {dateRangeText}"; return(selectionOutput); }
/// <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 = "Registrant"; string[] selectionValues = selection.Split('|'); if (selectionValues.Length >= 1) { var rockContext = new RockContext(); var registrationTemplateGuids = selectionValues[0].Split(',').AsGuidList(); var registrationTemplates = new RegistrationTemplateService(rockContext).GetByGuids(registrationTemplateGuids); SlidingDateRangePicker fakeSlidingDateRangePicker = null; bool includeInactiveRegistrationInstances = false; if (selectionValues.Length >= 2) { includeInactiveRegistrationInstances = selectionValues[1].AsBooleanOrNull() ?? false; if (selectionValues.Length >= 3) { fakeSlidingDateRangePicker = new SlidingDateRangePicker(); // convert comma delimited to pipe fakeSlidingDateRangePicker.DelimitedValues = selectionValues[2].Replace(',', '|'); } } if (registrationTemplates != null) { result = string.Format(registrationTemplates.Count() > 0 ? "In Registration Templates: {0}" : "In a Registration", registrationTemplates.Select(a => a.Name).ToList().AsDelimited(", ", " or ")); if (includeInactiveRegistrationInstances) { result += ", including inactive registration instances"; } if (fakeSlidingDateRangePicker != null) { result += string.Format(", registered in Date Range: {0}", SlidingDateRangePicker.FormatDelimitedValues(fakeSlidingDateRangePicker.DelimitedValues)); } } } 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 = "Interactions"; string[] selectionValues = selection.Split('|'); if (selectionValues.Length >= 2) { var rockContext = new RockContext(); var interactionChannel = new InteractionChannelService(rockContext).Get(selectionValues[0].AsGuid()); if (interactionChannel != null) { result = string.Format("In Interaction Channel: {0}", interactionChannel.Name); var interactionComponentGuid = selectionValues[1].AsGuidOrNull(); if (interactionComponentGuid.HasValue) { var interactionComponent = new InteractionComponentService(rockContext).Get(interactionComponentGuid.Value); if (interactionComponent != null) { result += string.Format(", in Interaction Component: {0}", interactionComponent.Name); } } var operation = selectionValues[2]; if (!string.IsNullOrEmpty(operation)) { result += string.Format(", with operation: {0}", operation); } if (!string.IsNullOrEmpty(selectionValues[3])) { SlidingDateRangePicker fakeSlidingDateRangePicker = new SlidingDateRangePicker(); var formattedDelimitedValues = SlidingDateRangePicker.FormatDelimitedValues(selectionValues[3].Replace(',', '|')); if (!string.IsNullOrEmpty(formattedDelimitedValues)) { result += string.Format(", date range: {0}", formattedDelimitedValues); } } } } return(result); }
/// <summary> /// Get the display value for a filter field. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected void fRegistrations_DisplayFilterValue(object sender, GridFilter.DisplayFilterValueArgs e) { switch (e.Key) { case "Registrations Date Range": e.Value = SlidingDateRangePicker.FormatDelimitedValues(e.Value); break; case "Payment Status": case "RegisteredBy First Name": case "RegisteredBy Last Name": case "Registrant First Name": case "Registrant Last Name": break; default: e.Value = string.Empty; break; } }
/// <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 = "Person Note"; var selectionConfig = SelectionConfig.Parse(selection); if (selectionConfig != null) { NoteTypeCache selectedNoteType = null; if (selectionConfig.NoteTypeId.HasValue) { selectedNoteType = NoteTypeCache.Get(selectionConfig.NoteTypeId.Value); } if (selectedNoteType != null) { result = $"Has a {selectedNoteType.Name} note"; } else { result = "Has a note"; } var containingText = selectionConfig.NoteContains; if (containingText.IsNotNullOrWhiteSpace()) { result += $" containing '{containingText}'"; } if (selectionConfig.DateRangeMode != null) { var dateRangeString = SlidingDateRangePicker.FormatDelimitedValues(selectionConfig.DelimitedValues); if (dateRangeString.IsNotNullOrWhiteSpace()) { result += $" Date Range: {dateRangeString}"; } } } 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 result = "Created Person Note"; var selectionConfig = SelectionConfig.Parse(selection); if (selectionConfig != null) { result = $"Created {selectionConfig.MinimumCount} or more Person {"Note".PluralizeIf( selectionConfig.MinimumCount > 1 )}"; if (selectionConfig.NoteTypeIds.Any()) { var noteTypeNames = new List <string>(); foreach (var noteTypeId in selectionConfig.NoteTypeIds) { var noteType = NoteTypeCache.Get(noteTypeId); if (noteType != null) { noteTypeNames.Add(noteType.Name); } } result += string.Format(" with note types: {0}.", noteTypeNames.AsDelimited(",")); } if (selectionConfig.DelimitedValues.IsNotNullOrWhiteSpace()) { var dateRangeString = SlidingDateRangePicker.FormatDelimitedValues(selectionConfig.DelimitedValues); if (dateRangeString.IsNotNullOrWhiteSpace()) { result += $" Date Range: {dateRangeString}"; } } } return(result); }
/// <summary> /// Rs the filter_ display filter value. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> protected void rFilter_DisplayFilterValue(object sender, GridFilter.DisplayFilterValueArgs e) { switch (e.Key) { case FilterKey.DateRange: e.Value = SlidingDateRangePicker.FormatDelimitedValues(e.Value); break; case FilterKey.LoginStatus: var boolValue = e.Value.AsBooleanOrNull(); e.Value = boolValue == null ? "Both" : boolValue == true ? "Logged In" : "Not Logged In"; break; case FilterKey.UrlContains: break; default: e.Value = string.Empty; break; } }
public string GetSlidingDateRangeTextValue(SlidingDateRangePicker.SlidingDateRangeType slidingDateRangeType, SlidingDateRangePicker.TimeUnitType timeUnitType, string startDate, string endDate, int number = 1) { string textValue = SlidingDateRangePicker.FormatDelimitedValues(string.Format("{0}|{1}|{2}|{3}|{4}", slidingDateRangeType, number, timeUnitType, startDate, endDate)); return(textValue); }
/// <summary> /// Renders the specified writer. /// </summary> /// <param name="badge">The badge.</param> /// <param name="writer">The writer.</param> public override void Render(BadgeCache badge, System.Web.UI.HtmlTextWriter writer) { if (Person == null) { return; } var accountGuids = this.GetAttributeValue(badge, "Accounts")?.SplitDelimitedValues().AsGuidList(); var minimumAmount = this.GetAttributeValue(badge, "MinimumAmount")?.AsDecimalOrNull(); var slidingDateRangeDelimitedValues = this.GetAttributeValue(badge, "DateRange"); var lavaTemplate = this.GetAttributeValue(badge, "LavaTemplate"); var dateRange = SlidingDateRangePicker.CalculateDateRangeFromDelimitedValues(slidingDateRangeDelimitedValues); var dateRangeSummary = SlidingDateRangePicker.FormatDelimitedValues(slidingDateRangeDelimitedValues); var mergeFields = Lava.LavaHelper.GetCommonMergeFields(null, null, new Lava.CommonMergeFieldsOptions { GetLegacyGlobalMergeFields = false }); mergeFields.Add("Person", this.Person); using (var rockContext = new RockContext()) { mergeFields.Add("Badge", badge); mergeFields.Add("DateRange", new { Dates = dateRange, Summary = dateRangeSummary }); // fetch all the possible PersonAliasIds that have this GivingID to help optimize the SQL var personAliasIds = new PersonAliasService(rockContext).Queryable().Where(a => a.Person.GivingId == this.Person.GivingId).Select(a => a.Id).ToList(); var transactionTypeContributionValueId = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.TRANSACTION_TYPE_CONTRIBUTION.AsGuid()).Id; var qry = new FinancialTransactionService(rockContext).Queryable().Where(a => a.TransactionTypeValueId == transactionTypeContributionValueId); // get the transactions for the person or all the members in the person's giving group (Family) qry = qry.Where(t => t.AuthorizedPersonAliasId.HasValue && personAliasIds.Contains(t.AuthorizedPersonAliasId.Value)); if (dateRange.Start.HasValue) { qry = qry.Where(t => t.TransactionDateTime >= dateRange.Start.Value); } if (dateRange.End.HasValue) { qry = qry.Where(t => t.TransactionDateTime < dateRange.End.Value); } if (minimumAmount.HasValue) { qry = qry.Where(a => a.TransactionDetails.Sum(d => ( decimal? )d.Amount) > minimumAmount); } if (accountGuids.Any()) { qry = qry.Where(t => t.TransactionDetails.Any(d => accountGuids.Contains(d.Account.Guid))); } var contributionList = qry.Select(a => new { a.TransactionDateTime, ContributionAmount = a.TransactionDetails.Sum(d => ( decimal? )d.Amount) }).ToList(); if (contributionList.Any()) { var contributionResult = new { Count = contributionList.Count(), LastDateTime = contributionList.Max(a => a.TransactionDateTime), TotalAmount = contributionList.Sum(a => a.ContributionAmount), }; mergeFields.Add("Contributions", contributionResult); } string output = lavaTemplate.ResolveMergeFields(mergeFields); writer.Write(output); } }
/// <summary> /// Formats the selection for the InGroupFilter/NotInGroupFilter based on if we are in "Not" mode /// </summary> /// <param name="selection">The selection.</param> /// <param name="not">if set to <c>true</c> [not].</param> /// <returns></returns> public virtual string GroupFilterFormatSelection(string selection, bool not) { string result = "Group Member"; string[] selectionValues = selection.Split('|'); if (selectionValues.Length >= 2) { var rockContext = new RockContext(); var groupGuids = selectionValues[0].Split(',').AsGuidList(); var groups = new GroupService(rockContext).GetByGuids(groupGuids); var groupTypeRoleGuidList = selectionValues[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(a => a.AsGuid()).ToList(); var groupTypeRoles = new GroupTypeRoleService(rockContext).Queryable().Where(a => groupTypeRoleGuidList.Contains(a.Guid)).ToList(); bool includeChildGroups = false; bool includeChildGroupsPlusDescendants = false; bool includeChildGroupsIncludeSelected = false; bool includeInactiveGroups = false; string addedOnDateRangeText = null; string firstAttendanceDateRangeText = null; string lastAttendanceDateRangeText = null; if (selectionValues.Length >= 3) { includeChildGroups = selectionValues[2].AsBooleanOrNull() ?? false; if (selectionValues.Length >= 6) { includeChildGroupsIncludeSelected = selectionValues[4].AsBooleanOrNull() ?? false; includeChildGroupsPlusDescendants = selectionValues[5].AsBooleanOrNull() ?? false; } if (selectionValues.Length >= 7) { includeInactiveGroups = selectionValues[6].AsBooleanOrNull() ?? false; } if (selectionValues.Length >= 8) { // convert comma delimited to pipe then get date range text addedOnDateRangeText = SlidingDateRangePicker.FormatDelimitedValues(selectionValues[7].Replace(',', '|')); } if (selectionValues.Length >= 10) { // convert comma delimited to pipe then get date range text firstAttendanceDateRangeText = SlidingDateRangePicker.FormatDelimitedValues(selectionValues[8].Replace(',', '|')); // convert comma delimited to pipe then get date range text lastAttendanceDateRangeText = SlidingDateRangePicker.FormatDelimitedValues(selectionValues[9].Replace(',', '|')); } } GroupMemberStatus?groupMemberStatus = null; if (selectionValues.Length >= 4) { groupMemberStatus = selectionValues[3].ConvertToEnumOrNull <GroupMemberStatus>(); } if (groups != null) { result = string.Format(not ? "Not in groups: {0}" : "In groups: {0}", groups.Select(a => a.Name).ToList().AsDelimited(", ", " or ")); if (includeChildGroups) { if (includeChildGroupsPlusDescendants) { result += " or descendant groups"; } else { result += " or child groups"; } if (includeInactiveGroups) { result += ", including inactive groups"; } if (!includeChildGroupsIncludeSelected) { result += ", not including selected groups"; } } if (groupTypeRoles.Count() > 0) { result += string.Format(", with role(s): {0}", groupTypeRoles.Select(a => string.Format("{0} ({1})", a.Name, a.GroupType.Name)).ToList().AsDelimited(",")); } if (groupMemberStatus.HasValue) { result += string.Format(", with member status: {0}", groupMemberStatus.ConvertToString()); } if (!string.IsNullOrEmpty(addedOnDateRangeText)) { result += string.Format(", added to group in Date Range: {0}", addedOnDateRangeText); } if (!string.IsNullOrEmpty(firstAttendanceDateRangeText)) { result += string.Format(", first attendance to group in Date Range: {0}", firstAttendanceDateRangeText); } if (!string.IsNullOrEmpty(lastAttendanceDateRangeText)) { result += string.Format(", last attendance to group in Date Range: {0}", lastAttendanceDateRangeText); } } } return(result); }
public string GetSlidingDateRangeTextValue(Rock.Web.UI.Controls.SlidingDateRangePicker.SlidingDateRangeType slidingDateRangeType, Rock.Web.UI.Controls.SlidingDateRangePicker.TimeUnitType timeUnitType, int number = 1) { string textValue = SlidingDateRangePicker.FormatDelimitedValues(string.Format("{0}|{1}|{2}||", slidingDateRangeType, number, timeUnitType)); return(textValue); }
/// <summary> /// Returns the field's current value(s) /// </summary> /// <param name="parentControl">The parent control.</param> /// <param name="value">Information about the value</param> /// <param name="configurationValues">The configuration values.</param> /// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param> /// <returns></returns> public override string FormatValue(Control parentControl, string value, Dictionary <string, ConfigurationValue> configurationValues, bool condensed) { return(SlidingDateRangePicker.FormatDelimitedValues(value)); }