コード例 #1
0
        private void UpdateConversionHistory(
            MigrationAction action,
            Watermark targetItemWatermark,
            ConversionResult changeResult)
        {
            TargetWorkItemId = int.Parse(targetItemWatermark.Id);
            string sourceWorkItemRevision = GetSourceWorkItemRevision(action);

            // update work item mapping cache
            if (!m_mappedWorkItem.ContainsKey(action.SourceWorkItemId))
            {
                m_mappedWorkItem.Add(action.SourceWorkItemId, TargetWorkItemId);
            }

            // insert conversion history for pushing to db
            changeResult.ItemConversionHistory.Add(
                new ItemConversionHistory(action.SourceWorkItemId, sourceWorkItemRevision, targetItemWatermark.Id,
                                          targetItemWatermark.Revision.ToString()));
            changeResult.ChangeId = targetItemWatermark.Id + ":" + targetItemWatermark.Revision;
        }
コード例 #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="core">Shared TFS core</param>
        /// <param name="item">TFS work item</param>
        /// <param name="fieldForm">Tells what field name should be used</param>
        public TfsMigrationWorkItem(
            TfsCore core,
            WorkItem item)
        {
            m_core      = core;
            m_watermark = new Watermark(
                item.Id.ToString(),
                item.Rev);
            m_workItemType = (string)item.Fields[CoreField.WorkItemType].Value;
            if ((int)item[CoreField.AttachedFileCount] > 0)
            {
                m_flags |= MigrationWorkItemData.Attachments;
            }
            int linkCount = (int)item[CoreField.ExternalLinkCount] + (int)item[CoreField.RelatedLinkCount] + (int)item[CoreField.HyperLinkCount];

            if (linkCount > 0)
            {
                m_flags |= MigrationWorkItemData.Links;
            }
            m_workItem = item;
        }
コード例 #3
0
        /// <summary>
        /// Submits items from the given range.
        /// </summary>
        /// <param name="firstItem">First item in the range</param>
        /// <param name="lastItem">Last item in the range</param>
        private void Submit(
            int firstItem,
            int lastItem)
        {
            Debug.Assert(firstItem <= lastItem, "Invalid range!");
            XmlDocument doc            = new XmlDocument();
            XmlElement  packageElement = doc.CreateElement("Package");

            packageElement.SetAttribute("Product", m_core.WorkItemTrackingUrl);
            doc.AppendChild(packageElement);

            for (int i = firstItem; i <= lastItem; i++)
            {
                XmlDocument u = m_updates[i];
                SubmitData(doc, u);
            }

            // Submit the update package
            XmlElement outElement   = null;
            Exception  resException = null;

            try
            {
                MetadataTableHaveEntry[] metadataHave = new MetadataTableHaveEntry[0];
                string           dbStamp;
                IMetadataRowSets rowsets;

                m_svc.Update(
                    m_svc.NewRequestId(),
                    packageElement,
                    out outElement,
                    metadataHave,
                    out dbStamp,
                    out rowsets);
            }
            catch (Exception e)
            {
                resException = e;
            }

            if (resException != null)
            {
                //$TODO_VNEXT: extract more information from SOAP exceptions
                if (firstItem == lastItem)
                {
                    m_results[firstItem] = new UpdateResult(resException);
                }
                else
                {
                    int mid = firstItem + (lastItem - firstItem) / 2;
                    Submit(firstItem, mid);
                    Submit(mid + 1, lastItem);
                }
            }
            else
            {
                // Process results
                foreach (XmlElement resElement in outElement.ChildNodes)
                {
                    int revision = 0;
                    if (resElement.Name == "InsertWorkItem" || resElement.Name == "UpdateWorkItem")
                    {
                        revision = XmlConvert.ToInt32(resElement.GetAttribute("Revision"));
                    }

                    Watermark wm = new Watermark(resElement.GetAttribute("ID"), revision);
                    m_results[firstItem++] = new UpdateResult(wm);
                }
            }
        }