Esempio n. 1
0
        protected override void StartLoop(NativeActivityContext context)
        {
            Interfaces.VT.ITerminalSession session = null;
            var timeout = Timeout.Get(context);

            if (Timeout == null || Timeout.Expression == null)
            {
                timeout = TimeSpan.FromSeconds(3);
            }
            string WorkflowInstanceId = context.WorkflowInstanceId.ToString();

            GenericTools.RunUI(() =>
            {
                //
                termOpen3270Config Config = new termOpen3270Config();
                Config.Hostname           = Hostname.Get(context);
                Config.TermType           = TermType.Get(context);
                Config.Port = Port.Get(context);

                session = RunPlugin.GetRecorderWindow(Config);
                if (string.IsNullOrEmpty(session.WorkflowInstanceId))
                {
                    session.WorkflowInstanceId = WorkflowInstanceId;
                }
                context.SetValue(_elements, session);
                if (!HideUI.Get(context))
                {
                    session.Show();
                }
                if (session.Terminal == null || !session.Terminal.IsConnected)
                {
                    session.Connect();
                }
            });
            var sw = new Stopwatch();

            sw.Start();
            while (!session.Terminal.IsConnected && sw.Elapsed < timeout)
            {
                System.Threading.Thread.Sleep(50);
            }
            Log.Output(string.Format("Connected to {0} in {1:mm\\:ss\\.fff}", session.Config.Hostname, sw.Elapsed));
            if (!session.Terminal.IsConnected)
            {
                throw new Exception("Timeout connecting to " + Hostname.Get(context) + ":" + Port.Get(context));
            }
            session.Refresh();
            context.ScheduleAction(Body, session, OnBodyComplete);
        }
Esempio n. 2
0
        protected override void Execute(CodeActivityContext context)
        {
            string key     = Key.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");
            }
            session.Refresh();
            if (WaitForKeyboard.Get(context))
            {
                session.Terminal.WaitForKeyboardUnlocked(timeout);
            }
            System.Windows.Input.Key _key;
            if (Enum.TryParse(key, true, out _key))
            {
                session.Terminal.SendKey(_key);
                if (WaitForKeyboard.Get(context))
                {
                    session.Terminal.WaitForKeyboardUnlocked(timeout);
                }
            }
        }
Esempio n. 3
0
        protected override void StartLoop(NativeActivityContext context)
        {
            string text    = Text.Get(context);
            var    timeout = Timeout.Get(context);
            var    _throw  = Throw.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");
            }
            var sw = new Stopwatch();

            sw.Start();
            var result = session.Terminal.WaitForText(text, timeout);

            if (result && Body != null)
            {
                context.ScheduleAction(Body, result, OnBodyComplete);
            }
            else if (_throw)
            {
                throw new ArgumentException("Timeout waiting for text");
            }
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
            }
        }