本文整理汇总了C#中Rock.Model.GroupService.PersonMeetsGroupRequirements方法的典型用法代码示例。如果您正苦于以下问题:C# GroupService.PersonMeetsGroupRequirements方法的具体用法?C# GroupService.PersonMeetsGroupRequirements怎么用?C# GroupService.PersonMeetsGroupRequirements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupService
的用法示例。
在下文中一共展示了GroupService.PersonMeetsGroupRequirements方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowConnectionOpportunityRequirementsStatuses
/// <summary>
/// Shows the connectionOpportunity requirements statuses.
/// </summary>
private void ShowConnectionOpportunityRequirementsStatuses()
{
using ( var rockContext = new RockContext() )
{
int connectionRequestId = hfConnectionRequestId.Value.AsInteger();
var connectionOpportunityId = hfConnectionOpportunityId.Value.AsInteger();
IEnumerable<GroupRequirementStatus> requirementsResults = new List<PersonGroupRequirementStatus>();
bool passedAllRequirements = true;
var connectionRequest = new ConnectionRequestService( rockContext ).Get( connectionRequestId );
if ( connectionRequest != null && connectionRequest.PersonAlias != null )
{
var group = new GroupService( rockContext ).Get( connectionRequest.AssignedGroupId.Value );
if ( group != null )
{
requirementsResults = group.PersonMeetsGroupRequirements(
connectionRequest.PersonAlias.PersonId,
connectionRequest.AssignedGroupMemberRoleId );
if ( requirementsResults != null )
{
// Ignore notapplicable requirements
requirementsResults = requirementsResults.Where( r => r.MeetsGroupRequirement != MeetsGroupRequirement.NotApplicable ).ToList();
}
// Clear results
cblManualRequirements.Items.Clear();
lRequirementsLabels.Text = string.Empty;
rcwRequirements.Visible = requirementsResults.Any();
foreach ( var requirementResult in requirementsResults )
{
if ( requirementResult.GroupRequirement.GroupRequirementType.RequirementCheckType == RequirementCheckType.Manual )
{
var checkboxItem = new ListItem( requirementResult.GroupRequirement.GroupRequirementType.CheckboxLabel, requirementResult.GroupRequirement.Id.ToString() );
if ( string.IsNullOrEmpty( requirementResult.GroupRequirement.GroupRequirementType.CheckboxLabel ) )
{
checkboxItem.Text = requirementResult.GroupRequirement.GroupRequirementType.Name;
}
checkboxItem.Selected = requirementResult.MeetsGroupRequirement == MeetsGroupRequirement.Meets;
cblManualRequirements.Items.Add( checkboxItem );
}
else
{
string labelText;
string labelType;
string labelTooltip;
if ( requirementResult.MeetsGroupRequirement == MeetsGroupRequirement.Meets )
{
labelText = requirementResult.GroupRequirement.GroupRequirementType.PositiveLabel;
labelType = "success";
}
else if ( requirementResult.MeetsGroupRequirement == MeetsGroupRequirement.MeetsWithWarning )
{
labelText = requirementResult.GroupRequirement.GroupRequirementType.WarningLabel;
labelType = "warning";
}
else
{
passedAllRequirements = false;
labelText = requirementResult.GroupRequirement.GroupRequirementType.NegativeLabel;
labelType = "danger";
}
if ( string.IsNullOrEmpty( labelText ) )
{
labelText = requirementResult.GroupRequirement.GroupRequirementType.Name;
}
if ( requirementResult.MeetsGroupRequirement == MeetsGroupRequirement.MeetsWithWarning )
{
labelTooltip = requirementResult.RequirementWarningDateTime.HasValue
? "Last Checked: " + requirementResult.RequirementWarningDateTime.Value.ToString( "g" )
: "Not calculated yet";
}
else
{
labelTooltip = requirementResult.LastRequirementCheckDateTime.HasValue
? "Last Checked: " + requirementResult.LastRequirementCheckDateTime.Value.ToString( "g" )
: "Not calculated yet";
}
lRequirementsLabels.Text += string.Format(
@"<span class='label label-{1}' title='{2}'>{0}</span>
",
labelText,
labelType,
labelTooltip );
}
}
var requirementsWithErrors = requirementsResults.Where( a => a.MeetsGroupRequirement == MeetsGroupRequirement.Error ).ToList();
if ( requirementsWithErrors.Any() )
{
nbRequirementsErrors.Text = string.Format(
//.........这里部分代码省略.........
示例2: CheckGroupRequirement
private void CheckGroupRequirement()
{
nbRequirementsWarning.Visible = false;
int? personId = ppRequestor.PersonId;
int? groupId = ddlPlacementGroup.SelectedValueAsInt();
int? roleId = ddlPlacementGroupRole.SelectedValueAsInt();
if ( personId.HasValue && groupId.HasValue && roleId.HasValue )
{
using ( var rockContext = new RockContext() )
{
var group = new GroupService( rockContext ).Get( groupId.Value );
if ( group != null && group.MustMeetRequirementsToAddMember.HasValue && group.MustMeetRequirementsToAddMember.Value )
{
var requirementsResults = group.PersonMeetsGroupRequirements(
personId.Value,
roleId.Value );
if ( requirementsResults != null && requirementsResults
.Any( r =>
r.MeetsGroupRequirement == MeetsGroupRequirement.NotMet &&
r.GroupRequirement.GroupRequirementType.RequirementCheckType != RequirementCheckType.Manual )
)
{
var person = new PersonService( rockContext ).Get( personId.Value );
if ( person != null )
{
nbRequirementsWarning.Text = string.Format( "{0} does not currently meet the requirements for the selected group/role and will not be able to be placed.", person.NickName );
}
else
{
nbRequirementsWarning.Text = "This person does not currently meet the requirements for this group and will not be able to be placed.";
}
nbRequirementsWarning.Visible = true;
}
}
}
}
}