本文整理汇总了C#中Rock.Model.AttributeValueService.GetByAttributeId方法的典型用法代码示例。如果您正苦于以下问题:C# AttributeValueService.GetByAttributeId方法的具体用法?C# AttributeValueService.GetByAttributeId怎么用?C# AttributeValueService.GetByAttributeId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.AttributeValueService
的用法示例。
在下文中一共展示了AttributeValueService.GetByAttributeId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadExistingRockData
/// <summary>
/// Loads Rock data that's used globally by the transform
/// </summary>
private void LoadExistingRockData()
{
var attributeValueService = new AttributeValueService();
var attributeService = new AttributeService();
IntegerFieldTypeId = FieldTypeCache.Read( new Guid( Rock.SystemGuid.FieldType.INTEGER ) ).Id;
TextFieldTypeId = FieldTypeCache.Read( new Guid( Rock.SystemGuid.FieldType.TEXT ) ).Id;
PersonEntityTypeId = EntityTypeCache.Read( "Rock.Model.Person" ).Id;
BatchEntityTypeId = EntityTypeCache.Read( "Rock.Model.FinancialBatch" ).Id;
var personAttributes = attributeService.GetByEntityTypeId( PersonEntityTypeId ).ToList();
var householdAttribute = personAttributes.FirstOrDefault( a => a.Key == "F1HouseholdId" );
if ( householdAttribute == null )
{
householdAttribute = new Rock.Model.Attribute();
householdAttribute.Key = "F1HouseholdId";
householdAttribute.Name = "F1 Household Id";
householdAttribute.FieldTypeId = IntegerFieldTypeId;
householdAttribute.EntityTypeId = PersonEntityTypeId;
householdAttribute.EntityTypeQualifierValue = string.Empty;
householdAttribute.EntityTypeQualifierColumn = string.Empty;
householdAttribute.Description = "The FellowshipOne household identifier for the person that was imported";
householdAttribute.DefaultValue = string.Empty;
householdAttribute.IsMultiValue = false;
householdAttribute.IsRequired = false;
householdAttribute.Order = 0;
attributeService.Add( householdAttribute, ImportPersonAlias );
attributeService.Save( householdAttribute, ImportPersonAlias );
personAttributes.Add( householdAttribute );
}
var individualAttribute = personAttributes.FirstOrDefault( a => a.Key == "F1IndividualId" );
if ( individualAttribute == null )
{
individualAttribute = new Rock.Model.Attribute();
individualAttribute.Key = "F1IndividualId";
individualAttribute.Name = "F1 Individual Id";
individualAttribute.FieldTypeId = IntegerFieldTypeId;
individualAttribute.EntityTypeId = PersonEntityTypeId;
individualAttribute.EntityTypeQualifierValue = string.Empty;
individualAttribute.EntityTypeQualifierColumn = string.Empty;
individualAttribute.Description = "The FellowshipOne individual identifier for the person that was imported";
individualAttribute.DefaultValue = string.Empty;
individualAttribute.IsMultiValue = false;
individualAttribute.IsRequired = false;
individualAttribute.Order = 0;
attributeService.Add( individualAttribute, ImportPersonAlias );
attributeService.Save( individualAttribute, ImportPersonAlias );
personAttributes.Add( individualAttribute );
}
IndividualAttributeId = individualAttribute.Id;
HouseholdAttributeId = householdAttribute.Id;
ReportProgress( 0, "Checking for existing people..." );
var listHouseholdId = attributeValueService.GetByAttributeId( householdAttribute.Id ).Select( av => new { PersonId = av.EntityId, HouseholdId = av.Value } ).ToList();
var listIndividualId = attributeValueService.GetByAttributeId( individualAttribute.Id ).Select( av => new { PersonId = av.EntityId, IndividualId = av.Value } ).ToList();
ImportedPeople = listHouseholdId.GroupJoin( listIndividualId, household => household.PersonId,
individual => individual.PersonId, ( household, individual ) => new ImportedPerson
{
PersonId = household.PersonId,
HouseholdId = household.HouseholdId.AsType<int?>(),
IndividualId = individual.Select( i => i.IndividualId.AsType<int?>() ).FirstOrDefault()
} ).ToList();
var batchAttribute = attributeService.Queryable().FirstOrDefault( a => a.EntityTypeId == BatchEntityTypeId
&& a.Key == "F1BatchId" );
if ( batchAttribute == null )
{
batchAttribute = new Rock.Model.Attribute();
batchAttribute.Key = "F1BatchId";
batchAttribute.Name = "F1 Batch Id";
batchAttribute.FieldTypeId = IntegerFieldTypeId;
batchAttribute.EntityTypeId = BatchEntityTypeId;
batchAttribute.EntityTypeQualifierValue = string.Empty;
batchAttribute.EntityTypeQualifierColumn = string.Empty;
batchAttribute.Description = "The FellowshipOne identifier for the batch that was imported";
batchAttribute.DefaultValue = string.Empty;
batchAttribute.IsMultiValue = false;
batchAttribute.IsRequired = false;
batchAttribute.Order = 0;
attributeService.Add( batchAttribute, ImportPersonAlias );
attributeService.Save( batchAttribute, ImportPersonAlias );
}
BatchAttributeId = batchAttribute.Id;
ReportProgress( 0, "Checking for existing contributions..." );
ImportedBatches = new AttributeValueService().GetByAttributeId( batchAttribute.Id )
.Select( av => new { F1BatchId = av.Value.AsType<int?>(), RockBatchId = av.EntityId } )
.ToDictionary( t => t.F1BatchId, t => t.RockBatchId );
//.........这里部分代码省略.........
示例2: LoadExistingRockData
//.........这里部分代码省略.........
individualAttribute.FieldTypeId = IntegerFieldTypeId;
individualAttribute.EntityTypeId = PersonEntityTypeId;
individualAttribute.EntityTypeQualifierValue = string.Empty;
individualAttribute.EntityTypeQualifierColumn = string.Empty;
individualAttribute.Description = "The FellowshipOne individual identifier for the person that was imported";
individualAttribute.DefaultValue = string.Empty;
individualAttribute.IsMultiValue = false;
individualAttribute.IsRequired = false;
individualAttribute.Order = 0;
lookupContext.Attributes.Add( individualAttribute );
lookupContext.SaveChanges( DisableAuditing );
personAttributes.Add( individualAttribute );
}
var secondaryEmailAttribute = personAttributes.FirstOrDefault( a => a.Key.Equals( "SecondaryEmail", StringComparison.InvariantCultureIgnoreCase ) );
if ( secondaryEmailAttribute == null )
{
secondaryEmailAttribute = new Rock.Model.Attribute();
secondaryEmailAttribute.Key = "SecondaryEmail";
secondaryEmailAttribute.Name = "Secondary Email";
secondaryEmailAttribute.FieldTypeId = TextFieldTypeId;
secondaryEmailAttribute.EntityTypeId = PersonEntityTypeId;
secondaryEmailAttribute.EntityTypeQualifierValue = string.Empty;
secondaryEmailAttribute.EntityTypeQualifierColumn = string.Empty;
secondaryEmailAttribute.Description = "The secondary email for this person";
secondaryEmailAttribute.DefaultValue = string.Empty;
secondaryEmailAttribute.IsMultiValue = false;
secondaryEmailAttribute.IsRequired = false;
secondaryEmailAttribute.Order = 0;
lookupContext.Attributes.Add( secondaryEmailAttribute );
var visitInfoCategory = new CategoryService( lookupContext ).Get( visitInfoCategoryId );
secondaryEmailAttribute.Categories.Add( visitInfoCategory );
lookupContext.SaveChanges( DisableAuditing );
}
var infellowshipLoginAttribute = personAttributes.FirstOrDefault( a => a.Key.Equals( "InFellowshipLogin", StringComparison.InvariantCultureIgnoreCase ) );
if ( infellowshipLoginAttribute == null )
{
infellowshipLoginAttribute = new Rock.Model.Attribute();
infellowshipLoginAttribute.Key = "InFellowshipLogin";
infellowshipLoginAttribute.Name = "InFellowship Login";
infellowshipLoginAttribute.FieldTypeId = TextFieldTypeId;
infellowshipLoginAttribute.EntityTypeId = PersonEntityTypeId;
infellowshipLoginAttribute.EntityTypeQualifierValue = string.Empty;
infellowshipLoginAttribute.EntityTypeQualifierColumn = string.Empty;
infellowshipLoginAttribute.Description = "The InFellowship login for this person";
infellowshipLoginAttribute.DefaultValue = string.Empty;
infellowshipLoginAttribute.IsMultiValue = false;
infellowshipLoginAttribute.IsRequired = false;
infellowshipLoginAttribute.Order = 0;
// don't add a category as this attribute is only used via the API
lookupContext.Attributes.Add( infellowshipLoginAttribute );
lookupContext.SaveChanges( DisableAuditing );
}
IndividualIdAttribute = AttributeCache.Read( individualAttribute.Id );
HouseholdIdAttribute = AttributeCache.Read( householdAttribute.Id );
InFellowshipLoginAttribute = AttributeCache.Read( infellowshipLoginAttribute.Id );
SecondaryEmailAttribute = AttributeCache.Read( secondaryEmailAttribute.Id );
// Set AuthProviderEntityTypeId if Apollos/Infellowship provider exists
var f1AuthProvider = "cc.newspring.F1.Security.Authentication.F1Migrator";
var cache = EntityTypeCache.Read( f1AuthProvider );
AuthProviderEntityTypeId = cache == null ? (int?)null : cache.Id;
var aliasIdList = new PersonAliasService( lookupContext ).Queryable().AsNoTracking()
.Select( pa => new
{
PersonAliasId = pa.Id,
PersonId = pa.PersonId,
IndividualId = pa.ForeignId,
FamilyRole = pa.Person.ReviewReasonNote
} ).ToList();
var householdIdList = attributeValueService.GetByAttributeId( householdAttribute.Id ).AsNoTracking()
.Select( av => new
{
PersonId = (int)av.EntityId,
HouseholdId = av.Value
} ).ToList();
ImportedPeople = householdIdList.GroupJoin( aliasIdList,
household => household.PersonId,
aliases => aliases.PersonId,
( household, aliases ) => new PersonKeys
{
PersonAliasId = aliases.Select( a => a.PersonAliasId ).FirstOrDefault(),
PersonId = household.PersonId,
IndividualId = aliases.Select( a => a.IndividualId ).FirstOrDefault(),
HouseholdId = household.HouseholdId.AsType<int?>(),
FamilyRoleId = aliases.Select( a => a.FamilyRole.ConvertToEnum<FamilyRole>( 0 ) ).FirstOrDefault()
}
).ToList();
ImportedBatches = new FinancialBatchService( lookupContext ).Queryable().AsNoTracking()
.Where( b => b.ForeignId != null )
.ToDictionary( t => (int)t.ForeignId, t => (int?)t.Id );
}
示例3: LoadExistingRockData
/// <summary>
/// Loads Rock data that's used globally by the transform
/// </summary>
private void LoadExistingRockData()
{
var lookupContext = new RockContext();
var attributeValueService = new AttributeValueService( lookupContext );
var attributeService = new AttributeService( lookupContext );
IntegerFieldTypeId = FieldTypeCache.Read( new Guid( Rock.SystemGuid.FieldType.INTEGER ) ).Id;
TextFieldTypeId = FieldTypeCache.Read( new Guid( Rock.SystemGuid.FieldType.TEXT ) ).Id;
PersonEntityTypeId = EntityTypeCache.Read( "Rock.Model.Person" ).Id;
CampusList = CampusCache.All( lookupContext );
int attributeEntityTypeId = EntityTypeCache.Read( "Rock.Model.Attribute" ).Id;
int batchEntityTypeId = EntityTypeCache.Read( "Rock.Model.FinancialBatch" ).Id;
int userLoginTypeId = EntityTypeCache.Read( "Rock.Model.UserLogin" ).Id;
int visitInfoCategoryId = new CategoryService( lookupContext ).GetByEntityTypeId( attributeEntityTypeId )
.Where( c => c.Name == "Visit Information" ).Select( c => c.Id ).FirstOrDefault();
// Look up and create attributes for F1 unique identifiers if they don't exist
var personAttributes = attributeService.GetByEntityTypeId( PersonEntityTypeId ).ToList();
var householdAttribute = personAttributes.FirstOrDefault( a => a.Key == "F1HouseholdId" );
if ( householdAttribute == null )
{
householdAttribute = new Rock.Model.Attribute();
householdAttribute.Key = "F1HouseholdId";
householdAttribute.Name = "F1 Household Id";
householdAttribute.FieldTypeId = IntegerFieldTypeId;
householdAttribute.EntityTypeId = PersonEntityTypeId;
householdAttribute.EntityTypeQualifierValue = string.Empty;
householdAttribute.EntityTypeQualifierColumn = string.Empty;
householdAttribute.Description = "The FellowshipOne household identifier for the person that was imported";
householdAttribute.DefaultValue = string.Empty;
householdAttribute.IsMultiValue = false;
householdAttribute.IsRequired = false;
householdAttribute.Order = 0;
lookupContext.Attributes.Add( householdAttribute );
lookupContext.SaveChanges( DisableAudit );
personAttributes.Add( householdAttribute );
}
var individualAttribute = personAttributes.FirstOrDefault( a => a.Key == "F1IndividualId" );
if ( individualAttribute == null )
{
individualAttribute = new Rock.Model.Attribute();
individualAttribute.Key = "F1IndividualId";
individualAttribute.Name = "F1 Individual Id";
individualAttribute.FieldTypeId = IntegerFieldTypeId;
individualAttribute.EntityTypeId = PersonEntityTypeId;
individualAttribute.EntityTypeQualifierValue = string.Empty;
individualAttribute.EntityTypeQualifierColumn = string.Empty;
individualAttribute.Description = "The FellowshipOne individual identifier for the person that was imported";
individualAttribute.DefaultValue = string.Empty;
individualAttribute.IsMultiValue = false;
individualAttribute.IsRequired = false;
individualAttribute.Order = 0;
lookupContext.Attributes.Add( individualAttribute );
lookupContext.SaveChanges( DisableAudit );
personAttributes.Add( individualAttribute );
}
var secondaryEmailAttribute = personAttributes.FirstOrDefault( a => a.Key == "SecondaryEmail" );
if ( secondaryEmailAttribute == null )
{
secondaryEmailAttribute = new Rock.Model.Attribute();
secondaryEmailAttribute.Key = "SecondaryEmail";
secondaryEmailAttribute.Name = "Secondary Email";
secondaryEmailAttribute.FieldTypeId = TextFieldTypeId;
secondaryEmailAttribute.EntityTypeId = PersonEntityTypeId;
secondaryEmailAttribute.EntityTypeQualifierValue = string.Empty;
secondaryEmailAttribute.EntityTypeQualifierColumn = string.Empty;
secondaryEmailAttribute.Description = "The secondary email for this person";
secondaryEmailAttribute.DefaultValue = string.Empty;
secondaryEmailAttribute.IsMultiValue = false;
secondaryEmailAttribute.IsRequired = false;
secondaryEmailAttribute.Order = 0;
lookupContext.Attributes.Add( secondaryEmailAttribute );
var visitInfoCategory = new CategoryService( lookupContext ).Get( visitInfoCategoryId );
secondaryEmailAttribute.Categories.Add( visitInfoCategory );
lookupContext.SaveChanges( DisableAudit );
}
IndividualAttributeId = individualAttribute.Id;
HouseholdAttributeId = householdAttribute.Id;
SecondaryEmailAttributeId = secondaryEmailAttribute.Id;
ReportProgress( 0, "Checking for existing data..." );
var listHouseholdId = attributeValueService.GetByAttributeId( householdAttribute.Id ).Select( av => new { PersonId = av.EntityId, HouseholdId = av.Value } ).ToList();
var listIndividualId = attributeValueService.GetByAttributeId( individualAttribute.Id ).Select( av => new { PersonId = av.EntityId, IndividualId = av.Value } ).ToList();
// var listHouseholdId = new PersonService().Queryable().Select( )
ImportedPeople = listHouseholdId.GroupJoin( listIndividualId,
household => household.PersonId,
individual => individual.PersonId,
//.........这里部分代码省略.........