本文整理汇总了C#中Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem类的典型用法代码示例。如果您正苦于以下问题:C# WorkItem类的具体用法?C# WorkItem怎么用?C# WorkItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WorkItem类属于Microsoft.TeamFoundation.WorkItemTracking.Client命名空间,在下文中一共展示了WorkItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RefreshWorkItems
public void RefreshWorkItems(IResultsDocument queryResultsDocument)
{
string query = queryResultsDocument.QueryDocument.QueryText;
Hashtable context = GetTfsQueryParameters(queryResultsDocument);
var tpc = visualStudioAdapter.GetCurrent();
var workItemStore = tpc.GetService<WorkItemStore>();
var workItemQuery = new Query(workItemStore, query, context);
NumericFieldDefinitions = GetNumericFieldDefinitions(workItemQuery);
if (!NumericFieldDefinitions.Any())
{
CurrentWorkItems = new WorkItem[0];
return;
}
WorkItemCollection workItemCollection = workItemStore.GetWorkItems(workItemQuery, NumericFieldDefinitions);
WorkItem[] workItemsA = new WorkItem[workItemCollection.Count];
((ICollection)workItemCollection).CopyTo(workItemsA, 0);
CurrentWorkItems = workItemsA;
RefreshTotals((queryResultsDocument.SelectedItemIds ?? new int[0]));
}
示例2: QueryResultsTotalizerModel
public QueryResultsTotalizerModel(IVisualStudioAdapter visualStudioAdapter)
{
this.visualStudioAdapter = visualStudioAdapter;
CurrentWorkItems = new WorkItem[0];
NumericFieldDefinitions = new FieldDefinition[0];
}
示例3: GetRelatedWorkItemLinks
private IEnumerable<RelatedLink> GetRelatedWorkItemLinks(WorkItem workItem)
{
return workItem.Links.Cast<Link>()
.Where(link => link.BaseType == BaseLinkType.RelatedLink)
.Select(link => link as RelatedLink)
.ToList();
}
示例4: createChildWorkItems
/// <summary>
/// Copies the child work items from the templat work item, under parentWorkItem.
/// Currently there is no support for multiple nesting in the template. This will only copy one level deep.
/// </summary>
/// <param name="parentWorkItem"></param>
public void createChildWorkItems(WorkItem parentWorkItem, WorkItem templateWorkItem)
{
WorkItemLinkTypeEnd childLinkType = workItemStore.WorkItemLinkTypes.LinkTypeEnds["Child"];
WorkItemLinkTypeEnd parentLinkType = workItemStore.WorkItemLinkTypes.LinkTypeEnds["Parent"];
foreach(WorkItemLink itemLInk in templateWorkItem.WorkItemLinks) {
if ((itemLInk.BaseType == BaseLinkType.WorkItemLink) && (itemLInk.LinkTypeEnd == childLinkType)) {
WorkItem copyWorkItem = getWorkItem(itemLInk.TargetId);
if (!copyWorkItem["State"].Equals("Removed")) {
WorkItem newWorkItem = copyWorkItem.Copy();
newWorkItem.Title = newWorkItem.Title;
newWorkItem.IterationId = parentWorkItem.IterationId;
newWorkItem.Links.Clear();
clearHistoryFromWorkItem(newWorkItem);
//This history entry is added to the new items to prevent recursion on newly created items.
newWorkItem.History = Resources.strings.HISTORYTEXT_CLONED;
WorkItemLinkTypeEnd linkTypeEnd = parentLinkType;
newWorkItem.Links.Add(new RelatedLink(linkTypeEnd, parentWorkItem.Id));
newWorkItem.Save();
}
}
}
}
示例5: CreateWorkItem
/// <summary>
/// Creates a new work item of a defined type
/// </summary>
/// <param name="workItemType">The type name</param>
/// <param name="title">Default title</param>
/// <param name="description">Default description</param>
/// <param name="fieldsAndValues">List of extra propierties and values</param>
/// <returns></returns>
public WorkItem CreateWorkItem(string workItemType, string title, string description, Dictionary<string, object> fieldsAndValues)
{
WorkItemType wiType = workItemTypeCollection[workItemType];
WorkItem wi = new WorkItem(wiType) { Title = title, Description = description };
foreach (KeyValuePair<string, object> fieldAndValue in fieldsAndValues)
{
string fieldName = fieldAndValue.Key;
object value = fieldAndValue.Value;
if (wi.Fields.Contains(fieldName))
wi.Fields[fieldName].Value = value;
else
throw new ApplicationException(string.Format("Field not found {0} in workItemType {1}, failed to save the item", fieldName, workItemType));
}
if (wi.IsValid())
{
wi.Save();
}
else
{
ArrayList validationErrors = wi.Validate();
string errMessage = "Work item cannot be saved...";
foreach (Field field in validationErrors)
errMessage += "Field: " + field.Name + " has status: " + field.Status + "/n";
throw new ApplicationException(errMessage);
}
return wi;
}
示例6: ConfigureAsync
/// <inheritdoc/>
public async Task ConfigureAsync(TfsServiceProviderConfiguration configuration)
{
if (configuration == null)
{
throw new ArgumentNullException(nameof(configuration));
}
if(string.IsNullOrEmpty(configuration.WorkItemType))
{
throw new ArgumentNullException(nameof(configuration.WorkItemType));
}
this.logger.Debug("Configure of TfsSoapServiceProvider started...");
var networkCredential = new NetworkCredential(configuration.Username, configuration.Password);
var tfsClientCredentials = new TfsClientCredentials(new BasicAuthCredential(networkCredential)) { AllowInteractive = false };
var tfsProjectCollection = new TfsTeamProjectCollection(this.serviceUri, tfsClientCredentials);
this.workItemType = configuration.WorkItemType;
tfsProjectCollection.Authenticate();
tfsProjectCollection.EnsureAuthenticated();
this.logger.Debug("Authentication successful for {serviceUri}.", this.serviceUri.AbsoluteUri);
await Task.Run(
() =>
{
this.logger.Debug("Fetching workitem for id {parentWorkItemId}.", configuration.ParentWorkItemId);
this.workItemStore = new WorkItemStore(tfsProjectCollection);
this.parentWorkItem = this.workItemStore.GetWorkItem(configuration.ParentWorkItemId);
this.logger.Debug("Found parent work item '{title}'.", this.parentWorkItem.Title);
});
this.logger.Verbose("Tfs service provider configuration complete.");
}
示例7: IsIncluded
public bool IsIncluded(WorkItem item)
{
if (ExcludedItemTypes.Any(x => x.Equals(item.Type.Name, StringComparison.InvariantCultureIgnoreCase)))
{
return false;
}
if (Projects.Any(x => x.ProjectName.Equals(item.Project.Name, StringComparison.InvariantCultureIgnoreCase)))
{
if (Projects.First(x => x.ProjectName.Equals(item.Project.Name, StringComparison.InvariantCultureIgnoreCase))
.ExcludedItemTypes.Any(x => x.Equals(item.Type.Name, StringComparison.InvariantCultureIgnoreCase)))
{
return false;
}
}
if (Whitelist)
{
return WhitelistedProjects.Any(x => x.Equals(item.Project.Name, StringComparison.InvariantCultureIgnoreCase)) &&
!BlacklistedProjects.Any(x => x.Equals(item.Project.Name, StringComparison.InvariantCultureIgnoreCase));
}
else
{
return !BlacklistedProjects.Any(x => x.Equals(item.Project.Name, StringComparison.InvariantCultureIgnoreCase));
}
}
示例8: Map
public static List<WorkItemField> Map(WorkItem workItem)
{
switch (workItem.Type.Name)
{
case Constants.TfsBug:
{
return GetMapping(workItem, BugFields);
}
case Constants.TfsTask:
{
return GetMapping(workItem, TaskFields);
}
case Constants.TfsUserStory:
{
return GetMapping(workItem, UserStoryFields);
}
case Constants.TfsIssue:
{
return GetMapping(workItem, IssueFields);
}
case Constants.TfsBacklogItem:
{
return GetMapping(workItem, BackLogFields);
}
case Constants.TfsImpediment:
{
return GetMapping(workItem, ImpedimentFields);
}
default:
throw new ArgumentException(string.Format("Invalid Work Item Type: {0}", workItem.Type.Name));
}
}
示例9: GetReleaseNumber
private static string GetReleaseNumber(WorkItem workItem, string customReleaseNumberFieldName)
{
if (string.IsNullOrEmpty(customReleaseNumberFieldName))
return workItem.IterationPath.Substring(workItem.IterationPath.LastIndexOf('\\') + 1);
else
return workItem.Fields[customReleaseNumberFieldName].Value.ToString().Trim();
}
示例10: CopyAttributes
public bool CopyAttributes(Story pivotalstorySource, WorkItem destinationWorkItem)
{
destinationWorkItem.Fields[ConchangoTeamsystemScrumEstimatedeffort].Value = pivotalstorySource.Estimate;
destinationWorkItem.Fields[ConchangoTeamsystemScrumBusinesspriority].Value = pivotalstorySource.Priority;
destinationWorkItem.Fields[ConchangoTeamsystemScrumDeliveryorder].Value = pivotalstorySource.Priority;
return true;
}
示例11: ProcessWorkItemRelationships
/// <summary>
/// Method for processing work items down to the changesets that are related to them
/// </summary>
/// <param name="wi">Work Item to process</param>
/// <param name="outputFile">File to write the dgml to</param>
/// <param name="vcs">Version Control Server which contains the changesets</param>
public void ProcessWorkItemRelationships(WorkItem[] wi,
string outputFile,
bool hideReverse,
bool groupbyIteration,
bool dependencyAnalysis,
List<TempLinkType> selectedLinks,
VersionControlServer vcs)
{
string projectName = wi[0].Project.Name;
_workItemStubs = new List<WorkItemStub>();
_wis = wi[0].Store;
_vcs = vcs;
_tms = vcs.TeamProjectCollection.GetService<ITestManagementService>();
_tmp = _tms.GetTeamProject(projectName);
_selectedLinks = selectedLinks;
//Store options
_hideReverse = hideReverse;
_groupbyIteration = groupbyIteration;
_dependencyAnalysis = dependencyAnalysis;
for (int i = 0; i < wi.Length; i++)
{
ProcessWorkItemCS(wi[i]);
}
WriteChangesetInfo(outputFile, projectName);
}
示例12: AddWorkItem
public void AddWorkItem()
{
WorkItem newItem = new WorkItem( teamProject.WorkItemTypes["タスク"] );
newItem.Title = "作業項目の概要です";
newItem.Description = "作業項目の詳細です";
newItem.Save();
}
示例13: WorkItemModel
public WorkItemModel(WorkItem workItem)
{
Title = workItem.Title;
ID = workItem.Id;
Type = workItem.Type.Name;
CompletedWork = Type == "Task" && workItem["Completed Work"] != null ? (double)workItem["Completed Work"] : 0;
}
示例14: FromWorkItem
/// <summary>
/// Fills this instance's fields using the values from the provided <see cref="WorkItem"/>.
/// This includes the Priority, Reason, Original Estimate, Remaining Work and Completed work fields.
/// </summary>
public override void FromWorkItem(WorkItem item)
{
base.FromWorkItem(item);
ResolvedBy = GetFieldValue(item, "Resolved By");
if (item.Fields.Contains("Priority") && item.Fields["Priority"].Value != null)
Priority = item.Fields["Priority"].Value.ToString().ToIntOrDefault();
if (item.Fields.Contains("Reason") && item.Fields["Reason"].Value != null)
Reason = item.Fields["Reason"].Value.ToString();
// Estimates
// Check this field exists. 4.2 Agile doesn't have this field
if (item.Fields.Contains("Original Estimate") && item.Fields["Original Estimate"].Value != null)
EstimatedHours = item.Fields["Original Estimate"].Value.ToString().ToDoubleOrDefault();
if (item.Fields.Contains("Remaining Work") && item.Fields["Remaining Work"].Value != null)
RemainingHours = item.Fields["Remaining Work"].Value.ToString().ToDoubleOrDefault();
if (item.Fields.Contains("Completed Work") && item.Fields["Completed Work"].Value != null)
CompletedHours = item.Fields["Completed Work"].Value.ToString().ToDoubleOrDefault();
// For updates only
if (item.Fields.Contains("Original Estimate") && item.Fields["Original Estimate"].Value != null)
EstimatedHours = item.Fields["Original Estimate"].Value.ToString().ToDoubleOrDefault();
}
示例15: AddToTFVC
public bool AddToTFVC(string[] _files, WorkItem _wi, Workspace _ws)
{
try
{
_ws.Get();
// Now add everything.
_ws.PendAdd(_files, false);
WorkItemCheckinInfo[] _wici = new WorkItemCheckinInfo[1];
_wici[0] = new WorkItemCheckinInfo(_wi, WorkItemCheckinAction.Associate);
if (_ws.CheckIn(_ws.GetPendingChanges(), null, null, _wici, null) > 0)
{
_ws.Delete();
return true;
}
else
{
return false;
}
}
catch
{
return false;
}
}