コード例 #1
0
        TNEmulator ConnectAndLogin(string user, string pass, string ip, int port)
        {
            CloseTerminal();
            TNEmulator emulator = new TNEmulator();

            emulator.Debug                 = false;
            emulator.Config.TermType       = "IBM-3278-2-E";
            emulator.Config.FastScreenMode = true;
            emulator.Connect(ip, port, null);
            if (!emulator.WaitForText(0, 5, "THIS TERMINAL IS LOGGED ON", _timeout))
            {
                throw new Exception("Erro ao logar, não encontrada mensagem: THIS TERMINAL IS LOGGED ON");
            }
            emulator.SendText("0cicabnpt");
            emulator.SendKey(true, TnKey.Enter, _timeout);
            emulator.SendKey(true, TnKey.Enter, _timeout);

            if (!emulator.WaitForText(1, 2, "WELCOME TO CICS", _timeout))
            {
                throw new Exception("Erro ao logar, não encontrada mensagem: WELCOME TO CICS");
            }

            WriteTextToField(emulator.CurrentScreenXML.Fields[18], emulator, user);
            WriteTextToField(emulator.CurrentScreenXML.Fields[25], emulator, pass);
            emulator.SendKey(true, TnKey.Enter, _timeout);
            emulator.WaitForHostSettle(100, _timeout);
            emulator.SendKey(true, TnKey.Enter, _timeout);

            if (!emulator.WaitForText(5, 0, "CICS-SSO", _timeout))
            {
                throw new Exception("Erro ao logar, não encontrada mensagem: CICS-SSO");
            }
            return(emulator);
        }
コード例 #2
0
        public bool Connect(string server, int port, string type, bool useSsl)
        {
            if (InvokeRequired)
            {
                var d = new ConnectDelegate(Connect);
                return((bool)Invoke(d, new object[] { server, port, type, useSsl }));
            }
            else
            {
                try
                {
                    TN3270.Config.UseSSL   = useSsl;
                    TN3270.Config.TermType = type;
                    TN3270.Audit           = this;
                    //TN3270.Debug = true;
                    TN3270.Config.FastScreenMode = true;

                    TN3270.Connect(server, port, string.Empty);

                    Redraw();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error");
                    return(false);
                }
                return(true);
            }
        }
コード例 #3
0
        private void ConnectToHost()
        {
            emu.Connect();

            //Account for delays
            emu.Refresh(true, 1000);
        }
コード例 #4
0
        public void Connect(string Server, int Port, string Type, bool UseSsl)
        {
            TN3270.Config.UseSSL   = UseSsl;
            TN3270.Config.TermType = Type;
            TN3270.Connect(Server, Port, string.Empty);

            Redraw();
        }
コード例 #5
0
        public void Connect(string server, int port, string type, bool useSsl)
        {
            _tn3270.Config.UseSSL   = useSsl;
            _tn3270.Config.TermType = type;
            _tn3270.Connect(server, port, string.Empty);

            Redraw();
        }
