本文整理汇总了C#中WorkflowAction.AddLogEntry方法的典型用法代码示例。如果您正苦于以下问题:C# WorkflowAction.AddLogEntry方法的具体用法?C# WorkflowAction.AddLogEntry怎么用?C# WorkflowAction.AddLogEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorkflowAction
的用法示例。
在下文中一共展示了WorkflowAction.AddLogEntry方法的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
/// <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;
}
示例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>();
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;
}
示例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, "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;
}
示例5: 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;
}
示例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 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;
}*/
}
示例7: 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 query = GetAttributeValue( action, "SQLQuery" );
var mergeFields = GetMergeFields( action );
query = query.ResolveMergeFields( mergeFields );
try
{
object sqlResult = DbService.ExecuteScaler( query );
action.AddLogEntry( "SQL query has been run" );
if ( sqlResult != null )
{
Guid? attributeGuid = GetAttributeValue( action, "ResultAttribute" ).AsGuidOrNull();
if ( attributeGuid.HasValue )
{
var attribute = AttributeCache.Read( attributeGuid.Value, rockContext );
if ( attribute != null )
{
string resultValue = sqlResult.ToString();
if ( attribute.EntityTypeId == new Rock.Model.Workflow().TypeId )
{
action.Activity.Workflow.SetAttributeValue( attribute.Key, resultValue );
action.AddLogEntry( string.Format( "Set '{0}' attribute to '{1}'.", attribute.Name, resultValue ) );
}
else if ( attribute.EntityTypeId == new Rock.Model.WorkflowActivity().TypeId )
{
action.Activity.SetAttributeValue( attribute.Key, resultValue );
action.AddLogEntry( string.Format( "Set '{0}' attribute to '{1}'.", attribute.Name, resultValue ) );
}
}
}
}
return true;
}
catch (Exception ex)
{
action.AddLogEntry( ex.Message, true );
if ( !GetAttributeValue( action, "ContinueOnError" ).AsBoolean() )
{
errorMessages.Add( ex.Message );
return false;
}
else
{
return true;
}
}
}
示例8: 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 existingValue = action.GetWorklowAttributeValue( guid );
string value = GetAttributeValue( action, "Value" );
string separator;
if (String.IsNullOrEmpty( existingValue ))
{
separator = "";
}
else
{
separator = GetAttributeValue( action, "Separator" );
}
var mergeFields = GetMergeFields( action );
value = value.ResolveMergeFields( mergeFields );
string valueAction;
string newValue;
if (GetAttributeValue(action,"Prepend").AsBoolean())
{
valueAction = "Prepended";
newValue = string.Format("{1}{2}{0}", existingValue, value, separator);
} else {
valueAction = "Appended";
newValue = string.Format("{0}{2}{1}", existingValue, value, separator);
}
if ( attribute.EntityTypeId == new Rock.Model.Workflow().TypeId )
{
action.Activity.Workflow.SetAttributeValue( attribute.Key, newValue );
action.AddLogEntry( string.Format( "{2} '{0}' attribute to '{1}'.", attribute.Name, newValue, valueAction ) );
}
else if ( attribute.EntityTypeId == new Rock.Model.WorkflowActivity().TypeId )
{
action.Activity.SetAttributeValue( attribute.Key, newValue );
action.AddLogEntry( string.Format( "{2} '{0}' attribute to '{1}'.", attribute.Name, newValue, valueAction ) );
}
}
}
return true;
}
示例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>();
var workflowActivityGuid = action.GetWorklowAttributeValue( GetAttributeValue( action, "Activity" ).AsGuid() ).AsGuid();
if ( workflowActivityGuid.IsEmpty() )
{
action.AddLogEntry( "Invalid Activity Property", true );
return false;
}
var attributeKey = GetAttributeValue( action, "WorkflowAttributeKey", true );
var attributeValue = GetAttributeValue( action, "WorkflowAttributeValue", true );
if ( string.IsNullOrWhiteSpace( attributeKey) || string.IsNullOrWhiteSpace(attributeValue) )
{
action.AddLogEntry( "Invalid Workflow Property", true );
return false;
}
var activityType = new WorkflowActivityTypeService( rockContext ).Queryable()
.Where( a => a.Guid.Equals( workflowActivityGuid ) ).FirstOrDefault();
if ( activityType == null )
{
action.AddLogEntry( "Invalid Activity Property", true );
return false;
}
var entityType = EntityTypeCache.Read( typeof( Rock.Model.Workflow ) );
var workflowIds = new AttributeValueService( rockContext )
.Queryable()
.AsNoTracking()
.Where( a => a.Attribute.Key == attributeKey && a.Value == attributeValue && a.Attribute.EntityTypeId == entityType.Id )
.Select(a => a.EntityId);
var workflows = new WorkflowService( rockContext )
.Queryable()
//.AsNoTracking()
.Where( w => w.WorkflowType.ActivityTypes.Any( a => a.Guid == activityType.Guid ) && workflowIds.Contains(w.Id) )
.ToList();
foreach (var workflow in workflows )
{
WorkflowActivity.Activate( activityType, workflow );
action.AddLogEntry( string.Format( "Activated new '{0}' activity in {1} {2}", activityType.ToString(), workflow.TypeName, workflow.WorkflowId ) );
}
return true;
}
示例10: 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 groupAttribute = GetAttributeValue( action, "GroupAttribute" );
Guid groupAttrGuid = groupAttribute.AsGuid();
if (!groupAttrGuid.IsEmpty())
{
string attributeGroupValue = action.GetWorklowAttributeValue( groupAttrGuid );
Guid groupGuid = attributeGroupValue.AsGuid();
var groupRoleAttr = GetAttributeValue( action, "Group Role" );
Guid groupRoleGuid = groupRoleAttr.AsGuid();
if (!groupRoleGuid.IsEmpty())
{
var groupM = (new GroupService( rockContext )).Get( groupGuid );
if (groupM != null)
{
var groupRole = (new GroupTypeRoleService( rockContext )).Get( groupRoleGuid );
var person = (from m in groupM.Members
where m.GroupRoleId == groupRole.Id
select m.Person).FirstOrDefault();
if (person != null)
{
action.Activity.AssignedPersonAlias = person.PrimaryAlias;
action.Activity.AssignedPersonAliasId = person.PrimaryAliasId;
action.Activity.AssignedGroup = null;
action.Activity.AssignedGroupId = null;
action.AddLogEntry( string.Format( "Assigned activity to '{0}' ({1})", person.FullName, person.Id ) );
return true;
}
else
{
action.AddLogEntry( string.Format( "Nobody assigned to Role ({0}) for Group ({1})", groupRole.Name, groupM.Name ) );
}
}
}
}
errorMessages.Add( "An assignment to person could not be completed." );
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>();
string attributeValue = GetAttributeValue( action, "Attribute" );
Guid guid = attributeValue.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 personAlias = new PersonAliasService( rockContext ).Get( guid );
if ( personAlias != null && personAlias.Person != null )
{
action.Activity.Workflow.SetAttributeValue( attribute.Key, value );
action.AddLogEntry( string.Format( "Set '{0}' attribute to '{1}'.", attribute.Name, personAlias.Person.FullName ) );
return true;
}
else
{
errorMessages.Add( string.Format( "Person could not be found for selected value ('{0}')!", guid.ToString() ) );
}
}
else
{
action.Activity.Workflow.SetAttributeValue( attribute.Key, string.Empty );
action.AddLogEntry( string.Format( "Set '{0}' attribute to nobody.", attribute.Name ) );
return true;
}
}
else
{
errorMessages.Add( string.Format( "Attribute could not be found for selected attribute value ('{0}')!", guid.ToString() ) );
}
}
else
{
errorMessages.Add( string.Format( "Selected attribute value ('{0}') was not a valid Guid!", attributeValue ) );
}
errorMessages.ForEach( m => action.AddLogEntry( m, true ) );
return true;
}
示例12: 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;
}
示例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 ( 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;
}
示例14: 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;
}
示例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 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;
}