Пример #1
0
        protected void LoadWorkFlowsToSession()
        {
            var environment = new EnvironmentContext
            {
                Name = "prod",
                RootRouteKey = "admin",
            };

            // Setup workflow with a job and a command
            var wf = new WorkFlow("Get Current Network Shares", environment)
            {
                Jobs = new List<Job> {
                         new Job {
                         Name = "List Shares",
                         Commands = new List<Command>() {
                           new Command("NET Command","listshares")
                           {
                              ExecuteFile = @"c:\windows\system32\net.exe",
                              Arguments = "share",
                           },
                         }
                     }
                }
            };

            Session["workflows"] = new List<WorkFlow> { wf };
        }
        public WorkFlowResultWatcher(WorkFlow wf)
        {
            if (wf == null)
                throw new Exception("Workflow must not be null");

            _results = new Dictionary<string, List<CommandResultMessage>>();
            Tasks = new List<Task>();

            var cmds = wf.Jobs.SelectMany(j => j.Commands).ToList();
            foreach (var c in cmds)
            {
                AddCommandResultQueue(wf.TargetEnvironment,c.CommandQueue);
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            var environment = new EnvironmentContext();

            // Setup workflow with a job and a command
            var wf = new WorkFlow("Get Current Network Shares and Windows Directory", environment)
            {
                Jobs = new List<Job> {
                         new Job {
                         Name = "List Shares and Directories",
                         Commands = new List<Command>() {
                           new Command("NET Command","listshares")
                           {
                              ExecuteFile = @"c:\windows\system32\net.exe",
                              Arguments = "share",
                           },
                           new Command("NET Command","listdir")
                           {
                              ExecuteFile = @"c:\windows\system32\cmd.exe",
                              Arguments = @"/c dir",
                              WorkingDirectory = @"c:\windows",
                           },
                         }
                     }
                }
            };

            // Listen for results
            var workflowResultWatcher = new WorkFlowResultWatcher(wf);

            // Execute the workflow
            do
            {
                Console.WriteLine("Hit Enter To Execute Workflow");
                if (Console.ReadLine()=="q")
                    break;
                wf.Execute();
            } while (true);

            foreach (var line in workflowResultWatcher.GetAllResults())
                Console.WriteLine(line.CommandResult);
        }
Пример #4
0
 public void WorkflowNameNotNull()
 {
     try
     {
         var wf = new WorkFlow(null,
                               new EnvironmentContext {
                                   Name = "prod",
                                   });
     }
     catch (Exception ex)
     {
         Assert.AreEqual("Workflow must have a name.", ex.Message);
     }
 }
Пример #5
0
 public void WorkflowMustHaveEnvironment()
 {
     try
     {
         var wf = new WorkFlow("MAT Security Import", null);
     }
     catch (Exception ex)
     {
         Assert.AreEqual("Workflow must have an environment.", ex.Message);
     }
 }
Пример #6
0
 public void WorkflowHasTarget()
 {
     var wf = new WorkFlow("MAT Securities Import",new EnvironmentContext { Name = "prod" });
     Assert.IsNotNull(wf.TargetEnvironment);
 }
Пример #7
0
        public void JobExecutesCommandUsingAMessageProducer()
        {
            var env = new EnvironmentContext
            {
                Name = "atest",
                RootRouteKey = "admin",
            };

            var wf = new WorkFlow("Test Workflow", env);
            var job = new Job {
                ParentWorkFlow = wf,
                Commands = new Command[] { new Command("Test Command","testqueue") },
                };

            job.MessageProducer = Substitute.For<IMessageProducer>();
            job.Execute();

            Assert.AreEqual("atest.admin.testqueue", job.Commands[0].RoutingKey);
            job.MessageProducer.Received().Publish(Arg.Any<Message>(),Arg.Any<NetworkCredential>());
        }