コード例 #1
0
ファイル: Program.cs プロジェクト: spzenk/sfdocsamples
        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);
                }
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: ssickles/archive
        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);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: spzenk/sfdocsamples
        // 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;
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: ssickles/archive
        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);
        }
コード例 #5
0
ファイル: GlobalWorkflowRuntime.cs プロジェクト: 0anion0/IBN
        /// <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);
        }
コード例 #6
0
 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.
     }
 }
コード例 #7
0
ファイル: Form1.cs プロジェクト: spzenk/sfdocsamples
 void workflowRuntime_WorkflowIdled(object sender, WorkflowEventArgs e)
 {
     this.UpdateButtonStatus();
 }
コード例 #8
0
ファイル: Program.cs プロジェクト: spzenk/sfdocsamples
 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();
 }
コード例 #9
0
 private void _runtime_WorkflowCreated(object sender, WorkflowEventArgs e)
 {
     LogStatus(e.WorkflowInstance.InstanceId, "WorkflowCreated");
 }
コード例 #10
0
ファイル: WorkflowMediator.cs プロジェクト: UrviGandhi/IGRSS
 static void Runtime_WorkflowIdled(object sender, WorkflowEventArgs e)
 {
     //CurrentResultsInContext = WorkflowResults.CreateRunningWorkflowResults(e);
 }
コード例 #11
0
ファイル: Program.cs プロジェクト: spzenk/sfdocsamples
 static void OnWorkflowCreated(object sender, WorkflowEventArgs e)
 {
     ThreadMonitor.WriteToConsole(Thread.CurrentThread, "Host", "Host: Processed WorkflowCreated Event");
 }
コード例 #12
0
ファイル: WorkflowResults.cs プロジェクト: UrviGandhi/IGRSS
 private WorkflowResults(WorkflowEventArgs args)
 {
     Check.ArgumentIsNotNull(args, "args");
     InstanceId = args.WorkflowInstance.InstanceId;
 }
コード例 #13
0
ファイル: WorkflowResults.cs プロジェクト: UrviGandhi/IGRSS
 //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;
 }
コード例 #14
0
ファイル: LinqWikiProvider.cs プロジェクト: kohku/codefactory
 // 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));
 }
コード例 #15
0
ファイル: LinqWikiProvider.cs プロジェクト: kohku/codefactory
 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);
 }
コード例 #16
0
ファイル: Program.cs プロジェクト: spzenk/sfdocsamples
 static void OnWorkflowResume(object sender, WorkflowEventArgs instance)
 {
     Console.WriteLine("\nWorkflow Resumed event raised");
 }
コード例 #17
0
ファイル: WorkflowMediator.cs プロジェクト: UrviGandhi/IGRSS
 static void Runtime_WorkflowAborted(object sender, WorkflowEventArgs e)
 {
     //CurrentResultsInContext = WorkflowResults.CreateAbortedWorkflowResults(e);
 }
コード例 #18
0
ファイル: Program.cs プロジェクト: spzenk/sfdocsamples
        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");
        }
コード例 #19
0
ファイル: Program.cs プロジェクト: spzenk/sfdocsamples
 private static void OnWorkflowAborted(object sender, WorkflowEventArgs e)
 {
     Console.WriteLine("Workflow has been aborted.");
     waitHandle.Set();
 }
コード例 #20
0
        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());
            }
        }
コード例 #21
0
 private void _runtime_WorkflowAborted(object sender, WorkflowEventArgs e)
 {
     LogStatus(e.WorkflowInstance.InstanceId, "WorkflowAborted");
     //ManagedWorkflowInstance managedInstance = FindWorkflow(e.WorkflowInstance.InstanceId);
     //if (managedInstance != null)
     //{
     //    managedInstance.StopWaiting();
     //}
 }
コード例 #22
0
ファイル: Program.cs プロジェクト: ssickles/archive
 // Called when a workflow is started
 static void OnWorkflowStarted(object sender, WorkflowEventArgs e)
 {
     Console.WriteLine("Workflow started.\n");
 }
コード例 #23
0
ファイル: Program.cs プロジェクト: spzenk/sfdocsamples
 static void wr_WorkflowIdled(object sender, WorkflowEventArgs e)
 {
     Console.ForegroundColor = ConsoleColor.DarkYellow;
     Console.WriteLine("Idled:\t\t{0}", e.WorkflowInstance.InstanceId);
     Console.ResetColor();
 }
コード例 #24
0
ファイル: Program.cs プロジェクト: spzenk/sfdocsamples
 //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.");
 }
コード例 #25
0
ファイル: Program.cs プロジェクト: ssickles/archive
 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");
 }
コード例 #26
0
ファイル: Program.cs プロジェクト: spzenk/sfdocsamples
 //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();
 }
コード例 #27
0
 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.
     }
 }
コード例 #28
0
ファイル: Program.cs プロジェクト: spzenk/sfdocsamples
 static void OnWorkflowAborted(object sender, WorkflowEventArgs e)
 {
     Console.WriteLine("Workflow aborted: Please check database connectivity");
     waitHandle.Set();
 }
コード例 #29
0
ファイル: Mainform.cs プロジェクト: spzenk/sfdocsamples
        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();
        }
コード例 #30
0
ファイル: Program.cs プロジェクト: spzenk/sfdocsamples
 //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.");
 }