当前位置: 首页>>代码示例>>C#>>正文


C# WorkflowContext.SaveChanges方法代码示例

本文整理汇总了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();
     }
 }
开发者ID:riezebosch,项目名称:wf-deploy,代码行数:8,代码来源:WorkflowManager.cs

示例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;
        }
开发者ID:riezebosch,项目名称:wf-deploy,代码行数:56,代码来源:WorkflowManager.cs

示例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();
            }
        }
开发者ID:riezebosch,项目名称:wf-deploy,代码行数:14,代码来源:WorkflowManager.cs


注:本文中的WorkflowContext.SaveChanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。