Show Contents / Index / Search

Make Session Visible (OpenSystems)

using System;

using System.Collections.Generic;

using System.Text;

using Attachmate.Reflection.Framework;

using Attachmate.Reflection.UserInterface;

using Attachmate.Reflection.Emulation.OpenSystems;

 

namespace MakeSessionVisible

{

  class Program

  {

    static void Main(string[] args)

    {

      Attachmate.Reflection.Framework.Application reflectionApplication = MyReflection.CreateApplication("Reflection");

      if (reflectionApplication != null)

      {

        ITerminal terminal = (ITerminal)reflectionApplication.CreateControl(@"C:\Users\[user name]\Documents\Attachmate\Reflection\[session filename]");

        if (terminal != null)

        {

          terminal.Connect();

          //You can also use AfterConnect event to wait for the connection.

          while (!terminal.IsConnected)

          {

            System.Threading.Thread.Sleep(500);

          }

          IScreen screen = terminal.Screen;

          string text = screen.GetText(18, 2, 48);

          Console.WriteLine(text);

        }

        else

          Console.WriteLine("Can not create the control. Check the session file path.");

        //This makes a session visible in the Reflection 2008 application.

        IView sessionView;

        IFrame theFrame = (IFrame)reflectionApplication.GetObject("Frame");

        if (theFrame != null)

        {

          sessionView = theFrame.CreateView(terminal);

        }

        else

          Console.WriteLine("Fatal error. Check Reflection 2008 installation.");

      }

      else

        Console.WriteLine("Failed to get Application object.");

    }

  }

}