Asynchronous event to display the list of files downloaded

Post your questions regarding using the Vault and Fortress API in your programs.

Moderator: SourceGear

Post Reply
christinson
Posts: 4
Joined: Wed Dec 02, 2009 11:07 am

Asynchronous event to display the list of files downloaded

Post by christinson » Wed Dec 02, 2009 11:15 pm

Hi,

I am using Source Gear Vault API in my C# project. I need to display the list of files (like a progress message) that are downloaded during the get(recursive) operation asynchronously. I came across two events in the API that displays the list of files that are downloaded. ServerOperations.GetInstance().UserMessage and ClientInstance.EventEngine.AddListener(). I tried both. But, I found that these events are triggered only after all the files are downloaded to the disk. That is not useful to me. I need the events to be fired at once each file is getting downloaded when doing a recursive get using the GetOperations.ProcessCommandGet on a folder.

Did Source Gear API have such an event support?

Thanks,
Christinson.

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Re: Asynchronous event to display the list of files downloaded

Post by jeremy_sg » Thu Dec 03, 2009 2:19 pm

You'll need to listen to the StatusMessageEvent through the EventEngine. If you want more real-time download messages, add a listener for the ProgressChangedEvent.
Subscribe to the Fortress/Vault blog

christinson
Posts: 4
Joined: Wed Dec 02, 2009 11:07 am

Re: Asynchronous event to display the list of files downloaded

Post by christinson » Fri Dec 04, 2009 12:05 am

Tried subscribing to the StatusMessageEvent, but I got only the following messages while performing a recursive get operation on a folder.

Retrieving repository structure information from the server...
Saving repository information to disk...
Working
Updating local files...

I did not get the list of files downloaded. Also, the ProgressChangedEvent only has the percentage of progess, it does not give the list of files that are being downloaded.

Thanks,
Christinson.

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Re: Asynchronous event to display the list of files downloaded

Post by jeremy_sg » Fri Dec 04, 2009 9:37 am

That's odd. Is it possible that your get request is not getting any files? Are they already up to date in the working folder?
Subscribe to the Fortress/Vault blog

christinson
Posts: 4
Joined: Wed Dec 02, 2009 11:07 am

Re: Asynchronous event to display the list of files downloaded

Post by christinson » Mon Dec 07, 2009 1:16 am

My working folder was empty when I tried the get and I verified with the windows explorer that, the files were getting downloaded.

Thanks,
Christinson.

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Re: Asynchronous event to display the list of files downloaded

Post by jeremy_sg » Tue Dec 08, 2009 10:08 am

This code worked for me:

Code: Select all

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VaultClientIntegrationLib;

namespace GetOutputer
{
    class PrivateClass
    {
        public void Run()
        {
            string url = "http://localhost/VaultService";
            string username = "admin";
            string password = "admin";
            string repository = "Test Repository";

            // Set the login options and login/connect to a repository.
            ServerOperations.client.LoginOptions.URL = url;
            ServerOperations.client.LoginOptions.User = username;
            ServerOperations.client.LoginOptions.Password = password;
            ServerOperations.client.LoginOptions.Repository = repository;
            ServerOperations.Login();

            ServerOperations.client.ClientInstance.EventEngine.addListener(this, typeof(VaultClientOperationsLib.StatusMessageEvent));
            GetOperations.ProcessCommandGetToLocationOutsideWorkingFolder(new string[] {"$"}, new GetOptions(), "c:\\temp\\GetLocation");
        }
        public void HandleEvent(VaultClientOperationsLib.StatusMessageEvent e)
        {
            Console.Out.WriteLine(e.Message);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            PrivateClass p = new PrivateClass();
            p.Run();
            
        }
    }
}
Subscribe to the Fortress/Vault blog

christinson
Posts: 4
Joined: Wed Dec 02, 2009 11:07 am

Re: Asynchronous event to display the list of files downloaded

Post by christinson » Wed Dec 09, 2009 1:14 am

Thanks for your sample code.

I am using almost a similar code. The only difference in my code is, I am using the API 'GetOperations.ProcessCommandGet' with working folder set instead of using 'GetOperations.ProcessCommandGetToLocationOutsideWorkingFolder'.

I found that, when I use 'GetOperations.ProcessCommandGet' the event does not trigger some times. It some times display only the mesage 'Working', 'Updating local files... ' and dont list out the names of the files that are downloaded. I verified that no files exist in the target folder before initating the Get operation in each round of testing.

But when I use 'GetOperations.ProcessCommandGetToLocationOutsideWorkingFolder', the event get fired all the time as expected.

Can you please tell me whether there is any issue exist with the API 'GetOperations.ProcessCommandGet' ?

Thanks,
Christinson.

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Re: Asynchronous event to display the list of files downloaded

Post by jeremy_sg » Wed Dec 09, 2009 9:00 am

It's probable that those files are cached in you client cache folder, and aren't being downloaded from the server. They're just being copied from another location on disk. To force a full cache-free get latest, set a new working folder before doing the get.
Subscribe to the Fortress/Vault blog

Post Reply