예제 #1
0
        static void Main(string[] args)
        {
            //4.1)
            SimpleActivity greaterThan100Activity = new SimpleActivity(()=>Console.WriteLine("Value is greater than 100."));

            //4.2)
            SimpleActivity lessThan100Activity = new SimpleActivity(()=>Console.WriteLine("Value is less than 100."));

            //3.)
            Decision<int> greaterOrLess100Decision = new Decision<int>(multipliedValue => multipliedValue > 100, greaterThan100Activity, lessThan100Activity);

            //2.)
            InputOutputActivity<int,int> mutiplyBy10Activity = new InputOutputActivity<int, int>(inputValue => inputValue * 10, greaterOrLess100Decision);

            //1.)
            OutputActivity<int> getInputValueActivity = new OutputActivity<int>(()=>
                                                                                {
                                                                                    Console.Write("Please type in value:");
                                                                                    var input = Console.ReadLine();
                                                                                    return Convert.ToInt32(input);
                                                                                }, mutiplyBy10Activity);

            WorkflowEngine engine = new WorkflowEngine();
            engine.WorkflowProgressChanged += (arg1, arg2, arg3, arg4) => Console.WriteLine("Step:{0}\r\nContext:{1}\r\nSuccess:{2}\r\nException message:{3}", arg1, arg2, arg3, arg4 != null ? arg4.Message : string.Empty);

            engine.WorkflowCompleted += (arg1, arg2) => Console.WriteLine("Completed:\r\nSucceeded:{0}\r\nException message:{1}", arg1, arg2 != null ? arg2.Message : string.Empty);

            engine.Run(getInputValueActivity);

            Console.ReadLine();

            engine.Dispose();
        }
예제 #2
0
        static void Main(string[] args)
        {
            var workflow = new Workflow();
            workflow.RegisterActivity(new VideoUploadActivity());
            workflow.RegisterActivity(new VideoEncodeActivity());
            var workflowEngine = new WorkflowEngine(workflow);
            workflowEngine.Run();

            Console.WriteLine("\nPress a key to continue...");
            Console.ReadKey();
        }
예제 #3
0
        static void Main(string[] args)
        {
            var workFlow = new Workflow();
            workFlow.Add(new Upload());
            workFlow.Add(new ReadyForEncodingNotifier());
            workFlow.Add(new SendMail());
            workFlow.Add(new DbInformer());

            var workFlowEngine = new WorkflowEngine();
            workFlowEngine.Run(workFlow);

            System.Console.ReadLine();
        } 
예제 #4
0
        public async Task UnitTestStateWorkflowAndActions()
        {
            using (var engine = new WorkflowEngine())
            {
                var instance = engine.CreateWorkflow <PhoneCallWorkflow, PhoneStates>();

                var messageArg = new Argument <string>("Message");
                var canDialArg = new Argument <bool>("CanDial", true);
                var args       = new Argument[] { messageArg, canDialArg };

                await instance.Start(args);

                // test action
                messageArg.Value = "Dialing...";
                await instance.Action("Call Dialed");

                // test asynchronous action
                await instance.Action("Connected", true);

                Assert.AreEqual("Dialing...", messageArg.Value);

                // test waiting for action to complete
                await instance.WaitAction();

                Assert.AreEqual("Connected", messageArg.Value);

                // test return value
                var response = await instance.Action <string>("Hang Up");

                Assert.AreEqual("Goodbye", response);

                // wait for workflow to complete
                await instance.Wait();

                Assert.AreEqual("Hello World!", messageArg.Value);
                Assert.AreEqual(PhoneStates.Disconnected, instance.State);
            }
        }
예제 #5
0
        public static void SaveDataToBizagi(string fileNameWithPath, string subject, string body = "")
        {
            string fileBytes = ConvertToBase64(fileNameWithPath);
            string fileName  = fileNameWithPath.Split('\\').LastOrDefault();
            string bizagiUrl = ConfigurationManager.AppSettings["BizagiUrl"];

            if (string.IsNullOrEmpty(fileName))
            {
                fileName = "EmailAttachment.eml";
            }
            List <KeyValuePair <string, string> > keyvaluepair = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>(bizagiEmailSubjectColumnName, subject),
                new KeyValuePair <string, string>(bizagiEmailBodyCOlumnName, body)
            };
            // Connection bizagicon = new Connection(bizagiUrl);
            WorkflowEngine bizagi = new WorkflowEngine(bizagiUrl);

            try
            {
                var jsonObject   = JObject.Parse(subject);//JsonConvert.DeserializeObject(subject);
                var caseNumber   = Convert.ToString(jsonObject.GetValue("Case"));
                var activityName = Convert.ToString(jsonObject.GetValue("Activity"));
                if (!string.IsNullOrEmpty(caseNumber) && !string.IsNullOrEmpty(activityName))
                {
                    var data = bizagi.UpdateCase(bizagiUserName, bizagiDomain, bizagiProcessName, caseNumber, activityName, bizagiEntityName, keyvaluepair, bizagiEmailFileAttributeName, fileName, fileBytes);
                }
                else
                {
                    throw new FormatException();
                }
            }
            catch (Exception ex)
            {
                //It means subject is not in recognised Format .... Nothing to do here but just proceed with normal new case creation.
                var data = bizagi.CreateCase(bizagiUserName, bizagiDomain, bizagiProcessName, bizagiEntityName, keyvaluepair, bizagiEmailFileAttributeName, fileName, fileBytes);
            }
        }
