static void OnWorkflowIdled(object sender, WorkflowEventArgs e) { WorkflowInstance workflow = e.WorkflowInstance; Console.WriteLine("\n...waiting for 3 seconds... \n"); Thread.Sleep(3000); // what activity is blocking the workflow ReadOnlyCollection<WorkflowQueueInfo> wqi = workflow.GetWorkflowQueueData(); foreach (WorkflowQueueInfo q in wqi) { EventQueueName eq = q.QueueName as EventQueueName; if (eq != null) { // get activity that is waiting for event ReadOnlyCollection<string> blockedActivity = q.SubscribedActivityNames; Console.WriteLine("Host: Workflow is blocked on " + blockedActivity[0]); // this event is never going to arrive eg. employee left the company // lets send an exception to this queue // it will either be handled by exception handler that was modeled in workflow // or the runtime will unwind running compensation handlers and exit the workflow Console.WriteLine("Host: This event is not going to arrive"); Console.WriteLine("Host: Cancel workflow with unhandled exception"); workflow.EnqueueItem(q.QueueName, new Exception("ExitWorkflowException"), null, null); } } }
static void OnWorkflowIdled(object sender, WorkflowEventArgs e) { WorkflowInstance workflowInstance = e.WorkflowInstance; Activity wRoot = workflowInstance.GetWorkflowDefinition(); // // use WorkflowChanges class to author dynamic change // WorkflowChanges changes = new WorkflowChanges(wRoot); Console.WriteLine(" Host is denying all PO requests - Removing POCreated step"); // // remove POCreated activity // changes.TransientWorkflow.Activities.Remove(changes.TransientWorkflow.Activities["POCreated"]); // // apply transient changes to instance // workflowInstance.ApplyWorkflowChanges(changes); }
// This method will be called when a workflow instance is idled static void OnWorkflowIdled(object sender, WorkflowEventArgs e) { orderService.instanceId = e.WorkflowInstance; // Randomly approve, reject or timeout purchase orders Random randGen = new Random(); int pick = randGen.Next(1, 100) % 3; switch (pick) { case 0: orderService.ApproveOrder(); break; case 1: orderService.RejectOrder(); break; case 2: // timeout break; } }
static void OnWorkflowIdle(object sender, WorkflowEventArgs e) { if (wasChanged) return; wasChanged = true; WorkflowInstance workflowInstance = e.WorkflowInstance; Int32 newAmount = 15000; Console.WriteLine("Dynamically change approved amount to {0:c}", newAmount); // Dynamic update of order rule WorkflowChanges workflowchanges = new WorkflowChanges(workflowInstance.GetWorkflowDefinition()); CompositeActivity transient = workflowchanges.TransientWorkflow; RuleDefinitions ruleDefinitions = (RuleDefinitions)transient.GetValue(RuleDefinitions.RuleDefinitionsProperty); RuleConditionCollection conditions = ruleDefinitions.Conditions; RuleExpressionCondition condition1 = (RuleExpressionCondition)conditions["Check"]; (condition1.Expression as CodeBinaryOperatorExpression).Right = new CodePrimitiveExpression(newAmount); workflowInstance.ApplyWorkflowChanges(workflowchanges); }
/// <summary> /// Handles the WorkflowStarted event of the WorkflowRuntime control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Workflow.Runtime.WorkflowEventArgs"/> instance containing the event data.</param> static void WorkflowRuntime_WorkflowStarted(object sender, WorkflowEventArgs e) { DateTime dateTimeNow = DataContext.Current.CurrentUserTimeZone.ToLocalTime(DateTime.UtcNow); WorkflowInstanceEntity wf = (WorkflowInstanceEntity)BusinessManager.Load(WorkflowInstanceEntity.ClassName, (PrimaryKeyId)e.WorkflowInstance.InstanceId); wf.ActualStartDate = dateTimeNow; wf.State = (int)BusinessProcessState.Active; BusinessManager.Update(wf); }
private void InstanceUnloaded(object sender, WorkflowEventArgs args) { // Treat this as if the instance completed so that it won't show up in the UI anymore. try { UnloadExistingInstance(args.WorkflowInstance); } catch { // Don't throw exceptions to the Runtime. Ignore exceptions that may occur if the debugger detaches // and closes the remoting channel. } }
void workflowRuntime_WorkflowIdled(object sender, WorkflowEventArgs e) { this.UpdateButtonStatus(); }
static void wr_WorkflowCreated(object sender, WorkflowEventArgs e) { Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine("Created:\t{0}, {1}", e.WorkflowInstance.InstanceId, e.WorkflowInstance.GetWorkflowDefinition().Name); Console.ResetColor(); }
private void _runtime_WorkflowCreated(object sender, WorkflowEventArgs e) { LogStatus(e.WorkflowInstance.InstanceId, "WorkflowCreated"); }
static void Runtime_WorkflowIdled(object sender, WorkflowEventArgs e) { //CurrentResultsInContext = WorkflowResults.CreateRunningWorkflowResults(e); }
static void OnWorkflowCreated(object sender, WorkflowEventArgs e) { ThreadMonitor.WriteToConsole(Thread.CurrentThread, "Host", "Host: Processed WorkflowCreated Event"); }
private WorkflowResults(WorkflowEventArgs args) { Check.ArgumentIsNotNull(args, "args"); InstanceId = args.WorkflowInstance.InstanceId; }
//public WorkflowResults CreateAbortedWorkflowResults(WorkflowEventArgs args) //{ // WorkflowResults results = new WorkflowResults(args); // results.Status = WorkflowStatus.Aborted; // return results; //} public static WorkflowResults CreateRunningWorkflowResults(WorkflowEventArgs args) { WorkflowResults results = new WorkflowResults(args); results.Status = WorkflowStatus.Running; return results; }
// Fired when the workflow is loaded from storage private void theWorkflowRuntime_WorkflowLoaded(object sender, WorkflowEventArgs e) { Trace.TraceInformation(string.Format( "Workflow report: The instance {0} is loading from storage.", e.WorkflowInstance.InstanceId)); }
private void theWorkflowRuntime_WorkflowIdled(object sender, WorkflowEventArgs e) { Trace.TraceInformation(string.Format( "Workflow report: The instance {0} is going idled.", e.WorkflowInstance.InstanceId)); ThreadPool.QueueUserWorkItem(UnloadInstance, e.WorkflowInstance); }
static void OnWorkflowResume(object sender, WorkflowEventArgs instance) { Console.WriteLine("\nWorkflow Resumed event raised"); }
static void Runtime_WorkflowAborted(object sender, WorkflowEventArgs e) { //CurrentResultsInContext = WorkflowResults.CreateAbortedWorkflowResults(e); }
static void OnWorkflowIdled(object sender, WorkflowEventArgs e) { if (workflowRuntime.GetService<ManualWorkflowSchedulerService>() != null) { // Set a system timer to reload this workflow when its next timer expires SetReloadWorkflowTimer(); } else { readyHandle.Set(); } ThreadMonitor.WriteToConsole(Thread.CurrentThread, "Host", "Host: Processed WorkflowIdle Event"); Console.WriteLine("\n--- Workflow Idle ---\n"); }
private static void OnWorkflowAborted(object sender, WorkflowEventArgs e) { Console.WriteLine("Workflow has been aborted."); waitHandle.Set(); }
private void LogWorkflowChange(string change, WorkflowEventArgs args, bool logUserName, bool workflowDefinitionAvailable, bool error) { WorkflowInstance instance = null; string activityTypeName = null; try { instance = args.WorkflowInstance; } catch { // Silent } if (workflowDefinitionAvailable && instance != null) { try { activityTypeName = instance.GetWorkflowDefinition().GetType().FullName; } catch { // Silent } } var message = new StringBuilder("Workflow ").Append(change); if (activityTypeName != null) { message.Append(", Activity = " + activityTypeName); } if (instance != null) { message.Append(", Id = " + instance.InstanceId); } if (logUserName) { string identity = UserValidationFacade.IsLoggedIn() ? UserValidationFacade.GetUsername() : "(system process)"; message.Append(", User = " + identity); } if (!error) { Log.LogVerbose(LogTitle, message.ToString()); } else { Log.LogError(LogTitle, message.ToString()); } }
private void _runtime_WorkflowAborted(object sender, WorkflowEventArgs e) { LogStatus(e.WorkflowInstance.InstanceId, "WorkflowAborted"); //ManagedWorkflowInstance managedInstance = FindWorkflow(e.WorkflowInstance.InstanceId); //if (managedInstance != null) //{ // managedInstance.StopWaiting(); //} }
// Called when a workflow is started static void OnWorkflowStarted(object sender, WorkflowEventArgs e) { Console.WriteLine("Workflow started.\n"); }
static void wr_WorkflowIdled(object sender, WorkflowEventArgs e) { Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine("Idled:\t\t{0}", e.WorkflowInstance.InstanceId); Console.ResetColor(); }
//Called when the workflow is persisted - in this sample when it is unloaded and completed static void OnWorkflowPersisted(object sender, WorkflowEventArgs e) { Console.WriteLine("Workflow was persisted."); }
static void OnWorkflowIdled(object sender, WorkflowEventArgs e) { // Raise the DocumentApproved event Console.WriteLine("\nHost: RaiseDocumentApproval event to load workflow"); documentApprover.RaiseDocumentApproved(e.WorkflowInstance.InstanceId, "Approver1"); }
//Called when the workflow is idle - in this sample this occurs when the workflow is waiting on the // delay1 activity to expire. static void OnWorkflowIdled(object sender, WorkflowEventArgs e) { Console.WriteLine("Workflow is idle."); e.WorkflowInstance.TryUnload(); }
private void InstanceTerminated(object sender, WorkflowEventArgs args) { try { UnloadExistingInstance(args.WorkflowInstance); } catch { // Don't throw exceptions to the Runtime. Ignore exceptions that may occur if the debugger detaches // and closes the remoting channel. } }
static void OnWorkflowAborted(object sender, WorkflowEventArgs e) { Console.WriteLine("Workflow aborted: Please check database connectivity"); waitHandle.Set(); }
private void Runtime_WorkflowIdled(object sender, WorkflowEventArgs e) { // Get the underlying WorkflowInstance StateMachineWorkflowInstance stateMachineInstance = new StateMachineWorkflowInstance(runtime, e.WorkflowInstance.InstanceId); // Update the Workflow State & Status on the ListItem this.UpdateListItem(stateMachineInstance.WorkflowInstance,stateMachineInstance.CurrentState.Name, "Running"); // Update the status of the buttons for the selected ListItem this.UpdateUI(); }
//Called when the workflow is unloaded from memory - in this sample the workflow instance is unloaded by the application // in the UnloadInstance method below. static void OnWorkflowUnloaded(object sender, WorkflowEventArgs e) { Console.WriteLine("Workflow was unloaded."); }