Пример #1
0
        private ServerToolkit GetServerToolkit(MapInfo.Data.NamedConnectionInfo nci)
        {
            switch (nci.ConnectionMethod)
            {
            case ConnectionMethod.Odbc:
                return(ServerToolkit.Odbc);

            case ConnectionMethod.OracleOci:
                return(ServerToolkit.Oci);

            default:
                throw new ArgumentException("ConnectionMethod should only be Odbc or OracleOci!", "nci");
            }
        }
Пример #2
0
        private MapInfo.Data.Table OpenNativeTable(MapInfo.Data.NamedConnectionInfo nci, string tableName)
        {
            string fileName = tableName;
            string alias    = tableName + "_" + nci.Name;

            MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.GetTable(alias);
            if (table == null)
            {
                if (tableName.ToLower().IndexOf(".tab") <= 0)
                {
                    fileName = tableName + ".tab";
                }
                table = MapInfo.Engine.Session.Current.Catalog.OpenTable(nci.Name, alias, fileName);
            }
            return(table);
        }
Пример #3
0
 private MapInfo.Data.Table OpenTable(string connectionName, string tableName)
 {
     MapInfo.Data.NamedConnectionInfo nci = MapInfo.Engine.Session.Current.Catalog.NamedConnections.Get(connectionName);
     if (nci == null)
     {
         return(null);
     }
     if (nci.DBType.ToLower().Equals("file"))
     {
         return(OpenNativeTable(nci, tableName));
     }
     else
     {
         return(OpenDataBaseTable(nci, tableName));
     }
 }
Пример #4
0
        private MapInfo.Data.Table OpenDataBaseTable(MapInfo.Data.NamedConnectionInfo nci, string dbTableName)
        {
            String tableAlias = dbTableName + "_" + nci.Name.Replace(" ", "_").Replace(".", "_");

            MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.GetTable(tableAlias);
            // we need to create a new table if there is no table in the catalog.
            if (table == null)
            {
                TableInfoServer tis = new TableInfoServer("tableInfoServer_" + dbTableName);
                tis.ConnectString = nci.ConnectionString;
                tis.Query         = "select * from " + dbTableName;
                tis.Toolkit       = this.GetServerToolkit(nci);
                tis.CacheSettings = new CacheParameters(CacheOption.On);
                tis.Alias         = tableAlias;
                table             = MapInfo.Engine.Session.Current.Catalog.OpenTable(nci.Name, tis);
            }
            return(table);
        }