コード例 #1
0
        } // end of Convert()

        private void GenerateLinkTypeMappings()
        {
            Linking linkTypeMappingSettings = new Linking();

            LinkingLinkTypeMapping[] mappings = new LinkingLinkTypeMapping[m_linkTypeMaps.Values.Count];
            m_linkTypeMaps.Values.CopyTo(mappings, 0);
            linkTypeMappingSettings.LinkTypeMappings = mappings;

            string linkTypeMapFile = CQConverterUtil.GetFileNameWithPath(CQConstants.LinkMapFile);

            using (var fStream = new FileStream(linkTypeMapFile, FileMode.Create))
            {
                var serializer = new XmlSerializer(typeof(Linking));
                serializer.Serialize(fStream, linkTypeMappingSettings);
            }
        }
コード例 #2
0
        private void MapLinkTypes(string[] refEntities, string entityToMigrate, OAdEntityDef entityDef)
        {
            List <string> refEntityList = new List <string>(refEntities);

            object[] fieldDefNameObjs = CQWrapper.GetFieldDefNames(entityDef) as object[];

            // add the field reference[list] links
            foreach (object fieldDefNameObj in fieldDefNameObjs)
            {
                string fieldDefName = fieldDefNameObj as string;
                int    fieldDefType = CQWrapper.GetFieldDefType(entityDef, fieldDefName);

                if (fieldDefType == CQConstants.FIELD_REFERENCE)
                {
                    OAdEntityDef childRecordEntityDef     = CQWrapper.GetFieldReferenceEntityDef(entityDef, fieldDefName);
                    string       childRecordEntityDefName = CQWrapper.GetEntityDefName(childRecordEntityDef);

                    if (refEntityList.Contains(childRecordEntityDefName))
                    {
                        var linkTypeMapping = new LinkingLinkTypeMapping();
                        linkTypeMapping.LeftMigrationSourceUniqueId  = "[Please add Left Migration Source Migration Id]";
                        linkTypeMapping.RightMigrationSourceUniqueId = "[Please add Right Migration Source Migration Id]";
                        linkTypeMapping.LeftLinkType = string.Format("ClearQuestAdapter.LinkType.ReferenceFieldRecordLink.{0}.{1}",
                                                                     entityToMigrate, childRecordEntityDef);
                        linkTypeMapping.RightLinkType = "[Please add Right link type reference name]";

                        if (!m_linkTypeMaps.ContainsKey(linkTypeMapping.LeftLinkType))
                        {
                            m_linkTypeMaps.Add(linkTypeMapping.LeftLinkType, linkTypeMapping);
                        }
                    }
                }
                else if (fieldDefType == CQConstants.FIELD_REFERENCE_LIST)
                {
                    OAdEntityDef childRecordEntityDef     = CQWrapper.GetFieldReferenceEntityDef(entityDef, fieldDefName);
                    string       childRecordEntityDefName = CQWrapper.GetEntityDefName(childRecordEntityDef);

                    if (refEntityList.Contains(childRecordEntityDefName))
                    {
                        var linkTypeMapping = new LinkingLinkTypeMapping();
                        linkTypeMapping.LeftMigrationSourceUniqueId  = "[Please add Left Migration Source Migration Id]";
                        linkTypeMapping.RightMigrationSourceUniqueId = "[Please add Right Migration Source Migration Id]";
                        linkTypeMapping.LeftLinkType = string.Format("ClearQuestAdapter.LinkType.ReferenceListFieldRecordLink.{0}.{1}",
                                                                     entityToMigrate, childRecordEntityDef);
                        linkTypeMapping.RightLinkType = "[Please add Right link type reference name]";

                        if (!m_linkTypeMaps.ContainsKey(linkTypeMapping.LeftLinkType))
                        {
                            m_linkTypeMaps.Add(linkTypeMapping.LeftLinkType, linkTypeMapping);
                        }
                    }
                }
            }

            // add the duplicate links
            var duplinkTypeMapping = new LinkingLinkTypeMapping();

            duplinkTypeMapping.LeftMigrationSourceUniqueId  = "[Please add Left Migration Source Migration Id]";
            duplinkTypeMapping.RightMigrationSourceUniqueId = "[Please add Right Migration Source Migration Id]";
            duplinkTypeMapping.LeftLinkType  = "ClearQuestAdapter.LinkType.Duplicate";
            duplinkTypeMapping.RightLinkType = "[Please add Right link type reference name]";
            if (!m_linkTypeMaps.ContainsKey(duplinkTypeMapping.LeftLinkType))
            {
                m_linkTypeMaps.Add(duplinkTypeMapping.LeftLinkType, duplinkTypeMapping);
            }
        }