IFileRepositoryService Methods

The IFileRepositoryService interface exposes the methods listed in the following table:

Methods

Description

IFileRepositoryService.Close Method

Closes the FileRepositoryService.

IFileRepositoryService.Connect Method

Establishes a connection to the FileRepositoryService in the server machine.

IFileRepositoryService.ConnectAsync Method

Establishes a connection to the FileRepositoryService in the server machine.

IFileRepositoryService.Download Method

Performs the download processing to return a file from the server as a byte array.

IFileRepositoryService.DownloadAsync Method

Performs the download processing to return a file from the server as a byte array.

IFileRepositoryService.DownloadData Method

Downloads the data.

IFileRepositoryService.DownloadDataAsync Method

Downloads the asynchronous data.

IFileRepositoryService.GetTimeStamp Method

Retrieves the current timestamp of the file specified in the virtualPath parameter.

IFileRepositoryService.GetTimeStampAsync Method

Retrieves the current timestamp of the file specified in the virtualPath parameter.

IFileRepositoryService.Upload Method

Uploads a specified file to the FileRepository.

IFileRepositoryService.UploadAsync Method

Performs the upload processing to send a file to the server.

IFileRepositoryService.UploadData Method

Uploads the data.

IFileRepositoryService.UploadDataAsync Method

Uploads the asynchronous data.

IFileRepositoryService.Close Method

The Close method closes the FileRepositoryService.

Namespace – ABSuite.AccessLayer.Connector.Core

Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)

Syntax

void Close()

Using the IFileRepositoryService Interface for the Close Method

The following code is an example of using the Close method:

// Declare the FileRepositoryService
       IFileRepositoryService fileRepos = FileRepositoryServiceFactory.Create();
// Close the FileRepositoryService
fileRepos.Close()

IFileRepositoryService.Connect Method

The Connect method is used to establish a connection to the FileRepositoryService in the server machine.

Namespace – ABSuite.AccessLayer.Connector.Core

Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)

Syntax

bool Connect(
   FileRepositoryConnectionDetails details
)

Argument

  • details – ABSuite.AccessLayer.Connector.Core.FileRepositoryConnectionDetails

    This argument provides the connection details for the FileRepositoryService.

    Refer to the details argument in the Connect() method of the IConnection interface for more information.

Return Value

If this method succeeds in establishing a connection, it returns true; otherwise, it returns false.

Using the IFileRepositoryService Interface for the Connect Method

The following code is an example of using the Connect method to establish a connection with the FileRepositoryService:

 // Declare the FileRepositoryService
    IFileRepositoryService fileRepos =  FileRepositoryServiceFactory.Create();
 
 // Specify the connection details for the repository access
    ConnectionDetails fDetails = new ConnectionDetails();
    fDetails.FileRepositoryDirectory = "\\\\MyMachineName\\FREPOS";
 
 // Connect to the File Repository Service
    fileRepos.Connect(fDetails);

IFileRepositoryService.ConnectAsync Method

The ConnectAsync method allows you to establish a connection to FileRepositoryService in the server machine.

Namespace – ABSuite.AccessLayer.Connector.Core

Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)

Syntax

Task<bool> ConnectAsync(
   FileRepositoryConnectionDetails details
)

Argument

  • details – ABSuite.AccessLayer.Connector.Core.FileRepositoryConnectionDetail

    This argument provides the connection details for FileRepositoryService.

Return Value

If this method succeeds in establishing a connection, it returns true; otherwise, it returns false.

Using the IFileRepositoryService Interface for the ConnectAsync Method

The following code is an example of using the ConnectAsync method:

// Declare the FileRepositoryService
            IFileRepositoryService fileRepos =  FileRepositoryServiceFactory.Create();
 
 // Specify the connection details for the repository access
           ConnectionDetails fDetails = new ConnectionDetails();
           fDetails.FileRepositoryDirectory = "\\\\MyMachineName\\FREPOS";
 
 // Connect to the File Repository Service
           fileRepos.Connect(fDetails).ContinueWith((t) =>
{
            
         bool isConnected = t.Result;
            
}

IFileRepositoryService.Download Method

The Download method performs the download processing to return a file from the server as a string.

Namespace – ABSuite.AccessLayer.Connector.Core

Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)

Syntax

string Download(
   string virtualPath,
   string targetFolder = null
)

Argument

  • virtualPath – System.String

    This argument provides the path and filename of a specific file on the server.

  • targetFolder – System.String

    This argument is optional. It specifies the path where the file is downloaded. If this argument is null the file is downloaded to the File Repository Local folder.

Return Value

This method returns a string containing the location of the downloaded file or data.

Using the IFileRepositoryService Interface for the Download Method

The following code is an example of using the Download() method:

