protected override Task PerformAction(object sender, ApplicationHookEventArgs args) { if (PerformActionOverride == null) { return base.PerformAction(sender, args); } return PerformActionOverride(sender, args); }
private void OnEventOccurred(object sender, ApplicationHookEventArgs args) { if (this.isDisposed) { return; } PerformAction(sender, args); }
protected override void PerformAction(object sender, ApplicationHookEventArgs args) { if (PerformActionOverride == null) { base.PerformAction(sender, args); return; } PerformActionOverride(sender, args); }
protected virtual Task PerformAction(object sender, ApplicationHookEventArgs args) { return Task.Factory.StartNew( () => { if (!File.Exists(FileName)) { using (File.CreateText(FileName)) { } } string commandLine = string.Format( CultureInfo.CurrentCulture, "{0} \"{1}\" \"{2}\" \"{3}\" \"{4}\" \"{5}\"", FileName, args.EventType, args.EventSubcategory, args.Origin, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), sender); this.logger.LogInfo(() => "Executing batch file with commandline: " + commandLine); var processInfo = new ProcessStartInfo("cmd.exe", "/c " + commandLine) { CreateNoWindow = true, UseShellExecute = false, RedirectStandardError = false, RedirectStandardOutput = false, }; Process process = Process.Start(processInfo); process.WaitForExit(5000); this.logger.LogInfo(() => "Output from commandline:\n" + process.StandardOutput.ReadToEnd()); }); }
protected virtual void PerformAction(object sender, ApplicationHookEventArgs args) { this.logger.LogInfo(() => string.Format(CultureInfo.CurrentCulture, "Application Hook Event Occurred. Sender: [{0}], Type: {1}, Origin: {2}", sender, args.EventType, args.Origin)); }