本文整理汇总了C#中Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem.Open方法的典型用法代码示例。如果您正苦于以下问题:C# WorkItem.Open方法的具体用法?C# WorkItem.Open怎么用?C# WorkItem.Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem
的用法示例。
在下文中一共展示了WorkItem.Open方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateWorkItem
/// <param name="values">The list of fields and their desired values to apply to the work item</param>
/// <returns>Work item ID of the newly created work item</returns>
public int CreateWorkItem(Dictionary<string, string> values)
{
if (values == null)
{
throw new ArgumentNullException("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)
{
TryApplyFieldValue(workItem, key, values[key]);
}
// 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]);
}
ValidateAndSaveWorkItem(workItem);
CacheWorkItem(workItem);
return workItem.Id;
}
示例2: updateToLatestStatus
public void updateToLatestStatus(WorkItem oldWorkItem, WorkItem newWorkItem)
{
Queue<string> result = new Queue<string>();
string previousState = null;
string originalState = (string)newWorkItem.Fields["State"].Value;
string sourceState = (string)oldWorkItem.Fields["State"].Value;
string sourceFinalReason = (string)oldWorkItem.Fields["Reason"].Value;
//try to change the status directly
newWorkItem.Open();
newWorkItem.Fields["State"].Value = oldWorkItem.Fields["State"].Value;
//System.Diagnostics.Debug.WriteLine(newWorkItem.Type.Name + " " + newWorkItem.Fields["State"].Value);
//if status can't be changed directly...
if (newWorkItem.Fields["State"].Status != FieldStatus.Valid)
{
//get the state transition history of the source work item.
foreach (Revision revision in oldWorkItem.Revisions)
{
// Get Status
if (!revision.Fields["State"].Value.Equals(previousState))
{
previousState = revision.Fields["State"].Value.ToString();
result.Enqueue(previousState);
}
}
int i = 1;
previousState = originalState;
//traverse new work item through old work items's transition states
foreach (String currentStatus in result)
{
bool success = false;
if (i != result.Count)
{
success = ChangeWorkItemStatus(newWorkItem, previousState, currentStatus);
previousState = currentStatus;
}
else
{
success = ChangeWorkItemStatus(newWorkItem, previousState, currentStatus, sourceFinalReason);
}
i++;
// If we could not do the incremental state change then we are done. We will have to go back to the orginal...
if (!success)
break;
}
}
else
{
// Just save it off if we can.
bool success = ChangeWorkItemStatus(newWorkItem, originalState, sourceState);
}
}
示例3: ChangeWorkItemStatus
//save final state transition and set final reason.
private bool ChangeWorkItemStatus(WorkItem workItem, string orginalSourceState, string destState, string reason)
{
//Try to save the new state. If that fails then we also go back to the orginal state.
try
{
workItem.Open();
workItem.Fields["State"].Value = destState;
workItem.Fields["Reason"].Value = reason;
ArrayList list = workItem.Validate();
workItem.Save();
return true;
}
catch (Exception)
{
logger.WarnFormat("Failed to save state for workItem: {0} type:'{1}' state from '{2}' to '{3}' =>rolling workItem status to original state '{4}'",
workItem.Id, workItem.Type.Name, orginalSourceState, destState, orginalSourceState);
//Revert back to the original value.
workItem.Fields["State"].Value = orginalSourceState;
return false;
}
}
示例4: OpenWorkItem
public WorkItem OpenWorkItem(WorkItem _wi)
{
_wi.Open();
return _wi;
}