c# - How to get the TFS workitem validation error message by code? -
i know workitem.validate
method can arraylist
of fields in work item not valid(msdn).
but seem contain invalid fields , names, not contain error messages, i.e. why they're invalid, useful situation of submitting workitem without using built in tfs controls.
how error tip "new bug 1: tf200012: field 'title' cannot empty."?
for better understanding, please see picture.
using vs2010 sp1 chinese language, , error discription translated above.
visual studio client wraps tfs error messages. can't capture tf* errors can fieldstatus
, print own message.
var invalidfields = workitem.validate(); if (invalidfields.count > 0) { foreach (field field in invalidfields) { string errormessage = string.empty; if (field.status == fieldstatus.invalidempty) { errormessage = string.format("{0} {1} {2}: tf20012: field \"{3}\" cannot empty." , field.workitem.state , field.workitem.type.name , field.workitem.temporaryid , field.name); } //... more handling here console.writeline(errormessage); } } else // validation passed { workitem.save(); }
Comments
Post a Comment