本文整理汇总了C#中WorkflowRuntime.GetWorkflow方法的典型用法代码示例。如果您正苦于以下问题:C# WorkflowRuntime.GetWorkflow方法的具体用法?C# WorkflowRuntime.GetWorkflow怎么用?C# WorkflowRuntime.GetWorkflow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorkflowRuntime
的用法示例。
在下文中一共展示了WorkflowRuntime.GetWorkflow方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StateMachineWorkflowInstance
public StateMachineWorkflowInstance(WorkflowRuntime runtime, Guid instanceId)
{
if (runtime == null)
throw new ArgumentNullException("runtime");
if (instanceId == Guid.Empty)
throw new ArgumentNullException("instanceId");
_runtime = runtime;
_instanceId = instanceId;
_workflowInstance = runtime.GetWorkflow(instanceId);
_stateMachineWorkflow = _workflowInstance.GetWorkflowDefinition() as StateMachineWorkflowActivity;
if (_stateMachineWorkflow == null)
throw new ArgumentException(SR.GetStateMachineWorkflowRequired(), "instanceId");
}
示例2: UpgradeWorkflow
public void UpgradeWorkflow(WorkflowRuntime runtime, Guid instanceId)
{
WorkflowInstance workflowInstance = runtime.GetWorkflow(instanceId);
var definition = workflowInstance.GetWorkflowDefinition();
if (!OldAssemblyNames.Contains(definition.GetType().Assembly.FullName))
return;
lock (GetLockForWorkflow(instanceId))
{
workflowInstance.Unload();
var are = new AutoResetEvent(false);
var parameters = new Dictionary<string, object>();
//Получаем перзистанс и извлекаем состояние
var persistance = runtime.GetService<NotTerminatingSqlWorkflowPersistenceService>();
persistance.OnArgsAllowed +=
delegate(object sender, NotTerminatingSqlWorkflowPersistenceService.WorkflowSavedParametersArgs e)
{
if (e.InstanceId == instanceId)
{
parameters = e.Parameters;
are.Set();
}
};
workflowInstance = runtime.GetWorkflow(instanceId);
definition = workflowInstance.GetWorkflowDefinition();
if (!OldAssemblyNames.Contains(definition.GetType().Assembly.FullName))
//Если версия изменилась то дальнейшие манипуляции не нужны
return;
are.WaitOne(10000);
workflowInstance.Unload();
using (var context = this.CreateContext())
{
context.DeleteWorkflowInPesistenceStore(instanceId);
context.SubmitChanges();
}
var workflowState = WorkflowStateService.GetWorkflowState(instanceId);
parameters.Add(StateMachineWithSimpleContainer.DontWriteToWorkflowHistoryPersistenceKey, true);
using (var sync = new WorkflowSync(runtime, instanceId))
{
if (!CreateWorkflowIfNotExists(runtime, instanceId, workflowState.Type, parameters))
//Это ожидание создания воркфлоу
{
sync.WaitHandle.WaitOne(600000);
}
}
var wfinstance = new StateMachineWorkflowInstance(runtime, instanceId);
using (var sync = new WorkflowSync(runtime, instanceId))
//Это ожидание завершения установки состояния воркфлоу
{
wfinstance.SetState(workflowState.WorkflowStateName);
sync.WaitHandle.WaitOne(600000);
}
var args = new SetWorkflowInternalParametersEventArgs(instanceId,
new Dictionary<string, object>()
{
{
StateMachineWithSimpleContainer.
DontWriteToWorkflowHistoryPersistenceKey
,
false
}
});
SetInternalParameters(null, args);
}
}
示例3: CreateWorkflowIfNotExists
public bool CreateWorkflowIfNotExists(WorkflowRuntime runtime, Guid instanceId, WorkflowType workflowType,Dictionary<string,object> parameters)
{
try
{
var workflow = runtime.GetWorkflow(instanceId);
return true;
}
catch (Exception)
{
}
WorkflowInstance instance = null;
var wfparameters = new Dictionary<string, object>();
if (parameters != null)
wfparameters = new Dictionary<string, object>(1) {{"WorkflowPersistanceParameters", parameters}};
if (workflowType == WorkflowType.BillDemandWorkfow)
instance = runtime.CreateWorkflow(typeof(BillDemand), wfparameters,
instanceId);
else if (workflowType == WorkflowType.DemandAdjustmentWorkflow)
instance = runtime.CreateWorkflow(typeof(DemandAdjustment), wfparameters,
instanceId);
else if (workflowType == WorkflowType.DemandWorkflow)
instance = runtime.CreateWorkflow(typeof(Demand), wfparameters,
instanceId);
else
throw new InvalidOperationException("Невозможно определить тип маршрута");
instance.Start();
return false;
//TODO Синхронизация и класс синхронизатор
}
示例4: GetWorkflowInstance
/// <summary>
/// 从持久化库在恢复实例
/// </summary>
/// <param name="WfRuntime"></param>
/// <param name="INSTANCEID"></param>
/// <returns></returns>
public static WorkflowInstance GetWorkflowInstance(WorkflowRuntime WfRuntime, string INSTANCEID)
{
try
{
if (!WfRuntime.IsStarted)
{
WfRuntime.StartRuntime();
}
WorkflowInstance instance = WfRuntime.GetWorkflow(new Guid(INSTANCEID));
//WfRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e)
//{
// instance = null;
//};
return instance;
}
catch (Exception ex)
{
LogHelper.WriteLog("实例ID instanceid=" + INSTANCEID + " ;GetWorkflowInstance异常信息 :" + ex.ToString());
throw new Exception(ex.Message);
}
}
示例5: GetInstanceNoRuntimeStarted
public void GetInstanceNoRuntimeStarted ()
{
// This operation can only be performed with a started WorkflowRuntime
WorkflowRuntime wr = new WorkflowRuntime ();
wr.GetWorkflow (Guid.NewGuid ());
}