| Back | Main view

Retrieving objects from IMiS/ARC with IMiS/Storage Connector .NET

Product:IMiS/Storage Connector .NET
Release:1.1.1007
Date:11/24/2010

Case: This article will demonstrate how to use IMiS/Storage Connector .NET interface to retrieve an object from IMiS/ARC Storage Server to a temporary file on the local file system.

Description:

Object retrieval with IMiS/Storage Connector is done with the following steps:
1. get an instance of the StorageConnector class
2. open a storage on IMiS/ARC Storage Server specified by the hostname and port
3. use the RetrieveObject method of the Storage class to retrieve a document from the IMiS/ARC Storage Server to a temporary file.

Notes:
The sample C# code provided is a Console Application project created in Visual Studio 2005 with a reference to an IMiS/Storage Connector assembly.
The Console Application gets the IMiS/ARC Storage Server host and port, and an object identifier through the command line arguments.


C#
 
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;

using IMiS.StorageConnector;

namespace ConsoleApplication1
{
  class Program
  {
    /// <summary>
    ///   Retrieves object from IMiS/ARC Storage Server to the local file system.
    /// </summary>
    /// <param name="host">
    ///   An IMiS/ARC Storage Server host.
    /// </param>
    /// <param name="port">
    ///   An IMiS/ARC Storage Server port.
    /// </param>
    /// <param name="objectId">
    ///   The IMiS/ARC Storage Server object identifier.
    /// </param>
    /// <returns>
    ///   The file path of the retrieved object.
    /// </returns>
    static string RetrieveObjectFromIMiSARC(string host, int port, string objectId)
    {
      string fileName = "";

      // Get an instance of the IMiS/Storage Connector
      StorageConnector sc = StorageConnector.Instance;
      try 
      {
        // Open IMiS/ARC storage
        Storage stg = sc.OpenIMiSARCStorage(host, port);
        try 
        {
          // Retrieve IMiS/ARC object to temporary file
          fileName = stg.RetrieveObject(objectId);
        }
        finally 
        {
          // Close IMiS/ARC storage
          stg.Close();
          stg = null;
        }
      }
      finally 
      {
        // Release IMiS/Storage Connector instance
        sc = null;
        StorageConnector.FreeInstance();
      }

      return fileName;
    }

    static void Main(string[] args)
    {
      try
      {
        // Get host and port and object id from command line arguments
        string host = args[0];
        int port = Int32.Parse(args[1]);
        string objId = args[2];

        // Retrieves object from IMiS/ARC to a local file
        string fileName = RetrieveObjectFromIMiSARC(host, port, objId);

        // Execute local file with associated application
        System.Diagnostics.Process.Start(fileName);
      }
      catch (Exception ex)
      {
        // Show error message
        Console.Out.WriteLine("ErrorMessage = {0}", ex.Message);
      }
    }
  }
}
 
 

Related Documents:

Database 'IMiS Knowledge database', View 'All Documents', Document 'Storing objects on IMiS/ARC with IMiS/Storage Connector .NET' Storing objects on IMiS/ARC with IMiS/Storage Connector .NET

| Back | Main view