示例#1
0
        public void Connect()
        {
            Yaz.ZOOM_connection_connect(_zoomConnection, _host, _port);
            int errorCode = Yaz.ZOOM_connection_errcode(_zoomConnection);

            CheckErrorCodeAndThrow(errorCode);
            _connected = true;
        }
示例#2
0
 public IScanTerm this[uint index]
 {
     get
     {
         int    occ, length;
         string term = Yaz.ZOOM_scanset_term(_scanSet, index, out occ, out length);
         return(new ScanTerm(term, occ));
     }
 }
示例#3
0
 void IDisposable.Dispose()
 {
     if (IntPtr.Zero != _package)
     {
         Yaz.ZOOM_package_destroy(_package);
         _connection = null;
         _package    = IntPtr.Zero;
     }
 }
示例#4
0
 public void Dispose()
 {
     if (!_disposed)
     {
         Yaz.ZOOM_scanset_destroy(_scanSet);
         _connection = null;
         _scanSet    = IntPtr.Zero;
         _disposed   = true;
     }
 }
示例#5
0
        public void Dispose()
        {
            if (!_disposed)
            {
                Yaz.ZOOM_connection_destroy(_zoomConnection);

                //Yaz.yaz_log(Yaz.LogLevel.LOG, "Connection Disposed");
                _zoomConnection = IntPtr.Zero;
                _disposed       = true;
            }
        }
示例#6
0
 internal ResultSet(IntPtr resultSet, Connection connection)
 {
     _connection = connection;
     _resultSet  = resultSet;
     _size       = Yaz.ZOOM_resultset_size(_resultSet);
     if (0 == _size)
     {
         Console.Out.WriteLine("Yaz.ZOOM_resultset_size zero");
     }
     _records = new Record[_size];
     //Yaz.yaz_log(Yaz.LogLevel.LOG, "ResultSet Created");
 }
示例#7
0
        public string this[string key]
        {
            get
            {
                return(Yaz.ZOOM_package_option_get(_package, key));
            }

            set
            {
                Yaz.ZOOM_package_option_set(_package, key, value);
            }
        }
示例#8
0
        public string this[string key]
        {
            get
            {
                return(Yaz.ZOOM_options_get(_zoomOptions, key));
            }

            set
            {
                Yaz.ZOOM_options_set(_zoomOptions, key, value);
            }
        }
示例#9
0
 IRecord IResultSet.this[uint index]
 {
     get
     {
         if (_records[index] == null)
         {
             IntPtr record = Yaz.ZOOM_resultset_record(_resultSet, index);
             _records[index] = new Record(record, this);
         }
         return(_records[index]);
     }
 }
        //internal IntPtr CreateResultSet()
        //{
        //	return Yaz.ZOOM_resultset_create(_resultset);
        //}

        public string this[string key]
        {
            get
            {
                return(Yaz.ZOOM_resultset_option_get(_resultSet, key));
            }

            set
            {
                Yaz.ZOOM_resultset_option_set(_resultSet, key, value);
            }
        }
示例#11
0
        public Connection(string host, int port)
        {
            _host = host;
            _port = port;

            _options        = new ConnectionOptionsCollection();
            _zoomConnection = Yaz.ZOOM_connection_create(_options._zoomOptions);

            int errorCode = Yaz.ZOOM_connection_errcode(_zoomConnection);

            CheckErrorCodeAndThrow(errorCode);
            //Yaz.yaz_log(Yaz.LogLevel.LOG, "Connection Created");
        }
示例#12
0
        public IPackage Package(string type)
        {
            EnsureConnected();
            Package pack = null;

            IntPtr options = Yaz.ZOOM_options_create();

            IntPtr yazPackage
                = Yaz.ZOOM_connection_package(_zoomConnection,
                                              options);

            pack = new Package(yazPackage, this, type);
            return(pack);
        }
示例#13
0
        /*
         *  public IResultSet Search(ICQLQuery query)
         *  {
         *          EnsureConnected();
         *          IntPtr yazQuery = Yaz.ZOOM_query_create();
         *          Yaz.ZOOM_query_cql(yazQuery, query.QueryString);
         *
         *          IntPtr yazResultSet = Yaz.ZOOM_connection_search(_zoomConnection, yazQuery);
         *
         *          int errorCode = Yaz.ZOOM_connection_errcode(_zoomConnection);
         *          if (errorCode != Yaz.ZOOM_ERROR_NONE)
         *          {
         *                  Yaz.ZOOM_resultset_destroy(yazResultSet);
         *          }
         *          Yaz.ZOOM_query_destroy(yazQuery);
         *          yazQuery = IntPtr.Zero;
         *          CheckErrorCodeAndThrow(errorCode);
         *
         *          ResultSet resultSet = new ResultSet(yazResultSet, this);
         *          return resultSet;
         *  }
         *
         *  public IResultSet Search(IPrefixQuery query)
         *  {
         *          EnsureConnected();
         *          IntPtr yazQuery = Yaz.ZOOM_query_create();
         *
         *          Yaz.ZOOM_query_prefix(yazQuery, query.QueryString);
         *
         *          IntPtr yazResultSet = Yaz.ZOOM_connection_search(_zoomConnection, yazQuery);
         *
         *          int errorCode = Yaz.ZOOM_connection_errcode(_zoomConnection);
         *          if (errorCode != Yaz.ZOOM_ERROR_NONE)
         *          {
         *                  Yaz.ZOOM_resultset_destroy(yazResultSet);
         *          }
         *          Yaz.ZOOM_query_destroy(yazQuery);
         *          yazQuery = IntPtr.Zero;
         *          CheckErrorCodeAndThrow(errorCode);
         *
         *          ResultSet resultSet = new ResultSet(yazResultSet, this);
         *          return resultSet;
         *  }
         *
         */
        public IScanSet Scan(IPrefixQuery query)
        {
            EnsureConnected();
            IntPtr yazScanSet = Yaz.ZOOM_connection_scan(_zoomConnection, query.QueryString);

            int errorCode = Yaz.ZOOM_connection_errcode(_zoomConnection);

            if (errorCode != Yaz.ZOOM_ERROR_NONE)
            {
                Yaz.ZOOM_scanset_destroy(yazScanSet);
            }
            CheckErrorCodeAndThrow(errorCode);

            ScanSet scanSet = new ScanSet(yazScanSet, this);

            return(scanSet);
        }
