本文整理汇总了C#中System.Activities.WorkflowApplication类的典型用法代码示例。如果您正苦于以下问题:C# WorkflowApplication类的具体用法?C# WorkflowApplication怎么用?C# WorkflowApplication使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WorkflowApplication类属于System.Activities命名空间,在下文中一共展示了WorkflowApplication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run()
{
this.workflowDesigner.Flush();
MemoryStream ms = new MemoryStream(ASCIIEncoding.Default.GetBytes(this.workflowDesigner.Text));
DynamicActivity activityToRun = ActivityXamlServices.Load(ms) as DynamicActivity;
this.workflowApplication = new WorkflowApplication(activityToRun);
this.workflowApplication.Extensions.Add(this.output);
this.workflowApplication.Completed = this.WorkflowCompleted;
this.workflowApplication.Aborted = this.WorkflowAborted;
this.workflowApplication.OnUnhandledException = this.WorkflowUnhandledException;
StatusViewModel.SetStatusText(Resources.RunningStatus, this.workflowName);
try
{
this.running = true;
this.workflowApplication.Run();
}
catch (Exception e)
{
this.output.WriteLine(ExceptionHelper.FormatStackTrace(e));
StatusViewModel.SetStatusText(Resources.ExceptionStatus, this.workflowName);
this.running = false;
}
}
示例2: LoadAndCompleteInstance
static void LoadAndCompleteInstance()
{
string input = Console.ReadLine();
WorkflowApplication application = new WorkflowApplication(activity);
application.InstanceStore = instanceStore;
application.Completed = (workflowApplicationCompletedEventArgs) =>
{
Console.WriteLine("\nWorkflowApplication has Completed in the {0} state.", workflowApplicationCompletedEventArgs.CompletionState);
};
application.Unloaded = (workflowApplicationEventArgs) =>
{
Console.WriteLine("WorkflowApplication has Unloaded\n");
instanceUnloaded.Set();
};
application.Load(id);
//this resumes the bookmark setup by readline
application.ResumeBookmark(readLineBookmark, input);
instanceUnloaded.WaitOne();
}
示例3: Main
static void Main(string[] args)
{
var connStr = @"Data Source=.\sqlexpress;Initial Catalog=WorkflowInstanceStore;Integrated Security=True;Pooling=False";
SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore(connStr);
Workflow1 w = new Workflow1();
//instanceStore.
//IDictionary<string, object> xx=WorkflowInvoker.Invoke(new Workflow1());
//ICollection<string> keys=xx.Keys;
WorkflowApplication a = new WorkflowApplication(w);
a.InstanceStore = instanceStore;
a.GetBookmarks();
//a.ResumeBookmark("Final State", new object());
a.Run();
//a.ResumeBookmark(
//a.Persist();
//a.Unload();
//Guid id = a.Id;
//WorkflowApplication b = new WorkflowApplication(w);
//b.InstanceStore = instanceStore;
//b.Load(id);
//WorkflowApplication a=new WorkflowApplication(
}
示例4: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
//设置参数
Dictionary<string,object> para=new Dictionary<string, object>();
CrowdTask task = new CrowdTask(TextBox1.Text,TextBox2.Text);
para.Add("task", task);
//启动工作流
WorkflowApplication crowdsourcing = new WorkflowApplication(new mainTask1(),para);
task.taskType= TaskType.mainTask;
crowdsourcing.Run();
task.taskWorkflowId = crowdsourcing.Id.ToString();
try
{
crowdTaskService = new CrowdTaskService();
int result = crowdTaskService.insert(task);
if(result==1){
//插入成功,保存对应的工作流实例
MyWorkflowInstance.setWorkflowApplication(crowdsourcing.Id.ToString(),crowdsourcing);
crowdTaskService.mainTaskSetCrowdTaskMainTaskIdByWorkflowId(crowdsourcing.Id.ToString());
Server.Transfer("viewMyTask.aspx?workflowId=" + task.taskWorkflowId);
}
}
catch (Exception exception)
{
throw exception ;
}
}
示例5: RunWorkflow
// resume execution of a workflow instance
static void RunWorkflow(WorkflowApplication application, AutoResetEvent resetEvent)
{
application.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
{
Console.WriteLine("Workflow completed in state " + e.CompletionState);
if (e.TerminationException != null)
{
Console.WriteLine("Termination exception: " + e.TerminationException);
}
Console.WriteLine("-------------------------------");
Console.WriteLine("- Input has been written to {0}\\out.txt", Environment.CurrentDirectory);
Console.WriteLine("-------------------------------");
resetEvent.Set();
};
application.Unloaded = delegate(WorkflowApplicationEventArgs e)
{
Console.WriteLine("Workflow unloaded");
resetEvent.Set();
};
application.Run();
}
示例6: Add
/// <summary>
/// Adds a new WorkflowApplication to the cache
/// </summary>
/// <param name="application">
/// The application.
/// </param>
/// <returns>
/// The WorkflowApplication that was added or updated
/// </returns>
public WorkflowApplication Add(WorkflowApplication application)
{
Debug.Assert(this.dictionary != null, "dictionary != null");
var observer = new WorkflowApplicationObserver(application) { Aborted = this.Aborted };
return this.dictionary.AddOrUpdate(
application.Id, guid => application, (guid, workflowApplication) => application);
}
示例7: Main
/*
* Enable Analytic and Debug Logs:
* Event Viewer -> Applications and Services Logs ->
* Microsoft -> Windows -> Application Server-Applications
* Right-click "Application Server-Applications" -> select View ->
* Show Analytic and Debug Logs -> Refresh
* */
static void Main(string[] args)
{
//Tracking Configuration
TrackingProfile trackingProfile = new TrackingProfile();
trackingProfile.Queries.Add(new WorkflowInstanceQuery
{
States = { "*" }
});
trackingProfile.Queries.Add(new ActivityStateQuery
{
States = { "*" }
});
trackingProfile.Queries.Add(new CustomTrackingQuery
{
ActivityName = "*",
Name = "*"
});
EtwTrackingParticipant etwTrackingParticipant =
new EtwTrackingParticipant();
etwTrackingParticipant.TrackingProfile = trackingProfile;
// Run workflow app "Workflow1.xaml"
AutoResetEvent waitHandler = new AutoResetEvent(false);
WorkflowApplication wfApp =
new WorkflowApplication(new Workflow1());
wfApp.Completed = (arg) => { waitHandler.Set(); };
wfApp.Extensions.Add(etwTrackingParticipant);
wfApp.Run();
waitHandler.WaitOne();
}
示例8: AnyActivityInstanceStateFindsClosed
public void AnyActivityInstanceStateFindsClosed()
{
// Arrange
var activity = new AddToNumOrThrow();
dynamic args = new WorkflowArguments();
args.Num = 2;
var host = new WorkflowApplication(activity, args);
var tracking = new ListTrackingParticipant();
host.Extensions.Add(tracking);
try
{
host.RunEpisode();
// Act
var any = tracking.Records.Any(ActivityInstanceState.Closed);
// Assert
Assert.IsTrue(any);
}
finally
{
tracking.Trace();
}
}
示例9: Main
static void Main(string[] args)
{
WorkflowApplication wfApplication = new WorkflowApplication(new Activity1());
SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore(ConfigurationManager.ConnectionStrings["ZhuangBPM"].ToString());
wfApplication.InstanceStore = instanceStore;
InstanceView view = instanceStore.Execute(instanceStore.CreateInstanceHandle(), new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30));
instanceStore.DefaultInstanceOwner = view.InstanceOwner;
wfApplication.PersistableIdle = (e) => {
System.Console.WriteLine("persistableIdle:{0}", e.InstanceId);
return PersistableIdleAction.Unload;
};
wfApplication.Run();
Console.ReadKey();
}
示例10: LoadAndExecute
protected override void LoadAndExecute()
{
MemoryStream ms = new MemoryStream(ASCIIEncoding.Default.GetBytes(this.workflowDesigner.Text));
DynamicActivity workflowToRun = ActivityXamlServices.Load(ms) as DynamicActivity;
WorkflowInspectionServices.CacheMetadata(workflowToRun);
this.workflowApplication = new WorkflowApplication(workflowToRun);
this.workflowApplication.Extensions.Add(this.output);
this.workflowApplication.Completed = this.WorkflowCompleted;
this.workflowApplication.OnUnhandledException = this.WorkflowUnhandledException;
this.workflowApplication.Aborted = this.WorkflowAborted;
this.workflowApplication.Extensions.Add(this.InitialiseVisualTrackingParticipant(workflowToRun));
try
{
this.running = true;
this.workflowApplication.Run();
}
catch (Exception e)
{
this.output.WriteLine(ExceptionHelper.FormatStackTrace(e));
StatusViewModel.SetStatusText(Resources.ExceptionInDebugStatus, this.workflowName);
}
}
示例11: Main
static void Main(string[] args)
{
var process = new WorkflowApplication(new Process());
process.Run();
System.Console.ReadKey();
}
示例12: Main
static void Main(string[] args)
{
AutoResetEvent syncEvent = new AutoResetEvent(false);
// create the workflow app and add handlers for the Idle and Completed actions
WorkflowApplication app = new WorkflowApplication(new Sequence1());
app.Idle = delegate(WorkflowApplicationIdleEventArgs e)
{
syncEvent.Set();
};
app.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
{
syncEvent.Set();
};
// start the application
app.Run();
syncEvent.WaitOne();
// read some text from the console and resume the readText bookmark (created in the first WaitForInput activity)
string text = Console.ReadLine();
app.ResumeBookmark("readText", text);
syncEvent.WaitOne();
// read some text from the console, convert it to number, and resume the readNumber bookmark (created in the second WaitForInput activity)
int number = ReadNumberFromConsole();
app.ResumeBookmark("readNumber", number);
syncEvent.WaitOne();
Console.WriteLine("");
Console.WriteLine("Press [ENTER] to exit...");
Console.ReadLine();
}
示例13: Main
static void Main(string[] args)
{
_event = new AutoResetEvent(false);
bool more = true;
int result = 0;
var activity = new AccumulatorActivity();
var accumulator = new WorkflowApplication(activity);
accumulator.Completed = new Action<WorkflowApplicationCompletedEventArgs>((e) =>
{
result = (int)e.Outputs["Sum"];
more = false;
_event.Set();
});
accumulator.Extensions.Add(new Notification(NotifySum));
accumulator.Run();
while (more)
{
Console.Write("Enter number: ");
int number = int.Parse(Console.ReadLine());
accumulator.ResumeBookmark("GetNumber", number);
_event.WaitOne();
}
Console.WriteLine("Result is " + result);
}
示例14: Run
static void Run()
{
AutoResetEvent applicationUnloaded = new AutoResetEvent(false);
WorkflowApplication application = new WorkflowApplication(workflow);
application.InstanceStore = instanceStore;
SetupApplication(application, applicationUnloaded);
StepCountExtension stepCountExtension = new StepCountExtension();
application.Extensions.Add(stepCountExtension);
application.Run();
Guid id = application.Id;
applicationUnloaded.WaitOne();
while (stepCountExtension.CurrentCount < totalSteps)
{
application = new WorkflowApplication(workflow);
application.InstanceStore = instanceStore;
SetupApplication(application, applicationUnloaded);
stepCountExtension = new StepCountExtension();
application.Extensions.Add(stepCountExtension);
application.Load(id);
string input = Console.ReadLine();
application.ResumeBookmark(echoPromptBookmark, input);
applicationUnloaded.WaitOne();
}
}
示例15: Interact
static void Interact(WorkflowApplication application)
{
IList<BookmarkInfo> bookmarks = application.GetBookmarks();
while (true)
{
Console.Write("Bookmarks:");
foreach (BookmarkInfo info in bookmarks)
{
Console.Write(" '" + info.BookmarkName + "'");
}
Console.WriteLine();
Console.WriteLine("Enter the name of the bookmark to resume");
string bookmarkName = Console.ReadLine();
if (bookmarkName != null && !bookmarkName.Equals(string.Empty))
{
Console.WriteLine("Enter the payload for the bookmark '{0}'", bookmarkName);
string bookmarkPayload = Console.ReadLine();
BookmarkResumptionResult result = application.ResumeBookmark(bookmarkName, bookmarkPayload);
if (result == BookmarkResumptionResult.Success)
{
return;
}
else
{
Console.WriteLine("BookmarkResumptionResult: " + result);
}
}
}
}