How do I add new file to Vault repository using the API?
Moderator: SourceGear
How do I add new file to Vault repository using the API?
How do I add new file to Vault repository using the API?
client.Repository.Root.Files.Add
or
Dim oItem As ChangeSetItem_AddFile = New ChangeSetItem_AddFile(System.DateTime.Now, "My Comments", "My Properties", PhysicalLocalPath, VaultPath)
is not helping me much. It will be great if you can point me to a good example.
Thanks
Srini
client.Repository.Root.Files.Add
or
Dim oItem As ChangeSetItem_AddFile = New ChangeSetItem_AddFile(System.DateTime.Now, "My Comments", "My Properties", PhysicalLocalPath, VaultPath)
is not helping me much. It will be great if you can point me to a good example.
Thanks
Srini
Once you've created a Change Set Item Collection with actual change set items, all you need to do is call Commit().
For more examples, download, build and step through the code for the Command Line Client in the Vault Client API. In particular, step through the handlers for "vault.exe ADD" and "vault COMMIT".
For more examples, download, build and step through the code for the Command Line Client in the Vault Client API. In particular, step through the handlers for "vault.exe ADD" and "vault COMMIT".
Jeff Clausius
SourceGear
SourceGear
How to add a file to repository ???
Here's the sample code I use:
col = new ChangeSetItemColl();
filePath = @"C:\dev1.txt";
project = "$/";
changeFile = new ChangeSetItem_AddFile(new VaultDateTime(), comment, String.Empty, filePath, project);
col.Add(changeFile);
res = moClient.Commit(col, "Changeset comments");
res is ALWAYS false.
Any ideas ?
col = new ChangeSetItemColl();
filePath = @"C:\dev1.txt";
project = "$/";
changeFile = new ChangeSetItem_AddFile(new VaultDateTime(), comment, String.Empty, filePath, project);
col.Add(changeFile);
res = moClient.Commit(col, "Changeset comments");
res is ALWAYS false.
Any ideas ?
Have you looked at the examples here: http://support.sourcegear.com/viewtopic.php?t=8020 ?
sure, but the examples use the integration library and the ServerOperations class. I am actually just using the <PORN SPAM> API since our application was written entirely based on that. Plus, I think the integration lib is just a wrapper around the <PORN SPAM> API and so they're calling the methods that I am. I am more interested to know what and how different we're calling the same functions. If we're both calling the same stuff, how can that lib work and not the way I am doing it ?
Thanks for your help. For logs on the client side, do you happen to know what they're called or perhaps if there's a pattern ? my %TEMP% directory is huge and I only found 3 .log files which had nothing to do with SGV it seems.
I am planning to install the new client API 4.1.0.16216 and see if that makes any difference at all. If not, I will also try the integration lib. I will get back to you soon.
Thanks again.
I am planning to install the new client API 4.1.0.16216 and see if that makes any difference at all. If not, I will also try the integration lib. I will get back to you soon.
Thanks again.
The log files are .txt files, but one of my coworkers suggested using the message events.
Are you subscribing to the message events in your code? Try writing them to the console or a file (or whatever display you have).
//During clientinstance login:
if ( ClientInstance != null )
{
ClientInstance.EventEngine.addListener(client, typeof(MessageEvent));
ClientInstance.EventEngine.addListener(client, typeof(BulkMessageEvent));
}
//Then define these two handlers
public void HandleEvent(MessageEvent e)
{
}
/// <summary>
/// BulkMessageEvent handler. Writes the message if Verbose is true or the message level is error.
/// </summary>
/// <param name="e"></param>
public void HandleEvent(BulkMessageEvent e)
{
}
Are you subscribing to the message events in your code? Try writing them to the console or a file (or whatever display you have).
//During clientinstance login:
if ( ClientInstance != null )
{
ClientInstance.EventEngine.addListener(client, typeof(MessageEvent));
ClientInstance.EventEngine.addListener(client, typeof(BulkMessageEvent));
}
//Then define these two handlers
public void HandleEvent(MessageEvent e)
{
}
/// <summary>
/// BulkMessageEvent handler. Writes the message if Verbose is true or the message level is error.
/// </summary>
/// <param name="e"></param>
public void HandleEvent(BulkMessageEvent e)
{
}
Thanks. I subscribed to the message engine and here are the messages that I go back from: HandleEvent(MessageEvent e)
VaultClientOperationsLib.ProgressMessageBeforeTransactionBegin
VaultClientOperationsLib.ProgressMessageTransactionBegin
VaultClientOperationsLib.ProgressMessageTransactionItemFailed
VaultClientOperationsLib.ProgressMessageTransactionFailed
So I looked at the log file on the server and I found out that that I have a message for: AddFile: $/Aspen2000 returned: FailObjAlreadyExists
The file I am trying to add is: C:\dev1.txt and the folder that it's going to is $/Aspen2000
What's strange is that when I bring up the client to actually find this file, it isnt there. Do I need to refresh something or perhaps clear out the server cache somehow to make the file show up ?
VaultClientOperationsLib.ProgressMessageBeforeTransactionBegin
VaultClientOperationsLib.ProgressMessageTransactionBegin
VaultClientOperationsLib.ProgressMessageTransactionItemFailed
VaultClientOperationsLib.ProgressMessageTransactionFailed
So I looked at the log file on the server and I found out that that I have a message for: AddFile: $/Aspen2000 returned: FailObjAlreadyExists
The file I am trying to add is: C:\dev1.txt and the folder that it's going to is $/Aspen2000
What's strange is that when I bring up the client to actually find this file, it isnt there. Do I need to refresh something or perhaps clear out the server cache somehow to make the file show up ?