private CommandElement GetStartCommand(CaptureProfileElement captureProfile) { CommandElement startCommand; if (!string.IsNullOrEmpty(captureProfile.Path)) { // Since they defined a Path/CommandLineFormat on the element // we'll use it instead of one that might have been defined in the Commands startCommand = captureProfile.Commands.FirstOrDefault(c => c.Event == CommandEvent.Start); if (startCommand != null) { captureProfile.Commands.Remove(startCommand); } startCommand = new CommandElement() { //Name = "__StartRecording", Event = CommandEvent.Start, Path = captureProfile.Path, CommandLineFormat = captureProfile.CommandLineFormat, DelayAfterStart = TimeSpan.FromSeconds(0), }; captureProfile.Commands.Add(startCommand); } else { if (!captureProfile.Commands.Any()) { throw new InvalidOperationException( string.Format("No commands defined for this CaptureProfile: name={0}", captureProfile.Name)); } if (captureProfile.Commands.All(c => c.Event != CommandEvent.Start)) { throw new InvalidOperationException( string.Format("No START event commands defined for this CaptureProfile: name={0}", captureProfile.Name)); } startCommand = captureProfile.Commands.FirstOrDefault(c => c.Event == CommandEvent.Start); } if (!File.Exists(startCommand.Path)) { var msg = string.Format("Cannot find capture executable {0}", startCommand.Path); throw new InvalidOperationException(msg); } return(startCommand); }
public ExecutableProcessCaptureManager(CaptureProfileElement captureProfile, TunerElement tuner) { _captureProfile = captureProfile; _tuner = tuner; var startCommand = GetStartCommand(captureProfile); Logger = LogManager.GetLogger(tuner.Name + ":" + _captureProfile.Name); _executableName = Path.GetFileNameWithoutExtension(startCommand.Path); Logger.Debug("PathToExecutable={0}", startCommand.Path); Logger.Debug("CommandLineFormat={0}", startCommand.CommandLineFormat); LookForExistingProcessForThisTuner(startCommand.Path); }