InfoConnect for Unisys
Get Started / Open a Session
In This Topic
    Open a Session
    In This Topic

    You can open session document files that were created in previous sessions. This sample program uses the CreateControl() to create a session from a saved session document file. (For other ways to get terminal sessions, see Getting Terminal and View Objects.)

    To create a session from a session document file

    1.   Create a session and save it as "gettingStarted" (for example, gettingStarted.rd3x) in the default folder (...\myDocuments\Micro Focus\InfoConnect).         
    2. In Visual Studio, create a new Console Application project and add references for the following InfoConnect assemblies. (Depending on your version of Visual Studio, these can be found either on the .NET tab or under Assemblies | Extensions.)
      Attachmate.Reflection.Framework
      Attachmate.Reflection.Emulation.IbmHosts
      Attachmate.Reflection.Emulation.OpenSystems
      Attachmate.Reflection

      Attachmate.Reflection.Emulation.UTS
      Attachmate.Reflection.Emulation.T27
    3. Replace all the code in the Program.cs file with the following code for the terminal you are using.

                                   

      Open a session
      Copy Code
      using System;
      using System.Collections.Generic;
      using System.Text;
      using Attachmate.Reflection.Framework;
      using Attachmate.Reflection.Emulation.IbmHosts;
      using Attachmate.Reflection.UserInterface;
      
      namespace OpenASession
      {
          class Program
          {
              static void Main(string[] args)
              {
                  //Start a visible instance of InfoConnect or get the instance running at the given channel name
                  Application app = MyReflection.CreateApplication("myWorkspace", true);
      
                  //Create a terminal from the session document file
                  string sessionPath = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\InfoConnect\gettingStarted.rd3x";
                  IIbmTerminal terminal = (IIbmTerminal)app.CreateControl(sessionPath);
      
                  //Make the session visible in the workspace
                  IFrame frame = (IFrame)app.GetObject("Frame");
                  frame.CreateView(terminal);
              }
          }
      }  
                                       
      
                                              
      

                                

                              

      Open a session
      Copy Code
      using System;
      using System.Collections.Generic;
      using System.Text;
      using Attachmate.Reflection.Framework;
      using Attachmate.Reflection.Emulation.OpenSystems;
      using Attachmate.Reflection.UserInterface;
      namespace OpenASession
      {
          class Program
          {
              static void Main(string[] args)
              {
                  //Start a visible instance of InfoConnect or get the instance running at the given channel name
                  Application app = MyReflection.CreateApplication("myWorkspace", true);
      
                  //Create a terminal from the session document file
                  string sessionPath = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\InfoConnect\gettingStarted.rdox";
                  ITerminal terminal = (ITerminal)app.CreateControl(sessionPath);
      
                  //Make the session visible in the workspace
                  IFrame frame = (IFrame)app.GetObject("Frame");
                  frame.CreateView(terminal);
      
              }
          }
      }
      
      
      Open a session
      Copy Code
      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using Attachmate.Reflection.Framework;
      using Attachmate.Reflection.UserInterface;
      using Attachmate.Reflection.Emulation.UTS;
      
      namespace QuickStartOpenUTS
      {
      
      
          class Program
          {
              static void Main(string[] args)
              {
                  //Create an application object
                  Attachmate.Reflection.Framework.Application app = MyReflection.CreateApplication("myWorkspace", true);
      
                  //Create a terminal by opeing the session
                  string sessionFileUTS = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\InfoConnect\gettingStarted.iuts";
                  IUtsTerminal terminalUTS = (IUtsTerminal)app.CreateControl(sessionFileUTS);
      
                  //Make the session visible                 
                  IFrame frame = (IFrame)app.GetObject("Frame");
                  IView sessionViewUTS = frame.CreateView(terminalUTS);
              }
          }
      }
      
      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using Attachmate.Reflection.Framework;
      using Attachmate.Reflection.Emulation.T27;
      using Attachmate.Reflection.UserInterface;
      
      namespace QuickstartOpenT27
      {
      
          class Program
          {
              static void Main(string[] args)
              {
                  //Create an application object
                  Attachmate.Reflection.Framework.Application app = MyReflection.CreateApplication("myWorkspace", true);
                  
                  //Create a terminal for an Ibm session
                  string sessionFileT27 = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\InfoConnect\gettingStarted.it27";
                  IT27Terminal terminalT27 = (IT27Terminal)app.CreateControl(sessionFileT27);
      
                  //Make the session visible                 
                  IFrame frame = (IFrame)app.GetObject("Frame");
                  IView sessionViewT27 = frame.CreateView(terminalT27);
              }
          }
      }
      

    To test this project