本文整理汇总了C#中WorkflowAction类的典型用法代码示例。如果您正苦于以下问题:C# WorkflowAction类的具体用法?C# WorkflowAction怎么用?C# WorkflowAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WorkflowAction类属于命名空间,在下文中一共展示了WorkflowAction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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>();
Guid? personAliasGuid = GetAttributeValue( action, "Person" ).AsGuidOrNull();
if ( personAliasGuid.HasValue )
{
var personAlias = new PersonAliasService( rockContext ).Queryable( "Person" )
.Where( a => a.Guid.Equals( personAliasGuid.Value ) )
.FirstOrDefault();
if (personAlias != null)
{
action.Activity.AssignedPersonAlias = personAlias;
action.Activity.AssignedPersonAliasId = personAlias.Id;
action.Activity.AssignedGroup = null;
action.Activity.AssignedGroupId = null;
action.AddLogEntry( string.Format( "Assigned activity to '{0}' ({1})", personAlias.Person.FullName, personAlias.Person.Id ) );
return true;
}
}
return false;
}
示例2: Execute
public override bool Execute( RockContext rockContext, WorkflowAction action, Object entity, out List<string> errorMessages )
{
errorMessages = new List<string>();
var JobGuid = GetAttributeValue( action, "Job" ).AsGuid();
if ( !JobGuid.IsEmpty() )
{
ServiceJob Job = new ServiceJobService( rockContext ).Get( JobGuid );
if ( Job != null )
{
var transaction = new Rock.Transactions.RunJobNowTransaction( Job.Id );
// Process the transaction on another thread
System.Threading.Tasks.Task.Run( () => transaction.Execute() );
action.AddLogEntry( string.Format( "The '{0}' job has been started.", Job.Name ) );
return true;
}
}
errorMessages.Add("The specified Job could not be found");
return false;
}
示例3: 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 providerGuid = GetAttributeValue( action, "Provider" );
if ( !string.IsNullOrWhiteSpace( providerGuid ) )
{
var provider = BackgroundCheckContainer.GetComponent( providerGuid );
if ( provider != null )
{
var personAttribute = AttributeCache.Read( GetAttributeValue( action, "PersonAttribute" ).AsGuid() );
var ssnAttribute = AttributeCache.Read( GetAttributeValue( action, "SSNAttribute" ).AsGuid() );
var requestTypeAttribute = AttributeCache.Read( GetAttributeValue( action, "RequestTypeAttribute" ).AsGuid() );
var billingCodeAttribute = AttributeCache.Read( GetAttributeValue( action, "BillingCodeAttribute" ).AsGuid() );
return provider.SendRequest( rockContext, action.Activity.Workflow, personAttribute,
ssnAttribute, requestTypeAttribute, billingCodeAttribute, out errorMessages );
}
else
{
errorMessages.Add( "Invalid Background Check Provider!" );
}
}
else
{
errorMessages.Add( "Invalid Background Check Provider Guid!" );
}
return false;
}
示例4: 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>();
Guid guid = GetAttributeValue( action, "Attribute" ).AsGuid();
if ( !guid.IsEmpty() )
{
var attribute = AttributeCache.Read( guid, rockContext );
if ( attribute != null )
{
string value = GetAttributeValue( action, "Value" );
value = value.ResolveMergeFields( GetMergeFields( action ) );
if ( attribute.EntityTypeId == new Rock.Model.Workflow().TypeId )
{
action.Activity.Workflow.SetAttributeValue( attribute.Key, value );
action.AddLogEntry( string.Format( "Set '{0}' attribute to '{1}'.", attribute.Name, value ) );
}
else if ( attribute.EntityTypeId == new Rock.Model.WorkflowActivity().TypeId )
{
action.Activity.SetAttributeValue( attribute.Key, value );
action.AddLogEntry( string.Format( "Set '{0}' attribute to '{1}'.", attribute.Name, value ) );
}
}
}
return true;
}
示例5: Execute
/// <summary>
/// Executes the specified workflow.
/// </summary>
/// <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( WorkflowAction action, Object entity, out List<string> errorMessages )
{
errorMessages = new List<string>();
string activityTypeId = GetAttributeValue( action, "ActivityType" );
if ( String.IsNullOrWhiteSpace( activityTypeId ) )
{
action.AddLogEntry( "Invalid Activity Type Property" );
return false;
}
var workflow = action.Activity.Workflow;
var activityType = workflow.WorkflowType.ActivityTypes
.Where( a => a.Id.ToString() == activityTypeId).FirstOrDefault();
if (activityType != null)
{
WorkflowActivity.Activate( activityType, workflow );
action.AddLogEntry( string.Format( "Activated new '{0}' activity", activityType.ToString() ) );
return true;
}
action.AddLogEntry( string.Format( "Could Not activate new '{0}' activity!", activityType.ToString() ) );
return false;
}
示例6: 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>();
var workflow = action.Activity.Workflow;
workflow.IsPersisted = true;
if ( GetAttributeValue( action, "PersistImmediately" ).AsBoolean( false ) )
{
var service = new WorkflowService( rockContext );
if ( workflow.Id == 0 )
{
service.Add( workflow );
}
rockContext.WrapTransaction( () =>
{
rockContext.SaveChanges();
workflow.SaveAttributeValues( rockContext );
foreach ( var activity in workflow.Activities )
{
activity.SaveAttributeValues( rockContext );
}
} );
}
action.AddLogEntry( "Updated workflow to be persisted!" );
return true;
}
示例7: Execute
/// <summary>
/// Executes the 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>();
if (HttpContext.Current != null)
{
var referrer = HttpContext.Current.Request.UrlReferrer.ToString();
if (! String.IsNullOrEmpty(referrer))
{
var urlAttrGuid = GetAttributeValue( action,"URLField" ).AsGuid();
var attribute = AttributeCache.Read( urlAttrGuid, rockContext );
if (attribute != null)
{
if (attribute.EntityTypeId == new Rock.Model.Workflow().TypeId)
{
action.Activity.Workflow.SetAttributeValue( attribute.Key, referrer );
}
else
{
action.Activity.SetAttributeValue( attribute.Key, referrer );
}
}
}
else
{
action.AddLogEntry( "No HTTP Referrer detected" );
}
}
else
{
action.AddLogEntry( "SetAttributeFromHTTPReferrer triggered outside an http context");
}
return true;
}
示例8: 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>();
var parts = ( GetAttributeValue( action, "Group" ) ?? string.Empty ).Split( '|' );
Guid? groupTypeGuid = null;
Guid? groupGuid = null;
if ( parts.Length >= 1 )
{
groupTypeGuid = parts[0].AsGuidOrNull();
if ( parts.Length >= 2 )
{
groupGuid = parts[1].AsGuidOrNull();
}
}
if ( groupGuid.HasValue )
{
var group = new GroupService( rockContext ).Get( groupGuid.Value );
if ( group != null )
{
action.Activity.AssignedPersonAlias = null;
action.Activity.AssignedPersonAliasId = null;
action.Activity.AssignedGroup = group;
action.Activity.AssignedGroupId = group.Id;
action.AddLogEntry( string.Format( "Assigned activity to '{0}' group ({1})", group.Name, group.Id ) );
return true;
}
}
return false;
}
示例9: 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 nameValue = GetAttributeValue( action, "NameValue" );
Guid guid = nameValue.AsGuid();
if (guid.IsEmpty())
{
nameValue = nameValue.ResolveMergeFields( GetMergeFields( action ) );
}
else
{
nameValue = action.GetWorklowAttributeValue( guid, true, true );
// HtmlDecode the name since we are storing it in the database and it might be formatted to be shown in HTML
nameValue = System.Web.HttpUtility.HtmlDecode( nameValue );
}
if ( !string.IsNullOrWhiteSpace( nameValue ) )
{
action.Activity.Workflow.Name = nameValue;
action.AddLogEntry( string.Format( "Set Workflow Name to '{0}'", nameValue ) );
}
return true;
}
示例10: 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>();
// Get the attribute's guid
Guid guid = GetAttributeValue( action, "PersonAttribute" ).AsGuid();
if ( !guid.IsEmpty() )
{
// Get the attribute
var attribute = AttributeCache.Read( guid, rockContext );
if ( attribute != null )
{
if ( attribute.FieldTypeId == FieldTypeCache.Read( SystemGuid.FieldType.PERSON.AsGuid(), rockContext ).Id )
{
// If attribute type is a person, value should be person alias id
Guid? personAliasGuid = action.GetWorklowAttributeValue( guid ).AsGuidOrNull();
if ( personAliasGuid.HasValue )
{
var personAlias = new PersonAliasService( rockContext ).Queryable( "Person" )
.Where( a => a.Guid.Equals( personAliasGuid.Value ) )
.FirstOrDefault();
if ( personAlias != null )
{
action.Activity.Workflow.InitiatorPersonAlias = personAlias;
action.Activity.Workflow.InitiatorPersonAliasId = personAlias.Id;
action.AddLogEntry( string.Format( "Assigned initiator to '{0}' ({1})", personAlias.Person.FullName, personAlias.Person.Id ) );
return true;
}
}
}
}
}
return false;
}
示例11: 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>();
if ( entity is Model.BinaryFile )
{
var binaryFile = (Model.BinaryFile) entity;
if ( binaryFile.BinaryFileType.Guid != new Guid( SystemGuid.BinaryFiletype.CHECKIN_LABEL ) )
{
errorMessages.Add( "Binary file is not a check-in label" );
action.AddLogEntry( "Binary file is not a check-in label", true );
return false;
}
StringBuilder sb = new StringBuilder();
var contentString = binaryFile.ContentsToString();
foreach ( Match match in Regex.Matches(
contentString,
@"(?<=\^FD)[^\^FS]*(?=\^FS)" ) )
{
sb.AppendFormat( "{0}^|", match.Value );
}
binaryFile.LoadAttributes();
var attributeValue = new AttributeValue();
attributeValue.Value = sb.ToString();
binaryFile.AttributeValues["MergeCodes"] = attributeValue;
binaryFile.SaveAttributeValues( rockContext );
}
return true;
}
示例12: 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 message = GetAttributeValue( action, "Message" ).ResolveMergeFields( GetMergeFields( action ) );
errorMessages.Add( message );
return false;
}
示例13: 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>();
if ( action.Activity.Workflow.InitiatorPersonAliasId.HasValue )
{
var personAlias = new PersonAliasService( rockContext ).Get( action.Activity.Workflow.InitiatorPersonAliasId.Value );
if ( personAlias != null )
{
// Get the attribute to set
Guid guid = GetAttributeValue( action, "PersonAttribute" ).AsGuid();
if ( !guid.IsEmpty() )
{
var personAttribute = AttributeCache.Read( guid, rockContext );
if ( personAttribute != null )
{
// If this is a person type attribute
if ( personAttribute.FieldTypeId == FieldTypeCache.Read( SystemGuid.FieldType.PERSON.AsGuid(), rockContext ).Id )
{
SetWorkflowAttributeValue( action, guid, personAlias.Guid.ToString() );
}
else if ( personAttribute.FieldTypeId == FieldTypeCache.Read( SystemGuid.FieldType.TEXT.AsGuid(), rockContext ).Id )
{
SetWorkflowAttributeValue( action, guid, personAlias.Person.FullName );
}
}
}
}
}
return true;
}
示例14: 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>();
Guid guid = GetAttributeValue( action, "Activity" ).AsGuid();
if ( guid.IsEmpty() )
{
action.AddLogEntry( "Invalid Activity Property", true );
return false;
}
var workflow = action.Activity.Workflow;
var activityType = new WorkflowActivityTypeService( rockContext ).Queryable()
.Where( a => a.Guid.Equals( guid ) ).FirstOrDefault();
if ( activityType == null )
{
action.AddLogEntry( "Invalid Activity Property", true );
return false;
}
WorkflowActivity.Activate( activityType, workflow );
action.AddLogEntry( string.Format( "Activated new '{0}' activity", activityType.ToString() ) );
return true;
}
示例15: 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>();
var guid = GetAttributeValue( action, "Workflow" ).AsGuid();
if (guid.IsEmpty())
{
action.AddLogEntry( "Invalid Workflow Property", true );
return false;
}
var currentActivity = action.Activity;
var newWorkflowType = new WorkflowTypeService( rockContext ).Get( guid );
var newWorkflowName = GetAttributeValue(action, "WorkflowName" );
if (newWorkflowType == null)
{
action.AddLogEntry( "Invalid Workflow Property", true );
return false;
}
var newWorkflow = Rock.Model.Workflow.Activate( newWorkflowType, newWorkflowName );
if (newWorkflow == null)
{
action.AddLogEntry( "The Workflow could not be activated", true );
return false;
}
CopyAttributes( newWorkflow, currentActivity, rockContext );
SaveForProcessingLater( newWorkflow, rockContext );
return true;
// Kick off processing of new Workflow
/*if(newWorkflow.Process( rockContext, entity, out errorMessages ))
{
if (newWorkflow.IsPersisted || newWorkflowType.IsPersisted)
{
var workflowService = new Rock.Model.WorkflowService( rockContext );
workflowService.Add( newWorkflow );
rockContext.WrapTransaction( () =>
{
rockContext.SaveChanges();
newWorkflow.SaveAttributeValues( rockContext );
foreach (var activity in newWorkflow.Activities)
{
activity.SaveAttributeValues( rockContext );
}
} );
}
return true;
}
else
{
return false;
}*/
}