コード例 #6
0
        public void Run()
        {
            TNEmulator emulator = new TNEmulator();

            emulator.Audit                 = this;
            emulator.Debug                 = false;
            emulator.Config.TermType       = "IBM-3278-2-E";
            emulator.Config.FastScreenMode = true;

            emulator.Connect("localhost", 3270, null);
            // wait for the host to startup
            //
            if (emulator.WaitForTextOnScreen(2000, "Multi-User System for Interactive Computing / System Product", "MUSIC/SP ESA/390") == -1)
            {
                Console.WriteLine("Connection failed - didn't find 'LIBRARY OF CONGRESS' on screen");
                Console.WriteLine(emulator.CurrentScreenXML.Dump());
                return;
            }
            //
            //
            //
            emulator.Refresh(true, 20000);
            bool done = false;

            do
            {
                string currentScreen = emulator.CurrentScreenXML.Dump();
                Console.WriteLine(currentScreen);


                Console.WriteLine("Enter command : - refresh, text <text>, key <key>, quit");
                Console.WriteLine("key is one of : Attn, Backspace,BackTab,CircumNot,Clear,CursorSelect,Delete,DeleteField, DeleteWord,Down,Dup,Enter,Erase,EraseEOF,EraseInput,FieldEnd, FieldMark,FieldExit,Home,Insert,Interrupt,Key,Left,Left2,Newline,NextWord, PAnn, PFnn, PreviousWord,Reset,Right,Right2,SysReq,Tab,Toggle,ToggleInsert,ToggleReverse,Up");

                string command = Console.ReadLine();
                if (command == "quit")
                {
                    done = true;
                }
                else if (command == "refresh")
                {
                    emulator.Refresh(false, 0);
                }
                else if (command.Length > 4 && command.Substring(0, 4) == "key ")
                {
                    emulator.SendKeyFromText(true, command.Substring(4));
                }
                else if (command.Length > 5 && command.Substring(0, 5) == "text ")
                {
                    emulator.SendText(command.Substring(5));
                }
                else
                {
                    Console.WriteLine("unknown command '" + command + "'");
                }
            }while (!done);
            emulator.Close();
        }
コード例 #7
0
        public void Run()
        {
            TNEmulator emulator = new TNEmulator();

            emulator.Audit                 = this;
            emulator.Debug                 = true;
            emulator.Config.TermType       = "IBM-3278-2-E";
            emulator.Config.FastScreenMode = true;
            emulator.Config.UseSSL         = true;
            emulator.Connect("ssl3270.nccourts.org", 2023, null);

            var index = emulator.WaitForTextOnScreen2(2000, "COURT INFORMATION SYSTEM");

            Console.WriteLine("Index = x=" + index.x + " y=" + index.y);
            return;

            // wait for the host to startup
            //
            if (!emulator.WaitForText(22, 0, "LIBRARY OF CONGRESS", 20000))
            {
                Console.WriteLine("Connection failed - didn't find 'LIBRARY OF CONGRESS' on screen");
                Console.WriteLine(emulator.CurrentScreenXML.Dump());
                return;
            }
            //
            //
            //
            emulator.Refresh(true, 20000);
            bool done = false;

            do
            {
                string currentScreen = emulator.CurrentScreenXML.Dump();
                Console.WriteLine(currentScreen);


                Console.WriteLine("Enter command : - refresh, text <text>, key <key>, quit");
                Console.WriteLine("key is one of : Attn, Backspace,BackTab,CircumNot,Clear,CursorSelect,Delete,DeleteField, DeleteWord,Down,Dup,Enter,Erase,EraseEOF,EraseInput,FieldEnd, FieldMark,FieldExit,Home,Insert,Interrupt,Key,Left,Left2,Newline,NextWord, PAnn, PFnn, PreviousWord,Reset,Right,Right2,SysReq,Tab,Toggle,ToggleInsert,ToggleReverse,Up");

                string command = Console.ReadLine();
                if (command == "quit")
                {
                    done = true;
                }
                else if (command == "refresh")
                {
                    emulator.Refresh(false, 0);
                }
                else if (command.Length > 4 && command.Substring(0, 4) == "key ")
                {
                    emulator.SendKeyFromText(true, command.Substring(4));
                }
                else if (command.Length > 5 && command.Substring(0, 5) == "text ")
                {
                    emulator.SendText(command.Substring(5));
                }
                else
                {
                    Console.WriteLine("unknown command '" + command + "'");
                }
            }while (!done);
            emulator.Close();
        }
