예제 #1
0
        private static void CreateFileCreateEventHandler(ISession session)
        {
            var workflow = new DefinedWorkflow();
            workflow.Name = "DeleteFileOnCreate";
            session.SaveOrUpdate(workflow);

            var definedTask = new DefinedTask();
            definedTask.Name = "Test";
            definedTask.RunCode =
                @"foreach(var parameter in parameters)
                                    {
                                        System.Console.WriteLine(""{0}:{1}:{2}"", parameter.Category, parameter.Name, parameter.Value);
                                    }

                                    string hostname = parameters.Where(p => p.Category == ""EventParameter"" && p.Name == ""Client"").Single().Value;
                                    string path = parameters.Where(p => p.Category == ""EventParameter"" && p.Name == ""Path"").Single().Value;
                                    string file = parameters.Where(p => p.Category == ""EventParameter"" && p.Name == ""Filename"").Single().Value;

                                    string filePath = System.IO.Path.Combine(path, file);

                                    System.Console.WriteLine(hostname);
                                    System.Console.WriteLine(filePath);

                                    File.Delete(hostname, filePath);

                                    return 0;";
            session.SaveOrUpdate(definedTask);

            var definedWorkflowStep = new DefinedWorkflowStep();
            definedWorkflowStep.DefinedTask = definedTask;
            definedWorkflowStep.DefinedWorkflow = workflow;
            session.SaveOrUpdate(definedWorkflowStep);

            var nextWorkflowStep = new DefinedNextWorkflowStep();
            nextWorkflowStep.DefinedWorkflow = workflow;
            nextWorkflowStep.NextStep = definedWorkflowStep;
            nextWorkflowStep.PreviousStep = null;
            session.SaveOrUpdate(nextWorkflowStep);

            var lastWorkflowStep = new DefinedNextWorkflowStep();
            lastWorkflowStep.DefinedWorkflow = workflow;
            lastWorkflowStep.PreviousStep = definedWorkflowStep;
            lastWorkflowStep.NextStep = null;
            session.SaveOrUpdate(lastWorkflowStep);

            var defaultEventHandler = new EventHandler();
            defaultEventHandler.DefinedWorkflow = workflow;
            defaultEventHandler.EventGroupTypes = "Filesystem";
            defaultEventHandler.EventType = "Add";

            session.SaveOrUpdate(defaultEventHandler);
        }
예제 #2
0
        private static void CreateEventHandler(ISession session)
        {
            var workflow = new DefinedWorkflow();
            workflow.Name = "Test";
            session.SaveOrUpdate(workflow);

            var definedTask = new DefinedTask();
            definedTask.Name = "Test";
            definedTask.RunCode =
                @"foreach(var parameter in parameters)
                                    {
                                        System.Console.WriteLine(""{0}:{1}:{2}"", parameter.Category, parameter.Name, parameter.Value);
                                    }

                                    return 0;";
            session.SaveOrUpdate(definedTask);

            var definedWorkflowStep = new DefinedWorkflowStep();
            definedWorkflowStep.DefinedTask = definedTask;
            definedWorkflowStep.DefinedWorkflow = workflow;
            session.SaveOrUpdate(definedWorkflowStep);

            var nextWorkflowStep = new DefinedNextWorkflowStep();
            nextWorkflowStep.DefinedWorkflow = workflow;
            nextWorkflowStep.NextStep = definedWorkflowStep;
            nextWorkflowStep.PreviousStep = null;
            session.SaveOrUpdate(nextWorkflowStep);

            var lastWorkflowStep = new DefinedNextWorkflowStep();
            lastWorkflowStep.DefinedWorkflow = workflow;
            lastWorkflowStep.PreviousStep = definedWorkflowStep;
            lastWorkflowStep.NextStep = null;
            session.SaveOrUpdate(lastWorkflowStep);

            var defaultEventHandler = new EventHandler();
            defaultEventHandler.DefinedWorkflow = workflow;

            session.SaveOrUpdate(defaultEventHandler);
        }
