Esempio n. 1
0
        /// <summary>
        /// Dump fields to the current audit output
        /// </summary>
        public void ShowFields()
        {
            if (currentConnection == null)
            {
                throw new TNHostException("TNEmulator is not connected", "There is no currently open TN3270 connection", null);
            }

            if (sout != null)
            {
                sout.WriteLine("-------------------dump screen data -----------------");
                currentConnection.ExecuteAction(false, "Fields");
                sout.WriteLine("" + currentConnection.GetAllStringData(false));
                this.CurrentScreenXML.Dump(sout);
                sout.WriteLine("-------------------dump screen end -----------------");
            }
            else
            {
                throw new ApplicationException("ShowFields requires an active 'Audit' connection on the emulator");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Dump fields to the current audit output
        /// </summary>
        public void ShowFields()
        {
            if (currentConnection == null)
            {
                throw new TNHostException("Terminal não está conectado", "Não existe conexão com terminal 3270 aberta", null);
            }

            if (sout != null)
            {
                sout.WriteLine("-------------------dump screen data -----------------");
                currentConnection.ExecuteAction(false, "Fields");
                sout.WriteLine("" + currentConnection.GetAllStringData(false));
                this.CurrentScreenObject.Dump(sout);
                sout.WriteLine("-------------------dump screen end -----------------");
            }
            else
            {
                throw new ApplicationException("ShowFields requires an active 'Audit' connection on the emulator");
            }
        }
Esempio n. 3
0
        /// <summary>
        ///     Sends the specified key stroke to the emulator.
        /// </summary>
        /// <param name="waitForScreenToUpdate"></param>
        /// <param name="key"></param>
        /// <param name="timeout"></param>
        /// <returns></returns>
        public bool SendKey(bool waitForScreenToUpdate, TnKey key, int timeout)
        {
            var    triggerSubmit = false;
            var    success       = false;
            string command;

            //This is only used as a parameter for other methods when we're using function keys.
            //e.g. F1 yields a command of "PF" and a functionInteger of 1.
            var functionInteger = -1;


            if (Audit != null && Debug)
            {
                Audit.WriteLine("SendKeyFromText(" + waitForScreenToUpdate + ", \"" + key + "\", " + timeout + ")");
            }

            if (currentConnection == null)
            {
                throw new TNHostException("TNEmulator is not connected", "There is no currently open TN3270 connection",
                                          null);
            }


            //Get the command name and accompanying int parameter, if applicable
            if (Constants.FunctionKeys.Contains(key))
            {
                command         = "PF";
                functionInteger = Constants.FunctionKeyIntLUT[key];
            }
            else if (Constants.AKeys.Contains(key))
            {
                command         = "PA";
                functionInteger = Constants.FunctionKeyIntLUT[key];
            }
            else
            {
                command = key.ToString();
            }

            //Should this action be followed by a submit?
            triggerSubmit = Config.SubmitAllKeyboardCommands || currentConnection.KeyboardCommandCausesSubmit(command);

            if (triggerSubmit)
            {
                lock (this)
                {
                    DisposeOfCurrentScreenXML();
                    currentScreenXML = null;

                    if (Audit != null && Debug)
                    {
                        Audit.WriteLine("mre.Reset. Count was " + semaphore.Count);
                    }

                    // Clear to initial count (0)
                    semaphore.Reset();
                }
            }

            success = currentConnection.ExecuteAction(triggerSubmit, command, functionInteger);


            if (Audit != null && Debug)
            {
                Audit.WriteLine("SendKeyFromText - submit = " + triggerSubmit + " ok=" + success);
            }

            if (triggerSubmit && success)
            {
                // Wait for a valid screen to appear
                if (waitForScreenToUpdate)
                {
                    success = Refresh(true, timeout);
                }
                else
                {
                    success = true;
                }
            }

            return(success);
        }