本文整理汇总了C#中Rock.Model.GroupTypeService.Queryable方法的典型用法代码示例。如果您正苦于以下问题:C# GroupTypeService.Queryable方法的具体用法?C# GroupTypeService.Queryable怎么用?C# GroupTypeService.Queryable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupTypeService
的用法示例。
在下文中一共展示了GroupTypeService.Queryable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EditControl
/// <summary>
/// Creates the control(s) neccessary for prompting user for a new value
/// </summary>
/// <param name="configurationValues">The configuration values.</param>
/// <returns>
/// The control
/// </returns>
public override System.Web.UI.Control EditControl( Dictionary<string, ConfigurationValue> configurationValues )
{
CheckBoxList editControl = new CheckBoxList();
GroupTypeService groupTypeService = new GroupTypeService();
var groupTypes = groupTypeService.Queryable().OrderBy( a => a.Name ).ToList();
foreach ( var groupType in groupTypes )
{
editControl.Items.Add(new ListItem(groupType.Name, groupType.Id.ToString()));
}
return editControl;
}
示例2: ConfigurationControls
/// <summary>
/// Creates the HTML controls required to configure this type of field
/// </summary>
/// <returns></returns>
public override List<Control> ConfigurationControls()
{
var controls = base.ConfigurationControls();
// build a drop down list of defined types (the one that gets selected is
// used to build a list of defined values)
var ddl = new RockDropDownList();
controls.Add( ddl );
ddl.AutoPostBack = true;
ddl.SelectedIndexChanged += OnQualifierUpdated;
ddl.Label = "Group Type";
ddl.Help = "Type of group to select roles from, if left blank any group type's role can be selected.";
ddl.Items.Add( new ListItem() );
var groupTypeService = new GroupTypeService( new RockContext() );
var groupTypes = groupTypeService.Queryable().OrderBy( a => a.Name ).ToList();
groupTypes.ForEach( g =>
ddl.Items.Add( new ListItem( g.Name, g.Id.ToString().ToUpper() ) )
);
return controls;
}
示例3: LoadAttributes
/// <summary>
/// Loads the <see cref="P:IHasAttributes.Attributes" /> and <see cref="P:IHasAttributes.AttributeValues" /> of any <see cref="IHasAttributes" /> object
/// </summary>
/// <param name="entity">The item.</param>
/// <param name="rockContext">The rock context.</param>
public static void LoadAttributes( Rock.Attribute.IHasAttributes entity, RockContext rockContext )
{
if ( entity != null )
{
Dictionary<string, PropertyInfo> properties = new Dictionary<string, PropertyInfo>();
Type entityType = entity.GetType();
if ( entityType.Namespace == "System.Data.Entity.DynamicProxies" )
entityType = entityType.BaseType;
rockContext = rockContext ?? new RockContext();
// Check for group type attributes
var groupTypeIds = new List<int>();
if ( entity is GroupMember || entity is Group || entity is GroupType )
{
// Can't use GroupTypeCache here since it loads attributes and would result in a recursive stack overflow situation
var groupTypeService = new GroupTypeService( rockContext );
GroupType groupType = null;
if ( entity is GroupMember )
{
var group = ( (GroupMember)entity ).Group ?? new GroupService( rockContext )
.Queryable().AsNoTracking().FirstOrDefault(g => g.Id == ( (GroupMember)entity ).GroupId );
if ( group != null )
{
groupType = group.GroupType ?? groupTypeService
.Queryable().AsNoTracking().FirstOrDefault( t => t.Id == group.GroupTypeId );
}
}
else if ( entity is Group )
{
groupType = ( (Group)entity ).GroupType ?? groupTypeService
.Queryable().AsNoTracking().FirstOrDefault( t => t.Id == ( (Group)entity ).GroupTypeId );
}
else
{
groupType = ( (GroupType)entity );
}
while ( groupType != null )
{
groupTypeIds.Insert( 0, groupType.Id );
// Check for inherited group type id's
if ( groupType.InheritedGroupTypeId.HasValue )
{
groupType = groupType.InheritedGroupType ?? groupTypeService
.Queryable().AsNoTracking().FirstOrDefault( t => t.Id == ( groupType.InheritedGroupTypeId ?? 0 ) );
}
else
{
groupType = null;
}
}
}
foreach ( PropertyInfo propertyInfo in entityType.GetProperties() )
properties.Add( propertyInfo.Name.ToLower(), propertyInfo );
Rock.Model.AttributeService attributeService = new Rock.Model.AttributeService( rockContext );
Rock.Model.AttributeValueService attributeValueService = new Rock.Model.AttributeValueService( rockContext );
var inheritedAttributes = new Dictionary<int, List<Rock.Web.Cache.AttributeCache>>();
if ( groupTypeIds.Any() )
{
groupTypeIds.ForEach( g => inheritedAttributes.Add( g, new List<Rock.Web.Cache.AttributeCache>() ) );
}
else
{
inheritedAttributes.Add( 0, new List<Rock.Web.Cache.AttributeCache>() );
}
var attributes = new List<Rock.Web.Cache.AttributeCache>();
// Get all the attributes that apply to this entity type and this entity's properties match any attribute qualifiers
var entityTypeCache = Rock.Web.Cache.EntityTypeCache.Read( entityType);
if ( entityTypeCache != null )
{
int entityTypeId = entityTypeCache.Id;
foreach ( var attribute in attributeService.Queryable()
.AsNoTracking()
.Where( a => a.EntityTypeId == entityTypeCache.Id )
.Select( a => new
{
a.Id,
a.EntityTypeQualifierColumn,
a.EntityTypeQualifierValue
}
) )
{
// group type ids exist (entity is either GroupMember, Group, or GroupType) and qualifier is for a group type id
if ( groupTypeIds.Any() && (
( entity is GroupMember && string.Compare( attribute.EntityTypeQualifierColumn, "GroupTypeId", true ) == 0 ) ||
//.........这里部分代码省略.........
示例4: MapRLC
/// <summary>
/// Maps the RLC data to rooms, locations & classes -- Mapping RLC Names as groups under check-in
/// </summary>
/// <param name="tableData">The table data.</param>
/// <returns></returns>
private void MapRLC( IQueryable<Row> tableData )
{
var lookupContext = new RockContext();
// Add an Attribute for the unique F1 Ministry Id
//int groupEntityTypeId = EntityTypeCache.Read("Rock.Model.Group").Id;
//var rlcAttributeId = new AttributeService(lookupContext).Queryable().Where(a => a.EntityTypeId == groupEntityTypeId
// && a.Key == "F1RLCId").Select(a => a.Id).FirstOrDefault();
//if (rlcAttributeId == 0)
//{
// var newRLCAttribute = new Rock.Model.Attribute();
// newRLCAttribute.Key = "F1RLCId";
// newRLCAttribute.Name = "F1 RLC Id";
// newRLCAttribute.FieldTypeId = IntegerFieldTypeId;
// newRLCAttribute.EntityTypeId = groupEntityTypeId;
// newRLCAttribute.EntityTypeQualifierValue = string.Empty;
// newRLCAttribute.EntityTypeQualifierColumn = string.Empty;
// newRLCAttribute.Description = "The FellowshipOne identifier for the RLC Group that was imported";
// newRLCAttribute.DefaultValue = string.Empty;
// newRLCAttribute.IsMultiValue = false;
// newRLCAttribute.IsRequired = false;
// newRLCAttribute.Order = 0;
// lookupContext.Attributes.Add(newRLCAttribute);
// lookupContext.SaveChanges(DisableAudit);
// rlcAttributeId = newRLCAttribute.Id;
//}
// Get previously imported Ministries
//var importedRLCs = new AttributeValueService(lookupContext).GetByAttributeId(rlcAttributeId)
// .Select(av => new { RLCId = av.Value.AsType<int?>(), RLCName = av.ForeignId })
// .ToDictionary(t => t.RLCId, t => t.RLCName);
//List<AttributeValue> importedRLCAVList = new AttributeValueService( lookupContext ).GetByAttributeId( rlcAttributeId ).ToList(); //Not in use
var newRLCGroupList = new List<Group>();
var rlcAttributeValueList = new List<AttributeValue>();
//Need a list of GroupTypes
var gtService = new GroupTypeService( lookupContext );
var existingGroupTypes = new List<GroupType>();
existingGroupTypes = gtService.Queryable().ToList();
int completed = 0;
int totalRows = tableData.Count();
int percentage = ( totalRows - 1 ) / 100 + 1;
ReportProgress( 0, string.Format( "Verifying RLC Group import ({0:N0} found).", totalRows ) );
foreach ( var row in tableData )
{
int? rlcId = row["RLC_ID"] as int?;
string rlcName = row["RLC_Name"] as string;
string rlcStringId = Convert.ToString( rlcId );
int? importedRLCs = new GroupService( lookupContext ).Queryable().Where( a => a.ForeignId == rlcStringId ).Select( a => a.Id ).FirstOrDefault();
if ( rlcId != null && importedRLCs == 0 )
{
if ( rlcName != null )
{
bool? rlcIsActive = row["Is_Active"] as bool?;
string roomName = row["Room_Name"] as string;
string maxCapacity = row["Max_Capacity"] as string;
string roomDescription = row["Room_Name"] as string;
string roomCode = row["Room_Code"] as string;
DateTime? startAgeDate = row["Start_Age_Date"] as DateTime?;
DateTime? endAgeDate = row["End_Age_Date"] as DateTime?;
int? activityId = row["Activity_ID"] as int?;
//Searches for Parent ActivityId
string activityStringId = activityId.ToString();
GroupType parentActivityArea = existingGroupTypes.Where( gt => gt.ForeignId == activityStringId ).FirstOrDefault();
if ( String.IsNullOrWhiteSpace( rlcName ) )
{
ReportProgress( 0, string.Format( "." ) );
rlcName = "Excavator Test";
}
var rlcGroup = new Group();
bool rlcIsActiveBool = (bool)rlcIsActive;
//Sets the Group values for RLC
rlcGroup.IsSystem = false;
rlcGroup.Name = rlcName.Trim();
rlcGroup.Order = 0;
//rlcGroup.Guid = new Guid();
rlcGroup.GroupTypeId = parentActivityArea.Id;
rlcGroup.IsActive = rlcIsActiveBool;
rlcGroup.Description = roomDescription;
rlcGroup.ForeignId = rlcStringId;
//rlcGroup.GroupLocations = new List<GroupLocation>();
//rlcGroup.GroupLocations.Add( CheckLocation( roomDescription ) );
//.........这里部分代码省略.........
示例5: ddlParentGroup_SelectedIndexChanged
/// <summary>
/// Handles the SelectedIndexChanged event of the ddlParentGroup control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected void ddlParentGroup_SelectedIndexChanged( object sender, EventArgs e )
{
var rockContext = new RockContext();
GroupTypeService groupTypeService = new GroupTypeService( rockContext );
var groupTypeQry = groupTypeService.Queryable();
// limit GroupType selection to what Block Attributes allow
List<Guid> groupTypeGuids = GetAttributeValue( "GroupTypes" ).SplitDelimitedValues().Select( a => Guid.Parse( a ) ).ToList();
if ( groupTypeGuids.Count > 0 )
{
groupTypeQry = groupTypeQry.Where( a => groupTypeGuids.Contains( a.Guid ) );
}
// next, limit GroupType to ChildGroupTypes that the ParentGroup allows
int? parentGroupId = gpParentGroup.SelectedValueAsInt();
if ( ( parentGroupId ?? 0 ) != 0 )
{
Group parentGroup = new GroupService( rockContext ).Queryable( "GroupType" ).Where( g => g.Id == parentGroupId.Value ).FirstOrDefault();
List<int> allowedChildGroupTypeIds = parentGroup.GroupType.ChildGroupTypes.Select( a => a.Id ).ToList();
groupTypeQry = groupTypeQry.Where( a => allowedChildGroupTypeIds.Contains( a.Id ) );
}
// limit to GroupTypes where ShowInNavigation=True depending on block setting
if ( GetAttributeValue( "LimitToShowInNavigationGroupTypes" ).AsBoolean() )
{
groupTypeQry = groupTypeQry.Where( a => a.ShowInNavigation );
}
List<GroupType> groupTypes = groupTypeQry.OrderBy( a => a.Name ).ToList();
if ( groupTypes.Count() > 1 )
{
// add a empty option so they are forced to choose
groupTypes.Insert( 0, new GroupType { Id = 0, Name = string.Empty } );
}
// If the currently selected GroupType isn't an option anymore, set selected GroupType to null
int? selectedGroupTypeId = ddlGroupType.SelectedValueAsInt();
if ( ddlGroupType.SelectedValue != null )
{
if ( !groupTypes.Any( a => a.Id.Equals( selectedGroupTypeId ?? 0 ) ) )
{
selectedGroupTypeId = null;
}
}
ddlGroupType.DataSource = groupTypes;
ddlGroupType.DataBind();
if ( selectedGroupTypeId.HasValue )
{
ddlGroupType.SelectedValue = selectedGroupTypeId.ToString();
}
else
{
ddlGroupType.SelectedValue = null;
}
}
示例6: LoadDropDowns
/// <summary>
/// Loads the drop downs.
/// </summary>
public void LoadDropDowns()
{
clbCampuses.Items.Clear();
var noCampusListItem = new ListItem();
noCampusListItem.Text = "<span title='Include records that are not associated with a campus'>No Campus</span>";
noCampusListItem.Value = "null";
clbCampuses.Items.Add( noCampusListItem );
foreach (var campus in CampusCache.All().OrderBy(a => a.Name))
{
var listItem = new ListItem();
listItem.Text = campus.Name;
listItem.Value = campus.Id.ToString();
clbCampuses.Items.Add( listItem );
}
var groupTypeTemplateGuid = this.GetAttributeValue( "GroupTypeTemplate" ).AsGuidOrNull();
if ( !groupTypeTemplateGuid.HasValue )
{
// show the CheckinType(GroupTypeTemplate) control if there isn't a block setting for it
ddlAttendanceType.Visible = true;
var groupTypeService = new GroupTypeService( _rockContext );
Guid groupTypePurposeGuid = Rock.SystemGuid.DefinedValue.GROUPTYPE_PURPOSE_CHECKIN_TEMPLATE.AsGuid();
ddlAttendanceType.GroupTypes = groupTypeService.Queryable()
.Where( a => a.GroupTypePurposeValue.Guid == groupTypePurposeGuid )
.OrderBy( a => a.Order ).ThenBy( a => a.Name ).ToList();
}
else
{
// hide the CheckinType(GroupTypeTemplate) control if there is a block setting for it
ddlAttendanceType.Visible = false;
}
}
示例7: ConfigurationControls
/// <summary>
/// Creates the HTML controls required to configure this type of field
/// </summary>
/// <returns></returns>
public override List<Control> ConfigurationControls()
{
var controls = base.ConfigurationControls();
// build a drop down list of group types (the one that gets selected is
// used to build a list of group location type defined values that the
// group type allows)
var ddl = new RockDropDownList();
controls.Add( ddl );
ddl.AutoPostBack = true;
ddl.SelectedIndexChanged += OnQualifierUpdated;
ddl.Label = "Group Type";
ddl.Help = "The Group Type to select location types from.";
Rock.Model.GroupTypeService groupTypeService = new Model.GroupTypeService();
foreach ( var groupType in groupTypeService.Queryable().OrderBy( g => g.Name ) )
{
ddl.Items.Add( new ListItem( groupType.Name, groupType.Guid.ToString() ) );
}
return controls;
}
示例8: LoadDropDowns
/// <summary>
/// Loads the groups.
/// </summary>
private void LoadDropDowns()
{
var groupEntityType = EntityTypeCache.Read( typeof( Group ) );
var currentGroup = RockPage.GetCurrentContext( groupEntityType ) as Group;
var groupIdString = Request.QueryString["groupId"];
if ( groupIdString != null )
{
var groupId = groupIdString.AsInteger();
if ( currentGroup == null || currentGroup.Id != groupId )
{
currentGroup = SetGroupContext( groupId, false );
}
}
var parts = ( GetAttributeValue( "GroupFilter" ) ?? string.Empty ).Split( '|' );
Guid? groupTypeGuid = null;
Guid? rootGroupGuid = null;
if ( parts.Length >= 1 )
{
groupTypeGuid = parts[0].AsGuidOrNull();
if ( parts.Length >= 2 )
{
rootGroupGuid = parts[1].AsGuidOrNull();
}
}
var rockContext = new RockContext();
var groupService = new GroupService( rockContext );
var groupTypeService = new GroupTypeService( rockContext );
IQueryable<Group> qryGroups = null;
// if rootGroup is set, use that as the filter. Otherwise, use GroupType as the filter
if ( rootGroupGuid.HasValue )
{
var rootGroup = groupService.Get( rootGroupGuid.Value );
if ( rootGroup != null )
{
qryGroups = groupService.GetAllDescendents( rootGroup.Id ).AsQueryable();
}
}
else if ( groupTypeGuid.HasValue )
{
SetGroupTypeContext( groupTypeGuid );
if ( GetAttributeValue( "IncludeGroupTypeChildren" ).AsBoolean() )
{
var childGroupTypeGuids = groupTypeService.Queryable().Where( t => t.ParentGroupTypes.Select( p => p.Guid ).Contains( groupTypeGuid.Value ) )
.Select( t => t.Guid ).ToList();
qryGroups = groupService.Queryable().Where( a => childGroupTypeGuids.Contains( a.GroupType.Guid ) );
}
else
{
qryGroups = groupService.Queryable().Where( a => a.GroupType.Guid == groupTypeGuid.Value );
}
}
// no results
if ( qryGroups == null )
{
nbSelectGroupTypeWarning.Visible = true;
lCurrentSelection.Text = string.Empty;
rptGroups.Visible = false;
}
else
{
nbSelectGroupTypeWarning.Visible = false;
rptGroups.Visible = true;
lCurrentSelection.Text = currentGroup != null ? currentGroup.ToString() : GetAttributeValue( "NoGroupText" );
var groupList = qryGroups.OrderBy( a => a.Order )
.ThenBy( a => a.Name ).ToList()
.Select( a => new GroupItem() { Name = a.Name, Id = a.Id } )
.ToList();
// check if the group can be unselected
if ( !string.IsNullOrEmpty( GetAttributeValue( "ClearSelectionText" ) ) )
{
var blankGroup = new GroupItem
{
Name = GetAttributeValue( "ClearSelectionText" ),
Id = Rock.Constants.All.Id
};
groupList.Insert( 0, blankGroup );
}
rptGroups.DataSource = groupList;
rptGroups.DataBind();
}
}
示例9: gConnectionOpportunityGroupConfigs_ShowEdit
/// <summary>
/// handles the connection opportunity group campuses_ show edit.
/// </summary>
/// <param name="connectionOpportunityGroupConfigsGuid">The connection opportunity group campus unique identifier.</param>
protected void gConnectionOpportunityGroupConfigs_ShowEdit( Guid connectionOpportunityGroupConfigsGuid )
{
// bind group types
ddlGroupType.Items.Clear();
ddlGroupType.Items.Add( new ListItem() );
using ( var rockContext = new RockContext() )
{
var groupTypeService = new Rock.Model.GroupTypeService( rockContext );
// get all group types that have at least one role
var groupTypes = groupTypeService.Queryable().Where( a => a.Roles.Any() ).OrderBy( a => a.Name ).ToList();
foreach ( var g in groupTypes )
{
ddlGroupType.Items.Add( new ListItem( g.Name, g.Id.ToString().ToUpper() ) );
}
}
ddlGroupMemberStatus.BindToEnum<GroupMemberStatus>();
var groupConfigStateObj = GroupConfigsState.FirstOrDefault( l => l.Guid.Equals( connectionOpportunityGroupConfigsGuid ) );
if ( groupConfigStateObj != null )
{
hfGroupConfigGuid.Value = connectionOpportunityGroupConfigsGuid.ToString();
ddlGroupType.SetValue( groupConfigStateObj.GroupTypeId );
LoadGroupRoles( ddlGroupType.SelectedValue.AsInteger() );
ddlGroupRole.SetValue( groupConfigStateObj.GroupMemberRoleId );
ddlGroupMemberStatus.SetValue( groupConfigStateObj.GroupMemberStatus.ConvertToInt() );
tglUseAllGroupsOfGroupType.Checked = groupConfigStateObj.UseAllGroupsOfType;
}
else
{
hfGroupConfigGuid.Value = string.Empty;
LoadGroupRoles( null );
ddlGroupMemberStatus.SetValue( GroupMemberStatus.Active.ConvertToInt() );
tglUseAllGroupsOfGroupType.Checked = false;
}
ShowDialog( "GroupConfigDetails", true );
}
示例10: GetGroupMemberAttributes
/// <summary>
/// Gets the Attributes for a Group Member of a specific Group Type.
/// </summary>
/// <returns></returns>
private List<EntityField> GetGroupMemberAttributes()
{
var entityAttributeFields = new Dictionary<string, EntityField>();
var context = new RockContext();
var attributeService = new AttributeService( context );
var groupTypeService = new GroupTypeService( context );
var groupMemberEntityTypeId = EntityTypeCache.GetId( typeof(Model.GroupMember) );
var groupMemberAttributes = attributeService.Queryable()
.AsNoTracking()
.Where( a => a.EntityTypeId == groupMemberEntityTypeId )
.Join( groupTypeService.Queryable(), a => a.EntityTypeQualifierValue, gt => gt.Id.ToString(),
( a, gt ) =>
new
{
Attribute = a,
AttributeKey = a.Key,
FieldTypeName = a.FieldType.Name,
a.FieldTypeId,
AttributeName = a.Name,
GroupTypeName = gt.Name
} )
.GroupBy( x => x.AttributeName )
.ToList();
foreach (var attributesByName in groupMemberAttributes)
{
var attributeNameAndTypeGroups = attributesByName.GroupBy( x => x.FieldTypeId ).ToList();
bool requiresTypeQualifier = ( attributeNameAndTypeGroups.Count > 1 );
foreach (var attributeNameAndTypeGroup in attributeNameAndTypeGroups)
{
foreach (var attribute in attributeNameAndTypeGroup)
{
string fieldKey;
string fieldName;
if (requiresTypeQualifier)
{
fieldKey = attribute.AttributeName + "_" + attribute.FieldTypeId;
fieldName = string.Format( "{0} [{1}]", attribute.AttributeName, attribute.FieldTypeName );
}
else
{
fieldName = attribute.AttributeName;
fieldKey = attribute.AttributeName;
}
if (entityAttributeFields.ContainsKey( fieldKey ))
{
continue;
}
var attributeCache = AttributeCache.Read( attribute.Attribute );
var entityField = EntityHelper.GetEntityFieldForAttribute( attributeCache );
entityField.Title = fieldName;
entityField.AttributeGuid = null;
entityAttributeFields.Add( fieldKey, entityField );
}
}
}
int index = 0;
var sortedFields = new List<EntityField>();
foreach (var entityProperty in entityAttributeFields.Values.OrderBy( p => p.Title ).ThenBy( p => p.Name ))
{
entityProperty.Index = index;
index++;
sortedFields.Add( entityProperty );
}
return sortedFields;
}
示例11: GetParentGroupType
private GroupType GetParentGroupType(GroupType groupType)
{
GroupTypeService groupTypeService = new GroupTypeService(_rockContext);
return groupTypeService.Queryable()
.Include(t => t.ParentGroupTypes)
.AsNoTracking()
.Where(t => t.ChildGroupTypes.Select(p => p.Id).Contains(groupType.Id)).FirstOrDefault();
}
示例12: GetRootGroupType
private GroupType GetRootGroupType(int groupId)
{
List<int> parentRecursionHistory = new List<int>();
GroupTypeService groupTypeService = new GroupTypeService(_rockContext);
var groupType = groupTypeService.Queryable().AsNoTracking().Include(t => t.ParentGroupTypes).Where(t => t.Groups.Select(g => g.Id).Contains(groupId)).FirstOrDefault();
while (groupType != null && groupType.ParentGroupTypes.Count != 0)
{
if (parentRecursionHistory.Contains(groupType.Id))
{
var exception = new Exception("Infinite Recursion detected in GetRootGroupType for groupId: " + groupId.ToString());
LogException(exception);
return null;
}
else
{
var parentGroupType = GetParentGroupType(groupType);
if (parentGroupType != null && parentGroupType.Id == groupType.Id)
{
// the group type's parent is itself
return groupType;
}
groupType = parentGroupType;
}
parentRecursionHistory.Add(groupType.Id);
}
return groupType;
}
示例13: BuildHeirarchy
private void BuildHeirarchy(Guid parentGroupTypeGuid)
{
GroupTypeService groupTypeService = new GroupTypeService(_rockContext);
var groupTypes = groupTypeService.Queryable("Groups, ChildGroupTypes").AsNoTracking()
.Where(t => t.ParentGroupTypes.Select(p => p.Guid).Contains(parentGroupTypeGuid) && t.Guid != parentGroupTypeGuid).ToList();
foreach (var groupType in groupTypes)
{
if (groupType.GroupTypePurposeValueId == null || groupType.Groups.Count > 0)
{
_content.Append("<ul>");
_content.Append(string.Format("<li><strong>{0}</strong></li>", groupType.Name));
if (groupType.ChildGroupTypes.Count > 0)
{
BuildHeirarchy(groupType.Guid);
}
_content.Append("<ul>");
foreach (var group in groupType.Groups)
{
if (!string.IsNullOrWhiteSpace(GetAttributeValue("GroupDetailPage")))
{
var groupPageParams = new Dictionary<string, string>();
if (Request["GroupTypeId"] != null)
{
groupPageParams.Add("GroupTypeId", Request["GroupTypeId"]);
}
groupPageParams.Add("GroupId", group.Id.ToString());
_content.Append(string.Format("<li><a href='{0}'>{1}</a></li>", LinkedPageUrl("GroupDetailPage", groupPageParams), group.Name));
}
else
{
_content.Append(string.Format("<li>{0}</li>", group.Name));
}
}
_content.Append("</ul>");
_content.Append("</ul>");
}
else
{
BuildHeirarchy(groupType.Guid);
}
}
}
示例14: GetAvailableGroupTypes
/// <summary>
/// Gets the available group types.
/// </summary>
/// <returns></returns>
private List<int> GetAvailableGroupTypes()
{
var groupTypeIds = new List<int>();
var groupTypeService = new GroupTypeService( new RockContext() );
var qry = groupTypeService.Queryable().Where( t => t.ShowInGroupList );
List<Guid> includeGroupTypeGuids = GetAttributeValue( "IncludeGroupTypes" ).SplitDelimitedValues().Select( a => Guid.Parse( a ) ).ToList();
if ( includeGroupTypeGuids.Count > 0 )
{
_groupTypesCount = includeGroupTypeGuids.Count;
qry = qry.Where( t => includeGroupTypeGuids.Contains( t.Guid ) );
}
List<Guid> excludeGroupTypeGuids = GetAttributeValue( "ExcludeGroupTypes" ).SplitDelimitedValues().Select( a => Guid.Parse( a ) ).ToList();
if ( excludeGroupTypeGuids.Count > 0 )
{
qry = qry.Where( t => !excludeGroupTypeGuids.Contains( t.Guid ) );
}
foreach ( int groupTypeId in qry.Select( t => t.Id ) )
{
var groupType = GroupTypeCache.Read( groupTypeId );
if ( groupType != null && groupType.IsAuthorized( Authorization.VIEW, CurrentPerson ) )
{
groupTypeIds.Add( groupTypeId );
}
}
// If there's only one group type, use it's 'group term' in the panel title.
if ( groupTypeIds.Count == 1 )
{
var singleGroupType = GroupTypeCache.Read( groupTypeIds.FirstOrDefault() );
lTitle.Text = string.Format( "{0}", singleGroupType.GroupTerm.Pluralize() );
iIcon.AddCssClass( singleGroupType.IconCssClass );
}
else
{
iIcon.AddCssClass( "fa fa-users" );
}
groupTypeIds = qry.Select( t => t.Id ).ToList();
return groupTypeIds;
}
示例15: BindFilter
/// <summary>
/// Binds any needed data to the Grid Filter also using the user's stored
/// preferences.
/// </summary>
private void BindFilter()
{
ddlGroupType.Items.Clear();
ddlGroupType.Items.Add( Rock.Constants.All.ListItem );
// populate the GroupType DropDownList only with GroupTypes with GroupTypePurpose of Checkin Template
int groupTypePurposeCheckInTemplateId = DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.GROUPTYPE_PURPOSE_CHECKIN_TEMPLATE ) ).Id;
var rockContext = new RockContext();
GroupTypeService groupTypeService = new GroupTypeService( rockContext );
var groupTypeList = groupTypeService.Queryable()
.Where( a => a.GroupTypePurposeValueId == groupTypePurposeCheckInTemplateId )
.ToList();
foreach ( var groupType in groupTypeList )
{
ddlGroupType.Items.Add( new ListItem( groupType.Name, groupType.Id.ToString() ) );
}
ddlGroupType.SetValue( rFilter.GetUserPreference( "Group Type" ) );
// hide the GroupType filter if this page has a groupTypeId parameter
int? groupTypeIdPageParam = this.PageParameter( "groupTypeId" ).AsIntegerOrNull();
if ( groupTypeIdPageParam.HasValue )
{
ddlGroupType.Visible = false;
}
var filterCategory = new CategoryService( rockContext ).Get( rFilter.GetUserPreference( "Category" ).AsInteger() );
pCategory.SetValue( filterCategory );
pkrParentLocation.SetValue( rFilter.GetUserPreference( "Parent Location" ).AsIntegerOrNull() );
}