Esempio n. 1
0
 /// <summary>
 /// Closes the current connection to the mainframe.
 /// </summary>
 public void Close()
 {
     if (currentConnection != null)
     {
         currentConnection.Disconnect();
         currentConnection = null;
     }
 }
Esempio n. 2
0
 //
 //
 /// <summary>
 /// Constructor for TNEmulator
 /// </summary>
 public TNEmulator()
 {
     _currentScreenXML = null;
     //
     currentConnection = null;
     //
     //
     this.mConnectionConfiguration = new ConnectionConfig();
     //
 }
Esempio n. 3
0
        /// <summary>
        /// </summary>
        public TN3270HostParser()
        {
            var config = new ConnectionConfig();

            config.HostName = "DUMMY_PARSER";
            var api = new TN3270API();

            telnet = new Telnet(api, this, config);
            telnet.Trace.optionTraceAnsi        = true;
            telnet.Trace.optionTraceDS          = true;
            telnet.Trace.optionTraceDSN         = true;
            telnet.Trace.optionTraceEvent       = true;
            telnet.Trace.optionTraceNetworkData = true;
            telnet.telnetDataEventOccurred     += telnet_telnetDataEvent;

            telnet.Connect(null, null, 0);
        }
Esempio n. 4
0
        protected virtual void Dispose(bool disposing)
        {
            lock (this)
            {
                if (IsDisposed)
                {
                    return;
                }
                isDisposed = true;

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

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

                    if (currentConnection != null)
                    {
                        if (sout != null && Debug)
                        {
                            sout.WriteLine("TNEmulator.Dispose() Disposing of currentConnection");
                        }
                        try
                        {
                            currentConnection.Disconnect();
                            this.currentConnection.CursorLocationChanged -= currentConnection_CursorLocationChanged;

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

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

                    Disconnected = null;

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

                    DisposeOfCurrentScreenXML();

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

                //------------------------------
                // release unmanaged resources
            }
        }
Esempio n. 5
0
 public TNEmulator()
 {
     currentScreenXML              = null;
     currentConnection             = null;
     this.mConnectionConfiguration = new ConnectionConfig();
 }
Esempio n. 6
0
        /// <summary>
        /// Connect to TN3270 server using the connection details specified.
        /// </summary>
        /// <remarks>
        /// You should set the Audit property to an instance of an object that implements
        /// the IAudit interface if you want to see any debugging information from this function
        /// call.
        /// </remarks>
        /// <param name="host">Host name or IP address. Mandatory</param>
        /// <param name="port">TCP/IP port to connect to (default TN3270 port is 23)</param>
        /// <param name="lu">TN3270E LU to connect to. Specify null for no LU.</param>
        public void Connect(string host, int port, string lu)
        {
            if (this.currentConnection != null)
            {
                this.currentConnection.Disconnect();
                this.currentConnection.CursorLocationChanged -= currentConnection_CursorLocationChanged;
            }

            try
            {
                semaphore.Reset();

                this.currentConnection       = null;
                this.currentConnection       = new TN3270API();
                this.currentConnection.Debug = debug;
                this.currentConnection.RunScriptRequested    += new RunScriptDelegate(currentConnection_RunScriptEvent);
                this.currentConnection.CursorLocationChanged += currentConnection_CursorLocationChanged;
                this.currentConnection.Disconnected          += apiOnDisconnectDelegate;

                this.apiOnDisconnectDelegate = new OnDisconnectDelegate(currentConnection_OnDisconnect);

                //
                // Debug out our current state
                //
                if (sout != null)
                {
                    sout.WriteLine("Open3270 emulator version " + Assembly.GetAssembly(typeof(Open3270.TNEmulator)).GetName().Version + " (c) 2004-2017 Mike Warriner and many others");
#if false
                    sout.WriteLine("(c) 2004-2006 Mike Warriner ([email protected]). All rights reserved");
                    sout.WriteLine("");
                    sout.WriteLine("This is free software; you can redistribute it and/or modify it");
                    sout.WriteLine("under the terms of the GNU Lesser General Public License as");
                    sout.WriteLine("published by the Free Software Foundation; either version 2.1 of");
                    sout.WriteLine("the License, or (at your option) any later version.");
                    sout.WriteLine("");
                    sout.WriteLine("This software is distributed in the hope that it will be useful,");
                    sout.WriteLine("but WITHOUT ANY WARRANTY; without even the implied warranty of");
                    sout.WriteLine("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU");
                    sout.WriteLine("Lesser General Public License for more details.");
                    sout.WriteLine("");
                    sout.WriteLine("You should have received a copy of the GNU Lesser General Public");
                    sout.WriteLine("License along with this software; if not, write to the Free");
                    sout.WriteLine("Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA");
                    sout.WriteLine("02110-1301 USA, or see the FSF site: http://www.fsf.org.");
                    sout.WriteLine("");
#endif

                    if (firstTime)
                    {
                        firstTime = false;
                    }
                    if (Debug)
                    {
                        Config.Dump(sout);
                        sout.WriteLine("Connect to host \"" + host + "\"");
                        sout.WriteLine("           port \"" + port + "\"");
                        sout.WriteLine("           LU   \"" + lu + "\"");
                        sout.WriteLine("     Local IP   \"" + _localIP + "\"");
                    }
                }
                else
                {
                }

                currentConnection.UseSSL = this.mUseSSL;


                /// Modified CFCJR Feb/29/2008 to support local IP endpoint
                if (!string.IsNullOrEmpty(_localIP))
                {
                    currentConnection.Connect(this.sout, _localIP, host, port, this.mConnectionConfiguration);
                }
                else
                {
                    currentConnection.Connect(this.sout, host, port, lu, this.mConnectionConfiguration);
                }

                currentConnection.WaitForConnect(-1);
                DisposeOfCurrentScreenXML();
                currentScreenXML = null;
                // Force refresh
                // GetScreenAsXML();
            }
            catch (Exception)
            {
                currentConnection = null;
                throw;
            }

            // These don't close the connection
            try
            {
                this.mScreenName = "Start";
                Refresh(true, 10000);
                if (sout != null && Debug == true)
                {
                    sout.WriteLine("Debug::Connected");
                }
                //mScreenProcessor.Update_Screen(currentScreenXML, true);
            }
            catch (Exception)
            {
                throw;
            }
            return;
        }
Esempio n. 7
0
        /// <summary>
        /// Connect to TN3270 server using the connection details specified.
        /// </summary>
        /// <remarks>
        /// You should set the Audit property to an instance of an object that implements
        /// the IAudit interface if you want to see any debugging information from this function
        /// call.
        /// </remarks>
        /// <param name="host">Host name or IP address. Mandatory</param>
        /// <param name="port">TCP/IP port to connect to (default TN3270 port is 23)</param>
        /// <param name="lu">TN3270E LU to connect to. Specify null for no LU.</param>
        public void Connect(string host, int port, string lu)
        {
            if (currentConnection != null)
            {
                currentConnection.Disconnect();
            }
            //
            //
            try
            {
                mre.Reset();

                currentConnection                 = null;
                currentConnection                 = new TN3270API();
                currentConnection.Debug           = mDebug;
                currentConnection.RunScriptEvent += new RunScriptDelegate(currentConnection_RunScriptEvent);
                apiOnDisconnectDelegate           = new OnDisconnectDelegate(currentConnection_OnDisconnect);
                currentConnection.OnDisconnect   += apiOnDisconnectDelegate;
                //
                // Debug out our current state
                //
                if (sout != null)
                {
                    sout.WriteLine("Open3270 emulator version " + Assembly.GetAssembly(typeof(Open3270.TNEmulator)).GetName().Version);
                    sout.WriteLine("(c) 2004-2006 Mike Warriner ([email protected]). All rights reserved");
                    sout.WriteLine("");
                    //
                    if (mFirstTime)
                    {
                        mFirstTime = false;
                    }
                    if (Debug)
                    {
                        Config.Dump(sout);
                        sout.WriteLine("Connect to host \"" + host + "\"");
                        sout.WriteLine("           port \"" + port + "\"");
                        sout.WriteLine("           LU   \"" + lu + "\"");
                        sout.WriteLine("     Local IP   \"" + _localIP + "\"");
                    }
                }
                else
                {
                }
                //
                currentConnection.UseSSL = this.mUseSSL;
                //
                /// Modified CFCJR Feb/29/2008 to support local IP endpoint
                if (!string.IsNullOrEmpty(_localIP))
                {
                    currentConnection.Connect(this.sout, _localIP, host, port, this.mConnectionConfiguration);
                }
                else
                {
                    currentConnection.Connect(this.sout, host, port, lu, this.mConnectionConfiguration);
                }
                //
                //
                //
                currentConnection.WaitForConnect(-1);
                DisposeOfCurrentScreenXML();
                _currentScreenXML = null;                 // force refresh // GetScreenAsXML();
            }
            catch (Exception)
            {
                currentConnection = null;
                throw;
            }
            // these don't close the connection
            try
            {
                this.mScreenName = "Start";
                Refresh(true, 40000);
                if (sout != null && Debug == true)
                {
                    sout.WriteLine("Debug::Connected");
                }
                //mScreenProcessor.Update_Screen(currentScreenXML, true);
            }
            catch (Exception)
            {
                throw;
            }
            return;
        }
Esempio n. 8
0
 public TNEmulator()
 {
     currentScreenXML  = null;
     currentConnection = null;
     Config            = new ConnectionConfig();
 }