We're trying to calculate parameters in TFS server side plugin. I'm trying to restrict users from moving PBI into Committed state unless all of their child Tasks have value under the "remaining work" field.
This basic logic works, i can go through the child items and get all the values whether exists or not. What i'm failing to understand\Accomplish is how to prevent the Save action in case task's effort is null valued.
if (taskswithoutrw.Count() != 0)
{
permitted = false;
TeamFoundationApplicationCore.Log("changedpermitted to false", 0, EventLogEntryType.Information);
throw new Exception("Some tasks does not contain \"Remaining Work\" value");
}
else
{
var tasks = childs.Where(x => TFStringComparer.WorkItemTypeName.Equals(x.Type.Name, Task));
double workSum = 0;
foreach (var task in tasks)
{
workSum += Convert.ToDouble(task.Fields["Remaining Work"].Value) / 6;
TeamFoundationApplicationCore.Log("Remaining Work sum: " + workSum.ToString(), 0, EventLogEntryType.Information);
}
wi.Fields["Story Points"].Value = workSum.ToString();
wi.Save();
}
if exception is thrown im setting the EventNotificationStatus as ActionDenied
catch (Exception ex)
{
// Log error (Should be logged to the windows event log by default)
TeamFoundationApplicationCore.LogException(requestContext, "Exception occurd in ", ex);
TeamFoundationApplicationCore.Log("outercatch", 0, EventLogEntryType.Information);
statusCode = -1;
return EventNotificationStatus.ActionDenied;
}
Method must return this value
return EventNotificationStatus.ActionPermitted;
But that doesn't seems to do the trick, am i missing something?