/// <summary>
        /// Terminates the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        protected virtual void Terminate(BusinessContext context)
        {
            // Load WorkflowInstanceEntity
            WorkflowInstanceEntity wf = (WorkflowInstanceEntity)BusinessManager.Load(WorkflowInstanceEntity.ClassName, context.GetTargetPrimaryKeyId().Value);

            // Check Wf State
            if (wf.State != (int)BusinessProcessState.Active)
            {
                throw new InvalidOperationException();
            }

            WorkflowInstance instance = GlobalWorkflowRuntime.WorkflowRuntime.GetWorkflow((Guid)wf.PrimaryKeyId.Value);

            instance.Terminate("Cancel by user");
            GlobalWorkflowRuntime.RunWorkflow(instance);

            //wf.State = (int)BusinessProcessState.Completed;
            //wf.ExecutionResult = (int)BusinessProcessExecutionResult.Canceled;

            //BusinessManager.Update(wf);
        }