示例#14
0
        void IDisposable.Dispose()
        {
            //Console.Out.WriteLine("IDisposable.Dispose {0} {1}",
            //                       this, this.GetHashCode());

            if (!_disposed)
            {
                foreach (Record record in _records)
                {
                    if (record != null)
                    {
                        record.Dispose();
                    }
                }
                Yaz.ZOOM_resultset_destroy(_resultSet);
                //Yaz.yaz_log(Yaz.LogLevel.LOG, "ResultSet Disposed");
                _connection = null;
                _resultSet  = IntPtr.Zero;
                _disposed   = true;
            }
        }
示例#15
0
        private void CheckErrorCodeAndThrow(int errorCode)
        {
            string message;

            switch (errorCode)
            {
            case Yaz.ZOOM_ERROR_NONE:
                break;

            case Yaz.ZOOM_ERROR_CONNECT:
                message = string.Format("Connection could not be made to {0}:{1}", _host, _port);
                throw new ConnectionUnavailableException(message);

            case Yaz.ZOOM_ERROR_INVALID_QUERY:
                message = string.Format("The query requested is not valid or not supported");
                throw new InvalidQueryException(message);

            case Yaz.ZOOM_ERROR_INIT:
                message = string.Format("Server {0}:{1} rejected our init request", _host, _port);
                throw new InitRejectedException(message);

            case Yaz.ZOOM_ERROR_TIMEOUT:
                message = string.Format("Server {0}:{1} timed out handling our request", _host, _port);
                throw new ConnectionTimeoutException(message);

            case Yaz.ZOOM_ERROR_MEMORY:
            case Yaz.ZOOM_ERROR_ENCODE:
            case Yaz.ZOOM_ERROR_DECODE:
            case Yaz.ZOOM_ERROR_CONNECTION_LOST:
            case Yaz.ZOOM_ERROR_INTERNAL:
            case Yaz.ZOOM_ERROR_UNSUPPORTED_PROTOCOL:
            case Yaz.ZOOM_ERROR_UNSUPPORTED_QUERY:
                message = Yaz.ZOOM_connection_errmsg(_zoomConnection);
                throw new ZoomImplementationException("A fatal error occurred in Yaz: " + errorCode + " - " + message);

            default:
                Bib1Diagnostic code = (Bib1Diagnostic)errorCode;
                throw new Bib1Exception(code, Enum.GetName(typeof(Bib1Diagnostic), code));
            }
        }
示例#16
0
        public IResultSet Search(IQuery query)
        {
            EnsureConnected();
            IntPtr    yazQuery  = Yaz.ZOOM_query_create();
            ResultSet resultSet = null;

            try {
                // branching out to right YAZ-C call
                if (query is ICQLQuery)
                {
                    Yaz.ZOOM_query_cql(yazQuery, query.QueryString);
                }
                else if (query is IPrefixQuery)
                {
                    Yaz.ZOOM_query_prefix(yazQuery, query.QueryString);
                }
                else
                {
                    throw new NotImplementedException();
                }

                IntPtr yazResultSet = Yaz.ZOOM_connection_search(_zoomConnection, yazQuery);
                // error checking C-style
                int errorCode = Yaz.ZOOM_connection_errcode(_zoomConnection);
                if (errorCode != Yaz.ZOOM_ERROR_NONE)
                {
                    Yaz.ZOOM_resultset_destroy(yazResultSet);
                }
                CheckErrorCodeAndThrow(errorCode);

                // everything ok, create result set
                resultSet = new ResultSet(yazResultSet, this);
            }
            finally {
                // deallocate yazQuery also when exceptions
                Yaz.ZOOM_query_destroy(yazQuery);
                yazQuery = IntPtr.Zero;
            }
            return(resultSet);
        }
示例#17
0
 internal ConnectionOptionsCollection()
 {
     _zoomOptions = Yaz.ZOOM_options_create();
 }
示例#18
0
 void IPackage.Send()
 {
     Yaz.ZOOM_package_send(_package, _type);
 }
示例#19
0
 internal IntPtr CreateConnection()
 {
     return(Yaz.ZOOM_connection_create(_zoomOptions));
 }
示例#20
0
 public void Dispose()
 {
     Yaz.ZOOM_options_destroy(_zoomOptions);
     _zoomOptions = IntPtr.Zero;
 }