/// <summary> /// To the model. /// </summary> /// <param name="value">The value.</param> /// <returns></returns> public static WorkflowActivity ToModel(this WorkflowActivityDto value) { WorkflowActivity result = new WorkflowActivity(); value.CopyToModel(result); return(result); }
/// <summary> /// Activates the specified <see cref="Rock.Model.WorkflowType" />. /// </summary> /// <param name="workflowType">The <see cref="Rock.Model.WorkflowType" /> being activated.</param> /// <param name="name">A <see cref="System.String" /> representing the name of the <see cref="Rock.Model.Workflow" /> instance.</param> /// <param name="rockContext">The rock context.</param> /// <returns> /// The <see cref="Rock.Model.Workflow" /> instance. /// </returns> public static Workflow Activate(WorkflowType workflowType, string name, RockContext rockContext) { var workflow = new Workflow(); workflow.WorkflowType = workflowType; workflow.WorkflowTypeId = workflowType.Id; if (!string.IsNullOrWhiteSpace(name)) { workflow.Name = name; } else { workflow.Name = workflowType.Name; } workflow.Status = "Active"; workflow.IsProcessing = false; workflow.ActivatedDateTime = RockDateTime.Now; workflow.LoadAttributes(rockContext); workflow.AddLogEntry("Activated"); foreach (var activityType in workflowType.ActivityTypes.OrderBy(a => a.Order)) { if (activityType.IsActivatedWithWorkflow) { WorkflowActivity.Activate(activityType, workflow, rockContext); } } return(workflow); }
/// <summary> /// Activates the specified WorkflowActivity /// </summary> /// <param name="activityTypeCache">The activity type cache.</param> /// <param name="workflow">The persisted <see cref="Rock.Model.Workflow" /> instance that this Workflow activity belongs to.</param> /// <param name="rockContext">The rock context.</param> /// <returns> /// The activated <see cref="Rock.Model.WorkflowActivity" />. /// </returns> public static WorkflowActivity Activate(WorkflowActivityTypeCache activityTypeCache, Workflow workflow, RockContext rockContext) { if (!workflow.IsActive) { return(null); } var activity = new WorkflowActivity(); activity.Workflow = workflow; activity.ActivityTypeId = activityTypeCache.Id; activity.ActivatedDateTime = RockDateTime.Now; activity.LoadAttributes(rockContext); activity.AddLogEntry("Activated"); foreach (var actionType in activityTypeCache.ActionTypes) { activity.Actions.Add(WorkflowAction.Activate(actionType, activity, rockContext)); } workflow.Activities.Add(activity); return(activity); }
internal static WorkflowAction Activate(WorkflowActionType actionType, WorkflowActivity activity) { using (var rockContext = new RockContext()) { return(Activate(actionType, activity, rockContext)); } }
/// <summary> /// Copies the properties from another WorkflowActivity object to this WorkflowActivity object /// </summary> /// <param name="target">The target.</param> /// <param name="source">The source.</param> public static void CopyPropertiesFrom(this WorkflowActivity target, WorkflowActivity source) { target.WorkflowId = source.WorkflowId; target.ActivityTypeId = source.ActivityTypeId; target.ActivatedDateTime = source.ActivatedDateTime; target.LastProcessedDateTime = source.LastProcessedDateTime; target.CompletedDateTime = source.CompletedDateTime; target.Id = source.Id; target.Guid = source.Guid; }
/// <summary> /// Activates the specified action type. /// </summary> /// <param name="actionType">Type of the action.</param> /// <param name="activity">The activity.</param> /// <returns></returns> internal static WorkflowAction Activate(WorkflowActionType actionType, WorkflowActivity activity) { var action = new WorkflowAction(); action.Activity = activity; action.ActionType = actionType; action.AddSystemLogEntry("Activated"); return(action); }
/// <summary> /// Activates the specified <see cref="Rock.Model.WorkflowAction" />. /// </summary> /// <param name="actionType">The <see cref="Rock.Model.WorkflowActionType" /> to be activated.</param> /// <param name="activity">The <see cref="Rock.Model.WorkflowActivity" /> that this WorkflowAction belongs to..</param> /// <param name="rockContext">The rock context.</param> /// <returns> /// The <see cref="Rock.Model.WorkflowAction" /> /// </returns> internal static WorkflowAction Activate(WorkflowActionType actionType, WorkflowActivity activity, RockContext rockContext) { var action = new WorkflowAction(); action.Activity = activity; action.ActionType = actionType; action.LoadAttributes(rockContext); action.AddLogEntry("Activated"); return(action); }
/// <summary> /// Clones this WorkflowActivity object to a new WorkflowActivity object /// </summary> /// <param name="source">The source.</param> /// <param name="deepCopy">if set to <c>true</c> a deep copy is made. If false, only the basic entity properties are copied.</param> /// <returns></returns> public static WorkflowActivity Clone(this WorkflowActivity source, bool deepCopy) { if (deepCopy) { return(source.Clone() as WorkflowActivity); } else { var target = new WorkflowActivity(); target.CopyPropertiesFrom(source); return(target); } }
internal static WorkflowAction Activate(WorkflowActionType actionType, WorkflowActivity activity, RockContext rockContext) { if (actionType != null) { var actionTypeCache = WorkflowActionTypeCache.Get(actionType.Id); var action = Activate(actionTypeCache, activity, rockContext); if (action != null) { action.ActionType = actionType; } return(action); } return(null); }
/// <summary> /// Copies the properties from another WorkflowActivity object to this WorkflowActivity object /// </summary> /// <param name="target">The target.</param> /// <param name="source">The source.</param> public static void CopyPropertiesFrom(this WorkflowActivity target, WorkflowActivity source) { target.Id = source.Id; target.ActivatedByActivityId = source.ActivatedByActivityId; target.ActivatedDateTime = source.ActivatedDateTime; target.ActivityTypeId = source.ActivityTypeId; target.AssignedGroupId = source.AssignedGroupId; target.AssignedPersonAliasId = source.AssignedPersonAliasId; target.CompletedDateTime = source.CompletedDateTime; target.LastProcessedDateTime = source.LastProcessedDateTime; target.WorkflowId = source.WorkflowId; target.CreatedDateTime = source.CreatedDateTime; target.ModifiedDateTime = source.ModifiedDateTime; target.CreatedByPersonAliasId = source.CreatedByPersonAliasId; target.ModifiedByPersonAliasId = source.ModifiedByPersonAliasId; target.Guid = source.Guid; target.ForeignId = source.ForeignId; }
/// <summary> /// Activates the specified workflow type. /// </summary> /// <param name="workflowType">Type of the workflow.</param> /// <param name="name">The name.</param> /// <returns></returns> internal static Workflow Activate(WorkflowType workflowType, string name) { var workflow = new Workflow(); workflow.WorkflowTypeId = workflowType.Id; workflow.Name = name; workflow.Status = "Activated"; workflow.IsProcessing = false; workflow.ActivatedDateTime = DateTime.Now; workflow.AddSystemLogEntry("Activated"); foreach (var activityType in workflowType.ActivityTypes.OrderBy(a => a.Order)) { if (activityType.IsActivatedWithWorkflow) { workflow.Activities.Add(WorkflowActivity.Activate(activityType, workflow)); } } return(workflow); }
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)); } }
/// <summary> /// Instantiates a new DTO object from the entity /// </summary> /// <param name="workflowActivity"></param> public WorkflowActivityDto(WorkflowActivity workflowActivity) { CopyFromModel(workflowActivity); }
/// <summary> /// To the dto. /// </summary> /// <param name="value">The value.</param> /// <returns></returns> public static WorkflowActivityDto ToDto(this WorkflowActivity value) { return(new WorkflowActivityDto(value)); }