Пример #1
0
 public WorkItemState(WorkItemType wit)
 {
     this.wit = wit;
     selectedInProgressState =
         selectedApprovedState =
             initialState = wit.NewWorkItem().State;
     closedStates = new List<string> {"Done", "Inactive", "Closed", "Completed", "Rejected", "Removed" };
     witd = wit.Export(true);
     gatherNextStates();
     findDonePath();
 }
        /// <summary>
        /// Retrieves the <see cref="WorkItemSummary"/> derived class that is used for the <see cref="WorkItemType"/>.
        /// </summary>
        public static WorkItemSummary GetForType(WorkItemType workItemType)
        {
            if (!_types.ContainsKey(workItemType.Name))
            {
                Log.Warn("{0} has no equivalent WorkItemSummary. This is typically because its WIQLTypeName does not match the name assigned in TFS.", workItemType.Name);
                return new WorkItemSummary();
            }

            Type type = _types[workItemType.Name];
            return Activator.CreateInstance(type, false) as WorkItemSummary;
        }
Пример #3
0
        /// <summary>
        /// Constructor for VSTS work Item Helper
        /// </summary>
        /// <param name="conn">Team Foundation Connection</param>
        /// <param name="witName">Work Item Type Name</param>
        /// <param name="maps">Field Maps reference</param>
        /// <param name="userMap">User Maps refernce</param>
        /// <param name="sourceConvIndex">Source Converter Index</param>
        public VSTSWorkItemHelper(VSTSConnection conn,
                                  string witName,
                                  FieldMaps maps,
                                  UserMappings userMap,
                                  int sourceConvIndex,
                                  string fieldMapFile)
        {
            m_vstsConnection = conn;
            m_maps           = maps;
            m_witName        = witName;
            m_userMappings   = userMap;
            m_fieldMapFile   = fieldMapFile;

            // validate the field mappings
            ValidateFieldMaps();

            // build the field mappings
            BuildFieldMappings();

            CurClient.WorkItemType witType = m_vstsConnection.GetWorkItemType(m_witName);

            m_convSourceIndex = sourceConvIndex;

            // Check if the Duplicate WI ID is used by CQ!
            if (witType.FieldDefinitions.Contains(m_duplicateWiId) &&
                !m_fieldMappings.Contains(m_duplicateWiId))
            {
                m_canSetDuplicateWiId = true;
            }

            m_wi = CreateNewWorkItem();

            // prepare intial work item snapshot with all required and available field values
            foreach (string reqField in m_requiredFieldsForCreatingWI)
            {
                Field fld = m_wi.Fields[reqField];
                Debug.Assert(fld != null, "Null handle for core field while preparing initial snapshot");
                if (fld != null)
                {
                    Logger.Write(LogSource.WorkItemTracking, TraceLevel.Verbose, "Base WI Snapshot - Field [{0}], Value [{1}]", fld.ReferenceName, fld.Value);
                    m_baseWiSnapShot.Add(fld.ReferenceName, fld.Value);
                }
            }

            m_baseWiSnapShot.Add(VSTSConstants.CreatedDateFieldRefName, VSTSConstants.CurrentDate);
            m_baseWiSnapShot.Add(VSTSConstants.CreatedByFieldRefName, "Converter");

            m_MigStatusField = m_wi.Fields[m_migrationStatusFieldName];
            VSTSConstants.MigrationStatusField = m_MigStatusField.ReferenceName;

            // initialize web service URI's
            WSHelper.SetupProxy(conn.Tfs.Name);
        }
Пример #4
0
 internal WorkItemType(Tfs.WorkItemType type)
     : base(
         type?.Name,
         type?.Description,
         new Lazy <IFieldDefinitionCollection>(() => ExceptionHandlingDynamicProxyFactory.Create <IFieldDefinitionCollection>(new FieldDefinitionCollection(type?.FieldDefinitions))),
         () => ExceptionHandlingDynamicProxyFactory.Create <IWorkItem>(new WorkItem(type?.NewWorkItem()))
         )
 {
     if (type == null)
     {
         throw new ArgumentNullException(nameof(type));
     }
 }
