public SimpleWorkflowController(
     IWorkflowRunner workflowRunner,
     ISignaler signaler)
 {
     this.workflowRunner = workflowRunner;
     this.signaler       = signaler;
 }
Beispiel #2
0
 public DemoHttpWorkflowController(
     IWorkflowRunner workflowRunner,
     ISignaler signaler)
 {
     this.workflowRunner = workflowRunner;
     this.signaler       = signaler;
 }
        /// <summary>
        /// Run the workflow associated with notification reply
        /// </summary>
        void RunReplyWorkflow(IWorkflowRunner runner, Workflow workflow, ReplyRecord reply)
        {
            if (workflow.WorkflowRunAsOwner != true)
            {
                throw new ArgumentException($"The provided workflow is not marked as run as owner. This should never occur. Workflow: ${workflow.Name}");
            }

            var input = new Dictionary <string, object>();

            var inputArg = workflow?.InputArgumentForAction?.As <ResourceArgument>();

            if (inputArg != null)
            {
                if (inputArg.ConformsToType.Id == ReplyRecord.ReplyRecord_Type.Id)
                {
                    input.Add(inputArg.Name, reply);
                }
            }

            // Set the context to the owner and start the workflow.
            var wfOwner     = workflow.SecurityOwner;
            var contextData = new RequestContextData(RequestContext.GetContext());

            contextData.Identity = new ReadiNow.Security.IdentityInfo(wfOwner.Id, wfOwner.Name);

            using (CustomContext.SetContext(contextData))
            {
                runner.RunWorkflowAsync(new WorkflowStartEvent(workflow)
                {
                    Arguments = input
                });
            }
        }
 public WorkflowLaunchpad(
     IWorkflowInstanceStore workflowInstanceStore,
     IWorkflowFactory workflowFactory,
     IBookmarkFinder bookmarkFinder,
     ITriggerFinder triggerFinder,
     IDistributedLockProvider distributedLockProvider,
     IWorkflowInstanceDispatcher workflowInstanceDispatcher,
     IWorkflowInstanceExecutor workflowInstanceExecutor,
     IWorkflowRunner workflowRunner,
     IWorkflowRegistry workflowRegistry,
     IGetsStartActivities getsStartActivities,
     ElsaOptions elsaOptions,
     ILogger <WorkflowLaunchpad> logger)
 {
     _workflowInstanceStore      = workflowInstanceStore;
     _bookmarkFinder             = bookmarkFinder;
     _triggerFinder              = triggerFinder;
     _distributedLockProvider    = distributedLockProvider;
     _workflowInstanceDispatcher = workflowInstanceDispatcher;
     _elsaOptions              = elsaOptions;
     _logger                   = logger;
     _getsStartActivities      = getsStartActivities;
     _workflowRegistry         = workflowRegistry;
     _workflowRunner           = workflowRunner;
     _workflowInstanceExecutor = workflowInstanceExecutor;
     _workflowFactory          = workflowFactory;
 }
Beispiel #5
0
 public WorkflowTriggerInterruptor(IWorkflowRunner workflowRunner, IWorkflowRegistry workflowRegistry, IWorkflowInstanceStore workflowInstanceStore, IBookmarkFinder bookmarkFinder)
 {
     _workflowRunner        = workflowRunner;
     _workflowRegistry      = workflowRegistry;
     _workflowInstanceStore = workflowInstanceStore;
     _bookmarkFinder        = bookmarkFinder;
 }
 public StartController(IWorkflowRunner workflowInvoker, IWorkflowRegistry workflowRegistry, IWorkflowFactory workflowFactory, IWorkflowInstanceStore workflowInstanceStore, IWorkflowInstanceDispatcher workflowInstanceDispatcher)
 {
     this.workflowInvoker            = workflowInvoker;
     this.workflowRegistry           = workflowRegistry;
     this.workflowFactory            = workflowFactory;
     this.workflowInstanceStore      = workflowInstanceStore;
     this.workflowInstanceDispatcher = workflowInstanceDispatcher;
 }
Beispiel #7
0
 public WorkflowResumer(IWorkflowRegistry workflowRegistry, IBookmarkFinder bookmarkFinder, IWorkflowInstanceStore workflowInstanceStore, Func <IWorkflowBuilder> workflowBuilderFactory, IWorkflowRunner workflowRunner)
 {
     _workflowRegistry       = workflowRegistry;
     _bookmarkFinder         = bookmarkFinder;
     _workflowInstanceStore  = workflowInstanceStore;
     _workflowBuilderFactory = workflowBuilderFactory;
     _workflowRunner         = workflowRunner;
 }
