Page 1 of 1

Challenge with history listing

Posted: Mon Jun 30, 2008 11:35 am
by jbrown
I'm attempting to retrieve a list of all items checked in as of a date range and am not getting back all results.

ServerOperations.client.LoginOptions.URL = "http://devsrv";
ServerOperations.client.LoginOptions.User = "user";
ServerOperations.client.LoginOptions.Password = "pass";
ServerOperations.client.LoginOptions.Repository = "dev-rep";
ServerOperations.client.AutoCommit = true;
ServerOperations.client.Verbose = true;
ServerOperations.client.LoginOptions.AccessLevel = VaultClientNetLib.VaultConnection.AccessLevelType.Admin;

ServerOperations.Login();

string filePath = "$/filepath";


StringWriter sw = new StringWriter();
System.Xml.XmlTextWriter xml = new XmlTextWriter(sw);
xml.Formatting = System.Xml.Formatting.Indented;


//Query the file history so we can view the check in.
bool bRecursive = false;
int beginVersion = -1;
int endVersion = -1;
string excludedList = "add,create,label";
string startDate = "06/01/2008";
string endDate = "06/30/2008";
VaultHistoryItem[] items = ServerOperations.ProcessCommandHistory(filePath, bRecursive, DateSortOption.desc, null, excludedList, startDate, endDate, null, null, beginVersion, endVersion, 30);
// output the history items
xml.WriteStartElement("root");



xml.WriteStartElement("History");
XmlHelper.XmlOutput(xml, items);
xml.WriteEndElement();

xml.Close();
Console.Out.WriteLine(sw.ToString());

I've checked in new items today and do not see them in the list. Any ideas would be appreciated.

Posted: Mon Jun 30, 2008 12:05 pm
by shannon
You are telling it to only return 30 rows (the last parameter). It is returning the first 30 results it finds.

Posted: Mon Jun 30, 2008 12:15 pm
by jbrown
right...

I checked in 5 files last week, 3 today.

Only getting 5 back in the list.

Posted: Mon Jun 30, 2008 2:06 pm
by shannon
Most likely, since you aren't giving it a time, it's defaulting to the very beginning of 6/30. Try passing it the current time as part of the date string.

Posted: Tue Jul 01, 2008 6:32 am
by jbrown
No juice. I've attached an .xls file for your review. The tabbed worksheets are named for their source - one from the Vault client, one from the API.

Thanks for your help.

Posted: Tue Jul 01, 2008 7:26 am
by shannon
The tab labeled vault-history is a non-recursive history. The vault-history-from-client tab is a recursive history. Is this the problem?

Posted: Tue Jul 01, 2008 9:57 am
by jbrown
Excellent. Now how do I pass only the latest version to prevent duplicate files in the list?

Posted: Tue Jul 01, 2008 10:27 am
by shannon
Can you clarify what you're trying to do exactly?

In the example you are passing a file path, from the excel file I think you actually passed a folder.

Is this what you mean: you want to pass a folder and get back only one entry per file or folder, that entry being the one with the latest version? Or did you want to do them file by file, one history call each?

Posted: Tue Jul 01, 2008 10:35 am
by jbrown
Ultimately what I'm trying to get is all the checkins to the repository within a date range so we can build weekly releases.

The recursion brought back what I was looking for in that I can now see all the files in the root and subdirectories (hadn't realized this until you mentioned the recursion). This now matches the History filter on the Vault client when recursion is selected. Perfect....except:

Now I only want the most recent version of each file checked in within a date range; and thought using the ProcessCommandHistory could give me what I was looking for.

Thanks very much for your help so far.

Posted: Tue Jul 01, 2008 12:24 pm
by shannon
The easiest thing to do would be to loop over the items that are returned and pull out the ones that meet your criteria (latest version for each unique path).

Posted: Tue Jul 01, 2008 2:40 pm
by jbrown
What purpose do the beginVersion and endVersion parameters have in the ProcessCommandHistory then?

Posted: Tue Jul 01, 2008 2:54 pm
by shannon
Those will apply to the version of the folder or file you pass as the root object, but not recursive items when you're using a folder as the root object with recursion.

Posted: Tue Jul 01, 2008 2:58 pm
by jbrown
Thanks for the insight on that.

How does the Deploy Wizard do it? I'm really looking for a customized version of it to return a list of the checked in files based on the date range (as mentioned).

Any ideas?

Posted: Wed Jul 02, 2008 8:20 am
by shannon
Deploy just does a get. It only gets the most recent version of each file.