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);
}
}
}
}
|