c# - How to find changeset associated to work item -
i trying changeset allsociated work item able workitem not changeset asssociated workitem.
below code block using workitem
tfsteamprojectcollection tpc = new tfsteamprojectcollection( tfsuri); workitemstore workitemstore = (workitemstore)tpc.getservice(typeof(workitemstore)); workitemcollection queryresults = workitemstore.query( string.format("select [title] " + "from workitems " + "where [id] = '{0}' ", itemid)); foreach (workitem workitem in queryresults) { console.writeline(workitem.title); } also tried below solution not working
http://blogs.msdn.com/b/jmanning/archive/2005/09/21/472524.aspx
using system; using system.collections.generic; using microsoft.teamfoundation.client; using microsoft.teamfoundation.workitemtracking.client; using microsoft.teamfoundation; class changesetsfromworkitems { static void main(string[] args) { if (args.length < 2) { console.error.write("usage: changesetsfromworkitems <server> <workitemid> [workitemid...]"); environment.exit(1); } teamfoundationserver server = teamfoundationserverfactory.getserver(args[0]); workitemstore wistore = (workitemstore)server.getservice(typeof(workitemstore)); int workitemid; (int = 1; < args.length; i++) { if (!int.tryparse(args[i], out workitemid)) { console.error.writeline("ignoring unparseable argument {0}", args[i]); continue; } workitem workitem = wistore.getworkitem(workitemid); list<string> associatedchangesets = new list<string>(); foreach (link link in workitem.links) { externallink extlink = link externallink; if (extlink != null) { artifactid artifact = linkingutilities.decodeuri(extlink.linkedartifacturi); if (string.equals(artifact.artifacttype, "changeset", stringcomparison.ordinal)) { associatedchangesets.add(artifact.toolspecificid); } } } string changesets = string.join(", ", associatedchangesets.toarray()); console.writeline("workitem {0} has associated changeset(s): {1}", workitemid, changesets); } } } below condition returns false because extlink null
if (extlink != null)
if there not externallink (e.g. none of links can cast type), there no external link associated work item.
try looking @ workitem.links collection in debugger see kind of links attached it.
Comments
Post a Comment