本文整理汇总了C#中Person.LoadAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# Person.LoadAttributes方法的具体用法?C# Person.LoadAttributes怎么用?C# Person.LoadAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Person
的用法示例。
在下文中一共展示了Person.LoadAttributes方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowFormFieldEdit
/// <summary>
/// Shows the form field edit.
/// </summary>
/// <param name="formGuid">The form unique identifier.</param>
/// <param name="formFieldGuid">The form field unique identifier.</param>
private void ShowFormFieldEdit( Guid formGuid, Guid formFieldGuid )
{
if ( FormFieldsState.ContainsKey( formGuid ) )
{
ShowDialog( "Attributes" );
var fieldList = FormFieldsState[formGuid];
RegistrationTemplateFormField formField = fieldList.FirstOrDefault( a => a.Guid.Equals( formFieldGuid ) );
if ( formField == null )
{
formField = new RegistrationTemplateFormField();
formField.Guid = formFieldGuid;
formField.FieldSource = RegistrationFieldSource.PersonAttribute;
}
ceAttributePreText.Text = formField.PreText;
ceAttributePostText.Text = formField.PostText;
ddlFieldSource.SetValue( formField.FieldSource.ConvertToInt() );
ddlPersonField.SetValue( formField.PersonFieldType.ConvertToInt() );
lPersonField.Text = formField.PersonFieldType.ConvertToString();
ddlPersonAttributes.Items.Clear();
var person = new Person();
person.LoadAttributes();
foreach ( var attr in person.Attributes
.OrderBy( a => a.Value.Name )
.Select( a => a.Value ) )
{
if ( attr.IsAuthorized( Authorization.VIEW, CurrentPerson ) )
{
ddlPersonAttributes.Items.Add( new ListItem( attr.Name, attr.Id.ToString() ) );
}
}
ddlGroupTypeAttributes.Items.Clear();
var group = new Group();
group.GroupTypeId = gtpGroupType.SelectedGroupTypeId ?? 0;
var groupMember = new GroupMember();
groupMember.Group = group;
groupMember.LoadAttributes();
foreach ( var attr in groupMember.Attributes
.OrderBy( a => a.Value.Name )
.Select( a => a.Value ) )
{
if ( attr.IsAuthorized( Authorization.VIEW, CurrentPerson ) )
{
ddlGroupTypeAttributes.Items.Add( new ListItem( attr.Name, attr.Id.ToString() ) );
}
}
var attribute = new Attribute();
attribute.FieldTypeId = FieldTypeCache.Read( Rock.SystemGuid.FieldType.TEXT ).Id;
if ( formField.FieldSource == RegistrationFieldSource.PersonAttribute )
{
ddlPersonAttributes.SetValue( formField.AttributeId );
}
else if ( formField.FieldSource == RegistrationFieldSource.GroupMemberAttribute )
{
ddlGroupTypeAttributes.SetValue( formField.AttributeId );
}
else if ( formField.FieldSource == RegistrationFieldSource.RegistrationAttribute )
{
if ( formField.Attribute != null )
{
attribute = formField.Attribute;
}
}
edtRegistrationAttribute.SetAttributeProperties( attribute, typeof( RegistrationTemplate ) );
cbInternalField.Checked = formField.IsInternal;
cbShowOnGrid.Checked = formField.IsGridField;
cbRequireInInitialEntry.Checked = formField.IsRequired;
cbUsePersonCurrentValue.Checked = formField.ShowCurrentValue;
cbCommonValue.Checked = formField.IsSharedValue;
hfFormGuid.Value = formGuid.ToString();
hfAttributeGuid.Value = formFieldGuid.ToString();
lPersonField.Visible = formField.FieldSource == RegistrationFieldSource.PersonField && (
formField.PersonFieldType == RegistrationPersonFieldType.FirstName ||
formField.PersonFieldType == RegistrationPersonFieldType.LastName );
SetFieldDisplay();
}
BuildControls( true );
}
示例2: LoadSavedAssessmentResults
/// <summary>
/// Loads and returns saved Assessment scores for the Person.
/// </summary>
/// <param name="person">The Person to get the scores for.</param>
/// <returns>AssessmentResults</returns>
static public AssessmentResults LoadSavedAssessmentResults( Person person )
{
AssessmentResults savedScores = new AssessmentResults();
person.LoadAttributes();
var discAttributes = person.Attributes.Values.Where( a => a.Categories.Any( c => c.Guid == new Guid( "0B187C81-2106-4875-82B6-FBF1277AE23B" ) ) ).Select( a => a.Key );
foreach ( string attrib in discAttributes )
{
switch ( attrib )
{
case AttributeKeys.AdaptiveD:
savedScores.AdaptiveBehaviorD = AttributeValueLookup( person, attrib );
break;
case AttributeKeys.AdaptiveI:
savedScores.AdaptiveBehaviorI = AttributeValueLookup( person, attrib );
break;
case AttributeKeys.AdaptiveS:
savedScores.AdaptiveBehaviorS = AttributeValueLookup( person, attrib );
break;
case AttributeKeys.AdaptiveC:
savedScores.AdaptiveBehaviorC = AttributeValueLookup( person, attrib );
break;
case AttributeKeys.NaturalD:
savedScores.NaturalBehaviorD = AttributeValueLookup( person, attrib );
break;
case AttributeKeys.NaturalI:
savedScores.NaturalBehaviorI = AttributeValueLookup( person, attrib );
break;
case AttributeKeys.NaturalS:
savedScores.NaturalBehaviorS = AttributeValueLookup( person, attrib );
break;
case AttributeKeys.NaturalC:
savedScores.NaturalBehaviorC = AttributeValueLookup( person, attrib );
break;
case AttributeKeys.PersonalityType:
savedScores.PersonalityType = person.AttributeValues[attrib].Value;
break;
case AttributeKeys.LastSaveDate:
DateTime lastAssessmentDate = DateTime.MinValue;
bool bCatch = DateTime.TryParse( person.AttributeValues[attrib].Value, out lastAssessmentDate );
savedScores.LastSaveDate = lastAssessmentDate;
break;
}
}
return savedScores;
}
示例3: SaveAssessmentResults
/// <summary>
/// Saves Assessment results to a Person's PersonProperties
/// </summary>
/// <param name="person"></param>
/// <param name="ABd">Adaptive Behavior D</param>
/// <param name="ABi">Adaptive Behavior I</param>
/// <param name="ABs">Adaptive Behavior S</param>
/// <param name="ABc">Adaptive Behavior C</param>
/// <param name="NBd">Natural Behavior D</param>
/// <param name="NBi">Natural Behavior I</param>
/// <param name="NBs">Natural Behavior S</param>
/// <param name="NBc">Natural Behavior C</param>
/// <param name="personalityType">One or two letters of DISC that represents the personality.</param>
static public void SaveAssessmentResults( Person person, string ABd, string ABi, string ABs, string ABc, string NBd, string NBi, string NBs, string NBc, string personalityType )
{
person.LoadAttributes();
var discAttributes = person.Attributes.Values.Where( a => a.Categories.Any( c => c.Guid == new Guid( "0B187C81-2106-4875-82B6-FBF1277AE23B" ) ) ).Select( a => a.Key );
foreach ( string attrib in discAttributes )
{
switch ( attrib )
{
case AttributeKeys.AdaptiveD:
Rock.Attribute.Helper.SaveAttributeValue( person, person.Attributes[attrib], ABd );
break;
case AttributeKeys.AdaptiveI:
Rock.Attribute.Helper.SaveAttributeValue( person, person.Attributes[attrib], ABi );
break;
case AttributeKeys.AdaptiveS:
Rock.Attribute.Helper.SaveAttributeValue( person, person.Attributes[attrib], ABs );
break;
case AttributeKeys.AdaptiveC:
Rock.Attribute.Helper.SaveAttributeValue( person, person.Attributes[attrib], ABc );
break;
case AttributeKeys.NaturalD:
Rock.Attribute.Helper.SaveAttributeValue( person, person.Attributes[attrib], NBd );
break;
case AttributeKeys.NaturalI:
Rock.Attribute.Helper.SaveAttributeValue( person, person.Attributes[attrib], NBi );
break;
case AttributeKeys.NaturalS:
Rock.Attribute.Helper.SaveAttributeValue( person, person.Attributes[attrib], NBs );
break;
case AttributeKeys.NaturalC:
Rock.Attribute.Helper.SaveAttributeValue( person, person.Attributes[attrib], NBc );
break;
case AttributeKeys.PersonalityType:
Rock.Attribute.Helper.SaveAttributeValue( person, person.Attributes[attrib], personalityType );
break;
case AttributeKeys.LastSaveDate:
Rock.Attribute.Helper.SaveAttributeValue( person, person.Attributes[attrib], RockDateTime.Now.ToString( "o" ) );
break;
}
}
person.SaveAttributeValues();
}
示例4: lbSubmit_Click
protected void lbSubmit_Click( object sender, EventArgs e )
{
if ( Page.IsValid )
{
RockContext rockContext = new RockContext();
var adultRole = new GroupTypeRoleService( rockContext ).Get( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT.AsGuid() );
var childRole = new GroupTypeRoleService( rockContext ).Get( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_CHILD.AsGuid() );
Person parent = new Person();
parent.FirstName = rtbParentFirstName.Text;
parent.LastName = rtbParentLastName.Text;
parent.LoadAttributes( rockContext );
PhoneNumber parentPhone = new PhoneNumber();
parentPhone.Number = pnbParentPhoneNumber.Number;
parent.PhoneNumbers.Add( parentPhone );
List<GroupMember> familyMembers = new List<GroupMember>();
GroupMember parentGM = new GroupMember();
parentGM.Person = parent;
parentGM.GroupRoleId = adultRole.Id;
familyMembers.Add( parentGM );
foreach ( KidData kidData in kidsList )
{
Person kid = new Person();
kid.FirstName = kidData.FirstName;
kid.LastName = kidData.LastName;
kid.Gender = kidData.Gender;
kid.SetBirthDate( kidData.Birthdate );
kid.GradeOffset = kidData.Grade.Value.AsIntegerOrNull();
kid.LoadAttributes( rockContext );
kid.SetAttributeValue( "AbilityLevel", kidData.AbilityLevel.Guid.ToString() );
kid.SetAttributeValue( "Allergy", kidData.Allergy );
kid.SetAttributeValue( "LegalNotes", kidData.LegalNotes );
GroupMember kidGM = new GroupMember();
kidGM.Person = kid;
kidGM.GroupRoleId = childRole.Id;
familyMembers.Add( kidGM );
}
Group family = GroupService.SaveNewFamily( rockContext, familyMembers, cpCampus.SelectedValueAsInt(), true );
if ( !String.IsNullOrWhiteSpace( GetAttributeValue( "PersonDetailsPage" ) ) )
{
NavigateToLinkedPage( "PersonDetailsPage", new Dictionary<string, string>() { { "PersonId", parent.Id.ToString() } } );
}
else
{
NavigateToCurrentPage( new Dictionary<string, string>() { { "PersonId", parent.Id.ToString() } } );
}
}
}
示例5: OnInit
/// <summary>
/// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
/// </summary>
/// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
protected override void OnInit( EventArgs e )
{
base.OnInit( e );
Person = this.ContextEntity<Person>();
if ( Person == null )
{
// check the query string and attempt to load the person from it
if ( Request["PersonId"] != null )
{
int personId = Request["PersonId"].AsInteger();
Person = new PersonService( new RockContext() ).Get( personId );
Person.LoadAttributes();
}
if ( Person == null )
{
Person = new Person();
}
}
}
示例6: SaveTestResults
static public void SaveTestResults( Person person, string prophecy, string ministry, string teaching, string encouragement, string giving, string leadership, string mercy, string gifting )
{
person.LoadAttributes();
var discAttributes = person.Attributes.Values.Where( a => a.Categories.Any( c => c.Guid == new Guid( "12d8e61f-ed07-41d9-be0b-43c73907896d" ) ) ).Select( a => a.Key );
foreach ( string attrib in discAttributes )
{
switch ( attrib )
{
case AttributeKeys.Prophecy:
Rock.Attribute.Helper.SaveAttributeValue( person, person.Attributes[attrib], prophecy );
break;
case AttributeKeys.Ministry:
Rock.Attribute.Helper.SaveAttributeValue( person, person.Attributes[attrib], ministry );
break;
case AttributeKeys.Teaching:
Rock.Attribute.Helper.SaveAttributeValue( person, person.Attributes[attrib], teaching );
break;
case AttributeKeys.Encouragement:
Rock.Attribute.Helper.SaveAttributeValue( person, person.Attributes[attrib], encouragement );
break;
case AttributeKeys.Giving:
Rock.Attribute.Helper.SaveAttributeValue( person, person.Attributes[attrib], giving );
break;
case AttributeKeys.Leadership:
Rock.Attribute.Helper.SaveAttributeValue( person, person.Attributes[attrib], leadership );
break;
case AttributeKeys.Mercy:
Rock.Attribute.Helper.SaveAttributeValue( person, person.Attributes[attrib], mercy );
break;
case AttributeKeys.Gifting:
Rock.Attribute.Helper.SaveAttributeValue( person, person.Attributes[attrib], gifting );
break;
case AttributeKeys.LastSaveDate:
Rock.Attribute.Helper.SaveAttributeValue( person, person.Attributes[attrib], RockDateTime.Now.ToString( "o" ) );
break;
}
}
person.SaveAttributeValues();
}
示例7: LoadSavedTestResults
/// <summary>
/// Loads and returns saved Test scores for the Person.
/// </summary>
/// <param name="person">The Person to get the scores for.</param>
/// <returns>TestResults</returns>
static public TestResults LoadSavedTestResults( Person person )
{
TestResults savedScores = new TestResults();
person.LoadAttributes();
var discAttributes = person.Attributes.Values.Where( a => a.Categories.Any( c => c.Guid == new Guid( "12d8e61f-ed07-41d9-be0b-43c73907896d" ) ) ).Select( a => a.Key );
foreach ( string attrib in discAttributes )
{
switch ( attrib )
{
case AttributeKeys.Prophecy:
savedScores.Prophecy = AttributeValueLookup( person, attrib );
break;
case AttributeKeys.Ministry:
savedScores.Ministry = AttributeValueLookup( person, attrib );
break;
case AttributeKeys.Teaching:
savedScores.Teaching = AttributeValueLookup( person, attrib );
break;
case AttributeKeys.Encouragement:
savedScores.Encouragement = AttributeValueLookup( person, attrib );
break;
case AttributeKeys.Giving:
savedScores.Giving = AttributeValueLookup( person, attrib );
break;
case AttributeKeys.Leadership:
savedScores.Leadership = AttributeValueLookup( person, attrib );
break;
case AttributeKeys.Mercy:
savedScores.Mercy = AttributeValueLookup( person, attrib );
break;
case AttributeKeys.Gifting:
savedScores.Gifting = person.AttributeValues[attrib].Value;
break;
case AttributeKeys.LastSaveDate:
DateTime lastTestDate = DateTime.MinValue;
bool bCatch = DateTime.TryParse( person.AttributeValues[attrib].Value, out lastTestDate );
savedScores.LastSaveDate = lastTestDate;
break;
}
}
return savedScores;
}
示例8: ShowFormFieldEdit
/// <summary>
/// Shows the form field edit.
/// </summary>
/// <param name="formGuid">The form unique identifier.</param>
/// <param name="formFieldGuid">The form field unique identifier.</param>
private void ShowFormFieldEdit( Guid formGuid, Guid formFieldGuid )
{
var form = FormState.FirstOrDefault( f => f.Guid == formGuid );
if ( form != null )
{
var field = form.Fields.FirstOrDefault( a => a.Guid.Equals( formFieldGuid ) );
if ( field == null )
{
field = new AttributeFormField();
field.Guid = formFieldGuid;
field.ShowCurrentValue = true;
field.IsRequired = false;
}
ceAttributePreText.Text = field.PreText;
ceAttributePostText.Text = field.PostText;
ddlPersonAttributes.Items.Clear();
var person = new Person();
person.LoadAttributes();
foreach ( var attr in person.Attributes
.OrderBy( a => a.Value.Name )
.Select( a => a.Value ) )
{
if ( attr.IsAuthorized( Authorization.VIEW, CurrentPerson ) )
{
ddlPersonAttributes.Items.Add( new ListItem( attr.Name, attr.Id.ToString() ) );
}
}
ddlPersonAttributes.SetValue( field.AttributeId );
cbRequireInInitialEntry.Checked = field.IsRequired;
cbUsePersonCurrentValue.Checked = field.ShowCurrentValue;
hfFormGuid.Value = formGuid.ToString();
hfAttributeGuid.Value = formFieldGuid.ToString();
ShowDialog( "Attributes" );
}
BuildEditControls( true );
}