當前位置: 首頁>>代碼示例>>C#>>正文


C# Client.WorkItem類代碼示例

本文整理匯總了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]));
        }
開發者ID:cqse,項目名稱:ScrumPowerTools,代碼行數:27,代碼來源:QueryResultsTotalizerModel.cs

示例2: QueryResultsTotalizerModel

        public QueryResultsTotalizerModel(IVisualStudioAdapter visualStudioAdapter)
        {
            this.visualStudioAdapter = visualStudioAdapter;

            CurrentWorkItems = new WorkItem[0];
            NumericFieldDefinitions = new FieldDefinition[0];
        }
開發者ID:cqse,項目名稱:ScrumPowerTools,代碼行數:7,代碼來源:QueryResultsTotalizerModel.cs

示例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();
 }
開發者ID:benjambe,項目名稱:TeamCityBuildChanges,代碼行數:7,代碼來源:TfsApi.cs

示例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();
                    }
                }
            }
        }
開發者ID:JohnFx,項目名稱:ImprovedTFS,代碼行數:34,代碼來源:TFSHelper.cs

示例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;
        }
開發者ID:rolandocc,項目名稱:TFSAPIWrapper,代碼行數:40,代碼來源:TFSAPI.cs

示例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.");
        }
開發者ID:acesiddhu,項目名稱:supa,代碼行數:32,代碼來源:TfsSoapServiceProvider.cs

示例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));
            }
        }
開發者ID:DanMannMann,項目名稱:Timekeeper,代碼行數:26,代碼來源:TimekeeperVsExtensionSettings.cs

示例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));
			}
		}
開發者ID:TargetProcess,項目名稱:Target-Process-Plugins,代碼行數:32,代碼來源:WorkItemsUsedFields.cs

示例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();
 }
開發者ID:mwpnl,項目名稱:bmx-tfs2012,代碼行數:7,代碼來源:Tfs2012Issue.cs

示例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;
 }
開發者ID:ricred,項目名稱:PivotalTFS,代碼行數:7,代碼來源:Conchango_Template.cs

示例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);
        }
開發者ID:amccool,項目名稱:WorkItemVisualization,代碼行數:35,代碼來源:ProcessDGMLData.cs

示例12: AddWorkItem

 public void AddWorkItem()
 {
     WorkItem newItem = new WorkItem( teamProject.WorkItemTypes["タスク"] );
     newItem.Title = "作業項目の概要です";
     newItem.Description = "作業項目の詳細です";
     newItem.Save();
 }
開發者ID:kaorun55,項目名稱:tfs_sandbox,代碼行數:7,代碼來源:TfsClient.cs

示例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;
 }
開發者ID:campbell18,項目名稱:TimeSheet,代碼行數:7,代碼來源:WorkItemModel.cs

示例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();
        }
開發者ID:yetanotherchris,項目名稱:spruce,代碼行數:31,代碼來源:TaskSummary.cs

示例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;
             }
        }
開發者ID:hopenbr,項目名稱:HopDev,代碼行數:28,代碼來源:TFVC.cs


注:本文中的Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。