/// <summary> /// Gets the settings. /// </summary> private void GetSettings() { // Get General Settings nbGenderAutoFill.Text = Rock.Web.SystemSettings.GetValue(SystemSetting.GENDER_AUTO_FILL_CONFIDENCE); // Get Data Automation Settings _reactivateSettings = Rock.Web.SystemSettings.GetValue(SystemSetting.DATA_AUTOMATION_REACTIVATE_PEOPLE).FromJsonOrNull <ReactivatePeople>() ?? new ReactivatePeople(); _inactivateSettings = Rock.Web.SystemSettings.GetValue(SystemSetting.DATA_AUTOMATION_INACTIVATE_PEOPLE).FromJsonOrNull <InactivatePeople>() ?? new InactivatePeople(); _campusSettings = Rock.Web.SystemSettings.GetValue(SystemSetting.DATA_AUTOMATION_CAMPUS_UPDATE).FromJsonOrNull <UpdateFamilyCampus>() ?? new UpdateFamilyCampus(); _adultChildrenSettings = Rock.Web.SystemSettings.GetValue(SystemSetting.DATA_AUTOMATION_ADULT_CHILDREN).FromJsonOrNull <MoveAdultChildren>() ?? new MoveAdultChildren(); _updatePersonConnectionStatus = Rock.Web.SystemSettings.GetValue(SystemSetting.DATA_AUTOMATION_UPDATE_PERSON_CONNECTION_STATUS).FromJsonOrNull <UpdatePersonConnectionStatus>() ?? new UpdatePersonConnectionStatus(); _updateFamilyStatus = Rock.Web.SystemSettings.GetValue(SystemSetting.DATA_AUTOMATION_UPDATE_FAMILY_STATUS).FromJsonOrNull <UpdateFamilyStatus>() ?? new UpdateFamilyStatus(); // Set Data Automation Controls // Reactivate cbReactivatePeople.Checked = _reactivateSettings.IsEnabled; pnlReactivatePeople.Enabled = _reactivateSettings.IsEnabled; cbLastContribution.Checked = _reactivateSettings.IsLastContributionEnabled; nbLastContribution.Text = _reactivateSettings.LastContributionPeriod.ToStringSafe(); cbAttendanceInServiceGroup.Checked = _reactivateSettings.IsAttendanceInServiceGroupEnabled; nbAttendanceInServiceGroup.Text = _reactivateSettings.AttendanceInServiceGroupPeriod.ToStringSafe(); cbRegisteredInAnyEvent.Checked = _reactivateSettings.IsRegisteredInAnyEventEnabled; nbRegisteredInAnyEvent.Text = _reactivateSettings.RegisteredInAnyEventPeriod.ToStringSafe(); cbAttendanceInGroupType.Checked = _reactivateSettings.IsAttendanceInGroupTypeEnabled; nbAttendanceInGroupType.Text = _reactivateSettings.AttendanceInGroupTypeDays.ToStringSafe(); rlbAttendanceInGroupType.SetValues(_reactivateSettings.AttendanceInGroupType ?? new List <int>()); cbSiteLogin.Checked = _reactivateSettings.IsSiteLoginEnabled; nbSiteLogin.Text = _reactivateSettings.SiteLoginPeriod.ToStringSafe(); cbPrayerRequest.Checked = _reactivateSettings.IsPrayerRequestEnabled; nbPrayerRequest.Text = _reactivateSettings.PrayerRequestPeriod.ToStringSafe(); cbPersonAttributes.Checked = _reactivateSettings.IsPersonAttributesEnabled; nbPersonAttributes.Text = _reactivateSettings.PersonAttributesDays.ToStringSafe(); rlbPersonAttributes.SetValues(_reactivateSettings.PersonAttributes ?? new List <int>()); cbIncludeDataView.Checked = _reactivateSettings.IsIncludeDataViewEnabled; dvIncludeDataView.EntityTypeId = EntityTypeCache.Get(typeof(Rock.Model.Person)).Id; dvIncludeDataView.SetValue(_reactivateSettings.IncludeDataView); cbExcludeDataView.Checked = _reactivateSettings.IsExcludeDataViewEnabled; dvExcludeDataView.EntityTypeId = EntityTypeCache.Get(typeof(Rock.Model.Person)).Id; dvExcludeDataView.SetValue(_reactivateSettings.ExcludeDataView); cbInteractions.Checked = _reactivateSettings.IsInteractionsEnabled; var interactionChannels = new InteractionChannelService(_rockContext) .Queryable().AsNoTracking() .Select(a => new { a.Guid, a.Name }) .ToList(); var reactivateChannelTypes = interactionChannels.Select(c => new InteractionItem(c.Guid, c.Name)).ToList(); if (_reactivateSettings.Interactions != null) { bool noneSelected = !_reactivateSettings.Interactions.Any(i => i.IsInteractionTypeEnabled); foreach (var settingInteractionItem in _reactivateSettings.Interactions) { var interactionChannelType = reactivateChannelTypes.SingleOrDefault(a => a.Guid == settingInteractionItem.Guid); if (interactionChannelType != null) { interactionChannelType.IsInteractionTypeEnabled = noneSelected || settingInteractionItem.IsInteractionTypeEnabled; interactionChannelType.LastInteractionDays = settingInteractionItem.LastInteractionDays; } } // Now UNCHECK all channels that were NOT *previously* saved var remainingChannels = reactivateChannelTypes.Where(c => !_reactivateSettings.Interactions.Any(x => x.Guid == c.Guid)); foreach (var nonSavedInteractionItem in remainingChannels) { nonSavedInteractionItem.IsInteractionTypeEnabled = false; } } rInteractions.DataSource = reactivateChannelTypes; rInteractions.DataBind(); // Inactivate cbInactivatePeople.Checked = _inactivateSettings.IsEnabled; pnlInactivatePeople.Enabled = _inactivateSettings.IsEnabled; cbNoLastContribution.Checked = _inactivateSettings.IsNoLastContributionEnabled; nbNoLastContribution.Text = _inactivateSettings.NoLastContributionPeriod.ToStringSafe(); cbNoAttendanceInGroupType.Checked = _inactivateSettings.IsNoAttendanceInGroupTypeEnabled; nbNoAttendanceInGroupType.Text = _inactivateSettings.NoAttendanceInGroupTypeDays.ToStringSafe(); rlbNoAttendanceInGroupType.SetValues(_inactivateSettings.AttendanceInGroupType ?? new List <int>()); cbNoRegistrationInAnyEvent.Checked = _inactivateSettings.IsNotRegisteredInAnyEventEnabled; nbNoRegistrationInAnyEvent.Text = _inactivateSettings.NotRegisteredInAnyEventDays.ToStringSafe(); cbNoSiteLogin.Checked = _inactivateSettings.IsNoSiteLoginEnabled; nbNoSiteLogin.Text = _inactivateSettings.NoSiteLoginPeriod.ToStringSafe(); cbNoPrayerRequest.Checked = _inactivateSettings.IsNoPrayerRequestEnabled; nbNoPrayerRequest.Text = _inactivateSettings.NoPrayerRequestPeriod.ToStringSafe(); cbNoPersonAttributes.Checked = _inactivateSettings.IsNoPersonAttributesEnabled; nbNoPersonAttributes.Text = _inactivateSettings.NoPersonAttributesDays.ToStringSafe(); rlbNoPersonAttributes.SetValues(_inactivateSettings.PersonAttributes ?? new List <int>()); cbNotInDataView.Checked = _inactivateSettings.IsNotInDataviewEnabled; dvNotInDataView.EntityTypeId = EntityTypeCache.Get(typeof(Rock.Model.Person)).Id; dvNotInDataView.SetValue(_inactivateSettings.NotInDataview); cbNoInteractions.Checked = _inactivateSettings.IsNoInteractionsEnabled; nbRecordsOlderThan.Text = _inactivateSettings.RecordsOlderThan.ToStringSafe(); var inactivateChannelTypes = interactionChannels.Select(c => new InteractionItem(c.Guid, c.Name)).ToList(); if (_inactivateSettings.NoInteractions != null) { bool noneSelected = !_inactivateSettings.NoInteractions.Any(i => i.IsInteractionTypeEnabled); foreach (var settingInteractionItem in _inactivateSettings.NoInteractions) { var interactionChannelType = inactivateChannelTypes.SingleOrDefault(a => a.Guid == settingInteractionItem.Guid); if (interactionChannelType != null) { interactionChannelType.IsInteractionTypeEnabled = noneSelected || settingInteractionItem.IsInteractionTypeEnabled; interactionChannelType.LastInteractionDays = settingInteractionItem.LastInteractionDays; } } // Now UNCHECK all channels that were NOT *previously* saved var remainingChannels = inactivateChannelTypes.Where(c => !_inactivateSettings.NoInteractions.Any(x => x.Guid == c.Guid)); foreach (var nonSavedInteractionItem in remainingChannels) { nonSavedInteractionItem.IsInteractionTypeEnabled = false; } } rNoInteractions.DataSource = inactivateChannelTypes; rNoInteractions.DataBind(); // campus Update cbCampusUpdate.Checked = _campusSettings.IsEnabled; pnlCampusUpdate.Enabled = _campusSettings.IsEnabled; cbMostFamilyAttendance.Checked = _campusSettings.IsMostFamilyAttendanceEnabled; nbMostFamilyAttendance.Text = _campusSettings.MostFamilyAttendancePeriod.ToStringSafe(); cbMostFamilyGiving.Checked = _campusSettings.IsMostFamilyGivingEnabled; nbMostFamilyGiving.Text = _campusSettings.MostFamilyGivingPeriod.ToStringSafe(); ddlAttendanceOrGiving.SetValue(_campusSettings.MostAttendanceOrGiving.ConvertToInt()); cbIgnoreIfManualUpdate.Checked = _campusSettings.IsIgnoreIfManualUpdateEnabled; nbIgnoreIfManualUpdate.Text = _campusSettings.IgnoreIfManualUpdatePeriod.ToStringSafe(); cbIgnoreCampusChanges.Checked = _campusSettings.IsIgnoreCampusChangesEnabled; if (_campusSettings.IgnoreCampusChanges != null && _campusSettings.IgnoreCampusChanges.Any()) { int i = 1; _ignoreCampusChangeRows = _campusSettings.IgnoreCampusChanges .Select(a => new IgnoreCampusChangeRow() { Id = i++, CampusCriteria = a.BasedOn, FromCampusId = a.FromCampus, ToCampusId = a.ToCampus }).ToList(); } else { _ignoreCampusChangeRows = new List <IgnoreCampusChangeRow>() { new IgnoreCampusChangeRow() { Id = 1 } }; } rptIgnoreCampusChanges.DataSource = _ignoreCampusChangeRows; rptIgnoreCampusChanges.DataBind(); // Adult Children cbAdultChildren.Checked = _adultChildrenSettings.IsEnabled; cbisMoveGraduated.Checked = _adultChildrenSettings.IsOnlyMoveGraduated; pnlAdultChildren.Enabled = _adultChildrenSettings.IsEnabled; nbAdultAge.Text = _adultChildrenSettings.AdultAge.ToString(); rpParentRelationship.GroupRoleId = _adultChildrenSettings.ParentRelationshipId; rpSiblingRelationship.GroupRoleId = _adultChildrenSettings.SiblingRelationshipId; cbSameAddress.Checked = _adultChildrenSettings.UseSameHomeAddress; cbSamePhone.Checked = _adultChildrenSettings.UseSameHomePhone; wfWorkflows.SetValues(_adultChildrenSettings.WorkflowTypeIds); nbMaxRecords.Text = _adultChildrenSettings.MaximumRecords.ToString(); // Update Connection Status cbUpdatePersonConnectionStatus.Checked = _updatePersonConnectionStatus.IsEnabled; pnlUpdatePersonConnectionStatus.Enabled = _updatePersonConnectionStatus.IsEnabled; var personConnectionStatusDataViewSettingsList = DefinedTypeCache.Get(Rock.SystemGuid.DefinedType.PERSON_CONNECTION_STATUS.AsGuid()).DefinedValues .Select(a => new PersonConnectionStatusDataView { PersonConnectionStatusValue = a, DataViewId = _updatePersonConnectionStatus.ConnectionStatusValueIdDataviewIdMapping.GetValueOrNull(a.Id) }).ToList(); rptPersonConnectionStatusDataView.DataSource = personConnectionStatusDataViewSettingsList; rptPersonConnectionStatusDataView.DataBind(); // Update Family Status cbUpdateFamilyStatus.Checked = _updateFamilyStatus.IsEnabled; pnlUpdateFamilyStatus.Enabled = _updateFamilyStatus.IsEnabled; var groupStatusDataViewSettingsList = DefinedTypeCache.Get(Rock.SystemGuid.DefinedType.FAMILY_GROUP_STATUS.AsGuid()).DefinedValues .Select(a => new FamilyStatusDataView { GroupStatusValue = a, DataViewId = _updateFamilyStatus.GroupStatusValueIdDataviewIdMapping.GetValueOrNull(a.Id) }).ToList(); rptFamilyStatusDataView.DataSource = groupStatusDataViewSettingsList; rptFamilyStatusDataView.DataBind(); }
/// <summary> /// Gets the settings. /// </summary> private void GetSettings() { // Get Data Automation Settings _reactivateSettings = Rock.Web.SystemSettings.GetValue(SystemSetting.DATA_AUTOMATION_REACTIVATE_PEOPLE).FromJsonOrNull <ReactivatePeople>() ?? new ReactivatePeople(); _inactivateSettings = Rock.Web.SystemSettings.GetValue(SystemSetting.DATA_AUTOMATION_INACTIVATE_PEOPLE).FromJsonOrNull <InactivatePeople>() ?? new InactivatePeople(); _campusSettings = Rock.Web.SystemSettings.GetValue(SystemSetting.DATA_AUTOMATION_CAMPUS_UPDATE).FromJsonOrNull <UpdateFamilyCampus>() ?? new UpdateFamilyCampus(); _adultChildrenSettings = Rock.Web.SystemSettings.GetValue(SystemSetting.DATA_AUTOMATION_ADULT_CHILDREN).FromJsonOrNull <MoveAdultChildren>() ?? new MoveAdultChildren(); // Set Data Automation Controls // Reactivate cbReactivatePeople.Checked = _reactivateSettings.IsEnabled; pnlReactivatePeople.Enabled = _reactivateSettings.IsEnabled; cbLastContribution.Checked = _reactivateSettings.IsLastContributionEnabled; nbLastContribution.Text = _reactivateSettings.LastContributionPeriod.ToStringSafe(); cbAttendanceInServiceGroup.Checked = _reactivateSettings.IsAttendanceInServiceGroupEnabled; nbAttendanceInServiceGroup.Text = _reactivateSettings.AttendanceInServiceGroupPeriod.ToStringSafe(); cbAttendanceInGroupType.Checked = _reactivateSettings.IsAttendanceInGroupTypeEnabled; nbAttendanceInGroupType.Text = _reactivateSettings.AttendanceInGroupTypeDays.ToStringSafe(); rlbAttendanceInGroupType.SetValues(_reactivateSettings.AttendanceInGroupType ?? new List <int>()); cbPrayerRequest.Checked = _reactivateSettings.IsPrayerRequestEnabled; nbPrayerRequest.Text = _reactivateSettings.PrayerRequestPeriod.ToStringSafe(); cbPersonAttributes.Checked = _reactivateSettings.IsPersonAttributesEnabled; nbPersonAttributes.Text = _reactivateSettings.PersonAttributesDays.ToStringSafe(); rlbPersonAttributes.SetValues(_reactivateSettings.PersonAttributes ?? new List <int>()); cbIncludeDataView.Checked = _reactivateSettings.IsIncludeDataViewEnabled; dvIncludeDataView.EntityTypeId = EntityTypeCache.Read(typeof(Rock.Model.Person)).Id; dvIncludeDataView.SetValue(_reactivateSettings.IncludeDataView); cbExcludeDataView.Checked = _reactivateSettings.IsExcludeDataViewEnabled; dvExcludeDataView.EntityTypeId = EntityTypeCache.Read(typeof(Rock.Model.Person)).Id; dvExcludeDataView.SetValue(_reactivateSettings.ExcludeDataView); cbInteractions.Checked = _reactivateSettings.IsInteractionsEnabled; var interactionChannels = new InteractionChannelService(_rockContext) .Queryable().AsNoTracking() .Select(a => new { a.Guid, a.Name }) .ToList(); var reactivateChannelTypes = interactionChannels.Select(c => new InteractionItem(c.Guid, c.Name)).ToList(); if (_reactivateSettings.Interactions != null) { bool noneSelected = !_reactivateSettings.Interactions.Any(i => i.IsInteractionTypeEnabled); foreach (var settingInteractionItem in _reactivateSettings.Interactions) { var interactionChannelType = reactivateChannelTypes.SingleOrDefault(a => a.Guid == settingInteractionItem.Guid); if (interactionChannelType != null) { interactionChannelType.IsInteractionTypeEnabled = noneSelected || settingInteractionItem.IsInteractionTypeEnabled; interactionChannelType.LastInteractionDays = settingInteractionItem.LastInteractionDays; } } } rInteractions.DataSource = reactivateChannelTypes; rInteractions.DataBind(); // Inactivate cbInactivatePeople.Checked = _inactivateSettings.IsEnabled; pnlInactivatePeople.Enabled = _inactivateSettings.IsEnabled; cbNoLastContribution.Checked = _inactivateSettings.IsNoLastContributionEnabled; nbNoLastContribution.Text = _inactivateSettings.NoLastContributionPeriod.ToStringSafe(); cbNoAttendanceInGroupType.Checked = _inactivateSettings.IsNoAttendanceInGroupTypeEnabled; nbNoAttendanceInGroupType.Text = _inactivateSettings.NoAttendanceInGroupTypeDays.ToStringSafe(); rlbNoAttendanceInGroupType.SetValues(_inactivateSettings.AttendanceInGroupType ?? new List <int>()); cbNoPrayerRequest.Checked = _inactivateSettings.IsNoPrayerRequestEnabled; nbNoPrayerRequest.Text = _inactivateSettings.NoPrayerRequestPeriod.ToStringSafe(); cbNoPersonAttributes.Checked = _inactivateSettings.IsNoPersonAttributesEnabled; nbNoPersonAttributes.Text = _inactivateSettings.NoPersonAttributesDays.ToStringSafe(); rlbNoPersonAttributes.SetValues(_inactivateSettings.PersonAttributes ?? new List <int>()); cbNotInDataView.Checked = _inactivateSettings.IsNotInDataviewEnabled; dvNotInDataView.EntityTypeId = EntityTypeCache.Read(typeof(Rock.Model.Person)).Id; dvNotInDataView.SetValue(_inactivateSettings.NotInDataview); cbNoInteractions.Checked = _inactivateSettings.IsNoInteractionsEnabled; var inactivateChannelTypes = interactionChannels.Select(c => new InteractionItem(c.Guid, c.Name)).ToList(); if (_inactivateSettings.NoInteractions != null) { bool noneSelected = !_inactivateSettings.NoInteractions.Any(i => i.IsInteractionTypeEnabled); foreach (var settingInteractionItem in _inactivateSettings.NoInteractions) { var interactionChannelType = inactivateChannelTypes.SingleOrDefault(a => a.Guid == settingInteractionItem.Guid); if (interactionChannelType != null) { interactionChannelType.IsInteractionTypeEnabled = noneSelected || settingInteractionItem.IsInteractionTypeEnabled; interactionChannelType.LastInteractionDays = settingInteractionItem.LastInteractionDays; } } } rNoInteractions.DataSource = inactivateChannelTypes; rNoInteractions.DataBind(); // campus Update cbCampusUpdate.Checked = _campusSettings.IsEnabled; pnlCampusUpdate.Enabled = _campusSettings.IsEnabled; cbMostFamilyAttendance.Checked = _campusSettings.IsMostFamilyAttendanceEnabled; nbMostFamilyAttendance.Text = _campusSettings.MostFamilyAttendancePeriod.ToStringSafe(); cbMostFamilyGiving.Checked = _campusSettings.IsMostFamilyGivingEnabled; nbMostFamilyGiving.Text = _campusSettings.MostFamilyGivingPeriod.ToStringSafe(); ddlAttendanceOrGiving.SetValue(_campusSettings.MostAttendanceOrGiving.ConvertToInt()); cbIgnoreIfManualUpdate.Checked = _campusSettings.IsIgnoreIfManualUpdateEnabled; nbIgnoreIfManualUpdate.Text = _campusSettings.IgnoreIfManualUpdatePeriod.ToStringSafe(); cbIgnoreCampusChanges.Checked = _campusSettings.IsIgnoreCampusChangesEnabled; if (_campusSettings.IgnoreCampusChanges != null && _campusSettings.IgnoreCampusChanges.Any()) { int i = 1; _ignoreCampusChangeRows = _campusSettings.IgnoreCampusChanges .Select(a => new IgnoreCampusChangeRow() { Id = i++, CampusCriteria = a.BasedOn, FromCampusId = a.FromCampus, ToCampusId = a.ToCampus }).ToList(); } else { _ignoreCampusChangeRows = new List <IgnoreCampusChangeRow>() { new IgnoreCampusChangeRow() { Id = 1 } }; } rIgnoreCampusChanges.DataSource = _ignoreCampusChangeRows; rIgnoreCampusChanges.DataBind(); // Adult Children cbAdultChildren.Checked = _adultChildrenSettings.IsEnabled; pnlAdultChildren.Enabled = _adultChildrenSettings.IsEnabled; nbAdultAge.Text = _adultChildrenSettings.AdultAge.ToString(); rpParentRelationship.GroupRoleId = _adultChildrenSettings.ParentRelationshipId; rpSiblingRelationship.GroupRoleId = _adultChildrenSettings.SiblingRelationshipId; cbSameAddress.Checked = _adultChildrenSettings.UseSameHomeAddress; cbSamePhone.Checked = _adultChildrenSettings.UseSameHomePhone; wfWorkflows.SetValues(_adultChildrenSettings.WorkflowTypeIds); nbMaxRecords.Text = _adultChildrenSettings.MaximumRecords.ToString(); }