예제 #6
0
        public ResultModel <IdVersionModel> SaveWorkflow(WorkflowInfo model)
        {
            var result         = new ResultModel <IdVersionModel>();
            var workflowEngine = new WorkflowEngine(_configuration, _workflowConfig);

            if (model.Id == 0)
            {
                result.Data = new SaveWorkflowLogic(_configuration, _workflowConfig).AddNewWorkflow(model, workflowEngine, GetTaskNames().Data);
            }
            else
            {
                if (model.NewVersion)
                {
                    result.Data = new SaveWorkflowLogic(_configuration, _workflowConfig).AddNewVersionWorkflow(model, workflowEngine, GetTaskNames().Data);
                }
                else
                {
                    result.Data = new SaveWorkflowLogic(_configuration, _workflowConfig).EditWorkflow(model, workflowEngine, GetTaskNames().Data);
                }
            }

            return(result);
        }
예제 #7
0
        static void Main(string[] args)
        {
            //string input = "";

            //   1
            //var stopwatch = new Stopwatch();
            //stopwatch.Work(input);

            //   2
            //var post = new Post("Example", "An interesting text.");
            //post.Work(input);

            //   3
            //var stack = new Stack();
            //stack.Push(1);
            //stack.Push(2);
            //stack.Push(3);
            //Console.WriteLine(stack.Pop());
            //Console.WriteLine(stack.Pop());
            //Console.WriteLine(stack.Pop());
            //Console.WriteLine(stack.Pop()); // Exception trigger

            //   4
            //var dbCommand = new DbCommand(new SqlConnection("*****@*****.**"), "Maintain");
            //dbCommand.Execute();
            //dbCommand = new DbCommand(new OracleConnection("*****@*****.**"), "Test");
            //dbCommand.Execute();

            //   5
            var workflowEngine = new WorkflowEngine();
            var workflow       = new Workflow();

            workflow.AddActivity(new SendEmail());
            workflow.AddActivity(new CallService());
            workflow.AddActivity(new UploadVideo());
            workflowEngine.Run(workflow);
        }
예제 #8
0
        public static void StartDesktopServices()
        {
            // TODO: LOCALE
            CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("uk-UA");

            ServiceLocator.GetCurrentLocator = () =>
            {
                if (_currentService == null)
                {
                    _currentService = new ServiceLocator();
                }
                return(_currentService);
            };

            ServiceLocator.Start = (IServiceLocator service) =>
            {
                IProfiler        profiler  = new DesktopProfiler();
                IApplicationHost host      = new DesktopApplicationHost(profiler);
                ILocalizer       localizer = new DesktopLocalizer(host);
                IDbContext       dbContext = new SqlDbContext(
                    profiler as IDataProfiler,
                    host as IDataConfiguration,
                    localizer as IDataLocalizer,
                    tenantManager: null);                    /*host as ITenantManager*/
                IRenderer       renderer = new XamlRenderer(profiler, host);
                IWorkflowEngine wfEngine = new WorkflowEngine(host, dbContext, null);
                IDataScripter   scripter = new VueDataScripter(host, localizer);
                service.RegisterService <IProfiler>(profiler);
                service.RegisterService <IApplicationHost>(host);
                service.RegisterService <IDbContext>(dbContext);
                service.RegisterService <IRenderer>(renderer);
                service.RegisterService <IWorkflowEngine>(wfEngine);
                service.RegisterService <IDataScripter>(scripter);
                service.RegisterService <ILocalizer>(localizer);
                host.TenantId = 1;
            };
        }
