private void StopFlowButton_Click(object sender, EventArgs e) { FlowEnvironment flow = sender as FlowEnvironment; if (flow == null) { return; } flow.Stop(); }
private void ReloadFlowButton_Click(object sender, EventArgs e) { FlowEnvironment flow = sender as FlowEnvironment; if (flow == null) { return; } flow.Restart(true); }
public void Unload(FlowEnvironment flow) { Log.Debug("Unloading {0}", flow.File.Name); try { flow.Stop(); Log.Info("Unloaded {0}", flow.File.Name); } catch (Exception e) { OnNotification(new FlowTomatorNotification(LogVerbosity.Error, "Failed to unload the specified flow : " + flow.File.Name + ". " + e.Message)); } Flows.Remove(flow); }
private void RemoveFlowButton_Click(object sender, EventArgs e) { FlowEnvironment flow = sender as FlowEnvironment; if (flow == null) { return; } if (flow.Running) { flow.Stop(); } Service.Unload(flow); }
private void EditFlowButton_Click(object sender, EventArgs e) { FlowEnvironment flow = sender as FlowEnvironment; if (flow == null) { return; } // Try to find FlowTomator.Desktop.exe string assemblyPath = Assembly.GetExecutingAssembly().Location; string assemblyDirectory = Path.GetDirectoryName(assemblyPath); string editorPath = Path.Combine(assemblyDirectory, "FlowTomator.Desktop.exe"); if (!File.Exists(editorPath)) { MessageBox.Show("Could not find FlowTomator editor"); return; } // Start the editor Process.Start(editorPath, flow.File.FullName); }
private void LoadFlowButton_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "XFlow files (*.xflow)|*.xflow|All files (*.*)|*.*"; openFileDialog.FilterIndex = 1; DialogResult result = openFileDialog.ShowDialog(); if (result != DialogResult.OK) { return; } try { FlowEnvironment flow = Service.Load(openFileDialog.FileName); flow.Start(); } catch (Exception ex) { } }
public FlowEnvironment Load(string path) { FlowEnvironment flow = null; Log.Debug("Loading {0}", path); try { flow = FlowEnvironment.Load(path); Log.Info("Loaded {0}", flow.File.Name); } catch (Exception e) { OnNotification(new FlowTomatorNotification(LogVerbosity.Error, "Failed to load the specified flow : " + path + ". " + e.Message)); } if (flow == null) { return(null); } Flows.Add(flow); return(flow); }
protected override void OnStart(string[] args) { Parameters = args.Where(p => p.StartsWith("/")) .Select(p => p.TrimStart('/')) .Select(p => new { Parameter = p.Trim(), Separator = p.Trim().IndexOf(':') }) .ToDictionary(p => p.Separator == -1 ? p.Parameter.ToLower() : p.Parameter.Substring(0, p.Separator).ToLower(), p => p.Separator == -1 ? null : p.Parameter.Substring(p.Separator + 1)); // Handle parameters if (Parameters.ContainsKey("log")) { LogFile = new FileInfo(Parameters["log"]); } else { LogFile = new FileInfo(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "FlowTomator.Service.log")); } // Redirect logging LogTextWriter textWriter = new LogTextWriter(); textWriter.NewLine += TextWriter_Updated; Console.SetOut(textWriter); Console.SetError(textWriter); // Start service Log.Info(Environment.NewLine); Log.Info("Starting FlowTomator service"); base.OnStart(args); // Share service via .NET remoting Log.Debug("Enabling remote monitoring"); BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); serverProvider.TypeFilterLevel = TypeFilterLevel.Full; IChannel channel = new IpcServerChannel("FlowTomator", "FlowTomator.Service", serverProvider); ChannelServices.RegisterChannel(channel); serviceRef = RemotingServices.Marshal(this, nameof(FlowTomatorService)); Log.Info("Service started"); // Autostart startup flows if (Settings.Default.StartupFlows != null) { foreach (string startupFlow in Settings.Default.StartupFlows) { string path = startupFlow; if (!Path.IsPathRooted(path)) { path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), path); } FlowEnvironment flow = Load(path); flow.Start(); } } Flows.CollectionChanged += Flows_CollectionChanged; }
public void Unload(FlowEnvironment flow) { Log.Debug("Unloading {0}", flow.File.Name); try { flow.Stop(); Log.Info("Unloaded {0}", flow.File.Name); } catch (Exception e) { OnNotification(new FlowTomatorNotification(LogVerbosity.Error, "Failed to unload the specified flow : " + flow.File.Name + ". " + e.Message)); } Flows.Remove(flow); }