//WS: added internal IECSchema GetSchemaFromConnection(string fullSchemaName) { ECP.PersistenceService persistenceService = ECP.PersistenceServiceFactory.GetService(); object contextForSchemaLocate = persistenceService.GetSchemaContext(m_Connection); IECSchema schema = ECO.ECObjects.LocateSchema(fullSchemaName, ECOS.SchemaMatchType.LatestCompatible, null, contextForSchemaLocate); return(schema); }
/*-----------------------------------------------------------------------------*/ /// <summary> /// checks the active model /// does simple walk of the dgn file to look for schema that are not managed by the plugin. /// </summary> /// <param name="connection">The connection to the active dgn file.</param> /// <returns>true if a schema is found in model</returns> /*-----------------------------------------------------------------------------*/ public static bool FindEmbededSchemas(ECSR.RepositoryConnection connection, List <string> schemas) { bool bStatus = false; System.Collections.Generic.IList <ECOS.IECSchema> schemaList; schemaList = new System.Collections.Generic.List <ECOS.IECSchema>(); ECPS.PersistenceService pService = ECPS.PersistenceServiceFactory.GetService(); string[] schemaNames = pService.GetSchemaFullNames(connection); object schemaContext = pService.GetSchemaContext(connection); bool bFirstOne = true; if ((schemaNames.Length <= 0) || (schemaNames.Length == 2) && IsOPMBaseSchema(schemaNames)) { CSVReporter.writeLine(strCurrentProjectName, BVSchemaChecker.ComApp.ActiveDesignFile.Name, BVSchemaChecker.ComApp.ActiveModelReference.Name, "", true); return(bStatus); } else { //if the file is openned in OPM then OpenPlant and OpenPlant_3D are available by default. //if OPM host then schemacontext.managed <3 or those not in there are are OP and OP3D bStatus = false; foreach (string fullSchemaName in schemaNames) { ECOS.IECSchema schema = Bentley.ECObjects.ECObjects.LocateSchema( fullSchemaName, ECOS.SchemaMatchType.LatestCompatible, null, schemaContext); BDGNP.PersistenceStrategy pStrategy; pStrategy = BDGNP.DgnECPersistence.GetPersistenceStrategiesForSchema(connection, schema); if (bFirstOne) { bFirstOne = false; if (bUseLogFile) { LogWriter.writeLine( string.Format("FAILED: Processing File: {0} Model: {1}", BVSchemaChecker.ComApp.ActiveDesignFile.FullName, BVSchemaChecker.ComApp.ActiveModelReference.Name), true); } } if ((!IsOnWhiteList(schema.Name)) && (!IsABDBaseSchema(schema.Name)) && (!IsOPMSchema(schema.Name)) && (!IsBRCMSchema(schema.Name))) { if ((s_bIsUSTN) || ((s_bIsOPM) && (((schema.Name.CompareTo("OpenPlant") != 0) && (schema.Name.CompareTo("OpenPlant_3D") != 0))))) { BVSchemaChecker.ComApp.MessageCenter.AddMessage( string.Format("found {0}_{1}_{2}", schema.Name, schema.VersionMajor, schema.VersionMinor), "found " + fullSchemaName, BCOM.MsdMessageCenterPriority.Info, false); bStatus = true; } if (bUseLogFile) { LogWriter.writeLine(string.Format("\t Found Schema {0} in the file", fullSchemaName), false); } //this is a FAILED line if ((s_bIsUSTN) || ((s_bIsOPM) && (((schema.Name.CompareTo("OpenPlant") != 0) && (schema.Name.CompareTo("OpenPlant_3D") != 0))))) { CSVReporter.writeLine(strCurrentProjectName, BVSchemaChecker.ComApp.ActiveDesignFile.Name, BVSchemaChecker.ComApp.ActiveModelReference.Name, fullSchemaName, false); } } if (!IsOnWhiteList(schema.Name) && !IsABDBaseSchema(schema.Name) && !IsOPMSchema(schema.Name) && !IsBRCMSchema(schema.Name)) { schemas.Add(fullSchemaName); } } } return(bStatus); }