Ejemplo n.º 1
0
        private void AddReflectedWorkItemId(WITDUpdateCommands witdUpdateCommands)
        {
            // <CustomSetting SettingKey="ContextSyncOp" SettingValue="Op1::InsertNode" />
            // <CustomSetting SettingKey="Op1::SearchPath" SettingValue="//FIELDS" />
            // <CustomSetting SettingKey="Op1::NewNodeContent" SettingValue="content_xml_goes_here" />
            // <CustomSetting SettingKey="Op1::DuplicateSearchPath" SettingValue="//FIELDS/FIELD[@refname='TfsMigrationTool.ReflectedWorkItemId']" />

            SyncUpdateCmdBase reflectedIdInsertCmd = new InsertNodeCmd();

            reflectedIdInsertCmd.AddParam(WITDUpdateCommands.ParamSearchPath, "//FIELDS");
            reflectedIdInsertCmd.AddParam(WITDUpdateCommands.ParamNewNodeContent, ReflectedIdFieldDef);
            reflectedIdInsertCmd.AddParam(WITDUpdateCommands.ParamDuplicateSearchPath, ReflectedIdSearchPath);
            witdUpdateCommands.AddCommand(ReflectedIdInsertCmdName, reflectedIdInsertCmd);
        }
Ejemplo n.º 2
0
        private void SyncWorkItemTypeDefinition(XmlDocument xmlDocument, WitMetadataSyncPolicy witMetadataSyncPolicy)
        {
            if (witMetadataSyncPolicy != WitMetadataSyncPolicy.TakeTheirs)
            {
                throw new NotImplementedException();
            }

            var customSettings = m_configurationService.MigrationSource.CustomSettings.CustomSetting;
            WITDUpdateCommands witdUpdateCommands = new WITDUpdateCommands(customSettings);

            AddReflectedWorkItemId(witdUpdateCommands);

            byte[] newDocHash  = new byte[0];
            bool   hashMatched = m_md5Utility.CompareDocHash(xmlDocument, m_witdDocMD5, ref newDocHash);

            if (!hashMatched)
            {
                UpdateSchemaNamespace(xmlDocument);

                XmlNode workItemTypes = xmlDocument.SelectSingleNode("WorkItemTypes");

                XmlNode workItemTypeDef = workItemTypes.FirstChild;
                while (null != workItemTypeDef)
                {
                    XmlDocument witdDoc = new XmlDocument();
                    XmlNode     root    = witdDoc.ImportNode(workItemTypeDef, true);
                    witdDoc.AppendChild(root);

                    IWITDSyncer witdSyncer = new TfsWITDSyncer(witdDoc, m_migrationSource.WorkItemStore);
                    witdUpdateCommands.Process(witdSyncer);
                    witdSyncer.Sync();

                    workItemTypeDef = workItemTypeDef.NextSibling;
                }

                m_md5Utility.UpdateDocHash(ref m_witdDocMD5, newDocHash);
            }
        }