HistItemType property of VaultHistoryItem
Moderator: SourceGear
HistItemType property of VaultHistoryItem
Hi,
I am using the client API version 4.1.0.16216, trying to run a history request on a repository that should bring back "everything", (The top folder name is set to be "$") and there are no limits on the number of rows returned. I get back X number of results but when I look through the array of items the HistItemType on each history object only hits a few properties, mostly Created, Added and CheckedIn. I am mostly interested in MovedTo and MovedFrom and I dont seem them at all.
To test this, although I was sure we've moved around components in the repository, I manually moved file from one folder to another in the GUI client and ran the query again and it still never hit that the right case.
I also tried the HistoryQuery sample application on the site, made some modifications to make it compatible with my API version. Only change I made was in the BeginDate and EndDate and I moved the range back to 20 years ago and ran the query. Same results.
Any ideas ?
I am using the client API version 4.1.0.16216, trying to run a history request on a repository that should bring back "everything", (The top folder name is set to be "$") and there are no limits on the number of rows returned. I get back X number of results but when I look through the array of items the HistItemType on each history object only hits a few properties, mostly Created, Added and CheckedIn. I am mostly interested in MovedTo and MovedFrom and I dont seem them at all.
To test this, although I was sure we've moved around components in the repository, I manually moved file from one folder to another in the GUI client and ran the query again and it still never hit that the right case.
I also tried the HistoryQuery sample application on the site, made some modifications to make it compatible with my API version. Only change I made was in the BeginDate and EndDate and I moved the range back to 20 years ago and ran the query. Same results.
Any ideas ?
Re: HistItemType property of VaultHistoryItem
Just to make sure we are troubleshooting the right thing, can you see the moved to and from when you run a history query inside of the Vault GUI client instead of using the API? If you aren't seeing them there, then we'll troubleshoot that before looking at the API code.
Just so you know where to look for your thread, if this is only an issue in the API, then I'm going to move this over to the Development Tips section.
Just so you know where to look for your thread, if this is only an issue in the API, then I'm going to move this over to the Development Tips section.
Beth Kieler
SourceGear Technical Support
SourceGear Technical Support
Re: HistItemType property of VaultHistoryItem
Yes, I am using the GUI client 4.1.3 and when I try to retrieve history for a folder, I can see that a number of files have been moved to different places.
It's definitely an API problem.
It's definitely an API problem.
Re: HistItemType property of VaultHistoryItem
It would be helpful if I could see your code, can you provide a snippet?
Re: HistItemType property of VaultHistoryItem
The following lines are part of the LoadHistory() method with the following signature/parameters:
LoadHistory(myClient, "$", DateTime.Now.AddDays(-(double)8000));
This is taken from the HistoryQuery sample project posted on the forum as a sample.
LoadHistory(myClient, "$", DateTime.Now.AddDays(-(double)8000));
This is taken from the HistoryQuery sample project posted on the forum as a sample.
Code: Select all
VaultLib.VaultHistoryQueryRequest req = new VaultLib.VaultHistoryQueryRequest();
DateTime now = DateTime.Now;
ArrayList users = new ArrayList();
ArrayList substrings = new ArrayList();
ArrayList actions = new ArrayList();
ArrayList sorts = new ArrayList();
sorts.Add((long)VaultQueryRequestSort.DateSort);
req.SubstringType = VaultLib.VaultQueryRequestSubstrings.DoNotFilter;
req.IsFolder = true;
req.Recursive = true;
req.DateFilterType = VaultQueryRequestDateTypes.IncludePastDays;
req.DateFilterMask = VaultQueryRequestDates.HistoryBefore | VaultQueryRequestDates.HistoryAfter;
req.EndDate = new VaultDateTime(DateTime.Now, VaultDateTime.LocalKind);
req.BeginDate = new VaultDateTime(dtBegin, VaultDateTime.LocalKind);
actions.Clear();
req.CommentFilter = VaultLib.VaultQueryRequestComments.DoNotFilter;
req.RepID = ciUser.ActiveRepositoryID;
req.TopName = repositoryPath;
req.Recursive = true;
req.Users = (VaultLib.VaultUser[])users.ToArray(typeof(VaultLib.VaultUser));
req.Substrings = (string[])substrings.ToArray(typeof(string));
actions.Add((long)VaultHistoryType.MovedTo);
req.Actions = (long[])actions.ToArray(typeof(long));
req.Sorts = (long[])sorts.ToArray(typeof(long));
string token = String.Empty;
int rowsRetrieved = 0;
VaultLib.VaultHistoryItem[] items = new VaultLib.VaultHistoryItem[1];
ciUser.Connection.HistoryBegin(req, 0, ref rowsRetrieved, ref token);
if (rowsRetrieved > 0)
ciUser.Connection.HistoryFetch(token, 0, rowsRetrieved - 1, ref items);
ciUser.Connection.HistoryEnd(token);
Re: HistItemType property of VaultHistoryItem
You want your DateFilterType to be set to IncludeRange, based on your other values: req.DateFilterType = VaultQueryRequestDateTypes.IncludeRange;
Can you tell me what you would select in the history query of the gui client to get the query you're trying to get with this code?
Can you tell me what you would select in the history query of the gui client to get the query you're trying to get with this code?
Re: HistItemType property of VaultHistoryItem
I tried the IncludeRange flag and I got this exception:
Server was unable to process request. ---> StartIndex cannot be less than zero.
Parameter name: startIndex
In the GUI client, I simply right click on $, select Show History and accept all default values in the new screen. In the History screen, i can see that many files were moved to other folders.
Server was unable to process request. ---> StartIndex cannot be less than zero.
Parameter name: startIndex
In the GUI client, I simply right click on $, select Show History and accept all default values in the new screen. In the History screen, i can see that many files were moved to other folders.
Re: HistItemType property of VaultHistoryItem
Ok, that error might make sense....in HistoryBegin, the second parameter is the max number of items that will be returned, try changing it from 0 to something like 1000.
Re: HistItemType property of VaultHistoryItem
Changed to 1000, got the same exception.
Re: HistItemType property of VaultHistoryItem
Ok, I removed some lines it seemed like you weren't using and modified some values that weren't quite right. If you need to add substring or user filtering, you can do so, but I think passing empty arrays was causing a problem. Just to simplify the code, I removed the date filtering entirely since you were just going back a really long time.
Give that a try and see if it returns results closer to what you were expecting.
Code: Select all
VaultLib.VaultHistoryQueryRequest req = new VaultLib.VaultHistoryQueryRequest();
DateTime now = DateTime.Now;
ArrayList users = new ArrayList();
ArrayList substrings = new ArrayList();
ArrayList actions = new ArrayList();
ArrayList sorts = new ArrayList();
sorts.Add((long)(VaultQueryRequestSort.DateSort | VaultQueryRequestSort.DescSort));
req.SubstringType = VaultLib.VaultQueryRequestSubstrings.DoNotFilter;
req.IsFolder = true;
req.Recursive = true;
req.DateFilterType = VaultQueryRequestDateTypes.DoNotFilter;
req.BeginDate = req.EndDate = VaultDate.EmptyDate();
actions.Clear();
req.CommentFilter = VaultLib.VaultQueryRequestComments.DoNotFilter;
req.RepID = ciUser.ActiveRepositoryID;
req.TopName = repositoryPath;
VaultClientFolder vcf = ciUser.TreeCache.Repository.Root.FindFolderRecursive(repositoryPath);
req.TopID = vcf.ID;
req.Recursive = true;
actions.Add((long)VaultRequestType.Move);
req.Actions = (long[])actions.ToArray(typeof(long));
req.Sorts = (long[])sorts.ToArray(typeof(long));
string token = String.Empty;
int rowsRetrieved = 0;
VaultLib.VaultHistoryItem[] items = new VaultLib.VaultHistoryItem[1];
ciUser.Connection.HistoryBegin(req, 2000, ref rowsRetrieved, ref token);
if (rowsRetrieved > 0)
ciUser.Connection.HistoryFetch(token, 0, rowsRetrieved - 1, ref items);
ciUser.Connection.HistoryEnd(token);
Re: HistItemType property of VaultHistoryItem
Tried and this seems to work. Thanks!
Re: HistItemType property of VaultHistoryItem
Thanks for the update. Happy to hear it worked for you.
Beth Kieler
SourceGear Technical Support
SourceGear Technical Support