本文整理汇总了C#中Rock.Model.AttributeValueService.Where方法的典型用法代码示例。如果您正苦于以下问题:C# AttributeValueService.Where方法的具体用法?C# AttributeValueService.Where怎么用?C# AttributeValueService.Where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.AttributeValueService
的用法示例。
在下文中一共展示了AttributeValueService.Where方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Map
private void Map()
{
string mapStylingFormat = @"
<style>
#map_wrapper {{
height: {0}px;
}}
#map_canvas {{
width: 100%;
height: 100%;
border-radius: 8px;
}}
</style>";
lMapStyling.Text = string.Format( mapStylingFormat, GetAttributeValue( "MapHeight" ) );
string settingGroupTypeId = GetAttributeValue( "GroupType" );
string queryStringGroupTypeId = PageParameter( "GroupTypeId" );
if ( ( string.IsNullOrWhiteSpace(settingGroupTypeId) && string.IsNullOrWhiteSpace(queryStringGroupTypeId) ) )
{
pnlMap.Visible = false;
lMessages.Text = "<div class='alert alert-warning'><strong>Group Mapper</strong> Please configure a group type to display as a block setting or pass a GroupTypeId as a query parameter.</div>";
}
else
{
var rockContext = new RockContext();
pnlMap.Visible = true;
int groupsMapped = 0;
int groupsWithNoGeo = 0;
StringBuilder sbGroupJson = new StringBuilder();
StringBuilder sbGroupsWithNoGeo = new StringBuilder();
Guid? groupType = null;
int groupTypeId = -1;
if ( !string.IsNullOrWhiteSpace( settingGroupTypeId ) )
{
groupType = new Guid( settingGroupTypeId );
}
else
{
if ( !string.IsNullOrWhiteSpace( queryStringGroupTypeId ) && Int32.TryParse( queryStringGroupTypeId, out groupTypeId ) )
{
groupType = new GroupTypeService( rockContext ).Get( groupTypeId ).Guid;
}
}
if ( groupType != null )
{
Template template = null;
if ( GetAttributeValue( "ShowMapInfoWindow" ).AsBoolean() )
{
template = Template.Parse( GetAttributeValue( "InfoWindowContents" ).Trim() );
}
else
{
template = Template.Parse( string.Empty );
}
var groupPageRef = new PageReference( GetAttributeValue( "GroupDetailPage" ) );
// create group detail link for use in map's info window
var personPageParams = new Dictionary<string, string>();
personPageParams.Add( "PersonId", string.Empty );
var personProfilePage = LinkedPageUrl( "PersonProfilePage", personPageParams );
var groupEntityType = EntityTypeCache.Read( typeof( Group ) );
var dynamicGroups = new List<dynamic>();
// Create query to get attribute values for selected attribute keys.
var attributeKeys = GetAttributeValue( "Attributes" ).SplitDelimitedValues().ToList();
var attributeValues = new AttributeValueService( rockContext ).Queryable( "Attribute" )
.Where( v =>
v.Attribute.EntityTypeId == groupEntityType.Id &&
attributeKeys.Contains( v.Attribute.Key ) );
GroupService groupService = new GroupService( rockContext );
var groups = groupService.Queryable()
.Where( g => g.GroupType.Guid == groupType )
.Select( g => new
{
Group = g,
GroupId = g.Id,
GroupName = g.Name,
GroupGuid = g.Guid,
GroupMemberTerm = g.GroupType.GroupMemberTerm,
GroupCampus = g.Campus.Name,
IsActive = g.IsActive,
GroupLocation = g.GroupLocations
.Where( l => l.Location.GeoPoint != null )
.Select( l => new
{
l.Location.Street1,
l.Location.Street2,
//.........这里部分代码省略.........
示例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: MapAuthorizations
/// <summary>
/// Maps the authorizations to an attribute.
/// </summary>
/// <param name="tableData">The table data.</param>
private void MapAuthorizations( IQueryable<Row> tableData )
{
var lookupContext = new RockContext();
var rockContext = new RockContext();
var categoryService = new CategoryService( lookupContext );
var personService = new PersonService( lookupContext );
var noteList = new List<Note>();
int completed = 0;
int totalRows = tableData.Count();
int percentage = ( totalRows - 1 ) / 100 + 1;
ReportProgress( 0, string.Format( "Verifying Authorization import ({0:N0} found).", totalRows ) );
var attributeList = new AttributeService( lookupContext ).Queryable().ToList();
int authorizationAttributeId = 0;
if ( attributeList.Find( a => a.Key == "PickupAuthorization" ) != null )
{
authorizationAttributeId = attributeList.Find( a => a.Key == "PickupAuthorization" ).Id;
}
var authorizationAttributeValueList = new List<AttributeValue>();
authorizationAttributeValueList = new AttributeValueService( rockContext ).Queryable().Where( av => av.AttributeId == authorizationAttributeId ).ToList();
int f1HouseholdIdAttributeId = attributeList.Find( a => a.Key == "F1HouseholdId" ).Id;
//places all household attributes in a dictionary where the key is the personId and the houshold is the value.
var householdDictionary = new AttributeValueService( lookupContext ).Queryable()
.Where( av => av.AttributeId == f1HouseholdIdAttributeId )
.Select( av => new { PersonId = av.EntityId, HouseholdId = av.Value } )
.ToDictionary( t => t.PersonId, t => t.HouseholdId );
foreach ( var row in tableData )
{
//var rockContext = new RockContext();
var categoryList = new CategoryService( rockContext ).Queryable().ToList();
//check if category exists
//If it doesn't (though it should), it will create a new category called Authorization
if ( categoryList.Find( c => c.Name == "Childhood Information" ) == null )
{
var entityType = new EntityTypeService( rockContext );
//creates if category doesn't exist
var newCategory = new Category();
newCategory.IsSystem = false;
newCategory.EntityTypeId = entityType.Queryable().Where( e => e.Name == "Rock.Model.Attribute" ).Select( e => e.Id ).FirstOrDefault();
newCategory.EntityTypeQualifierColumn = "EntityTypeId";
newCategory.EntityTypeQualifierValue = Convert.ToString( PersonEntityTypeId );
newCategory.Name = "Authorization";
newCategory.Description = "Contains the pickup authorization";
//var newCategoryContext = new RockContext();
//newCategoryContext.WrapTransaction( () =>
//{
// newCategoryContext.Configuration.AutoDetectChangesEnabled = false;
// newCategoryContext.Categories.Add( newCategory );
// newCategoryContext.SaveChanges( DisableAudit );
//} );
rockContext.WrapTransaction( () =>
{
rockContext.Configuration.AutoDetectChangesEnabled = false;
rockContext.Categories.Add( newCategory );
rockContext.SaveChanges( DisableAudit );
} );
}
attributeList = new AttributeService( lookupContext ).Queryable().ToList();
//Check if Attribute exists
//If it doesn't it creates the attribute
if ( attributeList.Find( a => a.Key == "PickupAuthorization" ) == null )
{
var fieldType = new FieldTypeService( rockContext );
//var newAttributeList = new List<Rock.Model.Attribute>();
var fieldTypeId = fieldType.Queryable().Where( e => e.Name == "Memo" ).FirstOrDefault().Id;
var category2 = new CategoryService( rockContext ).Queryable().Where( gt => gt.Name == "Childhood Information" ).FirstOrDefault();
var category3 = new CategoryService( rockContext ).Queryable().Where( gt => gt.Name == "Authorization" ).FirstOrDefault();
//Creates if attribute doesn't exist
//The attribute is a memo attribute
var newAttribute = new Rock.Model.Attribute();
newAttribute.Key = "PickupAuthorization";
newAttribute.Name = "Pickup Authorization";
newAttribute.FieldTypeId = fieldTypeId;
newAttribute.EntityTypeId = PersonEntityTypeId;
newAttribute.EntityTypeQualifierValue = string.Empty;
newAttribute.EntityTypeQualifierColumn = string.Empty;
newAttribute.Description = "Lists who is authorized to pickup this child along with their current phone number.";
newAttribute.DefaultValue = string.Empty;
newAttribute.IsMultiValue = false;
newAttribute.IsRequired = false;
if ( categoryList.Find( c => c.Name == "Childhood Information" ) != null )
{
newAttribute.Categories = new List<Category>();
newAttribute.Categories.Add( category2 );
//.........这里部分代码省略.........