示例#1
0
 /// <summary>
 /// Copy constructor for creating revisions on the target side.
 /// </summary>
 /// <param name="sourceId">Id of the source work item</param>
 /// <param name="source">Source revision</param>
 internal MigrationRevision(
     string sourceId,
     MigrationRevision source)
 {
     Debug.Assert(source.m_source == null, "Copying an already copied revision!");
     Debug.Assert(source.m_revision >= 0, "Copying an invalid revision!");
     m_revision      = -1;
     m_author        = source.m_author;
     m_utcChangeTime = source.m_utcChangeTime;
     m_fields        = new Collection <MigrationField>();
     m_source        = new Watermark(sourceId, source.m_revision);
 }
示例#2
0
        /// <summary>
        /// Saves revision's fields into the given XML element.
        /// </summary>
        /// <param name="e">Target XML element</param>
        /// <param name="rev">Source revision</param>
        /// <param name="typeName">Work item type name</param>
        /// <param name="setDefaultPaths">Tells to set default area/iteration paths in case they were not specified explicitly</param>
        /// <param name="extraFields">Extra fields to set</param>
        public void SaveRevision(
            XmlElement e,
            MigrationRevision rev,
            string typeName,
            bool setDefaultPaths,
            MigrationField[] extraFields)
        {
            m_rwLock.AcquireReaderLock(-1);
            try
            {
                WorkItemType wit          = m_store.Projects[m_cfg.Project].WorkItemTypes[typeName];
                bool         hasArea      = false;
                bool         hasIteration = false;

                for (int i = 0; i < rev.Fields.Count; i++)
                {
                    MigrationField f = rev.Fields[i];

                    // Note: this cannot throw - we checked presence of each field while populating the revision
                    FieldDefinition fd = wit.FieldDefinitions[f.Name];
                    object          value;

                    if (fd.Id == (int)CoreField.AreaPath)
                    {
                        // Substitute AreaPath with AreaId
                        fd      = wit.FieldDefinitions[CoreField.AreaId];
                        value   = TranslatePath(Node.TreeType.Area, (string)f.Value);
                        hasArea = true;
                    }
                    else if (fd.Id == (int)CoreField.IterationPath)
                    {
                        // Substitute IterationPath with IterationId
                        fd           = wit.FieldDefinitions[CoreField.IterationId];
                        value        = TranslatePath(Node.TreeType.Iteration, (string)f.Value);
                        hasIteration = true;
                    }
                    else
                    {
                        value = f.Value;
                    }

                    AddColumn(e, fd, value);
                }

                if (setDefaultPaths)
                {
                    if (!hasArea)
                    {
                        AddColumn(e, wit.FieldDefinitions[CoreField.AreaId], DefaultAreaId);
                    }
                    if (!hasIteration)
                    {
                        AddColumn(e, wit.FieldDefinitions[CoreField.IterationId], DefaultIterationId);
                    }
                }

                // Process extra fields
                for (int i = 0; i < extraFields.Length; i++)
                {
                    MigrationField f = extraFields[i];
                    AddColumn(e, wit.FieldDefinitions[f.Name], f.Value);
                }

                // Changed By
                AddColumn(e, wit.FieldDefinitions[CoreField.ChangedBy], rev.Author);
            }
            finally
            {
                m_rwLock.ReleaseReaderLock();
            }
        }