/// <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, string areapath = "", string linkend = "", int linkid = 0, string DocUrl = "") { WorkItemType workItemType = TfsManager.Instance.ItemsStore.Projects[projectName].WorkItemTypes[workItemTypeString]; var wi = new WorkItem(workItemType) { Title = title }; if (areapath != "" && areapath != projectName) { wi.AreaPath = areapath; } 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); } if (linkend != "" && linkid > 0) { if (TfsManager.Instance.ItemsStore.WorkItemLinkTypes.LinkTypeEnds.Contains(linkend)) { WorkItemLinkTypeEnd linkTypeEnd = TfsManager.Instance.ItemsStore.WorkItemLinkTypes.LinkTypeEnds[linkend]; wi.Links.Add(new RelatedLink(linkTypeEnd, linkid)); } } if (DocUrl != "") { wi.Links.Add(new Hyperlink(DocUrl)); } var _save_errors = wi.Validate(); if (_save_errors.Count > 0) { return(0); } wi.Save(); return(wi.Id); }