예제 #1
0
        protected override void Execute(CodeActivityContext context)
        {
            int row     = Row.Get(context);
            int column  = Column.Get(context);
            int length  = Length.Get(context);
            var timeout = Timeout.Get(context);

            if (Timeout == null || Timeout.Expression == null)
            {
                timeout = TimeSpan.FromSeconds(3);
            }
            var vars = context.DataContext.GetProperties();

            Interfaces.VT.ITerminalSession session = null;
            foreach (dynamic v in vars)
            {
                var val = v.GetValue(context.DataContext);
                if (val is Interfaces.VT.ITerminalSession _session)
                {
                    session = val;
                }
            }
            if (session == null)
            {
                throw new ArgumentException("Failed locating terminal session");
            }
            if (session.Terminal == null)
            {
                throw new ArgumentException("Terminal Sessoin not initialized");
            }
            if (!session.Terminal.IsConnected)
            {
                throw new ArgumentException("Terminal Sessoin not connected");
            }
            if (WaitForKeyboard.Get(context))
            {
                session.Terminal.WaitForKeyboardUnlocked(timeout);
            }
            var result = session.Terminal.GetTextAt(column, row, length);

            Result.Set(context, result);
        }
예제 #2
0
        protected override void Execute(CodeActivityContext context)
        {
            int    field   = Field.Get(context);
            string text    = Text.Get(context);
            var    timeout = Timeout.Get(context);

            if (Timeout == null || Timeout.Expression == null)
            {
                timeout = TimeSpan.FromSeconds(3);
            }
            var vars = context.DataContext.GetProperties();

            Interfaces.VT.ITerminalSession session = null;
            foreach (dynamic v in vars)
            {
                var val = v.GetValue(context.DataContext);
                if (val is Interfaces.VT.ITerminalSession _session)
                {
                    session = val;
                }
            }
            if (session == null)
            {
                throw new ArgumentException("Failed locating terminal session");
            }
            if (session.Terminal == null)
            {
                throw new ArgumentException("Terminal Sessoin not initialized");
            }
            if (!session.Terminal.IsConnected)
            {
                throw new ArgumentException("Terminal Sessoin not connected");
            }
            Interfaces.VT.IField _f = null;
            var sw = new Stopwatch();

            sw.Start();

            do
            {
                _f = session.Terminal.GetField(field);
                if (sw.Elapsed > timeout)
                {
                    throw new Exception("Failed locating field #" + field);
                }
            } while (_f == null || (_f.Location.Column == 0 && _f.Location.Row == 0));
            if (_f == null)
            {
                throw new ArgumentException("Field not found");
            }
            session.Refresh();
            if (WaitForKeyboard.Get(context))
            {
                session.Terminal.WaitForKeyboardUnlocked(timeout);
            }
            session.Terminal.SendText(field, text);
            if (WaitForKeyboard.Get(context))
            {
                session.Terminal.WaitForKeyboardUnlocked(timeout);
            }
        }