예제 #9
0
        private WorkflowEngine CreateEngine(MemoryStorage storage, string configText)
        {
            var template = new TemplateRepository(typeof(TemplateModels))
            {
                DefaultAction = TemplateModels.DefaultAction,
            };
            var metadatas = new MetadatRepository(typeof(MetadataModels))
            {
                DefaultAction = MetadataModels.DefaultAction.ToDictionary(c => c.Key, c => c.Value),
            };

            var serializer = new PartialJsonWorkflowSerializer();

            WorkflowsConfig configs = new WorkflowsConfig()
                                      .AddDocument(GetConfig(configText))
            ;

            var factory = new WorkflowFactory <RunContext>(null, null)
            {
                Serializer = serializer,
            };

            var processor = new WorkflowProcessor <RunContext>(configs, factory)
            {
                LoadExistingWorkflowsByExternalId = (key) => storage.GetBy <Workflow, string>(key, c => c.ExternalId).ToList(),
                OutputActions = () => CreateOutput(serializer, storage),
                Templates     = template,
                Metadatas     = metadatas,
            };

            WorkflowEngine engine = new WorkflowEngine()
            {
                Processor = processor,
            };

            return(engine);
        }
예제 #10
0
        static void StartServices()
        {
            ServiceLocator.Start = (IServiceLocator loc) =>
            {
                var profiler         = new NullProfiler();
                var localizer        = new NullLocalizer();
                var host             = new BackgroundApplicationHost(profiler, loc);
                var dbContext        = new SqlDbContext(profiler, host, localizer);
                var logger           = new BackgroundLogger(dbContext);
                var workflow         = new WorkflowEngine(host, dbContext, null);
                var emailService     = new EmailService(logger, host);
                var smsService       = new SmsService(dbContext, logger);
                var messaging        = new MessageProcessor(host, dbContext, emailService, smsService, logger);
                var userLocale       = new BackgroundUserLocale();
                var userStateManager = new EmptyUserStateManager();

                loc.RegisterService <IProfiler>(profiler);
                loc.RegisterService <ILocalizer>(localizer);
                loc.RegisterService <IDbContext>(dbContext);
                loc.RegisterService <ILogger>(logger);
                loc.RegisterService <IApplicationHost>(host);
                loc.RegisterService <IWorkflowEngine>(workflow);
                loc.RegisterService <IMessaging>(messaging);
                loc.RegisterService <IUserLocale>(userLocale);
                loc.RegisterService <IUserStateManager>(userStateManager);
            };

            ServiceLocator.GetCurrentLocator = () =>
            {
                if (_currentService == null)
                {
                    _currentService = new ServiceLocator();
                }
                return(_currentService);
            };
        }
예제 #11
0
        public async Task UnitTestDelayUntilWorkflow()
        {
            using (var engine = new WorkflowEngine())
            {
                var escalationDateTime = DateTime.Now.AddSeconds(1);
                var delayUntilWorkflow = new DelayUntilWorkflow(
                    Workflow.Create(
                        instance =>
                {
                    instance.GetArgument <bool>("HasEscalated").Value = true;
                }),
                    escalationDateTime);

                var delayUntilInstance = engine.CreateWorkflow(delayUntilWorkflow);
                await delayUntilInstance.Start(new Argument <bool>("HasEscalated"));

                await delayUntilInstance.Wait();

                var completeTime = DateTime.Now;

                Assert.IsTrue(delayUntilInstance.GetArgument <bool>("HasEscalated").Value);
                Assert.IsTrue(completeTime >= escalationDateTime);
            }
        }
예제 #12
0
 /// <summary>
 /// Запуск бизнес-процесса
 /// </summary>
 /// <param name="processId">Идентификатор бизнес-процесса</param>
 /// <param name="processParameters">Входные параметры для бизнес-процесса</param>
 /// <returns>Контекст исполнения бизнес-процесса</returns>
 public WorkflowContextData WorkflowExecute(Guid processId, Dictionary <String, object> processParameters)
 {
     //var user = UserRepo.GetUserInfo(CurrentUserName);
     return(WorkflowEngine.Run(processId, processParameters));
 }