Пример #5
0
        private List <State> GetStates(Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemType workItemType)
        {
            string.Format("Getting TFS States for work item type '{0}'", workItemType.Name).Debug();
            var states = new SortedList <string, State>();

            var workItemTypeXml = workItemType.Export(false);
            var transitionsList = workItemTypeXml.GetElementsByTagName("TRANSITIONS");
            var transitions     = transitionsList[0];

            foreach (XmlNode transition in transitions)
            {
                if (transition.Attributes == null)
                {
                    continue;
                }

                if (transition.Attributes["to"] != null)
                {
                    var toState = transition.Attributes["to"].Value;
                    if (!string.IsNullOrEmpty(toState) && !states.ContainsKey(toState))
                    {
                        states.Add(toState, new State(toState));
                    }
                }

                if (transition.Attributes["from"] != null)
                {
                    var fromState = transition.Attributes["from"].Value;
                    if (!string.IsNullOrEmpty(fromState) && !states.ContainsKey(fromState))
                    {
                        states.Add(fromState, new State(fromState));
                    }
                }
            }

            return(states.Values.ToList());
        }
Пример #6
0
 public WorkItem(WorkItemType workItemType)
 {
     this.workItemType = workItemType;
 }
Пример #7
0
 internal WorkItemTypeProxy(Tfs.WorkItemType type)
 {
     _type = type;
 }
Пример #8
0
        public override void SetUp()
        {
            base.SetUp();

            _featureType = Project.WorkItemTypes.Cast<WorkItemType>().First(_ => _.Name == "Feature");
        }
Пример #9
0
        /// <summary>
        /// Creates a new <see cref="WorkItem"/> from a <see cref="WorkItemSummary"/> instance, populating its core fields with 
        /// the data from the <see cref="WorkItemSummary"/> object.
        /// </summary>
        protected virtual WorkItem CreateWorkItem(WorkItemType type, WorkItemSummary summary)
        {
            WorkItem item = new WorkItem(type);

            summary.CreatedBy = UserContext.Current.Name;
            summary.AssignedTo = UserContext.Current.Name;
            summary.Fields = item.Fields;
            summary.IsNew = true;

            // Default area + iteration
            summary.AreaPath = UserContext.Current.Settings.AreaPath;
            summary.IterationPath = UserContext.Current.Settings.IterationPath;

            summary.PopulateAllowedValues(item);
            summary.State = summary.ValidStates[0];
            summary.Reason = summary.ValidReasons[0];

            return item;
        }
Пример #10
0
 public WorkItem(WorkItemType workItemType)
 {
     this.workItemType = workItemType;
 }
Пример #11
0
 public WorkItemTypeWrapper(WorkItemType type)
 {
     this.type = type;
 }
Пример #12
0
        WorkItemCollection ITFS.GetWorkItems(string projectname, string iterationPath, string subPath,
		                                     WorkItemType workitemtype, int forSpecificBacklogItemId)
        {
            var completeiterationpath = string.Concat(projectname, "\\", iterationPath, "\\", subPath);
            if (forSpecificBacklogItemId < 0)
            {
                return
                    store.Query(
                        string.Format(
                            "SELECT * FROM WorkItems WHERE [System.TeamProject] = '{0}' AND [System.IterationPath]='{1}' AND  [System.WorkItemType] = '{2}'",
                            projectname, completeiterationpath, workitemtype.Name));
            }

            return
                store.Query(
                    string.Format(
                        "SELECT * FROM WorkItems WHERE [System.TeamProject] = '{0}' AND [System.IterationPath]='{1}' AND  [System.WorkItemType] = '{2}' AND [System.BacklogWorkItemId] = '{3}'",
                        projectname, completeiterationpath, workitemtype.Name, forSpecificBacklogItemId));
        }
 public static void OpenWorkItem(int id, WorkItemType workItemType, bool useProvisionalTab)
 {
     OpenWorkItemMethodByWorkItemIdAndType.Value.Invoke(null, new object[] { id, workItemType, useProvisionalTab });
 }