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); }
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); }
private RunnedTask CreateRunnedTask(ITransactionScope transactionScope, DefinedTask definedTask) { var runnedTask = _runnedTaskRepository.Create(); runnedTask.DefinedTask = definedTask; runnedTask.RunCode = definedTask.RunCode; _runnedTaskRepository.Save(transactionScope, runnedTask); return runnedTask; }
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); }
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); }