本文整理汇总了C#中GroupMatcher.GetMatches方法的典型用法代码示例。如果您正苦于以下问题:C# GroupMatcher.GetMatches方法的具体用法?C# GroupMatcher.GetMatches怎么用?C# GroupMatcher.GetMatches使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GroupMatcher
的用法示例。
在下文中一共展示了GroupMatcher.GetMatches方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
/// Executes the specified workflow action.
/// </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>();
GroupType groupType = GetGroupType( rockContext, action );
List<DayOfWeek> daysOfWeek = GetDaysOfWeek( rockContext, action );
Person person = GetPerson( rockContext, action );
int numMatches = GetNumberOfMatches( rockContext, action );
if (person != null)
{
if (groupType != null)
{
if (daysOfWeek != null)
{
var attrAssignments = GetAttributeValue( action, "AttributeAssignments" );
var ds = new Deserializer();
action.Activity.LoadAttributes();
action.Activity.Workflow.LoadAttributes();
var groupMatcher = new GroupMatcher(person,groupType,daysOfWeek);
groupMatcher.numMatches = numMatches;
var matches = groupMatcher.GetMatches();
var mergeFields = GetMergeFields( action );
mergeFields.Add( "Person", person );
mergeFields.Add( "matches", matches );
var attrList = ds.Deserialize< Dictionary<string, string> >( new StringReader( attrAssignments ) );
foreach(string key in attrList.Keys)
{
if (action.Activity.Attributes.ContainsKey( key ))
{
var lava = attrList[key];
try
{
var value = lava.ResolveMergeFields( mergeFields );
if (value.Contains( "Liquid error" ))
{
action.AddLogEntry( "Liquid Error: " + value );
}
else
{
action.Activity.SetAttributeValue( key, value );
}
}
catch (DotLiquid.Exceptions.LiquidException ex)
{
action.AddLogEntry( "Liquid Error: " + ex.Message );
}
}
else if(action.Activity.Workflow.Attributes.ContainsKey( key ))
{
var lava = attrList[key];
try
{
var value = lava.ResolveMergeFields( mergeFields );
if (value.Contains( "Liquid error" ))
{
action.AddLogEntry( "Liquid Error: " + value );
}
else
{
action.Activity.Workflow.SetAttributeValue( key, value );
}
}
catch (DotLiquid.Exceptions.LiquidException ex)
{
action.AddLogEntry( "Liquid Error: " + ex.Message );
}
}
}
return true;
}
else
{
errorMessages.Add( "Days of week attribute could not be found" );
}
}
else
{
errorMessages.Add( "Group Type could not be found" );
}
}
//.........这里部分代码省略.........