예제 #3
0
        private RunnedWorkflow CreateRunnedWorkflow(ITransactionScope transactionScope, DefinedWorkflow definedWorkflow, Event eventInformation)
        {
            var runnedWorkflow = _runnedWorkflowRepository.Create();
            runnedWorkflow.DefinedWorkflow = definedWorkflow;
            _runnedWorkflowRepository.Save(transactionScope, runnedWorkflow);

            var runnedWorkflowSteps = CreateRunnedWorkflowSteps(transactionScope, definedWorkflow.WorkflowSteps, runnedWorkflow);
            CreateRunnedNextWorkflowSteps(transactionScope, definedWorkflow.NextWorkflowSteps, runnedWorkflow, runnedWorkflowSteps);

            CreateParameters(transactionScope, runnedWorkflow, eventInformation);

            return runnedWorkflow;
        }
예제 #4
0
        private static void CreateSimpleWorkflow(ISession session, string workflowName, string taskName, string runCode, string eventGroupTypes)
        {
            var workflow = new DefinedWorkflow();
            workflow.Name = workflowName;
            session.SaveOrUpdate(workflow);

            var definedTask = new DefinedTask();
            definedTask.Name = taskName;
            definedTask.RunCode = runCode;
            session.SaveOrUpdate(definedTask);

            var definedWorkflowStep = new DefinedWorkflowStep();
            definedWorkflowStep.DefinedTask = definedTask;
            definedWorkflowStep.DefinedWorkflow = workflow;
            session.SaveOrUpdate(definedWorkflowStep);

            var nextWorkflowStep = new DefinedNextWorkflowStep();
            nextWorkflowStep.DefinedWorkflow = workflow;
            nextWorkflowStep.NextStep = definedWorkflowStep;
            nextWorkflowStep.PreviousStep = null;
            session.SaveOrUpdate(nextWorkflowStep);

            var lastWorkflowStep = new DefinedNextWorkflowStep();
            lastWorkflowStep.DefinedWorkflow = workflow;
            lastWorkflowStep.PreviousStep = definedWorkflowStep;
            lastWorkflowStep.NextStep = null;
            session.SaveOrUpdate(lastWorkflowStep);

            var defaultEventHandler = new EventHandler();
            defaultEventHandler.DefinedWorkflow = workflow;
            defaultEventHandler.EventGroupTypes = eventGroupTypes;

            session.SaveOrUpdate(defaultEventHandler);
        }
예제 #5
0
        private static void CreateIrcResponder(ISession session)
        {
            var workflow = new DefinedWorkflow();
            workflow.Name = "IrcResponder";
            session.SaveOrUpdate(workflow);

            var definedTask = new DefinedTask();
            definedTask.Name = "IrcAnswer";
            definedTask.RunCode = @"
                                    var channels = parameters.Where(p => p.Category == ""EventParameter"" && p.Name == ""Channels"").Single().Value;
                                    string message = parameters.Where(p => p.Category == ""EventParameter"" && p.Name == ""Message"").Single().Value;
                                    string hostname = parameters.Where(p => p.Category == ""EventParameter"" && p.Name == ""Client"").Single().Value;

                                    var channel = channels.Split(',')[0];

                                    Irc.SendMessage(hostname, channel, message);

                                    return 0;
                                    ";
            session.SaveOrUpdate(definedTask);

            var definedWorkflowStep = new DefinedWorkflowStep();
            definedWorkflowStep.DefinedTask = definedTask;
            definedWorkflowStep.DefinedWorkflow = workflow;
            session.SaveOrUpdate(definedWorkflowStep);

            var nextWorkflowStep = new DefinedNextWorkflowStep();
            nextWorkflowStep.DefinedWorkflow = workflow;
            nextWorkflowStep.NextStep = definedWorkflowStep;
            nextWorkflowStep.PreviousStep = null;
            session.SaveOrUpdate(nextWorkflowStep);

            var lastWorkflowStep = new DefinedNextWorkflowStep();
            lastWorkflowStep.DefinedWorkflow = workflow;
            lastWorkflowStep.PreviousStep = definedWorkflowStep;
            lastWorkflowStep.NextStep = null;
            session.SaveOrUpdate(lastWorkflowStep);

            var defaultEventHandler = new EventHandler();
            defaultEventHandler.DefinedWorkflow = workflow;
            defaultEventHandler.EventGroupTypes = "Irc";

            session.SaveOrUpdate(defaultEventHandler);
        }