本文整理汇总了C#中Rock.Model.PersonAliasService.LoadAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# PersonAliasService.LoadAttributes方法的具体用法?C# PersonAliasService.LoadAttributes怎么用?C# PersonAliasService.LoadAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.PersonAliasService
的用法示例。
在下文中一共展示了PersonAliasService.LoadAttributes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
/// Executes the specified workflow.
/// </summary>
/// <param name="rockContext">The rock context.</param>
/// <param name="action">The action.</param>
/// <param name="entity">The entity.</param>
/// <param name="errorMessages">The error messages.</param>
/// <returns></returns>
public override bool Execute( RockContext rockContext, WorkflowAction action, Object entity, out List<string> errorMessages )
{
errorMessages = new List<string>();
string updateValue = GetAttributeValue( action, "Value" );
Guid? valueGuid = updateValue.AsGuidOrNull();
if ( valueGuid.HasValue )
{
updateValue = action.GetWorklowAttributeValue( valueGuid.Value );
}
else
{
updateValue = updateValue.ResolveMergeFields( GetMergeFields( action ) );
}
string personAttribute = GetAttributeValue( action, "PersonAttribute" );
Guid guid = personAttribute.AsGuid();
if (!guid.IsEmpty())
{
var attribute = AttributeCache.Read( guid, rockContext );
if ( attribute != null )
{
string value = GetAttributeValue( action, "Person" );
guid = value.AsGuid();
if ( !guid.IsEmpty() )
{
var attributePerson = AttributeCache.Read( guid, rockContext );
if ( attributePerson != null )
{
string attributePersonValue = action.GetWorklowAttributeValue( guid );
if ( !string.IsNullOrWhiteSpace( attributePersonValue ) )
{
if ( attributePerson.FieldType.Class == "Rock.Field.Types.PersonFieldType" )
{
Guid personAliasGuid = attributePersonValue.AsGuid();
if ( !personAliasGuid.IsEmpty() )
{
var person = new PersonAliasService( rockContext ).Queryable()
.Where( a => a.Guid.Equals( personAliasGuid ) )
.Select( a => a.Person )
.FirstOrDefault();
if ( person != null )
{
// update person attribute
person.LoadAttributes();
string originalValue = person.GetAttributeValue( attribute.Key );
// Handle encrypted text fields as well.
if ( attribute.FieldType.Field is Field.Types.EncryptedTextFieldType )
{
updateValue = Security.Encryption.EncryptString( updateValue );
}
Rock.Attribute.Helper.SaveAttributeValue( person, attribute, updateValue, rockContext );
if ( ( originalValue ?? string.Empty ).Trim() != ( updateValue ?? string.Empty ).Trim() )
{
var changes = new List<string>();
string formattedOriginalValue = string.Empty;
if ( !string.IsNullOrWhiteSpace( originalValue ) )
{
formattedOriginalValue = attribute.FieldType.Field.FormatValue( null, originalValue, attribute.QualifierValues, false );
}
string formattedNewValue = string.Empty;
if ( !string.IsNullOrWhiteSpace( updateValue ) )
{
formattedNewValue = attribute.FieldType.Field.FormatValue( null, updateValue, attribute.QualifierValues, false );
}
History.EvaluateChange( changes, attribute.Name, formattedOriginalValue, formattedNewValue, attribute.FieldType.Field.IsSensitive() );
if ( changes.Any() )
{
HistoryService.SaveChanges( rockContext, typeof( Person ),
Rock.SystemGuid.Category.HISTORY_PERSON_DEMOGRAPHIC_CHANGES.AsGuid(),
person.Id, changes );
}
}
action.AddLogEntry( string.Format( "Set '{0}' attribute to '{1}'.", attribute.Name, updateValue ) );
return true;
}
else
{
errorMessages.Add( string.Format( "Person could not be found for selected value ('{0}')!", guid.ToString() ) );
}
}
}
else
//.........这里部分代码省略.........
示例2: SendRequest
/// <summary>
/// Sends a background request to Protect My Ministry
/// </summary>
/// <param name="rockContext">The rock context.</param>
/// <param name="workflow">The Workflow initiating the request.</param>
/// <param name="personAttribute">The person attribute.</param>
/// <param name="ssnAttribute">The SSN attribute.</param>
/// <param name="requestTypeAttribute">The request type attribute.</param>
/// <param name="billingCodeAttribute">The billing code attribute.</param>
/// <param name="errorMessages">The error messages.</param>
/// <returns>
/// True/False value of whether the request was successfully sent or not
/// </returns>
/// <exception cref="System.NotImplementedException"></exception>
/// <remarks>
/// Note: If the associated workflow type does not have attributes with the following keys, they
/// will automatically be added to the workflow type configuration in order to store the results
/// of the PMM background check request
/// RequestStatus: The request status returned by PMM request
/// RequestMessage: Any error messages returned by PMM request
/// ReportStatus: The report status returned by PMM
/// ReportLink: The location of the background report on PMM server
/// ReportRecommendation: PMM's recomendataion
/// Report (BinaryFile): The downloaded background report
/// </remarks>
public override bool SendRequest( RockContext rockContext, Model.Workflow workflow,
AttributeCache personAttribute, AttributeCache ssnAttribute, AttributeCache requestTypeAttribute,
AttributeCache billingCodeAttribute, out List<string> errorMessages )
{
errorMessages = new List<string>();
try
{
// Check to make sure workflow is not null
if ( workflow == null )
{
errorMessages.Add( "The 'Protect My Ministry' background check provider requires a valid workflow." );
return false;
}
// Get the person that the request is for
Person person = null;
if ( personAttribute != null )
{
Guid? personAliasGuid = workflow.GetAttributeValue( personAttribute.Key ).AsGuidOrNull();
if ( personAliasGuid.HasValue )
{
person = new PersonAliasService( rockContext ).Queryable()
.Where( p => p.Guid.Equals( personAliasGuid.Value ) )
.Select( p => p.Person )
.FirstOrDefault();
person.LoadAttributes( rockContext );
}
}
if ( person == null )
{
errorMessages.Add( "The 'Protect My Ministry' background check provider requires the workflow to have a 'Person' attribute that contains the person who the background check is for." );
return false;
}
string password = Encryption.DecryptString( GetAttributeValue( "Password" ) );
XElement rootElement = new XElement( "OrderXML",
new XElement( "Method", "SEND ORDER" ),
new XElement( "Authentication",
new XElement( "Username", GetAttributeValue( "UserName" ) ),
new XElement( "Password", password )
)
);
if ( GetAttributeValue( "TestMode" ).AsBoolean() )
{
rootElement.Add( new XElement( "TestMode", "YES" ) );
}
rootElement.Add( new XElement( "ReturnResultURL", GetAttributeValue( "ReturnURL" ) ) );
XElement orderElement = new XElement( "Order" );
rootElement.Add( orderElement );
if ( billingCodeAttribute != null )
{
string billingCode = workflow.GetAttributeValue( billingCodeAttribute.Key );
Guid? campusGuid = billingCode.AsGuidOrNull();
if ( campusGuid.HasValue )
{
var campus = CampusCache.Read( campusGuid.Value );
if ( campus != null )
{
billingCode = campus.Name;
}
}
orderElement.Add( new XElement( "BillingReferenceCode", billingCode ) );
}
XElement subjectElement = new XElement( "Subject",
new XElement( "FirstName", person.FirstName ),
new XElement( "MiddleName", person.MiddleName ),
new XElement( "LastName", person.LastName )
//.........这里部分代码省略.........