예제 #13
0
        public static void StartServices()
        {
            // DI ready
            ServiceLocator.Start = (IServiceLocator locator) =>
            {
                IProfiler        profiler      = new WebProfiler();
                IUserLocale      userLocale    = new WebUserLocale();
                IApplicationHost host          = new WebApplicationHost(profiler, userLocale);
                ILocalizer       localizer     = new WebLocalizer(host, userLocale);
                ITokenProvider   tokenProvider = new WebTokenProvider();
                IDbContext       dbContext     = new SqlDbContext(
                    profiler as IDataProfiler,
                    host as IDataConfiguration,
                    localizer as IDataLocalizer,
                    host as ITenantManager,
                    tokenProvider);
                ILogger               logger               = new WebLogger(host, dbContext);
                IMessageService       emailService         = new IdentityEmailService(logger, host);
                IMessaging            messaging            = new MessageProcessor(host, dbContext, emailService, logger);
                IRenderer             renderer             = new XamlRenderer(profiler, host);
                IWorkflowEngine       workflowEngine       = new WorkflowEngine(host, dbContext, messaging);
                IDataScripter         scripter             = new VueDataScripter(host, localizer);
                ISmsService           smsService           = new SmsService(dbContext, logger);
                IExternalLoginManager externalLoginManager = new ExternalLoginManager(dbContext);
                IUserStateManager     userStateManager     = new WebUserStateManager(host, dbContext);
                IExternalDataProvider dataProvider         = new ExternalDataContext();
                IScriptProcessor      scriptProcessor      = new ScriptProcessor(scripter, host);
                IHttpService          httpService          = new HttpService();
                IJavaScriptEngine     javaScriptEngine     = new JavaScriptEngine(dbContext, host);

                locator.RegisterService <IDbContext>(dbContext);
                locator.RegisterService <IProfiler>(profiler);
                locator.RegisterService <IApplicationHost>(host);
                locator.RegisterService <IRenderer>(renderer);
                locator.RegisterService <IWorkflowEngine>(workflowEngine);
                locator.RegisterService <IMessaging>(messaging);
                locator.RegisterService <IUserLocale>(userLocale);
                locator.RegisterService <ILocalizer>(localizer);
                locator.RegisterService <IDataScripter>(scripter);
                locator.RegisterService <ILogger>(logger);
                locator.RegisterService <IMessageService>(emailService);
                locator.RegisterService <ISmsService>(smsService);
                locator.RegisterService <IExternalLoginManager>(externalLoginManager);
                locator.RegisterService <IUserStateManager>(userStateManager);
                locator.RegisterService <IExternalDataProvider>(dataProvider);
                locator.RegisterService <IScriptProcessor>(scriptProcessor);
                locator.RegisterService <IHttpService>(httpService);
                locator.RegisterService <IJavaScriptEngine>(javaScriptEngine);
                locator.RegisterService <ITokenProvider>(tokenProvider);

                if (HttpContext.Current != null)
                {
                    HttpContext.Current.Items.Add("ServiceLocator", locator);
                }
            };

            ServiceLocator.GetCurrentLocator = () =>
            {
                if (HttpContext.Current == null)
                {
                    throw new InvalidProgramException("There is no http context");
                }
                var currentContext = HttpContext.Current;
                var locator        = currentContext.Items["ServiceLocator"];
                if (locator == null)
                {
                    new ServiceLocator();
                }
                return(HttpContext.Current.Items["ServiceLocator"] as IServiceLocator);
            };
        }
예제 #14
0
 public TransitionProcessor(WorkflowEngine workflowEngine)
 {
     _workflowEngine = workflowEngine;
 }
예제 #15
0
 public MessageProcessor(WorkflowEngine workflowEngine)
 {
     _workflowEngine = workflowEngine;
 }
예제 #16
0
 public ActivityProcessor(WorkflowEngine workflowEngine)
 {
     _workflowEngine = workflowEngine;
 }
예제 #17
0
        public async Task RunWorkflow()
        {
            var nm = new NotifyManager();

            var configuration = new ConfigurationBuilder().Build();

            var scriptEngine = new ScriptEngine();

            var lg = new A2v10.ProcS.Tests.FakeLogger();

            var epm = new EndpointManager();

            var sp = new Services(epm);

            var rm = new ResourceManager(sp);

            var storage = new A2v10.ProcS.Tests.FakeStorage(rm, "../../../workflows/");

            var repository = new Repository(storage, storage, configuration);

            var mgr = new SagaManager(sp);

            var pmr = new PluginManager(sp);

            String pluginPath = ChatbotTests.GetPluginPath();

            ProcS.RegisterSagas(rm, mgr, scriptEngine, repository);
            ProcS.RegisterActivities(rm);

            pmr.LoadPlugins(pluginPath, configuration);


            pmr.RegisterResources(rm, mgr);


            var taskManager = new SyncTaskManager();
            var keeper      = new InMemorySagaKeeper(mgr.Resolver);
            var bus         = new ServiceBus(taskManager, keeper, lg, nm);
            var engine      = new WorkflowEngine(repository, bus, scriptEngine, lg, nm);

            sp.Add(bus);
            sp.Add(engine);

            var param = new DynamicObject
            {
                ["ChatId"] = "0c3af6d2-0000-0000-d2f6-3a0c00000000"
            };
            IInstance inst = await engine.StartWorkflow(new Identity("ChatBotTest.json"), param);

            await bus.Process();

            var plug = pmr.GetPlugin <Plugin>(Plugin.Name);
            await plug.GetBotAsync(BotEngine.Mocking, "TestBot");

            var m1json = msg1.Replace('\'', '"');
            var m1do   = DynamicObjectConverters.FromJson(m1json);
            var m1     = rm.Unwrap <IMessage>(m1do);

            bus.Send(m1);

            await bus.Process();

            var ni = await repository.Get(inst.Id);

            Assert.AreEqual("WaitForName", ni.CurrentState);
        }
 public EventProcessor(WorkflowEngine workflowEngine)
 {
     _workflowEngine = workflowEngine;
 }
