Page 1 of 1
Asynchronous event to display the list of files downloaded
Posted: Wed Dec 02, 2009 11:15 pm
by christinson
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.
Re: Asynchronous event to display the list of files downloaded
Posted: Thu Dec 03, 2009 2:19 pm
by jeremy_sg
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.
Re: Asynchronous event to display the list of files downloaded
Posted: Fri Dec 04, 2009 12:05 am
by christinson
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.
Re: Asynchronous event to display the list of files downloaded
Posted: Fri Dec 04, 2009 9:37 am
by jeremy_sg
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?
Re: Asynchronous event to display the list of files downloaded
Posted: Mon Dec 07, 2009 1:16 am
by christinson
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.
Re: Asynchronous event to display the list of files downloaded
Posted: Tue Dec 08, 2009 10:08 am
by jeremy_sg
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();
}
}
}
Re: Asynchronous event to display the list of files downloaded
Posted: Wed Dec 09, 2009 1:14 am
by christinson
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.
Re: Asynchronous event to display the list of files downloaded
Posted: Wed Dec 09, 2009 9:00 am
by jeremy_sg
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.