本文整理汇总了C#中WorkflowContext.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# WorkflowContext.SaveChanges方法的具体用法?C# WorkflowContext.SaveChanges怎么用?C# WorkflowContext.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorkflowContext
的用法示例。
在下文中一共展示了WorkflowContext.SaveChanges方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddWorkflow
public void AddWorkflow(Workflow workflow)
{
using(var context = new WorkflowContext())
{
context.Workflows.Add(workflow);
context.SaveChanges();
}
}
示例2: StartWorkflow
public IList<TrackingRecord> StartWorkflow(int id, Dictionary<string, object> wfParams)
{
string fileLocation = null;
int workflowRunId = 0;
using (var context = new WorkflowContext())
{
fileLocation = context.Workflows.First(c => c.Id == id).FileLocation; // Hier kan een NullReferenceException optreden
var workflowRun = new WorkflowRun()
{
WorkflowId = id,
StartTime = DateTime.Now
};
context.WorkflowRuns.Add(workflowRun);
context.SaveChanges();
workflowRunId = workflowRun.WorkflowRunId;
}
var xamlData = ReadXamlFile(fileLocation);
var tracker = new CustomTrackingParticipant();
var wf = ActivityXamlServices.Load(new StringReader(xamlData), new ActivityXamlServicesSettings { CompileExpressions = true });
AutoResetEvent syncEvent = new AutoResetEvent(false);
WorkflowApplication wfApp = new WorkflowApplication(wf, wfParams);
wfApp.Extensions.Add(tracker);
wfApp.Extensions.Add<TextWriter>(() => new StreamWriter(@"C:/XAML/log.txt"));
// Handle the desired lifecycle events.
Exception exception = null;
wfApp.Completed = (e) => syncEvent.Set();
wfApp.OnUnhandledException += (WorkflowApplicationUnhandledExceptionEventArgs e) =>
{
using (WorkflowContext context = new WorkflowContext())
{
context.Tracks.Add(new Track()
{
ActivityName = e.UnhandledException.ToString(),
EventTime = DateTime.Now.AddHours(-1),
State = "Faulted",
WorkflowRunId = workflowRunId,
});
context.SaveChanges();
}
LogTracks(workflowRunId, tracker);
return UnhandledExceptionAction.Terminate;
};
// Start the workflow.
wfApp.Run();
syncEvent.WaitOne();
LogTracks(workflowRunId, tracker);
return tracker.Records;
}
示例3: LogTracks
private void LogTracks(int workflowRunId, CustomTrackingParticipant tracker)
{
var tracks = MapTracks(tracker.Records, (t) =>
{
t.WorkflowRunId = workflowRunId;
return t;
});
using (WorkflowContext context = new WorkflowContext())
{
context.Tracks.AddRange(tracks);
context.SaveChanges();
}
}