예제 #19
0
        protected string GetWfpExSetting(string wfId, string wfpId, string settingName)
        {
            string result = string.Empty;

            return(WorkflowEngine.GetWfpExSetting(wfId, wfpId, settingName));
        }
예제 #20
0
 public Lead(WorkflowDefinition <string> workflowDefinition)
 {
     _workflowEngine = new WorkflowEngine <string>(workflowDefinition, null, this);
     _workflowEngine.OnStateTransition += WorkflowEngine_OnStateTransition;
 }
예제 #21
0
        public IdVersionModel AddNewWorkflow(WorkflowInfo model, WorkflowEngine workflowEngine, List <TaskNameModel> taskNames)
        {
            var xtasks = new XElement(xn + "Tasks");

            if (model.Tasks != null)
            {
                foreach (var task in model.Tasks)
                {
                    int    taskId        = task.Id;
                    string taskName      = string.IsNullOrEmpty(task.Name) ? string.Empty : task.Name;
                    string taskDesc      = string.IsNullOrEmpty(task.Description) ? string.Empty : task.Description;
                    bool   isTaskEnabled = task.IsEnabled;

                    var xtask = new XElement(xn + "Task"
                                             , new XAttribute("id", taskId)
                                             , new XAttribute("name", taskName)
                                             , new XAttribute("description", taskDesc)
                                             , new XAttribute("enabled", isTaskEnabled.ToString().ToLower())
                                             , new XAttribute("isCommon", task.IsCommon == null ? false : task.IsCommon)
                                             );

                    var settings = task.Settings;
                    if (settings != null)
                    {
                        foreach (var setting in settings)
                        {
                            string settingName  = string.IsNullOrEmpty(setting.Name) ? string.Empty : setting.Name;
                            string settingValue = string.IsNullOrEmpty(setting.Value) ? string.Empty : setting.Value;

                            var xsetting = new XElement(xn + "Setting"
                                                        , new XAttribute("name", settingName)
                                                        );

                            if (!string.IsNullOrEmpty(settingValue))
                            {
                                xsetting.SetAttributeValue("value", settingValue);
                            }

                            if (settingName == "selectFiles" || settingName == "selectAttachments")
                            {
                                if (!string.IsNullOrEmpty(settingValue))
                                {
                                    xsetting.SetAttributeValue("value", settingValue);
                                }
                            }
                            else
                            {
                                xsetting.SetAttributeValue("value", settingValue);
                            }

                            xtask.Add(xsetting);
                        }
                    }
                    xtasks.Add(xtask);
                }
            }

            var xGraph = new XElement(xn + "ExecutionGraph");

            if (model.Graph.NodeDataArray != null)
            {
                xGraph = new GraphCompatibility.GraphCompatibility(
                    taskNames,
                    model.Tasks,
                    workflowEngine.WorkflowsFolder,
                    model.Name)
                         .DesignExecutionGraph(model.Graph);
                SaveJsonGraph(model.Graph, workflowEngine.WorkflowsFolder, model.Name + "_0");
            }

            var xwf = new XElement(xn + "Workflow"
                                   , new XAttribute("id", (Convert.ToInt64(GetLastWorkflowId()) + 1).ToString())
                                   , new XAttribute("name", model.Name)
                                   , new XAttribute("description", string.IsNullOrEmpty(model.Description) ? string.Empty : model.Description)
                                   , new XElement(xn + "Settings"
                                                  , new XElement(xn + "Setting"
                                                                 , new XAttribute("name", "launchType")
                                                                 , new XAttribute("value", model.LaunchType.ToString().ToLower()))
                                                  , new XElement(xn + "Setting"
                                                                 , new XAttribute("name", "enabled")
                                                                 , new XAttribute("value", model.IsEnabled.ToString().ToLower()))
                                                  , new XElement(xn + "Setting"
                                                                 , new XAttribute("name", "period")
                                                                 , new XAttribute("value", TimeSpan.Parse(string.IsNullOrEmpty(model.Period) ? "00.00:00:00" : model.Period).ToString(@"dd\.hh\:mm\:ss")))
                                                  , new XElement(xn + "Setting"
                                                                 , new XAttribute("name", "version")
                                                                 , new XAttribute("value", 0))
                                                  , new XElement(xn + "Setting"
                                                                 , new XAttribute("name", "deadLine")
                                                                 , new XAttribute("value", model.DeadLine.ToString()))
                                                  )
                                   , xtasks, xGraph
                                   );
            var xdoc = new XDocument();

            xwf.Save(_configuration.WorkflowsHistoryFolder + model.Name + "_" + "0" + ".xml");
            xwf.Save(_configuration.WorkflowsFolder + model.Name + "_" + "0" + ".xml");

            return(new IdVersionModel
            {
                Version = "0",
                Id = GetLastWorkflowId()
            });
        }
