public object CheckConnectionValid(DataSourceConnDTO dto) { dto.TypeCode = dto.TypeCode.ToUpper(); EnumDataSourceType @enum = EnumUtil.GetEnumObjByName <EnumDataSourceType>(dto.TypeCode); IDMEDataSourceFactory factory = null; IDMEDataSource dataSource = null; ValidResult result = new ValidResult(); try { switch (@enum) { case EnumDataSourceType.UNKNOWN: break; case EnumDataSourceType.SHAPEFILE: break; case EnumDataSourceType.COVERAGE: break; case EnumDataSourceType.PERSONAL_GEODATABASE: break; case EnumDataSourceType.FILE_GEODATABASE: break; case EnumDataSourceType.TIN: break; case EnumDataSourceType.CAD: break; case EnumDataSourceType.ORACLE: case EnumDataSourceType.ENTERPRISE_GEODATABASE: factory = new DMEOracleFactory(); dataSource = factory.OpenFromConnectionStr(dto.Connection, true); result.IsValid = dataSource.ValidConnection(); break; case EnumDataSourceType.MONGODB: factory = new DMEMongoFactory(); dataSource = factory.OpenFromConnectionStr(dto.Connection, true); result.IsValid = dataSource.ValidConnection(); break; default: break; } } catch (Exception ex) { LOG.Error(ex, ex.Message); result.Message = ex.Message; result.Ex = ex; } return(result); }
public object GetDatasourceConnMeta(string typeCode) { typeCode = typeCode.ToUpper(); EnumDataSourceType @enum = EnumUtil.GetEnumObjByName <EnumDataSourceType>(typeCode); IDMEDataSourceFactory factory = null; IDMEDataSource dataSource = null; object meta = ""; switch (@enum) { case EnumDataSourceType.ORACLE: factory = new DMEOracleFactory(); dataSource = factory.Open(null, false); meta = dataSource.ConnectionMeta; break; default: meta = ""; break; } return(meta); }