InfoConnect for Airlines
SaveScreenHistoryFile Method
Example 


The full pathname of the file to save the screen history contents to.
If true, overwrites an existing copy of the file. If false, the file will not be saved if it already exists.
Saves screen history contents to the specified file.
Syntax
'Declaration
 
Function SaveScreenHistoryFile( _
   ByVal filePath As String, _
   ByVal overwrite As Boolean _
) As ReturnCode
'Usage
 
Dim instance As IScreenHistory
Dim filePath As String
Dim overwrite As Boolean
Dim value As ReturnCode
 
value = instance.SaveScreenHistoryFile(filePath, overwrite)
ReturnCode SaveScreenHistoryFile( 
   string filePath,
   bool overwrite
)

Parameters

filePath
The full pathname of the file to save the screen history contents to.
overwrite
If true, overwrites an existing copy of the file. If false, the file will not be saved if it already exists.

Return Value

ReturnCode.Success if the save succeeded, ReturnCode.Error if it failed.
Remarks
If filePath exists, the file is overwritten.
Example
This sample uses SaveScreenHistory to save the screen history to the myScreens.rshx file before the session is disconnected. If the file exists, it is overwritten with the new screen history.
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