예제 #22
0
 public IdleState(WorkflowEngine context, StateMap stateMap) : base(context, stateMap)
 {
 }
예제 #23
0
 public void NullLogger_Ctor_Throws()
 {
     ILogger logger = null;
     var     engine = new WorkflowEngine(logger);
 }
예제 #24
0
 public WorkflowController()
 {
     _engine = WorkflowApiService.WorkflowEngine;
 }
예제 #25
0
        public void ConsoleProcessTest()
        {
            var processId  = Guid.NewGuid();
            var newProcess = new ConsoleProcess()
            {
                Id = processId
            };

            var dal    = new WorkflowEngineDAL();
            var engine = new WorkflowEngine(dal);

            //Running proces in engine
            engine.AddProcess(newProcess);

            engine.RunOneIteration();            //powinien wyśweitlić dane 'Enter name'
            Assert.AreEqual(engine.GetProcessStatus(processId), EnumProcessStatus.WaitingForUserData);
            engine.SetUserData(processId, null); //nic nie podaje - to było tylko wyświetlenie
            var ser     = dal.GetSerializedProcess(processId);
            var rozmiar = ser.VirtualMachineXml.Length;
            var vm      = ser.GetVirtualMachine();
            var process = vm.GetProcess();


            engine.RunOneIteration(); //powinien poprosić od wczytanie danych z klawiatury
            Assert.AreEqual(engine.GetProcessStatus(processId), EnumProcessStatus.WaitingForUserData);
            engine.SetUserData(processId, new ConsoleRead()
            {
                Text = "Tomek"
            });
            ser     = dal.GetSerializedProcess(processId);
            rozmiar = ser.VirtualMachineXml.Length;
            vm      = ser.GetVirtualMachine();
            process = vm.GetProcess();


            engine.RunOneIteration();            //powinien wyśweitlić dane 'Enter age'
            Assert.AreEqual(engine.GetProcessStatus(processId), EnumProcessStatus.WaitingForUserData);
            engine.SetUserData(processId, null); //nic nie podaje - to było tylko wyświetlenie
            ser     = dal.GetSerializedProcess(processId);
            rozmiar = ser.VirtualMachineXml.Length;
            vm      = ser.GetVirtualMachine();
            process = vm.GetProcess();


            engine.RunOneIteration(); //powinien poprosić od wczytanie danych z klawiatury
            Assert.AreEqual(engine.GetProcessStatus(processId), EnumProcessStatus.WaitingForUserData);
            engine.SetUserData(processId, new ConsoleRead()
            {
                Text = "30"
            });
            ser     = dal.GetSerializedProcess(processId);
            rozmiar = ser.VirtualMachineXml.Length;
            vm      = ser.GetVirtualMachine();
            process = vm.GetProcess();


            engine.RunOneIteration(); //powinien zakończyć proces
            Assert.AreEqual(engine.GetProcessStatus(processId), EnumProcessStatus.Executed);

            process = engine.GetProcess(processId);
            Assert.AreEqual("Hello Tomek 30", process.ProcesOutput);
        }
예제 #26
0
 public ExternalProcessExecuteResult WorkflowGateExecute(string gateName, WorkflowContextData contextData)
 {
     return(WorkflowEngine.RunGate(gateName, contextData));
 }
예제 #27
0
 public StateProcessor(WorkflowEngine workflowEngine)
 {
     _workflowEngine      = workflowEngine;
     _activityProcessor   = new ActivityProcessor(workflowEngine);
     _transitionProcessor = new TransitionProcessor(workflowEngine);
 }