Beispiel #8
0
 public WorkflowStarter(ITriggerFinder triggerFinder, IWorkflowFactory workflowFactory, Func <IWorkflowBuilder> workflowBuilderFactory, IWorkflowRunner workflowRunner, IWorkflowInstanceStore workflowInstanceStore)
 {
     _triggerFinder          = triggerFinder;
     _workflowFactory        = workflowFactory;
     _workflowBuilderFactory = workflowBuilderFactory;
     _workflowRunner         = workflowRunner;
     _workflowInstanceStore  = workflowInstanceStore;
 }
Beispiel #9
0
 public LockingWorkflowRunner(
     IWorkflowRunner workflowRunner,
     IDistributedLockProvider distributedLockProvider,
     ElsaOptions elsaOptions)
 {
     _workflowRunner          = workflowRunner;
     _distributedLockProvider = distributedLockProvider;
     _elsaOptions             = elsaOptions;
 }
        public void IWorkflowRunner_Instance()
        {
            IWorkflowRunner instance = Factory.Current.Resolve <IWorkflowRunner>();

            Assert.That(instance, Is.TypeOf <WorkflowRunner>());

            WorkflowRunner runner = (WorkflowRunner)instance;

            Assert.That(runner.MetadataFactory, Is.Not.Null);
        }
