/// <summary> /// Removes the activity. /// </summary> /// <param name="instanceId">The instance id.</param> /// <param name="parentActivity">The parent activity.</param> /// <param name="activityQualifiedName">Name of the activity qualified.</param> public static void RemoveActivity(object parentActivity, string activityQualifiedName) { CompositeActivity parent = parentActivity as CompositeActivity; if (parent == null) { throw new ArgumentException("The parent activity should be CompositeActivity.", "parentActivity"); } Activity activity = parent.GetActivityByName(activityQualifiedName); if (activity != null) { parent.Activities.Remove(activity); } // OZ Addon Alpply Modification to Workflow Instance //if (instanceId != Guid.Empty) //{ // try // { // //Guid instanceId = Guid.NewGuid(); // WorkflowInstance instance = GlobalWorkflowRuntime.WorkflowRuntime.GetWorkflow(instanceId); // Activity root = instance.GetWorkflowDefinition(); // WorkflowChanges wc = new WorkflowChanges(root); // CompositeActivity tmpParent = (CompositeActivity)wc.TransientWorkflow.GetActivityByName(parent.QualifiedName); // Activity tmpChild = wc.TransientWorkflow.GetActivityByName(activity.QualifiedName); ; // tmpParent.Activities.Remove(tmpChild); // instance.ApplyWorkflowChanges(wc); // } // catch (Exception ex) // { // System.Diagnostics.Trace.WriteLine(ex.ToString()); // } //} // End }
internal static Activity FindActivityByName(CompositeActivity parentActivity, string qualifiedName) { return(parentActivity.GetActivityByName(qualifiedName, true)); }