예제 #28
0
        // **************************************
        // CatalogUploadWorkflow
        // **************************************
        private WorkflowEngine<CatalogUploadState> CreateCatalogUploadWorkflow()
        {
            //Type t = Type.GetType("CatalogUploadWizardModel");

            var wf = new WorkflowEngine<CatalogUploadState>(new CatalogUploadState());
            //wf.Model = model;

            wf.WorkflowSteps = new List<WorkflowStep<CatalogUploadState>>();

            wf.WorkflowSteps.Add(new WorkflowStep<CatalogUploadState>(SelectCatalog, 0, "Select Catalog", "wfSelectCatalog", "Next Step"));
            wf.WorkflowSteps.Add(new WorkflowStep<CatalogUploadState>(AddSongFiles, 1, "Upload Song Files", "wfAddSongFiles", "Next Step"));
            wf.WorkflowSteps.Add(new WorkflowStep<CatalogUploadState>(AddSongPreviews, 2, "Upload Preview Files", "wfAddPreviewFiles", "Next Step"));
            wf.WorkflowSteps.Add(new WorkflowStep<CatalogUploadState>(EditMetadata, 3, "Review Song Data", "wfEditMetadata", "Next Step"));
            wf.WorkflowSteps.Add(new WorkflowStep<CatalogUploadState>(SaveCatalog, 4, "Save Catalog", "wfSaveCatalog", "Save"));
            wf.WorkflowSteps.Add(new WorkflowStep<CatalogUploadState>(ReviewComplete, 5, "Complete", "wfComplete", "Done"));

            return wf;
        }
예제 #29
0
        public static void StartServices(Action <StartOptions> opts)
        {
            // DI ready
            ServiceLocator.Start = (IServiceLocator locator) =>
            {
                var startOptions = new StartOptions();
                opts?.Invoke(startOptions);

                IProfiler        profiler   = startOptions.Profiler ?? new WebProfiler();
                IUserLocale      userLocale = new WebUserLocale();
                IApplicationHost host       = new WebApplicationHost(profiler, userLocale, locator);
                ILocalizer       localizer  = new WebLocalizer(host, userLocale);

                ITokenProvider tokenProvider = startOptions.TokenProvider;
                IDbContext     dbContext     = new SqlDbContext(
                    profiler as IDataProfiler,
                    host as IDataConfiguration,
                    localizer as IDataLocalizer,
                    host as ITenantManager,
                    tokenProvider);
                IDataScripter     scripter         = new VueDataScripter(host, localizer);
                ILogger           logger           = new WebLogger(host, dbContext);
                IMessageService   emailService     = new IdentityEmailService(logger, host);
                ISmsService       smsService       = new SmsService(dbContext, logger);
                IUserStateManager userStateManager = new EmptyUserStateManager();
                IMessaging        messaging        = new MessageProcessor(host, dbContext, emailService, smsService, logger);
                IWorkflowEngine   workflowEngine   = new WorkflowEngine(host, dbContext, messaging);
                IScriptProcessor  scriptProcessor  = new ScriptProcessor(scripter, host);
                IHttpService      httpService      = new HttpService();


                locator.RegisterService <IDbContext>(dbContext);
                locator.RegisterService <IProfiler>(profiler);
                locator.RegisterService <IApplicationHost>(host);
                locator.RegisterService <ILocalizer>(localizer);
                locator.RegisterService <IDataScripter>(scripter);
                locator.RegisterService <ILogger>(logger);
                locator.RegisterService <IMessageService>(emailService);
                locator.RegisterService <ISmsService>(smsService);
                locator.RegisterService <IMessaging>(messaging);
                locator.RegisterService <IWorkflowEngine>(workflowEngine);
                locator.RegisterService <IScriptProcessor>(scriptProcessor);
                locator.RegisterService <IHttpService>(httpService);
                locator.RegisterService <IUserLocale>(userLocale);
                locator.RegisterService <IUserStateManager>(userStateManager);
                if (tokenProvider != null)
                {
                    locator.RegisterService <ITokenProvider>(tokenProvider);
                }

                host.StartApplication(false);
                HttpContext.Current.Items.Add("ServiceLocator", locator);
            };

            ServiceLocator.GetCurrentLocator = () =>
            {
                var locator = HttpContext.Current.Items["ServiceLocator"];
                if (locator == null)
                {
                    new ServiceLocator();
                }
                return(HttpContext.Current.Items["ServiceLocator"] as IServiceLocator);
            };
        }
예제 #30
0
 public WorkflowController(WorkflowEngine engine)
 {
     _engine = engine;
 }
예제 #31
0
 public RunningState(WorkflowEngine context, StateMap stateMap) : base(context, stateMap)
 {
 }
