public void UpdateWorkItemLink(
            string sourceWorkItemId,
            string targetWorkItemId,
            int linkTypeId,
            string comment,
            bool isLocked)
        {
            CreateEmptyUpdateDoc();

            XmlElement xwi = UpdateDocument.CreateElement(UpdateWorkItemLinkElem);

            UpdateDocument.AppendChild(xwi);

            xwi.SetAttribute(WorkItemLinkSourceID, sourceWorkItemId);
            xwi.SetAttribute(WorkItemLinkTargetID, targetWorkItemId);
            xwi.SetAttribute(WorkItemLinkType, XmlConvert.ToString(linkTypeId));

            var autoMergeOption = XmlConvert.ToString(false);
            var lockOption      = XmlConvert.ToString(isLocked);

            xwi.SetAttribute(WorkItemLinkAutoMerge, autoMergeOption);

            xwi.SetAttribute(WorkItemLinkComment, comment);
            xwi.SetAttribute(WorkItemLinkLock, lockOption);
        }
Esempio n. 2
0
        internal void DeleteExternalLink(int extId)
        {
            // Hyperlink ot ExternalLink
            XmlElement e = UpdateDocument.CreateElement("RemoveResourceLink");

            e.SetAttribute("ResourceLinkId", XmlConvert.ToString(extId));
            UpdateDocument.FirstChild.AppendChild(e);
        }
        public void RemoveWorkItemLink(
            string sourceWorkItemId,
            string targetWorkItemId,
            int linkTypeId,
            string comment)
        {
            CreateEmptyUpdateDoc();

            XmlElement xwi = UpdateDocument.CreateElement(DeleteWorkItemLinkElem);

            UpdateDocument.AppendChild(xwi);

            xwi.SetAttribute(WorkItemLinkSourceID, sourceWorkItemId);
            xwi.SetAttribute(WorkItemLinkTargetID, targetWorkItemId);
            xwi.SetAttribute(WorkItemLinkType, XmlConvert.ToString(linkTypeId));

            var autoMergeOption = XmlConvert.ToString(true);

            xwi.SetAttribute(WorkItemLinkAutoMerge, autoMergeOption);
        }
        internal void AddFields(
            Hist.MigrationAction action,
            string workItemType,
            string author,
            string changedTime,
            bool insertWorkItem)
        {
            bool        hasArea      = false;
            bool        hasIteration = false;
            XmlDocument desc         = action.RecordDetails.DetailsDocument;

            XmlElement cs = UpdateDocument.CreateElement("Columns");

            UpdateDocument.FirstChild.AppendChild(cs);
            XmlNodeList columns = desc.SelectNodes("/WorkItemChanges/Columns/Column");

            foreach (XmlNode columnData in columns)
            {
                string fieldName          = columnData.Attributes["DisplayName"].Value;
                string fieldReferenceName = columnData.Attributes["ReferenceName"].Value;
                string stringVal          = columnData.FirstChild.InnerText;
                string fieldType          = columnData.Attributes["Type"].Value;

                if (fieldReferenceName.Equals(CoreFieldReferenceNames.AreaPath) ||
                    fieldReferenceName.Equals(CoreFieldReferenceNames.IterationPath))
                {
                    try
                    {
                        GetCSSNodeId(action, workItemType,
                                     ref fieldName, ref fieldReferenceName, ref stringVal, ref hasIteration, ref hasArea);;
                    }
                    catch (Exception ex)
                    {
                        TraceManager.TraceError(ex.ToString());
                        continue;
                    }
                }

                AddColumn(cs, workItemType, fieldName, fieldReferenceName, stringVal);
            }

            if (insertWorkItem)
            {
                if (!hasArea)
                //if (!hasArea && !ByPassrules)
                {
                    AddColumn(cs, workItemType, string.Empty, CoreFieldReferenceNames.AreaId,
                              MigrationWorkItemStore.Core.DefaultAreaId.ToString());
                }
                if (!hasIteration)
                //if (!hasIteration && !ByPassrules)
                {
                    AddColumn(cs, workItemType, string.Empty, CoreFieldReferenceNames.IterationId,
                              MigrationWorkItemStore.Core.DefaultIterationId.ToString());
                }

                AddColumn(cs, workItemType, string.Empty, CoreFieldReferenceNames.WorkItemType, workItemType);
                AddColumn(cs, workItemType, string.Empty, CoreFieldReferenceNames.CreatedDate, string.Empty);
                AddColumn(cs, workItemType, string.Empty, CoreFieldReferenceNames.CreatedBy, author);
                AddColumn(cs, workItemType, string.Empty, CoreFieldReferenceNames.ChangedBy, author);
            }
            else
            {
                AddColumn(cs, workItemType, string.Empty, CoreFieldReferenceNames.ChangedBy, author);
            }
        }