本文整理汇总了C#中Rock.Model.GroupMemberService.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# GroupMemberService.Contains方法的具体用法?C# GroupMemberService.Contains怎么用?C# GroupMemberService.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupMemberService
的用法示例。
在下文中一共展示了GroupMemberService.Contains方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetGuestsForFamily
public IQueryable<GuestFamily> GetGuestsForFamily( int groupId )
{
Guid knownRelationshipGuid = new Guid( Rock.SystemGuid.GroupType.GROUPTYPE_KNOWN_RELATIONSHIPS );
Guid knownRelationshipOwner = new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_OWNER );
Guid knownRelationshipCanCheckin = new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_CAN_CHECK_IN );
RockContext rockContext = new RockContext();
GroupMemberService groupMemberService = new GroupMemberService( rockContext );
PersonService personService = new PersonService( rockContext );
var familyMembers = groupMemberService.Queryable()
.Where( f => f.GroupId == groupId )
.Select( f => f.PersonId );
var familyMembersKnownRelationshipGroups = new GroupMemberService( rockContext ).Queryable()
.Where( g => g.Group.GroupType.Guid == knownRelationshipGuid
&& g.GroupRole.Guid == knownRelationshipOwner
&& familyMembers.Contains( g.PersonId ) )
.Select( m => m.GroupId );
rockContext.Database.Log = s => System.Diagnostics.Debug.WriteLine( s );
var guests = groupMemberService.Queryable()
.Where( g => g.GroupRole.Guid == knownRelationshipCanCheckin
&& familyMembersKnownRelationshipGroups.Contains( g.GroupId ) )
.Select( g => g.PersonId )
.Distinct().ToList();
var guestFamilies = new List<GuestFamily>();
rockContext.Database.Log = null;
foreach ( var guestPersonId in guests )
{
var families = personService.GetFamilies( guestPersonId );
foreach ( var family in families )
{
if ( !guestFamilies.Select( f => f.Id ).Contains( family.Id ) )
{
GuestFamily guestFamily = new GuestFamily();
guestFamily.Id = family.Id;
guestFamily.Guid = family.Guid;
guestFamily.Name = family.Name;
guestFamily.FamilyMembers = new List<GuestFamilyMember>();
foreach ( var familyMember in family.Members )
{
GuestFamilyMember guestFamilyMember = new GuestFamilyMember();
guestFamilyMember.Id = familyMember.PersonId;
guestFamilyMember.PersonAliasId = familyMember.Person.PrimaryAliasId.Value;
guestFamilyMember.Guid = familyMember.Person.Guid;
guestFamilyMember.FirstName = familyMember.Person.NickName;
guestFamilyMember.LastName = familyMember.Person.LastName;
guestFamilyMember.PhotoUrl = familyMember.Person.PhotoUrl;
guestFamilyMember.CanCheckin = guests.Contains( familyMember.PersonId );
guestFamilyMember.Role = familyMember.GroupRole.Name;
guestFamilyMember.Age = familyMember.Person.Age;
guestFamilyMember.Gender = familyMember.Person.Gender;
guestFamily.FamilyMembers.Add( guestFamilyMember );
}
guestFamilies.Add( guestFamily );
}
}
}
return guestFamilies.AsQueryable();
}
示例2: BindGroupPlacementGrid
/// <summary>
/// Binds the group placement grid.
/// </summary>
/// <param name="isExporting">if set to <c>true</c> [is exporting].</param>
private void BindGroupPlacementGrid( bool isExporting = false )
{
int? groupId = gpGroupPlacementParentGroup.SelectedValueAsInt();
int? instanceId = hfRegistrationInstanceId.Value.AsIntegerOrNull();
if ( instanceId.HasValue )
{
using ( var rockContext = new RockContext() )
{
// Start query for registrants
var qry = new RegistrationRegistrantService( rockContext )
.Queryable( "PersonAlias.Person.PhoneNumbers.NumberTypeValue,Fees.RegistrationTemplateFee,GroupMember.Group" ).AsNoTracking()
.Where( r =>
r.Registration.RegistrationInstanceId == instanceId.Value &&
r.PersonAlias != null &&
r.PersonAlias.Person != null );
if ( groupId.HasValue )
{
var validGroupIds = new GroupService( rockContext ).GetAllDescendents( groupId.Value )
.Select( g => g.Id )
.ToList();
var existingPeopleInGroups = new GroupMemberService( rockContext )
.Queryable().AsNoTracking()
.Where( m => validGroupIds.Contains( m.GroupId ) )
.Select( m => m.PersonId )
.ToList();
qry = qry.Where( r => !existingPeopleInGroups.Contains( r.PersonAlias.PersonId ) );
}
bool preloadCampusValues = false;
var registrantAttributeIds = new List<int>();
var personAttributesIds = new List<int>();
var groupMemberAttributesIds = new List<int>();
if ( RegistrantFields != null )
{
// Check if campus is used
preloadCampusValues = RegistrantFields
.Any( f =>
f.FieldSource == RegistrationFieldSource.PersonField &&
f.PersonFieldType.HasValue &&
f.PersonFieldType.Value == RegistrationPersonFieldType.Campus );
// Get all the registrant attributes selected
var registrantAttributes = RegistrantFields
.Where( f =>
f.Attribute != null &&
f.FieldSource == RegistrationFieldSource.RegistrationAttribute )
.Select( f => f.Attribute )
.ToList();
registrantAttributeIds = registrantAttributes.Select( a => a.Id ).Distinct().ToList();
// Get all the person attributes selected
var personAttributes = RegistrantFields
.Where( f =>
f.Attribute != null &&
f.FieldSource == RegistrationFieldSource.PersonAttribute )
.Select( f => f.Attribute )
.ToList();
personAttributesIds = personAttributes.Select( a => a.Id ).Distinct().ToList();
// Get all the group member attributes selected to be on grid
var groupMemberAttributes = RegistrantFields
.Where( f =>
f.Attribute != null &&
f.FieldSource == RegistrationFieldSource.GroupMemberAttribute )
.Select( f => f.Attribute )
.ToList();
groupMemberAttributesIds = groupMemberAttributes.Select( a => a.Id ).Distinct().ToList();
}
// Sort the query
IOrderedQueryable<RegistrationRegistrant> orderedQry = null;
SortProperty sortProperty = gGroupPlacements.SortProperty;
if ( sortProperty != null )
{
orderedQry = qry.Sort( sortProperty );
}
else
{
orderedQry = qry
.OrderBy( r => r.PersonAlias.Person.LastName )
.ThenBy( r => r.PersonAlias.Person.NickName );
}
// Set the grids LinqDataSource which will run query and set results for current page
gGroupPlacements.SetLinqDataSource<RegistrationRegistrant>( orderedQry );
if ( RegistrantFields != null )
{
// Get the query results for the current page
var currentPageRegistrants = gGroupPlacements.DataSource as List<RegistrationRegistrant>;
if ( currentPageRegistrants != null )
{
//.........这里部分代码省略.........
示例3: Execute
/// <summary>
/// Executes the specified context.
/// </summary>
/// <param name="context">The context.</param>
public void Execute( IJobExecutionContext context )
{
JobDataMap dataMap = context.JobDetail.JobDataMap;
Guid? groupGuid = dataMap.GetString( "EligibleFollowers" ).AsGuidOrNull();
Guid? systemEmailGuid = dataMap.GetString( "EmailTemplate" ).AsGuidOrNull();
int followingEventsSent = 0;
if ( groupGuid.HasValue && systemEmailGuid.HasValue )
{
var exceptionMsgs = new List<string>();
using ( var rockContext = new RockContext() )
{
var followingService = new FollowingService( rockContext );
var followingEventTypeService = new FollowingEventTypeService( rockContext );
var followingEventNotificationService = new FollowingEventNotificationService( rockContext );
// Get all the active event types
var eventTypes = followingEventTypeService
.Queryable().AsNoTracking()
.Where( e =>
e.EntityTypeId.HasValue &&
e.IsActive )
.OrderBy( e => e.Order )
.ToList();
// Get the required event types
var requiredEventTypes = eventTypes
.Where( e => e.IsNoticeRequired )
.ToList();
// The people who are eligible to get following event notices based on the group type setting for this job
var eligiblePersonIds = new GroupMemberService( rockContext )
.Queryable().AsNoTracking()
.Where( m =>
m.Group != null &&
m.Group.Guid.Equals( groupGuid.Value ) &&
m.GroupMemberStatus == GroupMemberStatus.Active &&
m.Person != null &&
m.Person.Email != null &&
m.Person.Email != "" )
.Select( m => m.PersonId )
.Distinct()
.ToList();
// Get all the subscriptions for the eligible people
var eventSubscriptions = new FollowingEventSubscriptionService( rockContext )
.Queryable( "PersonAlias" ).AsNoTracking()
.Where( f => eligiblePersonIds.Contains( f.PersonAlias.PersonId ) )
.ToList();
// Dictionaries used to store information that will be used to create notification
var personSubscriptions = new Dictionary<int, List<int>>(); // Key: personId, Value: list of event type ids that person subscribes to
var personFollowings = new Dictionary<int, List<int>>(); // Key: personId, Value: list of following ids that person follows
var eventsThatHappened = new Dictionary<int, Dictionary<int, string>>(); // Key: event type id Value: Dictionary of entity id and formatted event notice for the entity
//Get the subscriptions for each person
foreach ( int personId in eligiblePersonIds )
{
var personEventTypes = eventSubscriptions
.Where( s => s.PersonAlias.PersonId == personId )
.Select( s => s.EventType )
.ToList();
personEventTypes.AddRange( requiredEventTypes );
if ( personEventTypes.Any() )
{
personSubscriptions.AddOrIgnore( personId, personEventTypes
.OrderBy( e => e.Order )
.ThenBy( e => e.Name )
.Select( e => e.Id )
.Distinct()
.ToList() );
}
}
// Get a distinct list of each entitytype/entity that is being followed by anyone that subscribes to events
var followings = followingService
.Queryable( "PersonAlias" ).AsNoTracking()
.Where( f => personSubscriptions.Keys.Contains( f.PersonAlias.PersonId ) )
.ToList();
// group the followings by their type
var followedEntityIds = new Dictionary<int, List<int>>();
foreach ( var followedEntity in followings
.Select( f => new
{
f.EntityTypeId,
f.EntityId
} )
.Distinct() )
{
followedEntityIds.AddOrIgnore( followedEntity.EntityTypeId, new List<int>() );
followedEntityIds[followedEntity.EntityTypeId].Add( followedEntity.EntityId );
}
// group the followings by the follower
//.........这里部分代码省略.........
示例4: OnLoad
//.........这里部分代码省略.........
}
if ( !string.IsNullOrWhiteSpace( hfActiveTab.Value ) )
{
SetActiveTab();
modalAddPerson.Show();
}
BuildAttributes( false );
}
else
{
if ( _group != null )
{
tbGroupName.Text = _group.Name;
// add banner text
if ( _isFamilyGroupType && !_group.Name.ToLower().EndsWith( " family" ) )
{
lBanner.Text = ( _group.Name + " Family" ).FormatAsHtmlTitle();
}
else
{
lBanner.Text = _group.Name.FormatAsHtmlTitle();
}
cpCampus.SelectedCampusId = _group.CampusId;
if ( _isFamilyGroupType )
{
// If all group members have the same record status, display that value
if ( _group.Members.Select( m => m.Person.RecordStatusValueId ).Distinct().Count() == 1 )
{
ddlRecordStatus.SetValue( _group.Members.Select( m => m.Person.RecordStatusValueId ).FirstOrDefault() );
}
else
{
ddlRecordStatus.Warning = String.Format( "{0} members have different record statuses", _groupType.Name );
}
// If all group members have the same inactive reason, set that value
if ( _group.Members.Select( m => m.Person.RecordStatusReasonValueId ).Distinct().Count() == 1 )
{
ddlReason.SetValue( _group.Members.Select( m => m.Person.RecordStatusReasonValueId ).FirstOrDefault() );
}
else
{
if ( String.IsNullOrWhiteSpace( ddlRecordStatus.Warning ) )
{
ddlRecordStatus.Warning = String.Format( "{0} members have different record status reasons", _groupType.Name );
}
else
{
ddlRecordStatus.Warning += " and record status reasons";
}
}
}
// Get all the group members
GroupMembers = new List<GroupMemberInfo>();
foreach ( var groupMember in _group.Members )
{
GroupMembers.Add( new GroupMemberInfo( groupMember, true ) );
}
// Figure out which ones are in another group
var groupMemberPersonIds = GroupMembers.Select( m => m.Id ).ToList();
var otherGroupPersonIds = new GroupMemberService( new RockContext() ).Queryable()
.Where( m =>
groupMemberPersonIds.Contains( m.PersonId ) &&
m.Group.GroupTypeId == _groupType.Id &&
m.GroupId != _group.Id )
.Select( m => m.PersonId )
.Distinct();
GroupMembers
.Where( m => otherGroupPersonIds.Contains( m.Id ) )
.ToList()
.ForEach( m => m.IsInOtherGroups = true );
BindMembers();
GroupAddresses = new List<GroupAddressInfo>();
foreach ( var groupLocation in _group.GroupLocations
.Where( l => l.GroupLocationTypeValue != null )
.OrderBy( l => l.GroupLocationTypeValue.Order ) )
{
GroupAddresses.Add( new GroupAddressInfo( groupLocation ) );
}
foreach ( var groupLocation in _group.GroupLocations
.Where( l => l.GroupLocationTypeValue == null ) )
{
GroupAddresses.Add( new GroupAddressInfo( groupLocation ) );
}
BindLocations();
BuildAttributes( true );
}
}
}
示例5: Execute
/// <summary>
/// Executes the specified context.
/// </summary>
/// <param name="context">The context.</param>
public void Execute( IJobExecutionContext context )
{
var exceptionMsgs = new List<string>();
JobDataMap dataMap = context.JobDetail.JobDataMap;
Guid? groupGuid = dataMap.GetString( "EligibleFollowers" ).AsGuidOrNull();
Guid? systemEmailGuid = dataMap.GetString( "EmailTemplate" ).AsGuidOrNull();
int followingSuggestionsEmailsSent = 0;
int followingSuggestionsSuggestionsTotal = 0;
if ( groupGuid.HasValue && systemEmailGuid.HasValue )
{
using ( var rockContext = new RockContext() )
{
var followingService = new FollowingService( rockContext );
// The people who are eligible to get following suggestions based on the group type setting for this job
var eligiblePersonIds = new GroupMemberService( rockContext )
.Queryable().AsNoTracking()
.Where( m =>
m.Group != null &&
m.Group.Guid.Equals( groupGuid.Value ) &&
m.GroupMemberStatus == GroupMemberStatus.Active &&
m.Person != null &&
m.Person.Email != null &&
m.Person.Email != "" )
.Select( m => m.PersonId )
.Distinct();
// check to see if there are any event types that require notification
var followerPersonIds = new List<int>();
if ( new FollowingEventTypeService( rockContext )
.Queryable().AsNoTracking()
.Any( e => e.IsNoticeRequired ) )
{
// if so, include all eligible people
followerPersonIds = eligiblePersonIds.ToList();
}
else
{
// if not, filter the list of eligible people down to only those that actually have subscribed to one or more following events
followerPersonIds = new FollowingEventSubscriptionService( rockContext )
.Queryable().AsNoTracking()
.Where( f => eligiblePersonIds.Contains( f.PersonAlias.PersonId ) )
.Select( f => f.PersonAlias.PersonId )
.Distinct()
.ToList();
}
if ( followerPersonIds.Any() )
{
// Get the primary person alias id for each of the followers
var primaryAliasIds = new Dictionary<int, int>();
new PersonAliasService( rockContext )
.Queryable().AsNoTracking()
.Where( a =>
followerPersonIds.Contains( a.PersonId ) &&
a.PersonId == a.AliasPersonId )
.ToList()
.ForEach( a => primaryAliasIds.AddOrIgnore( a.PersonId, a.Id ) );
// Get current date/time.
var timestamp = RockDateTime.Now;
var suggestionTypes = new FollowingSuggestionTypeService( rockContext )
.Queryable().AsNoTracking()
.Where( s => s.IsActive )
.OrderBy( s => s.Name )
.ToList();
var components = new Dictionary<int, SuggestionComponent>();
var suggestedEntities = new Dictionary<int, Dictionary<int, IEntity>>();
foreach ( var suggestionType in suggestionTypes )
{
try
{
// Get the suggestion type component
var suggestionComponent = suggestionType.GetSuggestionComponent();
if ( suggestionComponent != null )
{
components.Add( suggestionType.Id, suggestionComponent );
// Get the entitytype for this suggestion type
var suggestionEntityType = EntityTypeCache.Read( suggestionComponent.FollowedType );
if ( suggestionEntityType != null )
{
var entityIds = new List<int>();
// Call the components method to return all of it's suggestions
var personEntitySuggestions = suggestionComponent.GetSuggestions( suggestionType, followerPersonIds );
// If any suggestions were returned by the component
if ( personEntitySuggestions.Any() )
{
int entityTypeId = suggestionEntityType.Id;
//.........这里部分代码省略.........
示例6: GetGroupOccurrences
/// <summary>
/// Gets occurrence data for the selected group
/// </summary>
/// <param name="group">The group.</param>
/// <param name="fromDateTime">From date time.</param>
/// <param name="toDateTime">To date time.</param>
/// <param name="locationIds">The location ids.</param>
/// <param name="scheduleIds">The schedule ids.</param>
/// <param name="loadSummaryData">if set to <c>true</c> [load summary data].</param>
/// <param name="campusId">The campus identifier.</param>
/// <returns></returns>
public List<ScheduleOccurrence> GetGroupOccurrences( Group group, DateTime? fromDateTime, DateTime? toDateTime,
List<int> locationIds, List<int> scheduleIds, bool loadSummaryData, int? campusId )
{
var occurrences = new List<ScheduleOccurrence>();
if ( group != null )
{
var rockContext = (RockContext)this.Context;
var attendanceService = new AttendanceService( rockContext );
var scheduleService = new ScheduleService( rockContext );
var locationService = new LocationService( rockContext );
using ( new Rock.Data.QueryHintScope( rockContext, QueryHintType.RECOMPILE ) )
{
// Set up an 'occurrences' query for the group
var qry = attendanceService
.Queryable().AsNoTracking()
.Where( a => a.GroupId == group.Id );
// Filter by date range
if ( fromDateTime.HasValue )
{
var fromDate = fromDateTime.Value.Date;
qry = qry.Where( a => DbFunctions.TruncateTime( a.StartDateTime ) >= ( fromDate ) );
}
if ( toDateTime.HasValue )
{
var toDate = toDateTime.Value.Date;
qry = qry.Where( a => DbFunctions.TruncateTime( a.StartDateTime ) < ( toDate ) );
}
// Location Filter
if ( locationIds.Any() )
{
qry = qry.Where( a => locationIds.Contains( a.LocationId ?? 0 ) );
}
// Schedule Filter
if ( scheduleIds.Any() )
{
qry = qry.Where( a => scheduleIds.Contains( a.ScheduleId ?? 0 ) );
}
// Get the unique combination of location/schedule/date for the selected group
var occurrenceDates = qry
.Select( a => new
{
a.LocationId,
a.ScheduleId,
Date = DbFunctions.TruncateTime( a.StartDateTime )
} )
.Distinct()
.ToList();
// Get the locations for each unique location id
var selectedlocationIds = occurrenceDates.Select( o => o.LocationId ).Distinct().ToList();
var locations = locationService
.Queryable().AsNoTracking()
.Where( l => selectedlocationIds.Contains( l.Id ) )
.Select( l => new { l.Id, l.ParentLocationId, l.Name } )
.ToList();
var locationNames = new Dictionary<int, string>();
locations.ForEach( l => locationNames.Add( l.Id, l.Name ) );
// Get the parent location path for each unique location
var parentlocationPaths = new Dictionary<int, string>();
locations
.Where( l => l.ParentLocationId.HasValue )
.Select( l => l.ParentLocationId.Value )
.Distinct()
.ToList()
.ForEach( l => parentlocationPaths.Add( l, locationService.GetPath( l ) ) );
var locationPaths = new Dictionary<int, string>();
locations
.Where( l => l.ParentLocationId.HasValue )
.ToList()
.ForEach( l => locationPaths.Add( l.Id, parentlocationPaths[l.ParentLocationId.Value] ) );
// Get the schedules for each unique schedule id
var selectedScheduleIds = occurrenceDates.Select( o => o.ScheduleId ).Distinct().ToList();
var schedules = scheduleService
.Queryable().AsNoTracking()
.Where( s => selectedScheduleIds.Contains( s.Id ) )
.ToList();
var scheduleNames = new Dictionary<int, string>();
var scheduleStartTimes = new Dictionary<int, TimeSpan>();
schedules
//.........这里部分代码省略.........
示例7: Execute
/// <summary>
/// Executes the specified workflow.
/// </summary>
/// <param name="rockContext">The rock context.</param>
/// <param name="action">The workflow action.</param>
/// <param name="entity">The entity.</param>
/// <param name="errorMessages">The error messages.</param>
/// <returns></returns>
/// <exception cref="System.NotImplementedException"></exception>
public override bool Execute( RockContext rockContext, Rock.Model.WorkflowAction action, Object entity, out List<string> errorMessages )
{
var checkInState = GetCheckInState( entity, out errorMessages );
if ( checkInState == null )
{
return false;
}
var roomBalanceGroupTypes = GetAttributeValue( action, "RoomBalanceGrouptypes" ).SplitDelimitedValues().AsGuidList();
bool useGroupMembership = GetAttributeValue( action, "PrioritizeGroupMembership" ).AsBoolean();
int roomBalanceOverride = GetAttributeValue( action, "BalancingOverride" ).AsIntegerOrNull() ?? 5;
var excludedLocations = GetAttributeValue( action, "ExcludedLocations" ).SplitDelimitedValues( false )
.Select( s => s.Trim() );
// get admin-selected attribute keys instead of using a hardcoded key
var personSpecialNeedsKey = string.Empty;
var personSpecialNeedsGuid = GetAttributeValue( action, "PersonSpecialNeedsAttribute" ).AsGuid();
if ( personSpecialNeedsGuid != Guid.Empty )
{
personSpecialNeedsKey = AttributeCache.Read( personSpecialNeedsGuid, rockContext ).Key;
}
var groupSpecialNeedsKey = string.Empty;
var groupSpecialNeedsGuid = GetAttributeValue( action, "GroupSpecialNeedsAttribute" ).AsGuid();
if ( personSpecialNeedsGuid != Guid.Empty )
{
groupSpecialNeedsKey = AttributeCache.Read( groupSpecialNeedsGuid, rockContext ).Key;
}
var groupAgeRangeKey = string.Empty;
var groupAgeRangeGuid = GetAttributeValue( action, "GroupAgeRangeAttribute" ).AsGuid();
if ( personSpecialNeedsGuid != Guid.Empty )
{
groupAgeRangeKey = AttributeCache.Read( groupAgeRangeGuid, rockContext ).Key;
}
var groupGradeRangeKey = string.Empty;
var groupGradeRangeGuid = GetAttributeValue( action, "GroupGradeRangeAttribute" ).AsGuid();
if ( personSpecialNeedsGuid != Guid.Empty )
{
groupGradeRangeKey = AttributeCache.Read( groupGradeRangeGuid, rockContext ).Key;
}
// log a warning if any of the attributes are missing or invalid
if ( string.IsNullOrWhiteSpace( personSpecialNeedsKey ) )
{
action.AddLogEntry( string.Format( "The Person Special Needs attribute is not selected or invalid for '{0}'.", action.ActionType.Name ) );
}
if ( string.IsNullOrWhiteSpace( groupSpecialNeedsKey ) )
{
action.AddLogEntry( string.Format( "The Group Special Needs attribute is not selected or invalid for '{0}'.", action.ActionType.Name ) );
}
if ( string.IsNullOrWhiteSpace( groupAgeRangeKey ) )
{
action.AddLogEntry( string.Format( "The Group Age Range attribute is not selected or invalid for '{0}'.", action.ActionType.Name ) );
}
if ( string.IsNullOrWhiteSpace( groupGradeRangeKey ) )
{
action.AddLogEntry( string.Format( "The Group Grade Range attribute is not selected or invalid for '{0}'.", action.ActionType.Name ) );
}
var family = checkInState.CheckIn.Families.FirstOrDefault( f => f.Selected );
if ( family != null )
{
// don't process people who already have assignments
foreach ( var person in family.People.Where( f => f.Selected && !f.GroupTypes.Any( gt => gt.Selected ) ) )
{
decimal baseVariance = 100;
char[] delimiter = { ',' };
// check if this person has special needs
var hasSpecialNeeds = person.Person.GetAttributeValue( personSpecialNeedsKey ).AsBoolean();
// get a list of room balanced grouptype ID's since CheckInGroup model is a shallow clone
var roomBalanceGroupTypeIds = person.GroupTypes.Where( gt => roomBalanceGroupTypes.Contains( gt.GroupType.Guid ) )
.Select( gt => gt.GroupType.Id ).ToList();
if ( person.GroupTypes.Count > 0 )
{
CheckInGroupType bestGroupType = null;
IEnumerable<CheckInGroup> validGroups;
if ( person.GroupTypes.Count == 1 )
{
bestGroupType = person.GroupTypes.FirstOrDefault();
validGroups = bestGroupType.Groups;
}
else
{
//.........这里部分代码省略.........
示例8: BindData
private void BindData()
{
using ( var rockContext = new RockContext() )
{
var dataView = new DataViewService( rockContext ).Get( _dataViewGuid ?? Guid.Empty );
if ( dataView != null )
{
var personService = new PersonService( rockContext );
// Filter people by dataview
var errorMessages = new List<string>();
var paramExpression = personService.ParameterExpression;
var whereExpression = dataView.GetExpression( personService, paramExpression, out errorMessages );
var personQry = personService
.Queryable( false, false ).AsNoTracking()
.Where( paramExpression, whereExpression, null );
var dvPersonIdQry = personQry.Select( p => p.Id );
bool filteredQry = false;
// Filter by first name
string firstName = tbFirstName.Text.Trim();
if ( !string.IsNullOrWhiteSpace( firstName ) )
{
personQry = personQry.Where( p =>
p.FirstName.StartsWith( firstName ) ||
p.NickName.StartsWith( firstName ) );
filteredQry = true;
}
// Filter by last name
string lastName = tbLastName.Text.Trim();
if ( !string.IsNullOrWhiteSpace( lastName ) )
{
personQry = personQry.Where( p =>
p.LastName.StartsWith( lastName ) );
filteredQry = true;
}
if ( filteredQry || _showAllPeople )
{
SetColumnWidths();
if ( _optOutGroupGuid.HasValue )
{
var optOutPersonIdQry = new GroupMemberService( rockContext )
.Queryable().AsNoTracking()
.Where( g => g.Group.Guid.Equals( _optOutGroupGuid.Value ) )
.Select( g => g.PersonId );
personQry = personQry.Where( p =>
!optOutPersonIdQry.Contains( p.Id ) );
}
if ( _showFamily )
{
BindFamilies( rockContext, personQry, dvPersonIdQry );
}
else
{
BindPeople( rockContext, personQry );
}
}
else
{
rptPeople.Visible = false;
rptFamilies.Visible = false;
}
}
else
{
rptPeople.Visible = false;
rptFamilies.Visible = false;
ShowMessages( new List<string> { "This block requires a valid Data View setting." } );
}
if ( CurrentPerson != null && _optOutGroupGuid.HasValue )
{
bool optedOut = new GroupMemberService( rockContext )
.Queryable().AsNoTracking()
.Any( m =>
m.PersonId == CurrentPerson.Id &&
m.Group.Guid.Equals( _optOutGroupGuid.Value ) );
lbOptInOut.Text = optedOut ? "Opt in to the Directory" : "Opt Out of the Directory";
}
}
}