// Declare the FileRepositoryService
IFileRepositoryService fileRepos =  FileRepositoryServiceFactory.Create();
 
// Specify the connection details for the repository access
FileRepositoryConnectionDetails fDetails = new FileRepositoryConnectionDetails();
fDetails.FileRepositoryDirectory = "\\\\au-papachj-5\\classes\\FREPOS";
 
// Connect to the File Repository Service
fileRepos.Connect(fDetails);
 
// Download an image which returns a byte array that can be stored as a file in a local directory. 
var file = fileRepos.Download("Images\\JP.JPG");

IFileRepositoryService.DownloadAsync Method

The DownloadAsync method performs the download processing to return a file from the server as a string.

Namespace – ABSuite.AccessLayer.Connector.Core

Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)

Syntax

string DownloadAsync(
   string virtualPath,
   string targetFolder = null
)

Arguments

  • virtualPath – System.String

    This argument provides the path and filename of a specific file on the server.

  • targetFolder – System.String

    This argument is optional. It specifies the path where the file is downloaded. If this argument is null, the file is downloaded to the File Repository Local folder.

Return Value

This method returns a string containing the location of the downloaded file or data.

Using the IFileRepositoryService Interface for the DownloadAsync Method

The following code is an example of using the DownloadAsync method:

fileRepos.Download("Images\\JP.JPG").ContinueWith((f) =>
{
   // Download completed… process the file
   If(Path.Exists(f.Result)...
}

IFileRepositoryService.DownloadData Method

The DownloadData method downloads the data.

Namespace – ABSuite.AccessLayer.Connector.Core

Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)

Syntax

byte[] DownloadData(
   string virtualPath
)

Argument

  • virtualPath – System.String

    This argument specifies the virtual path.

Return Value

This method returns the data from the server as a byte array.

Using the IFileRepositoryService Interface for the DownloadData Method

The following code is an example of using the DownloadData method:

// Declare the FileRepositoryService
IFileRepositoryService fileRepos =  FileRepositoryServiceFactory.Create();

// Specify the connection details for the repository access
FileRepositoryConnectionDetails fDetails = new FileRepositoryConnectionDetails();
fDetails.FileRepositoryDirectory = "\\\\au-papachj-5\\classes\\FREPOS";
 
// Connect to the File Repository Service
fileRepos.Connect(fDetails);
 
// Download an image that returns a byte array, which can be stored 
// as a file in a local directory. 
byte[] img = fileRepos.Download("Images\\JP.JPG");

IFileRepositoryService.DownloadDataAsync Method

The DownloadData method downloads the asynchronous data.

Namespace – ABSuite.AccessLayer.Connector.Core

Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)

Syntax

Task<byte[]> DownloadDataAsync(
   string virtualPath
)

Argument

  • virtualPath – System.String

    This argument specifies the virtual path.

Using the IFileRepositoryService Interface for the DownloadDataAsync Method

The following code is an example of using the DownloadDataAsync method:

// Declare the FileRepositoryService
  IFileRepositoryService fileRepos =  FileRepositoryServiceFactory.Create();
 
  // Specify the connection details for the repository access
  FileRepositoryConnectionDetails fDetails = new FileRepositoryConnectionDetails();
  fDetails.FileRepositoryDirectory = "\\\\au-papachj-5\\classes\\FREPOS";
 
  // Connect to the File Repository Service
  fileRepos.Connect(fDetails);
 
  // Download an image that returns a byte array, which can be 
  // stored as a file in a local directory. 
byte[] img = fileRepos.Download("Images\\JP.JPG").ContinueWith((img) => { // Process the image });

IFileRepositoryService.GetTimeStamp Method

The GetTimeStamp method retrieves the current timestamp of the file specified in the virtualPath parameter. This can be used to compare the timestamp of a local version against the server version, and download the file only if required.

Namespace – ABSuite.AccessLayer.Connector.Core

Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)

Syntax

long GetTimeStamp(
   string virtualPath
)

Argument

  • virtualPath – System.String

    This argument provides the path and filename of a specific file on the server.

Return Value

If this method succeeds, it returns a numeric value that identifies the timestamp of the specified file that was last uploaded on the server.

Using the IFileRepositoryService Interface for the GetTimeStamp Method

The following code is an example of using the GetTimeStamp() method:

  // Get the Timestamp of a specified file on the server. 
  long ts = fileRepos.GetTimeStamp("Images\\JP.JPG");
  DateTime dt = new DateTime(ts);

IFileRepositoryService.GetTimeStampAsync Method

The GetTimeStampAsync method retrieves the current timestamp of the file specified in the virtualPath parameter. This can be used to compare the timestamp of a local version against the server version, and download the file only if required.

Namespace – ABSuite.AccessLayer.Connector.Core

Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)

Syntax

