本文整理汇总了C#中System.Activities.WorkflowApplication.AddInitialInstanceValues方法的典型用法代码示例。如果您正苦于以下问题:C# WorkflowApplication.AddInitialInstanceValues方法的具体用法?C# WorkflowApplication.AddInitialInstanceValues怎么用?C# WorkflowApplication.AddInitialInstanceValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Activities.WorkflowApplication
的用法示例。
在下文中一共展示了WorkflowApplication.AddInitialInstanceValues方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WorkflowService
public WorkflowService(
IUsersService users
)
{
_users = users;
T = NullLocalizer.Instance;
Logger = NullLogger.Instance;
SqlWorkflowInstanceStore store = new SqlWorkflowInstanceStore(_users.ApplicationConnectionString);
_wfApp = new WorkflowApplication(new XODB.Workflow.AssignResponsibility());
_wfApp.InstanceStore = store;
XName wfHostTypeName = XName.Get("XODB", _users.ApplicationID.ToString());
Dictionary<XName, object> wfScope = new Dictionary<XName, object> { { workflowHostTypePropertyName, wfHostTypeName } };
_wfApp.AddInitialInstanceValues(wfScope);
_wfApp.Extensions.Add(new ResponsibilityExtension());
List<XName> variantProperties = new List<XName>()
{
ResponsibilityExtension.xNS.GetName("CompanyID"),
ResponsibilityExtension.xNS.GetName("ContactID")
};
store.Promote("Responsibility", variantProperties, null);
InstanceHandle handle = store.CreateInstanceHandle(null);
var cmd = new CreateWorkflowOwnerCommand
{
InstanceOwnerMetadata =
{
{workflowHostTypePropertyName, new InstanceValue(wfHostTypeName)}
}
};
InstanceOwner owner = store.Execute(handle, cmd, TimeSpan.MaxValue).InstanceOwner;
store.DefaultInstanceOwner = owner;
handle.Free();
_wfApp.PersistableIdle = delegate(WorkflowApplicationIdleEventArgs e)
{
return PersistableIdleAction.Persist;
};
_wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
{
if (System.Diagnostics.Debugger.IsAttached)
{
foreach (var item in e.Outputs)
{
System.Diagnostics.Debug.WriteLine("Variable:{0} has value: {1}", item.Key, item.Value);
}
}
};
var trackingParticipant = new TrackingHelper.DebugTrackingParticipant
{
TrackingProfile = TrackingHelper.SimpleProfile
};
_wfApp.Extensions.Add(trackingParticipant);
}
示例2: CreateWorkflowApplication
// Creates and configures a new instance of WorkflowApplication
private static WorkflowApplication CreateWorkflowApplication(Activity rootActivity, InstanceStore store, XName wfHostTypeName)
{
WorkflowApplication wfApp = new WorkflowApplication(rootActivity);
wfApp.InstanceStore = store;
Dictionary<XName, object> wfScope = new Dictionary<XName, object>
{
{ WorkflowHostTypePropertyName, wfHostTypeName }
};
// Add the WorkflowHostType value to workflow application so that it stores this data in the instance store when persisted
wfApp.AddInitialInstanceValues(wfScope);
// This statement is optional (see the comments in AbsoluteDelay.CacheMetadata details for more info).
// wfApp.Extensions.Add<DurableTimerExtension>(() => new DurableTimerExtension());
// For demonstration purposes the workflow is unloaded as soon as it is idle (and able to persist)
wfApp.PersistableIdle = delegate(WorkflowApplicationIdleEventArgs idleArgs)
{
Console.WriteLine("Workflow unloading...");
return PersistableIdleAction.Unload;
};
// Configure some tracing and synchronization for the other WorkflowApplication events
wfApp.Unloaded = delegate(WorkflowApplicationEventArgs eargs)
{
if (!workflowCompleted)
{
Console.WriteLine("Workflow unloaded");
}
else
{
Console.WriteLine("Workflow unloaded after completing");
}
workflowUnloadedEvent.Set();
};
wfApp.Completed = delegate
{
Console.WriteLine("Workflow completed");
workflowCompleted = true;
};
wfApp.Aborted = delegate(WorkflowApplicationAbortedEventArgs abortArgs)
{
Console.WriteLine("Workflow aborted (expected in this sample)");
};
return wfApp;
}
示例3: CreateWorkflowApplication
private static WorkflowApplication CreateWorkflowApplication(WorkflowHandlerBase workflowInstance, WorkflowApplicationCreationPurpose purpose,
IDictionary<string, object> parameters)
{
string version;
WorkflowApplication wfApp = null;
var workflow = workflowInstance.CreateWorkflowInstance(out version);
switch (purpose)
{
case WorkflowApplicationCreationPurpose.StartNew:
Dictionary<string, object> arguments = workflowInstance.CreateParameters();
arguments.Add(STATECONTENT, new WfContent(workflowInstance));
if (parameters != null)
foreach (var item in parameters)
arguments.Add(item.Key, item.Value);
wfApp = new WorkflowApplication(workflow, arguments);
workflowInstance.WorkflowDefinitionVersion = version;
workflowInstance.WorkflowInstanceGuid = wfApp.Id.ToString();
break;
default:
wfApp = new WorkflowApplication(workflow);
break;
}
var store = CreateInstanceStore(workflowInstance);
Dictionary<XName, object> wfScope = new Dictionary<XName, object>
{
{ GetWorkflowHostTypePropertyName(), GetWorkflowHostTypeName(workflowInstance) }
};
wfApp.InstanceStore = store;
wfApp.AddInitialInstanceValues(wfScope);
wfApp.PersistableIdle = a => { Debug.WriteLine("##WF> Pidle"); return PersistableIdleAction.Unload; };
wfApp.Unloaded = b => { Debug.WriteLine("##WF> Unload"); };
wfApp.Completed = OnWorkflowCompleted;
wfApp.Aborted = OnWorkflowAborted;
wfApp.OnUnhandledException = HandleError;
wfApp.Extensions.Add(new ContentWorkflowExtension() { WorkflowInstancePath = workflowInstance.Path });
return wfApp;
}