예제 #32
0
 public RestoredState(WorkflowEngine context, StateMap stateMap) : base(context, stateMap)
 {
 }
예제 #33
0
        public IdVersionModel EditWorkflow(WorkflowInfo model, WorkflowEngine workflowEngine, List <TaskNameModel> taskNames)
        {
            var wf = workflowEngine.GetWorkflow(model.Id, model.Version);

            if (wf != null)
            {
                var xdoc = wf.XDoc;

                xdoc.Root.Attribute("id").Value          = model.Id.ToString();
                xdoc.Root.Attribute("name").Value        = model.Name;
                xdoc.Root.Attribute("description").Value = model.Description == null ? string.Empty : model.Description;

                TimeSpan workflowPeriod = TimeSpan.Parse(string.IsNullOrEmpty(model.Period) ? "00.00:00:00" : model.Period);

                xdoc.Root.XPathSelectElement("wf:Settings/wf:Setting[@name='enabled']", wf.XmlNamespaceManager).Attribute("value").Value    = model.IsEnabled.ToString().ToLower();
                xdoc.Root.XPathSelectElement("wf:Settings/wf:Setting[@name='launchType']", wf.XmlNamespaceManager).Attribute("value").Value = model.LaunchType.ToString().ToLower();
                xdoc.Root.XPathSelectElement("wf:Settings/wf:Setting[@name='version']", wf.XmlNamespaceManager).Attribute("value").Value    = (model.Version).ToString();
                xdoc.Root.XPathSelectElement("wf:Settings/wf:Setting[@name='deadLine']", wf.XmlNamespaceManager).Attribute("value").Value   = model.DeadLine.ToString();;
                xdoc.Root.XPathSelectElement("wf:Settings/wf:Setting[@name='period']", wf.XmlNamespaceManager).Attribute("value").Value     = workflowPeriod.ToString(@"dd\.hh\:mm\:ss");

                var xtasks = xdoc.Root.Element(wf.XNamespaceWf + "Tasks");
                xtasks.Elements(wf.XNamespaceWf + "Task").Remove();

                if (model.Tasks != null)
                {
                    foreach (var task in model.Tasks)
                    {
                        int    taskId        = task.Id;
                        string taskName      = string.IsNullOrEmpty(task.Name) ? string.Empty : task.Name;
                        string taskDesc      = string.IsNullOrEmpty(task.Description) ? string.Empty : task.Description;
                        bool   isTaskEnabled = task.IsEnabled;

                        var xtask = new XElement(wf.XNamespaceWf + "Task"
                                                 , new XAttribute("id", taskId)
                                                 , new XAttribute("name", taskName)
                                                 , new XAttribute("description", taskDesc)
                                                 , new XAttribute("enabled", isTaskEnabled.ToString().ToLower())
                                                 , new XAttribute("isCommon", task.IsCommon)
                                                 );

                        if (task.Settings != null)
                        {
                            foreach (var setting in task.Settings)
                            {
                                string settingName  = string.IsNullOrEmpty(setting.Name) ? string.Empty : setting.Name;
                                string settingValue = string.IsNullOrEmpty(setting.Value) ? string.Empty : setting.Value;

                                var xsetting = new XElement(wf.XNamespaceWf + "Setting", new XAttribute("name", settingName));
                                xsetting.SetAttributeValue("value", settingValue);
                                xtask.Add(xsetting);
                            }
                        }
                        xtasks.Add(xtask);
                    }
                }

                var xGraph = xdoc.Root.Element(xn + "ExecutionGraph");
                if (model.Graph.NodeDataArray.Any())
                {
                    if (xGraph != null)
                    {
                        xGraph.Remove();
                    }
                    xGraph = new GraphCompatibility.GraphCompatibility(taskNames, model.Tasks, workflowEngine.WorkflowsFolder, model.Name + "_" + (model.Version))
                             .DesignExecutionGraph(model.Graph);
                    xdoc.Root.Add(xGraph);
                    SaveJsonGraph(model.Graph, workflowEngine.WorkflowsFolder, model.Name + "_" + model.Version);
                }
                var outStream = System.IO.File.CreateText(model.Path);
                xdoc.Save(outStream);
                var path          = workflowEngine.WorkflowsFolder + "\\" + model.Name + "_" + model.Version + ".xml";
                var outStreamRoot = System.IO.File.CreateText(path);
                xdoc.Save(outStreamRoot);
                outStreamRoot.Close();
                outStream.Close();
            }

            return(new IdVersionModel
            {
                Id = model.Id.ToString(),
                Version = (model.Version).ToString()
            });
        }