Task<long> GetTimeStampAsync(
    string virtualPath
)

Argument

  • virtualPath – System.String

    This argument provides the path and filename of a specific file on the server.

Return Value

If this method succeeds, it returns a numeric value that identifies the timestamp of the specified file that was last uploaded on the server.

Using the IFileRepositoryService Interface for the GetTimeStampAsync Method

The following code is an example of using the GetTimeStampAsync method:

// Get the Timestamp of a specified file on the server. 
long ts = await fileRepos.GetTimeStampAsync("Images\\Pic.JPG");
DateTime dt = new DateTime(ts);

IFileRepositoryService.Upload Method

The Upload method is used to upload a specified file to the FileRepository.

Namespace – ABSuite.AccessLayer.Connector.Core

Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)

Syntax

bool Upload(
   string file
)

Argument

  • file – System.String

    This argument specifies the file to be uploaded.

Return Value

This method returns true if the specified file is uploaded successfully to the FileRepository; otherwise, it returns false.

Using the IFileRepositoryService Interface for the Upload Method

The following code is an example of using the Upload() method:

fileRepos.Upload(("c:\\temp\\FREPOS\\Images\\Test.jpg"););

Note: The credentials being used to run the client application must have access rights to the file shared on the server machine to upload a file.

IFileRepositoryService.UploadAsync Method

The UploadAsync method performs the upload processing to send a file to the server.

Namespace – ABSuite.AccessLayer.Connector.Core

Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)

Syntax

Task<bool> UploadAsync(
   string file
)

Argument

  • file – System.String

    This argument specifies the file to be sent to the server.

Return Type

This method returns true if the upload is successful; otherwise, it returns false.

Using the IFileRepositoryService Interface for the UploadAsync Method

The following code is an example of using the UploadAsync method:

await fileRepos.UploadAsync(("c:\\temp\\FREPOS\\Images\\Picture.jpg"););

IFileRepositoryService.UploadData Method

The UploadData method uploads the data.

Namespace – ABSuite.AccessLayer.Connector.Core

Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)

Syntax

bool UploadData(
   byte[] data,
   string virtualPath
)

Arguments

  • data – System.Byte

    This argument specifies the data to be uploaded.

  • virtualPath – System.String

    This argument specifies the virtual path where the data is uploaded.

Return Value

This method returns true if the data upload is successful; otherwise, it returns false.

Using the IFileRepositoryService Interface for the UploadData Method

The following code is an example of using the UploadData method:

// Upload a file to the server repository
        FileUploadMessage fUploadMsg = new FileUploadMessage();
        fUploadMsg.VirtualPath = ("Images");
        Stream fs = File.OpenRead("c:\\temp\\FREPOS\\Images\\Test.jpg");
        fUploadMsg.Stream = ConvertStream(fs);
        bool bUploadOK = fileRepos.Upload(fUploadMsg);

        // This method converts the filestream into a byte array 
        private byte[] ConvertStream(Stream myStream)
        {            
            System.IO.MemoryStream data = new System.IO.MemoryStream();
            System.IO.Stream str = myStream;
    
            str.CopyTo(data);
            data.Seek(0, SeekOrigin.Begin); 
            byte[] buf = new byte[data.Length];
            data.Read(buf, 0, buf.Length);      
            return buf;     
        }

IFileRepositoryService.UploadDataAsync Method

The UploadDataAsync method uploads the asynchronous data.

Namespace – ABSuite.AccessLayer.Connector.Core

Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)

Syntax

Task<bool> UploadDataAsync(
   byte[] data,
   string virtualPath
)

Arguments

  • data – System.Byte

    This argument specifies the data to be uploaded.

  • virtualPath – System.String

    This argument specifies the virtual path where the data is uploaded.

Return Value

This method returns true if the data upload is successful; otherwise, it returns false.

Using the IFileRepositoryService Interface for the UploadDataAsync Method

The following code is an example of using the UploadDataAsync method:

// Upload a file to the server repository.
        FileUploadMessage fUploadMsg = new FileUploadMessage();
        fUploadMsg.VirtualPath = ("Images");
        Stream fs = File.OpenRead("c:\\temp\\FREPOS\\Images\\Test.jpg");
        fUploadMsg.Stream = ConvertStream(fs);
        bool bUploadOK = fileRepos.Upload(fUploadMsg);

        // This method converts the filestream into a byte array 
        private byte[] ConvertStream(Stream myStream)
        {            
            System.IO.MemoryStream data = new System.IO.MemoryStream();
            System.IO.Stream str = myStream;

            str.CopyTo(data);
            data.Seek(0, SeekOrigin.Begin); 
            byte[] buf = new byte[data.Length];
            data.Read(buf, 0, buf.Length);      
            return buf;    
        }