Beispiel #11
0
 public WorkflowTestLaunchpad(
     IWorkflowRegistry workflowRegistry,
     IWorkflowInstanceStore workflowInstanceStore,
     IWorkflowFactory workflowFactory,
     IWorkflowRunner workflowRunner)
 {
     _workflowRegistry      = workflowRegistry;
     _workflowInstanceStore = workflowInstanceStore;
     _workflowFactory       = workflowFactory;
     _workflowRunner        = workflowRunner;
 }
        public WorkflowOrchestrator(
            IAppClassWrapper?appClassWrapper               = null,
            IWorkflowRunner?mergeAlbumsWorkflowRunner      = null,
            IWorkflowRunner?importTrackNamesWorkflowRunner = null,
            IWorkflowRunner?albumWorkflowRunner            = null,
            IWorkflowRunner?trackWorkflowRunner            = null)
        {
            _appClassWrapper = appClassWrapper ?? new AppClassWrapper();

            _mergeAlbumsWorkflowRunner      = mergeAlbumsWorkflowRunner ?? new MergeAlbumsWorkflowRunner();
            _importTrackNamesWorkflowRunner = importTrackNamesWorkflowRunner ?? new ImportTrackNamesWorkflowRunner();
            _albumWorkflowRunner            = albumWorkflowRunner ?? new AlbumWorkflowRunner();
            _trackWorkflowRunner            = trackWorkflowRunner ?? new TrackWorkflowRunner();

            _status = Status.Create(default);
        public void Debug()
        {
            if (IsExecuting || !Save(true))
            {
                return;
            }

            // HACK ZONE

            // WorkflowDesigner have to be loaded all over again through WorkflowDesigner.Load(filepath) otherwise
            // SourceLocationProvider.CollectMapping() won't collect nothing later on WorkflowDebugger and
            // becaquse of that debug process won't work as expected.

            // Activities not loaded with WorkflowDesigner.Load(filepath) won't be recognized at all.

            // That's the only motive for the workflow to be saved before debug.

            // More info: http://social.msdn.microsoft.com/forums/en-us/wfprerelease/thread/2DEE4DD9-D3F7-4430-BCC7-D613859074D1
            //            http://social.msdn.microsoft.com/Forums/en/wfprerelease/thread/0a28cade-bd8d-417b-a1e4-efbc0d9ccd43
            //            http://blogs.msdn.com/b/tilovell/archive/2011/06/08/wf4-visual-workflow-tracking-and-workflowinspectionservices.aspx

            // This needs to be addressed by MS. Didn't test it on NET4.5
            // Should check this in detail later

            WorkflowDesigner = new WorkflowDesigner();
            WorkflowDesigner.Load(FilePath);

            // END OF HACK ZONE

            if (WorkflowType == WorkflowType.Activity)
            {
                executer = new ActivityDebugger(WorkflowDesigner, outputTextWriter);
            }
            else
            {
                executer = new WorkflowServiceDebugger(WorkflowDesigner, outputTextWriter);
            }

            ((IWorkflowDebugger)executer).DebugStepAdded += (sender, args) =>
            {
                Application.Current.Dispatcher.Invoke(
                    DispatcherPriority.Normal,
                    (Action)(() => DebugSteps.Add(args.DebugStep)));
            };

            executer.ExecutingStateChanged += OnExecuterRunningStateChanged;
            executer.Start();
        }
        /// <summary>
        /// Match the replies against the replyMap and trigger a workflow if there is a match
        /// </summary>
        void TestAndRunReplyMap(IWorkflowRunner runner, IEnumerable <ReplyMapEntry> replyMap, ReplyRecord reply)
        {
            var message = reply?.RrReply?.ToLower();

            if (message == null)
            {
                return;
            }

            var entry = ReplyRecordEventTarget.SelectReplyMapEntry(replyMap, message);

            if (entry != null)
            {
                RunReplyWorkflow(runner, entry.RmeWorkflow, reply);
            }
        }
        public IWorkflowRunner Start(IWorkflowJob workflow)
        {
            IWorkflowRunner runner = null;

            switch (Type)
            {
            case RuntimeType.Sequential:
                runner = new SequentialRunner().Start(workflow);
                break;

            case RuntimeType.Parallel:
                runner = new TaskRunner().Start(workflow);
                break;
            }

            return(runner);
        }
Beispiel #16
0
 public WorkflowStarter(
     ITriggerFinder triggerFinder,
     IWorkflowFactory workflowFactory,
     Func <IWorkflowBuilder> workflowBuilderFactory,
     IWorkflowRunner workflowRunner,
     IWorkflowInstanceStore workflowInstanceStore,
     IWorkflowStorageService workflowStorageService,
     IWorkflowRegistry workflowRegistry)
 {
     _triggerFinder          = triggerFinder;
     _workflowFactory        = workflowFactory;
     _workflowBuilderFactory = workflowBuilderFactory;
     _workflowRunner         = workflowRunner;
     _workflowInstanceStore  = workflowInstanceStore;
     _workflowStorageService = workflowStorageService;
     _workflowRegistry       = workflowRegistry;
 }
Beispiel #17
0
        private static ICommand GetWorkflowCommand(IWorkflowRunner workflowRunner)
        {
            var workflowCommands = workflowRunner.Commands.ToArray();

            for (var i = 0; i < 3; i++)
            {
                var index = 0;
                System.Console.WriteLine("Please select command (E for exit):");
                foreach (var workflowCommand in workflowCommands)
                {
                    System.Console.WriteLine($"[{(++index).ToString(CultureInfo.InvariantCulture).PadLeft(2, '0')}] - {workflowCommand.Name}");
                }

                var input = System.Console.ReadLine();
                if (string.Equals("E", input, StringComparison.OrdinalIgnoreCase))
                {
                    return(null);
                }

                if (!int.TryParse(input, out var position))
                {
                    if (i == 2)
                    {
                        System.Console.WriteLine("Selection failed : ( ... Exiting.");
                        return(null);
                    }

                    continue;
                }

                if (position > 0 && position <= workflowCommands.Length)
                {
                    return(workflowCommands[position - 1]);
                }

                if (i == 2)
                {
                    System.Console.WriteLine("Selection failed : ( ... Exiting.");
                    return(null);
                }

                System.Console.WriteLine($"Input must be in a range [1..{workflowCommands.Length}]");
            }

            return(null);
        }
        public void Run()
        {
            if (IsExecuting)
            {
                return;
            }

            WorkflowDesigner.Flush();

            if (WorkflowType == WorkflowType.Activity)
            {
                executer = new ActivityRunner(WorkflowDesigner.Text, outputTextWriter);
            }
            else
            {
                executer = new WorkflowServiceRunner(WorkflowDesigner.Text, outputTextWriter);
            }

            executer.ExecutingStateChanged += OnExecuterRunningStateChanged;
            executer.Start();
        }
Beispiel #19
0
        public void DebugWorkflow()
        {
            if (this.GetRootType() == typeof(WorkflowService))
            {
                this.runner = new WorkflowServiceHostDebugger(this.output, this.DisplayName, this.workflowDesigner, this.disableDebugViewOutput);
            }
            else
            {
                this.runner = new WorkflowDebugger(this.output, this.DisplayName, this.workflowDesigner, this.disableDebugViewOutput);
            }

            try
            {
                this.outputTextBox.Clear();
                this.runner.Run();
            }
            catch (Exception e)
            {
                MessageBox.Show(string.Format(Resources.ErrorLoadingInDebugDialogMessage, ExceptionHelper.FormatStackTrace(e)), Resources.ErrorLoadingInDebugDialogTitle, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #20
0
        public EnableViewModel(IWorkflowRunner runner,
                               IComponentViewCollection componentViewCollection,
                               IUserNotificationView userNotificationView,
                               IEventBroker eventBroker)
        {
            _runner      = runner;
            _eventBroker = eventBroker;

            _startCommand = new RelayCommand(
                param => Start(),
                param => CanStart);

            _abortCommand = new RelayCommand(
                param => Abort(),
                param => CanAbort);

            ComponentView    = componentViewCollection;
            UserNotification = userNotificationView;

            CanStart = true;
        }
 public RunStartupWorkflows(IWorkflowRunner workflowRunner)
 {
     _workflowRunner = workflowRunner;
 }
        public void Run()
        {
            if (IsExecuting)
            {
                return;
            }

            WorkflowDesigner.Flush();

            if (WorkflowType == WorkflowType.Activity)
            {
                executer = new ActivityRunner(WorkflowDesigner.Text, outputTextWriter);
            }
            else
            {
                executer = new WorkflowServiceRunner(WorkflowDesigner.Text, outputTextWriter);
            }

            executer.ExecutingStateChanged += OnExecuterRunningStateChanged;
            executer.Start();
        }
        public void Debug()
        {
            if (IsExecuting || !Save(true))
            {
                return;
            }

            // HACK ZONE

            // WorkflowDesigner have to be loaded all over again through WorkflowDesigner.Load(filepath) otherwise
            // SourceLocationProvider.CollectMapping() won't collect nothing later on WorkflowDebugger and
            // becaquse of that debug process won't work as expected.

            // Activities not loaded with WorkflowDesigner.Load(filepath) won't be recognized at all.

            // That's the only motive for the workflow to be saved before debug.

            // More info: http://social.msdn.microsoft.com/forums/en-us/wfprerelease/thread/2DEE4DD9-D3F7-4430-BCC7-D613859074D1
            //            http://social.msdn.microsoft.com/Forums/en/wfprerelease/thread/0a28cade-bd8d-417b-a1e4-efbc0d9ccd43
            //            http://blogs.msdn.com/b/tilovell/archive/2011/06/08/wf4-visual-workflow-tracking-and-workflowinspectionservices.aspx

            // This needs to be addressed by MS. Didn't test it on NET4.5
            // Should check this in detail later

            WorkflowDesigner = new WorkflowDesigner();
            WorkflowDesigner.Load(FilePath);

            // END OF HACK ZONE

            if (WorkflowType == WorkflowType.Activity)
            {
                executer = new ActivityDebugger(WorkflowDesigner, outputTextWriter);
            }
            else
            {
                executer = new WorkflowServiceDebugger(WorkflowDesigner, outputTextWriter);
            }

            ((IWorkflowDebugger) executer).DebugStepAdded += (sender, args) =>
                {
                    Application.Current.Dispatcher.Invoke(
                        DispatcherPriority.Normal,
                        (Action) (() => DebugSteps.Add(args.DebugStep)));
                };

            executer.ExecutingStateChanged += OnExecuterRunningStateChanged;
            executer.Start();
        }
 public WorkflowController(IWorkflowRunner workflowRunner, IWorkflowInstanceStore instanceStore)
 {
     this.workflowRunner = workflowRunner;
     this.instanceStore  = instanceStore;
 }
Beispiel #25
0
 public WorkflowTriggerInterruptor(IWorkflowRunner workflowRunner, IWorkflowRegistry workflowRegistry, IWorkflowInstanceStore workflowInstanceStore)
 {
     _workflowRunner        = workflowRunner;
     _workflowRegistry      = workflowRegistry;
     _workflowInstanceStore = workflowInstanceStore;
 }
Beispiel #26
0
 public XDatabaseContext(IWorkflowRunner runner, IStreamProvider streamProvider) : this()
 {
     this.Runner         = runner;
     this.StreamProvider = streamProvider;
 }
        public void DebugWorkflow()
        {
            if (this.GetRootType() == typeof(WorkflowService))
            {
                this.runner = new WorkflowServiceHostDebugger(this.output, this.DisplayName, this.workflowDesigner, this.disableDebugViewOutput);
            }
            else
            {
                this.runner = new WorkflowDebugger(this.output, this.DisplayName, this.workflowDesigner, this.disableDebugViewOutput);
            }

            try
            {
                this.outputTextBox.Clear();
                this.runner.Run();
            }
            catch (Exception e)
            {
                MessageBox.Show(string.Format(Resources.ErrorLoadingInDebugDialogMessage, ExceptionHelper.FormatStackTrace(e)), Resources.ErrorLoadingInDebugDialogTitle, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }