Пример #1
0
        public void Dump(IAudit stream)
        {
            int i;

            if (debugWithCoordinates)
            {
                stream.WriteLine("-----");
                string tens = "  ", singles = "  ";                 // the quoted strings must be 3 spaces each, it gets lost in translation by codeplex...
                for (i = 0; i < _CX; i += 10)
                {
                    tens    += String.Format("{0,-10}", i / 10);
                    singles += "0123456789";
                }
                stream.WriteLine(tens.Substring(0, 2 + _CX));
                stream.WriteLine(singles.Substring(0, 2 + _CX));
            }
            for (i = 0; i < _CY; i++)
            {
                string line = GetText(0, i, _CX);
                if (debugWithCoordinates)
                {
                    line = String.Format(" {0,02}{1}", i, line);
                }
                stream.WriteLine(line);
            }
            if (debugWithCoordinates)
            {
                stream.WriteLine("-----");
            }
        }
Пример #2
0
        public void Dump(IAudit stream)
        {
            int i;

            stream.WriteLine("-----");
            stream.WriteLine("   0         1         2         3         4         5         6         7         ");
            stream.WriteLine("   01234567890123456789012345678901234567890123456789012345678901234567890123456789");
            for (i = 0; i < _CY; i++)
            {
                string line = GetText(0, i, _CX);
                string lr   = "" + i + "       ";
                stream.WriteLine(lr.Substring(0, 2) + " " + line);
            }
            stream.WriteLine("-----");
        }
Пример #3
0
 public void WriteLine(string text)
 {
     if (!optionTraceDS)
     {
         return;
     }
     if (mAudit != null)
     {
         mAudit.WriteLine(text);
     }
 }
Пример #4
0
        public void Dump(IAudit stream)
        {
            int i;

            stream.WriteLine("-----");
            string tens = "   ", singles = "   ";            // the quoted strings must be 3 spaces each, it gets lost in translation by codeplex...

            for (i = 0; i < _CX; i += 10)
            {
                tens    += String.Format("{0,-10}", i / 10);
                singles += "0123456789";
            }
            stream.WriteLine(tens.Substring(0, 3 + _CX));
            stream.WriteLine(singles.Substring(0, 3 + _CX));
            for (i = 0; i < _CY; i++)
            {
                string line = GetText(0, i, _CX);
                string lr   = "" + i + "       ";
                stream.WriteLine(lr.Substring(0, 2) + " " + line);
            }
            stream.WriteLine("-----");
        }
Пример #5
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)
        {
            bool   triggerSubmit = false;
            bool   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.
            int functionInteger = -1;


            if (sout != null && Debug == true)
            {
                sout.WriteLine("SendKeyFromText(" + waitForScreenToUpdate + ", \"" + key.ToString() + "\", " + 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 = this.Config.SubmitAllKeyboardCommands || this.currentConnection.KeyboardCommandCausesSubmit(command);

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

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

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

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


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

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

            return(success);
        }
Пример #6
0
 internal void Dump(IAudit sout)
 {
     if (sout == null)
     {
         return;
     }
     sout.WriteLine("Config.FastScreenMode " + fastScreenMode);
     sout.WriteLine("Config.IgnoreSequenceCount " + ignoreSequenceCount);
     sout.WriteLine("Config.IdentificationEngineOn " + identificationEngineOn);
     sout.WriteLine("Config.AlwaysSkipToUnprotected " + alwaysSkipToUnprotected);
     sout.WriteLine("Config.LockScreenOnWriteToUnprotected " + lockScreenOnWriteToUnprotected);
     sout.WriteLine("Config.ThrowExceptionOnLockedScreen " + throwExceptionOnLockedScreen);
     sout.WriteLine("Config.DefaultTimeout " + defaultTimeout);
     sout.WriteLine("Config.hostName " + hostName);
     sout.WriteLine("Config.hostPort " + hostPort);
     sout.WriteLine("Config.hostLU " + hostLU);
     sout.WriteLine("Config.termType " + termType);
     sout.WriteLine("Config.AlwaysRefreshWhenWaiting " + alwaysRefreshWhenWaiting);
     sout.WriteLine("Config.SubmitAllKeyboardCommands " + submitAllKeyboardCommands);
     sout.WriteLine("Config.RefuseTN3270E " + refuseTN3270E);
 }
Пример #7
0
        protected virtual void Dispose(bool disposing)
        {
            lock (this)
            {
                if (IsDisposed)
                {
                    return;
                }
                isDisposed = true;

                if (sout != null)
                {
                    sout.WriteLine("TNEmulator.Dispose(" + IsDisposed.ToString() + ")");
                }

                if (disposing)
                {
                    //----------------------------
                    // release managed resources

                    if (currentConnection != null)
                    {
                        if (sout != null)
                        {
                            sout.WriteLine("TNEmulator.Dispose() Disposing of currentConnection");
                        }
                        try
                        {
                            currentConnection.Disconnect();

                            if (apiOnDisconnectDelegate != null)
                            {
                                currentConnection.OnDisconnect -= apiOnDisconnectDelegate;
                            }

                            currentConnection.Dispose();
                        }
                        catch
                        {
                            if (sout != null)
                            {
                                sout.WriteLine("TNEmulator.Dispose() Exception during currentConnection.Dispose");
                            }
                        }
                        currentConnection = null;
                    }

                    OnDisconnect = null;

                    if (sout != null)
                    {
                        sout.WriteLine("TNEmulator.Dispose() Disposing of currentScreenXML");
                    }

                    DisposeOfCurrentScreenXML();

                    if (mObjectState != null)
                    {
                        mObjectState = null;
                    }
                    if (mConnectionConfiguration != null)
                    {
                        mConnectionConfiguration = null;
                    }
                    if (mScreenName != null)
                    {
                        mScreenName = null;
                    }
                }

                //------------------------------
                // release unmanaged resources
            }
        }
Пример #8
0
 private void currentConnection_RunScriptEvent(string where)
 {
     lock (this)
     {
         _currentScreenXML = null;
         if (sout != null && Debug)
         {
             sout.WriteLine("mre.Release(1) from location " + where);
         }
         mre.Release(1);
     }
 }