コード例 #8
0
        public void Run()
        {
            using (TNEmulator emulator = new TNEmulator())
            {
                emulator.Audit                           = this;
                emulator.Debug                           = false;
                emulator.Config.TermType                 = "IBM-3278-2-E";
                emulator.Config.FastScreenMode           = true;
                emulator.Config.AlwaysRefreshWhenWaiting = false;

                emulator.Connect("localhost", 3270, null);
                // wait for the host to startup
                //
                int index = emulator.WaitForTextOnScreen(1000, "Hercules", "Multi-User System for Interactive Computing / System Product");

                if (index == 0)
                {
                    Console.WriteLine("Mainframe emulator isn't running MUSIC/SP properly - check readme.md file in TestMainframe project for help");
                    return;
                }

                if (index == -1)
                {
                    Console.WriteLine("Connection failed - didn't find 'Multi-User System for Interactive Computing / System Product' on screen");
                    Console.WriteLine(emulator.CurrentScreenXML.Dump());
                    return;
                }
                try
                {
                    //
                    //
                    //
                    //emulator.Refresh(true, 20000);
                    emulator.SendKey(false, TnKey.Enter, 0);
                    index = emulator.WaitForTextOnScreen(2000, "*MUSIC/SP ESA/390, sign on");
                    Console.WriteLine("Response : " + index);
                    if (index != 0)
                    {
                        Console.WriteLine(emulator.CurrentScreenXML.Dump());
                        Console.WriteLine("ERROR : Failed to find login form failed");
                        return;
                    }
                    //emulator.SendKey(true, TnKey.Enter, 10000);
                    //emulator.WaitForHostSettle(100, 10000);
                    emulator.SetText("$000");
                    emulator.SendKey(false, TnKey.Tab, 0);
                    emulator.SetText("music");
                    emulator.SendKey(false, TnKey.Enter, 0);
                    index = emulator.WaitForTextOnScreen(10000, "Press ENTER to continue...", "Userid is already signed on");
                    Console.WriteLine("Response : " + index);
                    if (index != 0)
                    {
                        Console.WriteLine(emulator.CurrentScreenXML.Dump());
                        Console.WriteLine("ERROR : Login failed");
                        return;
                    }
                    emulator.SendKey(false, TnKey.Enter, 0);
                    index = emulator.WaitForTextOnScreen(10000, "Support Tasks: ADMIN Main Menu");
                    Console.WriteLine("Response : " + index);
                    if (index != 0)
                    {
                        Console.WriteLine(emulator.CurrentScreenXML.Dump());
                        Console.WriteLine("ERROR : Failed to get to main menu");
                        return;
                    }
                    Console.WriteLine(emulator.CurrentScreenXML.Dump());
                    string timeText = emulator.GetText(65, 4, 15).Trim();
                    Console.WriteLine("Success! Scraped current mainframe time as : >>>" + timeText + "<<<");

                    return;
                }
                catch (Exception ex)
                {
                    Console.WriteLine("EX: " + ex);
                    Console.WriteLine(emulator.CurrentScreenXML.Dump());
                }

                //emulator.Refresh(true, 20000);

                bool done = false;
                do
                {
                    string currentScreen = emulator.CurrentScreenXML.Dump();
                    Console.WriteLine("DUMP SCREEN\n=============\n" + currentScreen + "\n=========\n");

                    Console.WriteLine("Enter command : - refresh, text <text>, key <key>, quit");
                    Console.WriteLine("key is one of : Attn, Backspace,BackTab,CircumNot,Clear,CursorSelect,Delete,DeleteField, DeleteWord,Down,Dup,Enter,Erase,EraseEOF,EraseInput,FieldEnd, FieldMark,FieldExit,Home,Insert,Interrupt,Key,Left,Left2,Newline,NextWord, PAnn, PFnn, PreviousWord,Reset,Right,Right2,SysReq,Tab,Toggle,ToggleInsert,ToggleReverse,Up");

                    string command = Console.ReadLine();
                    if (command == "quit")
                    {
                        done = true;
                    }
                    else if (command == "refresh")
                    {
                        emulator.Refresh(false, 0);
                    }
                    else if (command.Length > 4 && command.Substring(0, 4) == "key ")
                    {
                        emulator.SendKeyFromText(true, command.Substring(4));
                    }
                    else if (command.Length > 5 && command.Substring(0, 5) == "text ")
                    {
                        emulator.SendText(command.Substring(5));
                    }
                    else
                    {
                        Console.WriteLine("unknown command '" + command + "'");
                    }
                }while (!done);
                emulator.Close();
            }
        }