コード例 #1
0
        public void SuspendRestore()
        {
            using (new SecurityBypassContext())
            {
                var handler = new ResumeWorkflowHandler();

                var run = new WorkflowRun()
                {
                    WorkflowRunStatus_Enum = WorkflowRunState_Enumeration.WorkflowRunSuspended
                };
                run.Save();

                var task = ResumeWorkflowHandler.CreateBackgroundTask(run, new WorkflowRestoreEvent());

                var taskEntity = handler.CreateSuspendedTask(task).As <SuspendedRun>();
                taskEntity.Save();

                taskEntity.Should().NotBeNull();
                taskEntity.SrRun.Should().NotBeNull();
                taskEntity.SrRun.Id.Should().Be(run.Id);

                var bgTasks = handler.RestoreSuspendedTasks();

                bgTasks.Should().HaveCount(1);

                var runParam = bgTasks.First().GetData <ResumeWorkflowParams>();

                runParam.WorkflowRunId.ShouldBeEquivalentTo(run.Id);
                Assert.That(runParam.WorkflowRunId, Is.EqualTo(run.Id));
            }
        }
コード例 #2
0
ファイル: NotifyTest.cs プロジェクト: hardin253874/Platform
        Notification RunNotify(IEntity person, TwilioNotifier notifier, bool waitForReplies, IEntity linkTo = null, string replyWorkflowString = null, Workflow replyWorkflow = null)
        {
            var inputs = new Dictionary <string, object>
            {
                { "People", person.ToEnumerable() },
                { "LinkToRecord", linkTo },
            };

            var wf = new Workflow {
                Name = "RunNotify " + DateTime.UtcNow.ToString()
            };

            wf
            .AddDefaultExitPoint()
            .AddInput <ResourceListArgument>("People", Person.Person_Type)
            .AddInput <ResourceArgument>("LinkToRecord", UserResource.UserResource_Type)
            .AddOutput <ResourceArgument>("NotificationRecord", Notification.Notification_Type)
            .AddNotify(
                "Notify", "People", "'Test'",
                waitForReplies,
                linkToRecordExpression: "LinkToRecord",
                replyMap: replyWorkflowString == null ? null :
                new Dictionary <string, Workflow> {
                { replyWorkflowString, replyWorkflow }
            })
            .AddAssignToVar("Assign", "[Notify_Notification Record]", "NotificationRecord");

            wf.Save();
            ToDelete.Add(wf.Id);

            using (var scope = Factory.Current.BeginLifetimeScope(builder =>
            {
                builder.Register(c => new TenantSmsNotifier(notifier.Id)).As <INotifier>();
            }))
                using (Factory.SetCurrentScope(scope))
                {
                    WorkflowRun run = null;

                    using (new TestWfRunContext())
                    {
                        run = RunWorkflow(wf, inputs);
                        run.Save();
                    }

                    Thread.Sleep(1000);

                    Assert.That(run.WorkflowRunStatus_Enum, Is.EqualTo(WorkflowRunState_Enumeration.WorkflowRunCompleted));

                    var results = run.GetOutput();

                    Assert.That(results.Keys, Has.Member("NotificationRecord"));

                    var entity = (IEntity)results["NotificationRecord"];
                    return(entity.As <Notification>());
                }
        }
コード例 #3
0
        public void CancelRun()
        {
            var run = new WorkflowRun()
            {
                WorkflowRunStatus_Enum = WorkflowRunState_Enumeration.WorkflowRunStarted, TaskId = Guid.NewGuid().ToString()
            };

            run.Save();

            Factory.WorkflowRunTaskManager.RegisterStart(run.TaskId);

            WorkflowRunHelper.CancelRun(run.Id);

            var run2 = Entity.Get <WorkflowRun>(run.Id);

            Assert.That(run2.WorkflowRunStatus_Enum, Is.EqualTo(WorkflowRunState_Enumeration.WorkflowRunCancelled));

            Assert.That(DateTime.UtcNow - run2.RunCompletedAt, Is.LessThan(TimeSpan.FromMinutes(1)));

            Assert.That(Factory.WorkflowRunTaskManager.HasCompleted(run.TaskId), Is.True);
        }