当前位置: 首页>>代码示例>>C#>>正文


C# WorkItemStore.GetWorkItem方法代码示例

本文整理汇总了C#中Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore.GetWorkItem方法的典型用法代码示例。如果您正苦于以下问题:C# WorkItemStore.GetWorkItem方法的具体用法?C# WorkItemStore.GetWorkItem怎么用?C# WorkItemStore.GetWorkItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore的用法示例。


在下文中一共展示了WorkItemStore.GetWorkItem方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Close

        public void Close(string itemId, string comment)
        {
            using (var collection = new TfsTeamProjectCollection(locator.Location))
            {
                var workItemId = int.Parse(itemId);
                var workItemStore = new WorkItemStore(collection, WorkItemStoreFlags.BypassRules);
                var workItem = workItemStore.GetWorkItem(workItemId);
                var workItemDefinition = workItem.Store.Projects[workItem.Project.Name].WorkItemTypes[workItem.Type.Name];

                if (workItemDefinition == null)
                {
                    throw new ArgumentException("Could not obtain work item definition to close work item");
                }

                var definitionDocument = workItemDefinition.Export(false).InnerXml;
                var xDocument = XDocument.Parse(definitionDocument);
                var graphBuilder = new StateGraphBuilder();
                var stateGraph = graphBuilder.BuildStateGraph(xDocument);
                var currentStateNode = stateGraph.FindRelative(workItem.State);

                var graphWalker = new GraphWalker<string>(currentStateNode);
                var shortestWalk = graphWalker.WalkToNode("Closed");

                foreach (var step in shortestWalk.Path)
                {
                    workItem.State = step.Value;
                    workItem.Save();
                }

                workItem.Fields[CoreField.Description].Value = comment + "<br /><br/>" + workItem.Fields[CoreField.Description].Value;
                workItem.Save();
            }
        }
开发者ID:stephengodbold,项目名称:workitem-migrator,代码行数:33,代码来源:ExampleRepositoryProvider.cs

示例2: AddLinkToWorkItem

        public override void AddLinkToWorkItem(int parentId, int childWorkItemId, string comment)
        {
            using (var tfsProjectCollection = GetProjectCollection())
            {
                var workItemStore = new WorkItemStore(tfsProjectCollection);
                var parentWorkItem = workItemStore.GetWorkItem(parentId);
                var linked = false;

                // Update if there's an existing link already
                foreach (var link in parentWorkItem.Links)
                {
                    var relatedLink = link as RelatedLink;
                    if (relatedLink != null && relatedLink.RelatedWorkItemId == childWorkItemId)
                    {
                        relatedLink.Comment = comment;
                        linked = true;
                    }
                }

                if (!linked)
                {
                    parentWorkItem.Links.Add(new RelatedLink(childWorkItemId) { Comment = comment });
                }

                parentWorkItem.Validate();
                parentWorkItem.Save();
            }
        }
开发者ID:codito,项目名称:supa,代码行数:28,代码来源:TfsSoapServiceProviderTests.cs

示例3: RunLinkQuery

        private List<WorkItem> RunLinkQuery(WorkItemStore workItemStore, Query query)
        {
            var queryResults = query.RunLinkQuery();

            return queryResults.Select(i => workItemStore.GetWorkItem(i.TargetId)).ToList();
        }
开发者ID:ielcoro,项目名称:TFSWorkItemQueryToWebAPI,代码行数:6,代码来源:QueryExecutionTests.cs

示例4: CreateLinks

        /* Set links between workitems */
        private void CreateLinks(List<WorkItem> workItemCollection, WorkItemStore sourceStore, ProgressBar ProgressBar)
        {
            List<int> linkedWorkItemList = new List<int>();
            WorkItemCollection targetWorkItemCollection = GetWorkItemCollection();
            int index = 0;
            foreach (WorkItem workItem in workItemCollection)
            {
                WorkItemLinkCollection links = workItem.WorkItemLinks;
                if (links.Count > 0)
                {
                    int newWorkItemID = (int)itemMap[workItem.Id];
                    WorkItem newWorkItem = store.GetWorkItem(newWorkItemID);

                    foreach (WorkItemLink link in links)
                    {
                        try
                        {
                            WorkItem targetItem = sourceStore.GetWorkItem(link.TargetId);
                            if (itemMap.ContainsKey(link.TargetId) && targetItem != null)
                            {
                                int targetWorkItemID = 0;
                                if (itemMap.ContainsKey(link.TargetId))
                                {
                                    targetWorkItemID = (int)itemMap[link.TargetId];
                                }

                                //if the link is not already created(check if target id is not in list)
                                if (!linkedWorkItemList.Contains(link.TargetId))
                                {
                                    try
                                    {
                                        WorkItemLinkTypeEnd linkTypeEnd = store.WorkItemLinkTypes.LinkTypeEnds[link.LinkTypeEnd.Name];
                                        newWorkItem.Links.Add(new RelatedLink(linkTypeEnd, targetWorkItemID));

                                        ArrayList array = newWorkItem.Validate();
                                        if (array.Count == 0)
                                        {
                                            newWorkItem.Save();
                                        }
                                        else
                                        {
                                            logger.Info("WorkItem Validation failed at link setup for work item: " + workItem.Id);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        logger.ErrorFormat("Error occured when crearting link for work item: {0} target item: {1}", workItem.Id, link.TargetId);
                                        logger.Error("Error detail", ex);
                                    }
                                }
                            }
                            else
                            {
                                logger.Info("Link is not created for work item: " + workItem.Id + " - target item: " + link.TargetId + " does not exist");
                            }
                        }
                        catch (Exception)
                        {
                            logger.Warn("Link is not created for work item: " + workItem.Id + " - target item: " + link.TargetId + " is not in Source TFS or you do not have permission to access");
                        }
                    }
                    //add the work item to list if the links are processed
                    linkedWorkItemList.Add(workItem.Id);
                }
                index++;
                ProgressBar.Dispatcher.BeginInvoke(new Action(delegate ()
                {
                    float progress = (float)index / (float)workItemCollection.Count;
                    ProgressBar.Value = ((float)index / (float)workItemCollection.Count) * 100;
                }));
            }
        }
开发者ID:pmiossec,项目名称:TotalTfsMigrationTool,代码行数:73,代码来源:WorkItemWrite.cs

示例5: GetWorkItemCheckinInfo

        private static WorkItemCheckinInfo[] GetWorkItemCheckinInfo(IReadOnlyCollection<int> workItemIds, WorkItemStore workItemStore)
        {

            var result = new List<WorkItemCheckinInfo>(workItemIds.Count);
            foreach (var workItemId in workItemIds)
            {
                var workItem = workItemStore.GetWorkItem(workItemId);
                var workItemCheckinInfo = new WorkItemCheckinInfo(workItem, WorkItemCheckinAction.Associate);
                result.Add(workItemCheckinInfo);
            }

            return result.ToArray();
        }
开发者ID:Manuel-S,项目名称:AutoMerge,代码行数:13,代码来源:BranchesViewModel.cs

示例6: GetItemInfo

 private void GetItemInfo(WorkItemInfo item, WorkItemStore store, bool isRequirement = true)
 {
     var workItem = store.GetWorkItem(item.Id);
     item.Title = workItem.Title;
     if (isRequirement)
     {
         item.MatrixState = workItem.State;
     }
 }
开发者ID:colindembovsky,项目名称:TFSReqMatrix,代码行数:9,代码来源:RequirementMatrixGenerator.cs


注:本文中的Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore.GetWorkItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。