public static FlowEnvironment Load(string path) { FileInfo fileInfo = new FileInfo(path); if (!fileInfo.Exists) { throw new FileNotFoundException("The speficied flow path could not be found : " + path, path); } Flow flow = null; switch (fileInfo.Extension) { case ".xflow": XDocument document = XDocument.Load(fileInfo.FullName); flow = XFlow.Load(document); break; default: throw new NotSupportedException("The specified flow format is not supported by FlowTomator service yet"); } if (flow == null) { throw new Exception("The specified flow could not be loaded"); } return(new FlowEnvironment(path) { flow = flow }); }
private void Reload() { Log.Trace("{0}oading flow {1}", flow == null ? "L" : "Rel", File.Name); flow = null; switch (File.Extension) { case ".xflow": XDocument document = XDocument.Load(File.FullName); flow = XFlow.Load(document); break; } if (flow == null) { throw new Exception("The specified flow format is not supported"); } }
public static void Main(string[] args) { Console.Title = "FlowTomator"; Options = args.Where(a => a.StartsWith("/")) .Select(a => a.TrimStart('/')) .Select(a => new { Parameter = a.Trim(), Separator = a.Trim().IndexOf(':') }) .ToDictionary(a => a.Separator == -1 ? a.Parameter : a.Parameter.Substring(0, a.Separator).ToLower(), a => a.Separator == -1 ? null : a.Parameter.Substring(a.Separator + 1)); Parameters = args.Where(a => !a.StartsWith("/")) .ToList(); if (Options.ContainsKey("log")) { LogVerbosity verbosity; if (!Enum.TryParse(Options["log"], true, out verbosity)) { Log.Error("The specified log verbosity does not exist"); Exit(-1); } Log.Verbosity = verbosity; } string flowPath = Parameters.FirstOrDefault(); if (flowPath == null) { Log.Error("You must specify a flow to evaluate"); Exit(-1); } FileInfo flowInfo = new FileInfo(flowPath); if (!flowInfo.Exists) { Log.Error("Could not find the specified flow"); Exit(-1); } Console.Title = "FlowTomator - " + flowInfo.Name; Flow flow = null; try { switch (flowInfo.Extension) { case ".xflow": flow = XFlow.Load(XDocument.Load(flowInfo.FullName)); break; } } catch { } if (flow == null) { Log.Error("Could not load the specified flow"); return; } flow.Reset(); NodeStep nodeStep = flow.Evaluate(); Exit((int)nodeStep.Result); }