本文整理汇总了C#中Rock.Model.GroupMemberService.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# GroupMemberService.ToList方法的具体用法?C# GroupMemberService.ToList怎么用?C# GroupMemberService.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupMemberService
的用法示例。
在下文中一共展示了GroupMemberService.ToList方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
/// Executes the specified context.
/// </summary>
/// <param name="context">The context.</param>
public void Execute( IJobExecutionContext context )
{
var rockContext = new RockContext();
JobDataMap dataMap = context.JobDetail.JobDataMap;
Guid? systemEmailGuid = dataMap.GetString( "NotificationEmailTemplate" ).AsGuidOrNull();
if ( systemEmailGuid.HasValue )
{
var selectedGroupTypes = new List<Guid>();
if ( !string.IsNullOrWhiteSpace( dataMap.GetString( "GroupTypes" ) ) )
{
selectedGroupTypes = dataMap.GetString( "GroupTypes" ).Split( ',' ).Select( Guid.Parse ).ToList();
}
var excludedGroupRoleIds = new List<int>();
if ( !string.IsNullOrWhiteSpace( dataMap.GetString( "ExcludedGroupRoleIds" ) ) )
{
excludedGroupRoleIds = dataMap.GetString( "ExcludedGroupRoleIds" ).Split( ',' ).Select( int.Parse ).ToList();
}
var notificationOption = dataMap.GetString( "NotifyParentLeaders" ).ConvertToEnum<NotificationOption>( NotificationOption.None );
var accountAbilityGroupGuid = dataMap.GetString( "AccountabilityGroup" ).AsGuid();
// get groups matching of the types provided
GroupService groupService = new GroupService( rockContext );
var groups = groupService.Queryable().AsNoTracking()
.Where( g => selectedGroupTypes.Contains( g.GroupType.Guid )
&& g.IsActive == true
&& g.GroupRequirements.Any() );
foreach ( var group in groups )
{
// check for members that don't meet requirements
var groupMembersWithIssues = groupService.GroupMembersNotMeetingRequirements( group.Id, true );
if ( groupMembersWithIssues.Count > 0 )
{
// add issues to issue list
GroupsMissingRequirements groupMissingRequirements = new GroupsMissingRequirements();
groupMissingRequirements.Id = group.Id;
groupMissingRequirements.Name = group.Name;
if ( group.GroupType != null )
{
groupMissingRequirements.GroupTypeId = group.GroupTypeId;
groupMissingRequirements.GroupTypeName = group.GroupType.Name;
}
groupMissingRequirements.AncestorPathName = groupService.GroupAncestorPathName( group.Id );
// get list of the group leaders
groupMissingRequirements.Leaders = group.Members
.Where( m => m.GroupRole.IsLeader == true && !excludedGroupRoleIds.Contains( m.GroupRoleId ) )
.Select( m => new GroupMemberResult
{
Id = m.Id,
PersonId = m.PersonId,
FullName = m.Person.FullName
} )
.ToList();
List<GroupMembersMissingRequirements> groupMembers = new List<GroupMembersMissingRequirements>();
foreach ( var groupMemberIssue in groupMembersWithIssues )
{
GroupMembersMissingRequirements groupMember = new GroupMembersMissingRequirements();
groupMember.FullName = groupMemberIssue.Key.Person.FullName;
groupMember.Id = groupMemberIssue.Key.Id;
groupMember.PersonId = groupMemberIssue.Key.PersonId;
groupMember.GroupMemberRole = groupMemberIssue.Key.GroupRole.Name;
List<MissingRequirement> missingRequirements = new List<MissingRequirement>();
foreach ( var issue in groupMemberIssue.Value )
{
MissingRequirement missingRequirement = new MissingRequirement();
missingRequirement.Id = issue.Key.GroupRequirement.GroupRequirementType.Id;
missingRequirement.Name = issue.Key.GroupRequirement.GroupRequirementType.Name;
missingRequirement.Status = issue.Key.MeetsGroupRequirement;
missingRequirement.OccurrenceDate = issue.Value;
switch ( issue.Key.MeetsGroupRequirement )
{
case MeetsGroupRequirement.Meets:
missingRequirement.Message = issue.Key.GroupRequirement.GroupRequirementType.PositiveLabel;
break;
case MeetsGroupRequirement.MeetsWithWarning:
missingRequirement.Message = issue.Key.GroupRequirement.GroupRequirementType.WarningLabel;
break;
case MeetsGroupRequirement.NotMet:
missingRequirement.Message = issue.Key.GroupRequirement.GroupRequirementType.NegativeLabel;
break;
}
missingRequirements.Add( missingRequirement );
}
//.........这里部分代码省略.........
示例2: ListGroups
private void ListGroups()
{
RockContext rockContext = new RockContext();
var qry = new GroupMemberService( rockContext )
.Queryable( "Group" );
var parentGroupGuid = GetAttributeValue( "ParentGroup" ).AsGuidOrNull();
if ( parentGroupGuid!=null )
{
var availableGroupIds = ( List<int> ) GetCacheItem( "GroupListPersonalizedLava:" + parentGroupGuid.ToString() );
if ( availableGroupIds == null )
{
var parentGroup = new GroupService( rockContext ).Get( parentGroupGuid ?? new Guid() );
if ( parentGroup != null )
{
availableGroupIds = GetChildGroups( parentGroup ).Select( g => g.Id ).ToList();
}
else
{
availableGroupIds = new List<int>();
}
var cacheLength = GetAttributeValue( "CacheDuration" ).AsInteger();
AddCacheItem( "GroupListPersonalizedLava:" + parentGroupGuid.ToString(), availableGroupIds, cacheLength );
}
qry = qry.Where( m => availableGroupIds.Contains( m.GroupId ) );
}
qry = qry.Where( m => m.PersonId == CurrentPersonId
&& m.GroupMemberStatus == GroupMemberStatus.Active
&& m.Group.IsActive == true );
List<Guid> includeGroupTypeGuids = GetAttributeValue( "IncludeGroupTypes" ).SplitDelimitedValues().Select( a => Guid.Parse( a ) ).ToList();
if ( includeGroupTypeGuids.Count > 0 )
{
qry = qry.Where( t => includeGroupTypeGuids.Contains( t.Group.GroupType.Guid ) );
}
List<Guid> excludeGroupTypeGuids = GetAttributeValue( "ExcludeGroupTypes" ).SplitDelimitedValues().Select( a => Guid.Parse( a ) ).ToList();
if ( excludeGroupTypeGuids.Count > 0 )
{
qry = qry.Where( t => !excludeGroupTypeGuids.Contains( t.Group.GroupType.Guid ) );
}
var groups = new List<GroupInvolvementSummary>();
foreach ( var groupMember in qry.ToList() )
{
if ( groupMember.Group.IsAuthorized( Authorization.VIEW, CurrentPerson ) )
{
groups.Add( new GroupInvolvementSummary
{
Group = groupMember.Group,
Role = groupMember.GroupRole.Name,
IsLeader = groupMember.GroupRole.IsLeader,
GroupType = groupMember.Group.GroupType.Name
} );
}
}
var mergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields( this.RockPage, this.CurrentPerson );
mergeFields.Add( "Groups", groups );
Dictionary<string, object> linkedPages = new Dictionary<string, object>();
linkedPages.Add( "DetailPage", LinkedPageRoute( "DetailPage" ) );
mergeFields.Add( "LinkedPages", linkedPages );
string template = GetAttributeValue( "LavaTemplate" );
// show debug info
bool enableDebug = GetAttributeValue( "EnableDebug" ).AsBoolean();
if ( enableDebug && IsUserAuthorized( Authorization.EDIT ) )
{
lDebug.Visible = true;
lDebug.Text = mergeFields.lavaDebugInfo();
}
lContent.Text = template.ResolveMergeFields( mergeFields );
}
示例3: Execute
/// <summary>
/// Job that will sync groups.
///
/// Called by the <see cref="IScheduler" /> when a
/// <see cref="ITrigger" /> fires that is associated with
/// the <see cref="IJob" />.
/// </summary>
public virtual void Execute( IJobExecutionContext context )
{
JobDataMap dataMap = context.JobDetail.JobDataMap;
try
{
int notificationsSent = 0;
int pendingMembersCount = 0;
// get groups set to sync
RockContext rockContext = new RockContext();
Guid? groupTypeGuid = dataMap.GetString( "GroupType" ).AsGuidOrNull();
Guid? systemEmailGuid = dataMap.GetString( "NotificationEmail" ).AsGuidOrNull();
Guid? groupRoleFilterGuid = dataMap.GetString( "GroupRoleFilter" ).AsGuidOrNull();
int? pendingAge = dataMap.GetString( "PendingAge" ).AsIntegerOrNull();
bool includePreviouslyNotificed = dataMap.GetString( "IncludePreviouslyNotified" ).AsBoolean();
// get system email
SystemEmailService emailService = new SystemEmailService( rockContext );
SystemEmail systemEmail = null;
if ( systemEmailGuid.HasValue )
{
systemEmail = emailService.Get( systemEmailGuid.Value );
}
if ( systemEmail == null )
{
// no email specified, so nothing to do
return;
}
// get group members
if ( groupTypeGuid.HasValue && groupTypeGuid != Guid.Empty )
{
var qry = new GroupMemberService( rockContext ).Queryable( "Person, Group, Group.Members.GroupRole" )
.Where( m => m.Group.GroupType.Guid == groupTypeGuid.Value
&& m.GroupMemberStatus == GroupMemberStatus.Pending );
if ( !includePreviouslyNotificed )
{
qry = qry.Where( m => m.IsNotified == false );
}
if ( groupRoleFilterGuid.HasValue )
{
qry = qry.Where( m => m.GroupRole.Guid == groupRoleFilterGuid.Value );
}
if ( pendingAge.HasValue )
{
var ageDate = RockDateTime.Now.AddDays( pendingAge.Value * -1 );
qry = qry.Where( m => m.ModifiedDateTime > ageDate );
}
var pendingGroupMembers = qry.ToList();
var groups = pendingGroupMembers.GroupBy( m => m.Group );
foreach ( var groupKey in groups )
{
var group = groupKey.Key;
// get list of pending people
var qryPendingIndividuals = group.Members.Where( m => m.GroupMemberStatus == GroupMemberStatus.Pending );
if ( !includePreviouslyNotificed )
{
qryPendingIndividuals = qryPendingIndividuals.Where( m => m.IsNotified == false );
}
if ( groupRoleFilterGuid.HasValue )
{
qryPendingIndividuals = qryPendingIndividuals.Where( m => m.GroupRole.Guid == groupRoleFilterGuid.Value );
}
var pendingIndividuals = qryPendingIndividuals.Select( m => m.Person ).ToList();
// get list of leaders
var groupLeaders = group.Members.Where( m => m.GroupRole.IsLeader == true );
var appRoot = Rock.Web.Cache.GlobalAttributesCache.Read( rockContext ).GetValue( "PublicApplicationRoot" );
var recipients = new List<RecipientData>();
foreach ( var leader in groupLeaders )
{
// create merge object
var mergeFields = new Dictionary<string, object>();
mergeFields.Add( "PendingIndividuals", pendingIndividuals );
mergeFields.Add( "Group", group );
mergeFields.Add( "ParentGroup", group.ParentGroup );
//.........这里部分代码省略.........
示例4: Execute
/// <summary>
/// Executes the specified workflow.
/// </summary>
/// <param name="rockContext">The rock context.</param>
/// <param name="action">The action.</param>
/// <param name="entity">The entity.</param>
/// <param name="errorMessages">The error messages.</param>
/// <returns></returns>
public override bool Execute( RockContext rockContext, WorkflowAction action, Object entity, out List<string> errorMessages )
{
errorMessages = new List<string>();
Guid? groupGuid = null;
Person person = null;
string attributeValue = string.Empty;
Guid groupRoleGuid = Guid.Empty;
string attributeKey = string.Empty;
// get the group attribute
Guid groupAttributeGuid = GetAttributeValue(action, "Group").AsGuid();
if ( !groupAttributeGuid.IsEmpty() )
{
groupGuid = action.GetWorklowAttributeValue(groupAttributeGuid).AsGuidOrNull();
if ( !groupGuid.HasValue )
{
errorMessages.Add("The group could not be found!");
}
}
// get person alias guid
Guid personAliasGuid = Guid.Empty;
string personAttribute = GetAttributeValue( action, "Person" );
Guid guid = personAttribute.AsGuid();
if (!guid.IsEmpty())
{
var attribute = AttributeCache.Read( guid, rockContext );
if ( attribute != null )
{
string value = action.GetWorklowAttributeValue(guid);
personAliasGuid = value.AsGuid();
}
if ( personAliasGuid != Guid.Empty )
{
person = new PersonAliasService(rockContext).Queryable().AsNoTracking()
.Where(p => p.Guid.Equals(personAliasGuid))
.Select(p => p.Person)
.FirstOrDefault();
}
else {
errorMessages.Add("The person could not be found in the attribute!");
}
}
// get group member attribute value
attributeValue = GetAttributeValue(action, "AttributeValue");
guid = attributeValue.AsGuid();
if ( guid.IsEmpty() )
{
attributeValue = attributeValue.ResolveMergeFields(GetMergeFields(action));
}
else
{
var workflowAttributeValue = action.GetWorklowAttributeValue(guid);
if ( workflowAttributeValue != null )
{
attributeValue = workflowAttributeValue;
}
}
// get optional role filter
groupRoleGuid = GetAttributeValue(action, "GroupRoleFilter").AsGuid();
// get attribute key
attributeKey = GetAttributeValue(action, "GroupMemberAttributeKey").Replace(" ", "");
// set attribute
if ( groupGuid.HasValue && person != null )
{
var qry = new GroupMemberService(rockContext).Queryable()
.Where(m => m.Group.Guid == groupGuid && m.PersonId == person.Id);
if ( groupRoleGuid != Guid.Empty )
{
qry = qry.Where(m => m.GroupRole.Guid == groupRoleGuid);
}
foreach ( var groupMember in qry.ToList() )
{
groupMember.LoadAttributes(rockContext);
if ( groupMember.Attributes.ContainsKey(attributeKey) )
{
var attribute = groupMember.Attributes[attributeKey];
Rock.Attribute.Helper.SaveAttributeValue(groupMember, attribute, attributeValue, rockContext);
}
else
//.........这里部分代码省略.........
示例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: Groups
/// <summary>
/// Gets the groups of selected type that person is a member of
/// </summary>
/// <param name="context">The context.</param>
/// <param name="input">The input.</param>
/// <param name="groupTypeId">The group type identifier.</param>
/// <param name="status">The status.</param>
/// <returns></returns>
public static List<Rock.Model.GroupMember> Groups( DotLiquid.Context context, object input, string groupTypeId, string status = "Active" )
{
var person = GetPerson( input );
int? numericalGroupTypeId = groupTypeId.AsIntegerOrNull();
if ( person != null && numericalGroupTypeId.HasValue )
{
var groupQuery = new GroupMemberService( GetRockContext( context ) )
.Queryable("Group, GroupRole").AsNoTracking()
.Where( m =>
m.PersonId == person.Id &&
m.Group.GroupTypeId == numericalGroupTypeId.Value &&
m.Group.IsActive );
if ( status != "All" )
{
GroupMemberStatus queryStatus = GroupMemberStatus.Active;
queryStatus = (GroupMemberStatus)Enum.Parse( typeof( GroupMemberStatus ), status, true );
groupQuery = groupQuery.Where( m => m.GroupMemberStatus == queryStatus );
}
return groupQuery.ToList();
}
return new List<Model.GroupMember>();
}