本文整理汇总了C#中Rock.SetAttributeValue方法的典型用法代码示例。如果您正苦于以下问题:C# Rock.SetAttributeValue方法的具体用法?C# Rock.SetAttributeValue怎么用?C# Rock.SetAttributeValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock
的用法示例。
在下文中一共展示了Rock.SetAttributeValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveAttributeValue
private static void SaveAttributeValue( Rock.Model.Workflow workflow, string key, string value,
FieldTypeCache fieldType, RockContext rockContext, Dictionary<string, string> qualifiers = null )
{
if (workflow.Attributes.ContainsKey(key))
{
workflow.SetAttributeValue( key, value );
}
else
{
// If workflow attribute doesn't exist, create it
// ( should only happen first time a background check is processed for given workflow type)
var attribute = new Rock.Model.Attribute();
attribute.EntityTypeId = workflow.WorkflowType.TypeId;
attribute.EntityTypeQualifierColumn = "WorkflowTypeId";
attribute.EntityTypeQualifierValue = workflow.WorkflowTypeId.ToString();
attribute.Name = key.SplitCase();
attribute.Key = key;
attribute.FieldTypeId = fieldType.Id;
if ( qualifiers != null )
{
foreach( var keyVal in qualifiers )
{
var qualifier = new Rock.Model.AttributeQualifier();
qualifier.Key = keyVal.Key;
qualifier.Value = keyVal.Value;
attribute.AttributeQualifiers.Add( qualifier );
}
}
// Set the value for this action's instance to the current time
var attributeValue = new Rock.Model.AttributeValue();
attributeValue.Attribute = attribute;
attributeValue.EntityId = workflow.Id;
attributeValue.Value = value;
new AttributeValueService( rockContext ).Add( attributeValue );
}
}
示例2: CopyAttributes
private void CopyAttributes(Rock.Model.Workflow newWorkflow, Rock.Model.WorkflowActivity currentActivity, RockContext rockContext)
{
if (currentActivity.Attributes == null)
{
currentActivity.LoadAttributes( rockContext );
}
if (currentActivity.Workflow.Attributes == null)
{
currentActivity.Workflow.LoadAttributes( rockContext );
}
// Pass attributes from current Workflow to new Workflow.
foreach (string key in currentActivity.Workflow.AttributeValues.Keys)
{
newWorkflow.SetAttributeValue( key, currentActivity.Workflow.GetAttributeValue( key ) );
}
// Pass attributes from current Activity to new Workflow.
foreach (string key in currentActivity.AttributeValues.Keys)
{
newWorkflow.SetAttributeValue( key, currentActivity.GetAttributeValue(key) );
}
}