internal override void OnEventRaised(RaisedEvent raisedEvent, MAObjectHologram sender)
        {
            if (sender == null)
            {
                throw new ArgumentNullException("sender");
            }

            if (raisedEvent == null)
            {
                throw new ArgumentNullException("raisedEvent");
            }

            IList <object> arguments = this.Arguments.Expand(sender);

            if (arguments.Count > 1)
            {
                throw new ArgumentException(
                          string.Format("The command argument declaration returned too many values. Only a single value is allowed to be returned from the declaration\nDeclaration:{0}\nObject:{1}",
                                        this.Arguments.Declaration,
                                        sender.DisplayText));
            }

            string argument = arguments.FirstOrDefault() as string;

            if (argument != null)
            {
                raisedEvent.RaisedEventProperties.Add("arguments", argument);
            }
        }
        public void Execute(RaisedEvent raisedEvent)
        {
            if (this.IsDisabled)
            {
                Logger.WriteLine("Skipping disabled event: {0}", this.ID);
                return;
            }

            if (this.RunAsync)
            {
                AcmaExternalExitEvent.EventQueue.Add(raisedEvent);
            }
            else
            {
                this.ExecuteInternal(raisedEvent);
            }
        }
        protected override void ExecuteInternal(RaisedEvent raisedEvent)
        {
            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.FileName        = this.CommandLine;
            startInfo.Arguments       = raisedEvent.RaisedEventProperties.ContainsKey("arguments") ? raisedEvent.RaisedEventProperties["arguments"] as string : null;
            startInfo.CreateNoWindow  = true;
            startInfo.UseShellExecute = false;
            startInfo.WindowStyle     = ProcessWindowStyle.Hidden;

            Logger.WriteLine("Starting process {0} {1}", this.CommandLine, startInfo.Arguments);
            Process p = new Process();

            p.StartInfo = startInfo;
            p.Start();
            p.WaitForExit();
            Logger.WriteLine("Process returned exit code {0}", LogLevel.Info, p.ExitCode);

            if (p.ExitCode != 0)
            {
                throw new Win32Exception(p.ExitCode);
            }
        }
Esempio n. 4
0
 internal override void OnEventRaised(RaisedEvent raisedEvent, MAObjectHologram sender)
 {
     this.ExternalEvent.OnEventRaised(raisedEvent, sender);
 }
Esempio n. 5
0
 protected override void ExecuteInternal(RaisedEvent raisedEvent)
 {
     this.ExternalEvent.Execute(raisedEvent);
 }
 protected abstract void ExecuteInternal(RaisedEvent raisedEvent);
Esempio n. 7
0
 internal virtual void OnEventRaised(RaisedEvent raisedEvent, MAObjectHologram sender)
 {
 }