本文整理汇总了C#中WorkItem.Save方法的典型用法代码示例。如果您正苦于以下问题:C# WorkItem.Save方法的具体用法?C# WorkItem.Save怎么用?C# WorkItem.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorkItem
的用法示例。
在下文中一共展示了WorkItem.Save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NewLink_succeeds
public void NewLink_succeeds()
{
// prepare
this.fixture.PushPolicies("NewObjects");
string workItemTypeName = "Product Backlog Item";
var targetType = this.fixture.Project.WorkItemTypes[workItemTypeName];
var wiPBI = new WorkItem(targetType);
wiPBI.Title = workItemTypeName + " NewLink_succeeds";
wiPBI.Save();
workItemTypeName = "Task";
targetType = this.fixture.Project.WorkItemTypes[workItemTypeName];
var wiTask = new WorkItem(targetType);
wiTask.Title = workItemTypeName + " NewLink_succeeds";
// trigger
wiTask.Save();
Thread.Sleep(3000);
wiPBI.SyncToLatest();
wiTask.SyncToLatest();
// validate
var hierarchyRelationship = this.fixture.WorkItemStore.WorkItemLinkTypes["System.LinkTypes.Hierarchy"];
Assert.Equal(1, wiTask.WorkItemLinks.Count);
var actualLink = wiTask.WorkItemLinks[0];
Assert.Equal(hierarchyRelationship.ReverseEnd.ImmutableName, actualLink.LinkTypeEnd.ImmutableName);
Assert.Equal(wiTask.Id, actualLink.SourceId);
Assert.Equal(1, actualLink.TargetId);
}
示例2: NewTask_succeeds
public void NewTask_succeeds()
{
// prepare
this.fixture.PushPolicies("NewObjects");
string workItemTypeName = "Bug";
var targetType = this.fixture.Project.WorkItemTypes[workItemTypeName];
var wiBug = new WorkItem(targetType);
wiBug.Title = workItemTypeName + " NewLink_succeeds";
// trigger
wiBug.Save();
Thread.Sleep(4000);
wiBug.SyncToLatest();
// validate
var hierarchyRelationship = this.fixture.WorkItemStore.WorkItemLinkTypes["System.LinkTypes.Hierarchy"];
Assert.Equal(1, wiBug.WorkItemLinks.Count);
var actualLink = wiBug.WorkItemLinks[0];
Assert.Equal(hierarchyRelationship.ForwardEnd.ImmutableName, actualLink.LinkTypeEnd.ImmutableName);
Assert.Equal(wiBug.Id, actualLink.SourceId);
var wiTask = fixture.WorkItemStore.GetWorkItem(actualLink.TargetId);
Assert.NotNull(wiTask);
Assert.Equal("Task", wiTask.Type.Name);
Assert.Equal("Task auto-generated for " + wiBug.Title, wiTask.Title);
}
示例3: AddWorkItemForCurrentProject
/// <summary>
/// The add work item for current project.
/// </summary>
/// <param name="projectName">
/// The project name.
/// </param>
/// <param name="title">
/// The title.
/// </param>
/// <param name="workItemTypeString">
/// The work item type string.
/// </param>
/// <returns>
/// The <see cref="int"/>.
/// </returns>
public static int AddWorkItemForCurrentProject(string projectName, string title, string workItemTypeString)
{
WorkItemType workItemType =
TfsManager.Instance.ItemsStore.Projects[projectName].WorkItemTypes[workItemTypeString];
var wi = new WorkItem(workItemType) { Title = title };
var requiredFields = GetRequiredFieldsForWorkItem(wi);
var popup = new RequiredFields { DataContext = requiredFields };
if (requiredFields.Count != 0)
{
//Thread.CurrentThread.CurrentCulture = (CultureInfo)Thread.CurrentThread.CurrentCulture.Clone();
//Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern = "dd.MM.yyyy";
popup.Create(null, Icons.AddNewWorkItem);
if (popup.IsCancelled && !popup.IsCreated)
return 0;
}
if (!SetRequiredFieldsForWorkIetm(requiredFields, wi))
return 0;
wi.Save();
return wi.Id;
}
示例4: CreateNewItem
protected override void CreateNewItem(Card card, BoardMapping boardMapping)
{
var project = _projectCollectionWorkItemStore.Projects[boardMapping.Identity.TargetName];
var tfsWorkItemType = GetTfsWorkItemType(boardMapping, project.WorkItemTypes, card.TypeId);
var workItemType = project.WorkItemTypes[tfsWorkItemType.Name];
// Note: using the default state
var workItem = new WorkItem(workItemType)
{
Title = card.Title,
Description = card.Description,
};
SetWorkItemPriority(workItem, card.Priority);
if (!string.IsNullOrEmpty(card.DueDate))
{
if (workItem.Fields.Contains("Due Date"))
workItem.Fields["Due Date"].Value = card.DueDate;
}
if (card.AssignedUserIds != null && card.AssignedUserIds.Any())
{
SetAssignedUser(workItem, boardMapping.Identity.LeanKit, card.AssignedUserIds[0]);
}
if (!string.IsNullOrEmpty(boardMapping.IterationPath)) {
workItem.Fields["System.IterationPath"].Value = boardMapping.IterationPath;
}
try
{
Log.Debug("Attempting to create Work Item from Card [{0}]", card.Id);
workItem.Save();
Log.Debug("Created Work Item [{0}] from Card [{1}]", workItem.Id, card.Id);
card.ExternalCardID = workItem.Id.ToString(CultureInfo.InvariantCulture);
card.ExternalSystemName = ServiceName;
if (_projectHyperlinkService != null)
{
card.ExternalSystemUrl = _projectHyperlinkService.GetWorkItemEditorUrl(workItem.Id).ToString();
}
// now that we've created the work item let's try to set it to any matching state defined by lane
var states = boardMapping.LaneToStatesMap[card.LaneId];
if (states != null)
{
UpdateStateOfExternalItem(card, states, boardMapping, true);
}
LeanKit.UpdateCard(boardMapping.Identity.LeanKit, card);
}
catch (ValidationException ex)
{
Log.Error("Unable to create WorkItem from Card [{0}]. ValidationException: {1}", card.Id, ex.Message);
}
catch (Exception ex)
{
Log.Error("Unable to create WorkItem from Card [{0}], Exception: {1}", card.Id, ex.Message);
}
}