How do I retrieve the complete history changes for a Story

57 views
Skip to first unread message

William

unread,
Sep 1, 2010, 4:50:21 AM9/1/10
to VersionOne-dev
Hi,

I would like to get the complete history changes for a story. I want
to find all the times a story was changed, by whom and what comments
they left. I am using the core api (C#). I can retrieve the
ChangeDate, ChangedBy.Name and ChangeComment for the story but this
only returns last time these values changed.

Project rootProject = sandboxInstance.Get.ProjectByName("Root");
EpicFilter epicFilter = new EpicFilter();
var epics = rootProject.GetEpics(epicFilter, true);

foreach (var epic in epics)
{
Console.WriteLine("{0},{1},{2},{3}", epic.Name,
epic.ChangeDate, epic.ChangedBy.Name, epic.ChangeComment);
}

It does return all the times these values changed for a given story.
If someone could tell me how to do this it would be appreciated.

Regards
William

Pascalin Adrian Daniel

unread,
Sep 1, 2010, 5:05:22 AM9/1/10
to version...@googlegroups.com
Assuming you have:
Story story;
Here is the code for getting in the 'result' the list of historical
assets:

QueryResult result = null;
IAssetType storyType = _v1Server.MetaModel.GetAssetType("Story");
Query query = new Query(storyType, true); //here true is for historical
FilterTerm term = new
FilterTerm(storyType.GetAttributeDefinition("ID"));
term.Equal(story.ID); //here is your story - and it works for epics too,
but you must be carefull when you cast to/from US/Epic
query.Filter = term;

try
{
query.OrderBy.MajorSort(storyType.GetAttributeDefinition("ChangeDate"),
OrderBy.Order.Descending);
result = _v1Server.Services.Retrieve(query);
}
catch (Exception e)
{
}

foreach (Asset asset in result.Assets)
{
AssetID assetIn = AssetID.FromToken(asset.Oid.Token);
try
{
Story oldStory = v1Inst.Get.StoryByID(assetIn);

//display here the state of the object
}
catch (InvalidCastException)
{
//Epic converted to Story
Epic oldEpic = null;
try
{
oldEpic = v1Inst.Get.EpicByID(assetIn);
//display here the state of the object
}
catch (Exception ex)
{
}
}
}

Hope this helps, it took me a while till I figured it all out :)

Hi,

Regards
William

--
You received this message because you are subscribed to the Google
Groups "VersionOne-dev" group.
To post to this group, send email to version...@googlegroups.com.
To unsubscribe from this group, send email to
versionone-de...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/versionone-dev?hl=en.

Reply all
Reply to author
Forward
0 new messages