in Mail2Bug/WorkItemManagement/TFSWorkItemManager.cs [271:312]
public int CreateWorkItem(Dictionary<string, string> values, MessageAttachmentCollection attachments)
{
if (values == null)
{
throw new ArgumentNullException(nameof(values), "Must supply field values when creating new work item");
}
//create a work item
var workItemType = _tfsProject.WorkItemTypes[_config.TfsServerConfig.WorkItemTemplate];
var workItem = new WorkItem(workItemType);
workItem.Open();
foreach (var key in values.Keys)
{
string value = values[key];
// Resolve current iteration
if (_teamSettings != null && key == IterationPathFieldKey && value == CurrentIterationSpecialValue)
{
value = _teamSettings.CurrentIterationPath;
}
TryApplyFieldValue(workItem, key, value);
}
// Workaround for TFS issue - if you change the "Assigned To" field, and then you change the "Activated by" field, the "Assigned To" field reverts
// to its original setting. To prevent that, we reapply the "Assigned To" field in case it's in the list of values to change.
if (values.ContainsKey(AssignedToFieldKey))
{
TryApplyFieldValue(workItem, AssignedToFieldKey, values[AssignedToFieldKey]);
}
foreach (var attachmentPath in attachments.LocalFilePaths)
{
workItem.Attachments.Add(new Attachment(attachmentPath));
}
ValidateAndSaveWorkItem(workItem);
CacheWorkItem(workItem);
return workItem.Id;
}