InfoConnect API Guide
Attachmate.Reflection.Productivity Namespace / IScreenHistory Interface / ClearHistoryOnDisconnect Property
Example


In This Topic
    ClearHistoryOnDisconnect Property
    In This Topic
    Gets or sets a value for whether to clear the screen list when the session disconnects (if true).
    Syntax
    'Declaration
     
    
    Property ClearHistoryOnDisconnect As Boolean
    'Usage
     
    
    Dim instance As IScreenHistory
    Dim value As Boolean
     
    instance.ClearHistoryOnDisconnect = value
     
    value = instance.ClearHistoryOnDisconnect
    bool ClearHistoryOnDisconnect {get; set;}
    Example
    This sample sets the ClearHistoryOnDisconnect property to keep the screen history list when the session disconnects.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Attachmate.Reflection.UserInterface;
    using Attachmate.Reflection.Productivity;
    using Attachmate.Reflection.Emulation.IbmHosts;
    using Attachmate.Reflection.Framework;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.IO;
    using Word = Microsoft.Office.Interop.Word; 
    
    namespace ScreenHistory
    {
        class Program
        {
    
            static void terminal_BeforeDisconnect(object sender, EventArgs e)
            {
                IIbmTerminal terminal = (IIbmTerminal)sender;
    
                IScreenHistory history = terminal.Productivity.ScreenHistory;
    
                //Delete the first screen from the history
                history.DeleteScreen(0);
    
                List<Image> screenImages = new List<Image>();
    
    
    
                for (int i = 0; i < history.Count; i++)
                {
                    byte[] screenImage = history.GetHistoryScreenImage(i);
    
                    MemoryStream memstr = new MemoryStream(screenImage);
                    Image image = Image.FromStream(memstr);
    
    
    
                    screenImages.Add(image);
                }
    
    
                IOfficeTools tools = terminal.Productivity.OfficeTools;
    
                tools.CreateWordProcessingDocumentWithGraphicSet(screenImages, null, null);
    
    
                Word.Application word = (Word.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application");
    
    
                string screenLog = Environment.UserName + DateTime.Now.ToString("yyyyMMddHHmmssfff");
                
                
                word.ActiveDocument.SaveAs(Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\" + screenLog);
                word.ActiveDocument.Close();
                word.Quit();
    
    
                history.SaveScreenHistoryFile(Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\InfoConnect\myScreens.rshx", true);
            }
    
    
            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\demoSession.rd3x";
                IIbmTerminal terminal = (IIbmTerminal)app.CreateControl(sessionPath);
    
                //Make the session visible in the workspace
                IFrame frame = (IFrame)app.GetObject("Frame");
                frame.CreateView(terminal);
    
                IScreenHistory history = terminal.Productivity.ScreenHistory;
    
                history.ManualCaptureOnly = false;
    
                history.ClearAllScreens();
    
                history.ScreenHistoryPanelVisible = true;
    
                history.NumberOfScreensToRemember = 25;
    
                history.ClearHistoryOnDisconnect = false;
    
                terminal.BeforeDisconnect += terminal_BeforeDisconnect;
    
                Console.ReadLine();
            }
    
    
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    See Also