示例#1
0
        public void RunBasicWorkflow()
        {
            var batch = WorkflowEngineMock.GetRegisterCustomerWorkflowBatch();

            var runner = new WorkflowRunner(batch);

            var executionSummary = runner.Execute();

            var serialized = serializer.Serialize(executionSummary);

            Console.WriteLine(serialized);

            File.WriteAllText(GetExecutionResultsPath(String.Format("RegisterCustomer.Results.{0}", serializer.FileExtension)), serialized, Encoding.UTF8);
        }
示例#2
0
        public void Execute(LaunchArgument args)
        {
            if (!String.IsNullOrEmpty(args.Domain) && !String.IsNullOrEmpty(args.User) && !String.IsNullOrEmpty(args.Password) && !String.IsNullOrEmpty(args.SourceFile))
            {
                var login = new LoginModel(args.Domain, args.User, args.Password);

                var batch = serializer.DeserializeFrom<WorkflowBatch>(args.SourceFile);

                var runner = new WorkflowRunner(batch);

                Console.WriteLine("Validation messages");

                foreach (var item in runner.GetValidationMessages())
                {
                    Console.WriteLine("Workflow batch: {0}", item.WorkflowBatchName);
                    Console.WriteLine("Workflow name: {0}", item.WorkflowName);
                    Console.WriteLine("Workflow task: {0}", item.WorkflowTaskName);
                    Console.WriteLine("Type: {0}", item.MessageType);
                    Console.WriteLine("Message: {0}", item.Message);
                    Console.WriteLine();
                }

                Console.WriteLine("Workflow batch execution started at: '{0}'", DateTime.Now);
                Console.WriteLine();

                runner.StartProcessWorkflow += (source, a) =>
                {
                    Console.WriteLine("Workflow: '{0}'", a.Workflow.Name);
                    Console.WriteLine(" Starting at '{0}'", DateTime.Now);
                };

                runner.ProcessWorkflow += (source, a) =>
                {
                    Console.WriteLine(" Processing...");
                };

                runner.EndProcessWorkflow += (source, a) =>
                {
                    Console.WriteLine(" Ending at '{0}'", DateTime.Now);
                    Console.WriteLine();
                };

                var executionSummary = runner.Execute();

                Console.WriteLine("Workflow batch execution finished at: '{0}'", DateTime.Now);
                Console.WriteLine();

                Console.WriteLine("Execution Summary");
                Console.WriteLine();

                Console.WriteLine("Executed: {0}", executionSummary.ExecutedCount);
                Console.WriteLine("Success: {0}", executionSummary.SuccessCount);
                Console.WriteLine("KnownIssue: {0}", executionSummary.KnownIssueCount);
                Console.WriteLine("Failed: {0}", executionSummary.FailedCount);
                Console.WriteLine("Total: {0}", executionSummary.Results.Count);

                if (!String.IsNullOrEmpty(args.OutputFile))
                {
                    serializer.SerializeTo(args.OutputFile, executionSummary);
                }
            }
            else if (!String.IsNullOrEmpty(args.UI))
            {
                var login = new LoginModel(args.Domain, args.User, args.Password);

                var app = new App();

                var viewModel = new LayoutViewModel();

                var view = new LayoutView
                {
                    DataContext = viewModel
                };

                app.Run(view);
            }
        }
示例#3
0
        public void ExecuteAction()
        {
            if (String.IsNullOrEmpty(FileName))
            {
                return;
            }

            var batch = serializer.DeserializeFrom<WorkflowBatch>(FileName);

            var runner = new WorkflowRunner(batch);

            ExecutionSummary = new ExecutionSummary();

            foreach (var item in runner.GetValidationMessages())
            {
                ExecutionSummary.ValidationMessages.Add(item);
            }

            ExecutionWorker = new BackgroundWorker();

            ExecutionWorker.DoWork += (sender, eventArgs) =>
            {
                runner.StartProcessWorkflow += (source, args) =>
                {
                    Status = String.Format("Starting workflow: '{0}'", args.Workflow.Name);
                };

                runner.ProcessWorkflow += (source, args) =>
                {
                    Status = String.Format("Processing workflow: '{0}'", args.Workflow.Name);
                };

                runner.EndProcessWorkflow += (source, args) =>
                {
                    Status = String.Format("Ending workflow: '{0}'", args.Workflow.Name);
                };

                foreach (var item in runner.ExecuteWorkflows())
                {
                    App.Current.Dispatcher.Invoke(() =>
                    {
                        Results.Add(item);
                    });
                }
            };

            ExecutionWorker.RunWorkerAsync();
        }