示例#1
0
        public static void Main(String[] args)
        {
            Console.WriteLine("Workflow Engine");
            Console.WriteLine();

            var launchArguments = new LaunchArgument();

            foreach (var a in args)
            {
                if (a == "/ui")
                {
                    launchArguments.UI = "ui";
                }
                else if (a.StartsWith("/d:"))
                {
                    launchArguments.Domain = a.Substring(a.LastIndexOf(":") + 1);
                }
                else if (a.StartsWith("/u:"))
                {
                    launchArguments.User = a.Substring(a.LastIndexOf(":") + 1);
                }
                else if (a.StartsWith("/p:"))
                {
                    launchArguments.Password = a.Substring(a.LastIndexOf(":") + 1);
                }
                else if (a.StartsWith("/sd:"))
                {
                    launchArguments.SourceDirectory = a.Substring(a.LastIndexOf(":") + 1);
                }
                else if (a.StartsWith("/sf:"))
                {
                    launchArguments.SourceFile = a.Substring(a.LastIndexOf(":") + 1);
                }
                else if (a.StartsWith("/od:"))
                {
                    launchArguments.OutputDirectory = a.Substring(a.LastIndexOf(":") + 1);
                }
                else if (a.StartsWith("/of:"))
                {
                    launchArguments.OutputFile = a.Substring(a.LastIndexOf(":") + 1);
                }
                else if (a.StartsWith("/off:"))
                {
                    launchArguments.OutputFileFormat = a.Substring(a.LastIndexOf(":") + 1);
                }
            }

            var launcher = new WorkflowLauncher();

            launcher.Execute(launchArguments);
        }
示例#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);
            }
        }