コード例 #1
0
ファイル: SdeConnection.cs プロジェクト: jugstalt/gViewGisOS
 public void Close()
 {
     if (_pool == null || _sdeConnection == null)
     {
         return;
     }
     _pool.Free(_sdeConnection);
     _sdeConnection = null;
 }
コード例 #2
0
 private void CloseConnection(SdeConnection sdeConnection)
 {
     sdeConnection.FreeStream();
     if (sdeConnection.SeConnection.handle != 0)
     {
         Wrapper92_64.SE_connection_free(sdeConnection.SeConnection);
         sdeConnection.SeConnection.handle = 0;
     }
 }
コード例 #3
0
ファイル: SdeConnection.cs プロジェクト: jugstalt/gViewGisOS
        public bool Open()
        {
            _pool = Globals.ConnectionManager[_connectionString];
            if (_pool == null)
            {
                return(true);
            }
            _sdeConnection = _pool.Alloc();

            return(_sdeConnection != null);
        }
コード例 #4
0
 public void Free(SdeConnection sdeConnection)
 {
     if (sdeConnection == null)
     {
         return;
     }
     lock (_thisLock)
     {
         if (_usedConnections.IndexOf(sdeConnection) != -1)
         {
             _usedConnections.Remove(sdeConnection);
             _freeConnections.Add(sdeConnection);
             sdeConnection.ResetStream();
             sdeConnection.LastUse = DateTime.Now;
         }
     }
 }
コード例 #5
0
        public SdeConnection Alloc()
        {
            lock (_thisLock)
            {
                // Freie Connection suchen...
                foreach (SdeConnection SeConnection in ListOperations <SdeConnection> .Clone(_freeConnections))
                {
                    if (SeConnection.SeConnection.handle != 0)
                    {
                        _freeConnections.Remove(SeConnection);
                        _usedConnections.Add(SeConnection);
                        return(SeConnection);
                    }
                }

                // Freie Connection suchen, die bereits geschlossen wurde...
                foreach (SdeConnection SeConnection in ListOperations <SdeConnection> .Clone(_freeConnections))
                {
                    if (SeConnection.SeConnection.handle == 0)
                    {
                        if (OpenConnection(SeConnection))
                        {
                            _freeConnections.Remove(SeConnection);
                            _usedConnections.Add(SeConnection);
                            return(SeConnection);
                        }
                    }
                }

                // Neue Connection anlegen
                if (_usedConnections.Count + _freeConnections.Count < _maxConnections)
                {
                    SdeConnection SeConnection = new SdeConnection();
                    if (OpenConnection(SeConnection))
                    {
                        _usedConnections.Add(SeConnection);
                        return(SeConnection);
                    }
                }

                return(null);
            }
        }
コード例 #6
0
        private bool OpenConnection(SdeConnection SdeConnection)
        {
            if (SdeConnection.SeConnection.handle != 0)
            {
                CloseConnection(SdeConnection);
            }

            string server   = ConfigTextStream.ExtractValue(_connectionString, "server");
            string instance = ConfigTextStream.ExtractValue(_connectionString, "instance");
            string database = ConfigTextStream.ExtractValue(_connectionString, "database");
            string username = ConfigTextStream.ExtractValue(_connectionString, "usr");
            string password = ConfigTextStream.ExtractValue(_connectionString, "pwd");

            SE_ERROR_64 error = new SE_ERROR_64();

            try
            {
                if (Wrapper92_64.SE_connection_create(
                        server,
                        instance,
                        database,
                        username,
                        password,
                        ref error,
                        ref SdeConnection.SeConnection) != 0)
                {
                    _errMsg = Wrapper92_64.GetErrorMsg(SdeConnection.SeConnection, error);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                _errMsg = "SDE ERROR: " + ex.Message;
                return(false);
            }

            return(true);
        }