Пример #1
0
        /// <summary>
        /// Parametrized Constructor for instantiating schema object
        /// No other CTors are provided as these values are required to start with
        /// </summary>
        /// <param name="xmlFile">Name of the target schema xml file</param>
        /// <param name="cqSess">Handle to valid CQ session</param>
        /// <param name="entityDef">Handle to valid CQ Entity Definition</param>
        public WITDXMLGenerator(string schemaXmlFile,
                                string fieldMapXmlFile,
                                Session cqSess,
                                OAdEntityDef entityDef,
                                VSTSConnection vstsConn)
        {
            Logger.EnteredMethod(LogSource.CQ, schemaXmlFile, fieldMapXmlFile,
                                 cqSess, entityDef);

            // create instance of WITDFieldMap to store field mappings
            witdFieldMap = new WITFieldMappings();

            // create instance of WITDSchema to store WITD schema
            witdSchema = new WITDSchema();
            witdSchema.SetApplication(Application.Workitemtypeeditor);

            // set the VSTS connection handle for finding the unique fields in VSTS system
            WITDSchema.VstsConn = vstsConn;

            // store file name to be used later to generate xml
            schemaXMLFileName   = schemaXmlFile;
            fieldMapXMLFileName = fieldMapXmlFile;

            cqEntityDef = entityDef;
            cqSession   = cqSess;
            cqEntity    = CQWrapper.BuildEntity(cqSession, CQWrapper.GetEntityDefName(cqEntityDef));

            Logger.ExitingMethod(LogSource.CQ);
        }
Пример #2
0
        } // end of FindAllowedEntitiesToMigrate

        /// <summary>
        /// Validate all the Entity Types on Clear Quest
        /// Followed by the respective Field Mappings
        /// </summary>
        /// <returns>true if successful, false in case of some error</returns>
        private void ValidateSchemaMapOnCQ()
        {
            Session cqSession = m_cqConnection.GetUserSession();

            object[] cqEntities = (object[])CQWrapper.GetSubmitEntityDefNames(cqSession);
            Display.NewLine();

            foreach (SchemaMapping schMap in m_convParams.SchemaMaps)
            {
                string infoMsg = UtilityMethods.Format(CQResource.SchemaValidation, schMap.WITDFile);
                Logger.Write(LogSource.CQ, TraceLevel.Verbose, infoMsg);

                bool entityFoundInCQ = false;
                foreach (object obj in cqEntities)
                {
                    if (schMap.entity.Equals(obj.ToString(), StringComparison.OrdinalIgnoreCase))
                    {
                        entityFoundInCQ = true;
                        break;
                    }
                }

                if (!entityFoundInCQ)
                {
                    try
                    {
                        Display.StartProgressDisplay(infoMsg);
                        string errMsg = UtilityMethods.Format(CQResource.CQ_ENTITY_NOT_EXIST,
                                                              CurConResource.Analysis,
                                                              schMap.entity,
                                                              Path.GetFileName(m_convParams.SchemaMapFile));

                        PostMigrationReport.WriteIssue(null, null, RepStatus.Failed,
                                                       ReportIssueType.Critical, String.Empty,
                                                       schMap.entity, IssueGroup.Witd, errMsg);

                        throw new ConverterException(errMsg);
                    }
                    finally
                    {
                        Display.StopProgressDisplay();
                    }
                }
                else
                {
                    OAdEntityDef currEntityDef = CQWrapper.GetEntityDef(cqSession, schMap.entity);
                    // can validate the fields at CQ also, for this entity
                    string fieldMapFile = schMap.fieldMapFile;
                    if (fieldMapFile != null)
                    {
                        UtilityMethods.ValidateFile(fieldMapFile, schMap.schemaMapFile);
                        FieldMaps fldMaps = WITFieldMappings.CreateFromFile(fieldMapFile);
                        ValidateFieldMapOnCQ(currEntityDef, fldMaps.FieldMap, fieldMapFile);

                        // add the predefined/internal field maps
                        FieldMapsFieldMap[] internalFldMaps = GetInternalFieldMaps(fldMaps);

                        fldMaps.FieldMap.CopyTo(internalFldMaps, 0);
                        fldMaps.FieldMap = internalFldMaps;

                        // add the loaded field map in Schema Field Map for future use
                        m_schemaFieldMap.Add(schMap.entity, fldMaps);
                    }
                }
            } // end of foreach SchemaMappings
        }     // end of ValidateSchemaMapOnCQ