Ejemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        public MonetDbDataReader(MapiHdl queryHandle, MonetDbConnection connection)
        {
            _queryHandle = queryHandle;
            _connHandle = connection.GetConnectionHandle();

            Init();
        }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="connectionHandle"></param>
 /// <exception cref="MonetDbException"></exception>
 public static void DieConnectionError(MapiConnection connectionHandle)
 {
     if (connectionHandle.Ptr == IntPtr.Zero ||
         MapiLib.MapiError(connectionHandle).Ptr != IntPtr.Zero)
     {
         throw new MonetDbException(MapiLib.MapiErrorString(connectionHandle));
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="connectionHandle"></param>
 /// <exception cref="MonetDbException"></exception>
 public static void DieConnectionError(MapiConnection connectionHandle)
 {
     if (connectionHandle.Ptr == IntPtr.Zero ||
         MapiLib.MapiError(connectionHandle).Ptr != IntPtr.Zero)
     {
         throw new MonetDbException(MapiLib.MapiErrorString(connectionHandle));
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="query"></param>
        /// <returns></returns>
        /// <exception cref="MonetDbException"></exception>
        public static MapiHdl GetQueryHandle(MapiConnection connection, string query)
        {
            var queryHandle = MapiLib.MapiQuery(connection, query);

            DieQueryError(connection, queryHandle);

            return(queryHandle);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Return a list of accessible tables fields. This can also be obtained by
        /// inspecting the field descriptor returned by mapi_fetch_field().
        /// </summary>
        /// <param name="mid"></param>
        /// <returns></returns>
        public static string[] MapiFields(MapiConnection mid)
        {
            var pptr     = CMapiLib.mapi_fields(mid.Ptr);
            var ptr      = Marshal.ReadIntPtr(pptr);
            var exploded = new List <string>();

            do
            {
                exploded.Add(Marshal.PtrToStringAnsi(ptr));
                pptr = new IntPtr((int)pptr + IntPtr.Size);
                ptr  = Marshal.ReadIntPtr(pptr);
            } while (ptr != IntPtr.Zero);
            return(exploded.ToArray());
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Send the Command to the database server represented by mid. 
 /// This function returns a query handle with which the results of the 
 /// query can be retrieved. The handle should be closed with mapi_close_handle(). 
 /// The command response is buffered for consumption, c.f. mapi\_fetch\_row().
 /// </summary>
 /// <param name="mapi"></param>
 /// <param name="command"></param>
 /// <returns></returns>
 public static MapiHdl MapiQuery(MapiConnection mapi, string command)
 {
     return new MapiHdl(CMapiLib.mapi_query(mapi.Ptr, command));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Similar to mapi_query_array(), except that the response of the
 /// server is not analyzed, but shipped immediately to the file indicated.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="command"></param>
 /// <param name="args"></param>
 /// <param name="fs"></param>
 /// <returns></returns>
 public static MapiHdl MapiQuickQueryArray(MapiConnection mid, string command, string[] args, FileStream fs)
 {
     return new MapiHdl(CMapiLib.mapi_quick_query_array(mid.Ptr, command, args, fs.SafeFileHandle));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Return the current value of the trace flag.
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static int MapiGetTrace(MapiConnection mid)
 {
     return CMapiLib.mapi_get_trace(mid.Ptr);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Test availability of the server. Returns zero upon success.
 /// </summary>
 /// <param name="mapi"></param>
 /// <returns></returns>
 public static MapiMsg MapiPing(MapiConnection mapi)
 {
     return new MapiMsg(CMapiLib.mapi_ping(mapi.Ptr));
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Close the current channel (if still open) and re-establish a fresh connection.
 /// This will remove all global session variables.
 /// </summary>
 /// <param name="mapi"></param>
 /// <returns></returns>
 public static MapiMsg MapiReconnect(MapiConnection mapi)
 {
     return(new MapiMsg(CMapiLib.mapi_reconnect(mapi.Ptr)));
 }
Ejemplo n.º 11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static string MapiGetDbName(MapiConnection mid)
 {
     return Marshal.PtrToStringAnsi(CMapiLib.mapi_get_dbname(mid.Ptr));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// A limited number of tuples are pre-fetched after each execute().
 /// If maxrows is negative, all rows will be fetched before the application is
 /// permitted to continue. Once the cache is filled, a number of tuples are shuffled to
 /// make room for new ones, but taking into account non-read elements.
 /// Filling the cache quicker than reading leads to an error.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="maxrows"></param>
 /// <returns></returns>
 public static MapiMsg MapiCacheLimit(MapiConnection mid, int maxrows)
 {
     return(new MapiMsg(CMapiLib.mapi_cache_limit(mid.Ptr, maxrows)));
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Send the Command to the database server replacing the placeholders (?) by the string arguments presented.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="command"></param>
 /// <param name="args"></param>
 /// <returns></returns>
 public static MapiHdl MapiQueryArray(MapiConnection mid, string command, string[] args)
 {
     return(new MapiHdl(CMapiLib.mapi_query_array(mid.Ptr, command, args)));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Write the error message obtained from mserver to a file.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="fs"></param>
 /// <returns></returns>
 public static MapiMsg MapiExplain(MapiConnection mid, FileStream fs)
 {
     return(new MapiMsg(CMapiLib.mapi_explain(mid.Ptr, fs.SafeFileHandle)));
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Set the autocommit flag (default is on).
 /// This only has an effect when the language is SQL.
 /// In that case, the server commits after each statement sent to the server.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="autocommit"></param>
 /// <returns></returns>
 public static MapiMsg MapiSetAutocommit(MapiConnection mid, int autocommit)
 {
     return(new MapiMsg(CMapiLib.mapi_setAutocommit(mid.Ptr, autocommit)));
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Return a pointer to the last error message.
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static string MapiErrorString(MapiConnection mid)
 {
     return(Marshal.PtrToStringAnsi(CMapiLib.mapi_error_str(mid.Ptr)));
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Return the last error code or 0 if there is no error.
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static MapiMsg MapiError(MapiConnection mid)
 {
     return(new MapiMsg(CMapiLib.mapi_error(mid.Ptr)));
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Move the query to a newly allocated query handle (which is returned).
 /// Possibly interact with the back-end to prepare the query for execution.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="command"></param>
 /// <returns></returns>
 public static MapiHdl MapiPrepare(MapiConnection mid, string command)
 {
     return(new MapiHdl(CMapiLib.mapi_prepare(mid.Ptr, command)));
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Send the request for processing and fetch a limited number of tuples
 /// (determined by the window size) to assess any erroneous situation.
 /// Thereafter, prepare for continual reading of tuples from the stream,
 /// until an error occurs. Each time a tuple arrives, the cache is shifted one.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="command"></param>
 /// <param name="windowSize"></param>
 /// <returns></returns>
 public static MapiHdl MapiStreamQuery(MapiConnection mid, string command, int windowSize)
 {
     return(new MapiHdl(CMapiLib.mapi_stream_query(mid.Ptr, command, windowSize)));
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Set the trace flag to monitor interaction with the server.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="flag"></param>
 /// <returns></returns>
 public static MapiMsg MapiTrace(MapiConnection mid, int flag)
 {
     return(new MapiMsg(CMapiLib.mapi_trace(mid.Ptr, flag)));
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Log the interaction between the client and server for offline inspection. 
 /// Beware that the log file overwrites any previous log. It is not intended for recovery.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="filename"></param>
 /// <returns></returns>
 public static MapiMsg MapiTraceLog(MapiConnection mid, string filename)
 {
     return new MapiMsg(CMapiLib.mapi_trace_log(mid.Ptr, filename));
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Return the current value of the trace flag.
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static int MapiGetTrace(MapiConnection mid)
 {
     return(CMapiLib.mapi_get_trace(mid.Ptr));
 }
Ejemplo n.º 23
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="query"></param>
        /// <returns></returns>
        /// <exception cref="MonetDbException"></exception>
        public static MapiHdl GetQueryHandle(MapiConnection connection, string query)
        {
            var queryHandle = MapiLib.MapiQuery(connection, query);

            DieQueryError(connection, queryHandle);

            return queryHandle;
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Log the interaction between the client and server for offline inspection.
 /// Beware that the log file overwrites any previous log. It is not intended for recovery.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="filename"></param>
 /// <returns></returns>
 public static MapiMsg MapiTraceLog(MapiConnection mid, string filename)
 {
     return(new MapiMsg(CMapiLib.mapi_trace_log(mid.Ptr, filename)));
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Write the error message obtained from mserver to a file.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="fs"></param>
 /// <returns></returns>
 public static MapiMsg MapiExplain(MapiConnection mid, FileStream fs)
 {
     return new MapiMsg(CMapiLib.mapi_explain(mid.Ptr, fs.SafeFileHandle));
 }
Ejemplo n.º 26
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="fnr"></param>
 /// <returns></returns>
 public static int MapiGetlen(MapiConnection mid, int fnr)
 {
     return(CMapiLib.mapi_get_len(mid.Ptr, fnr));
 }
Ejemplo n.º 27
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="fnr"></param>
 /// <returns></returns>
 public static int MapiGetlen(MapiConnection mid, int fnr)
 {
     return CMapiLib.mapi_get_len(mid.Ptr, fnr);
 }
Ejemplo n.º 28
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static string MapiGetDbName(MapiConnection mid)
 {
     return(Marshal.PtrToStringAnsi(CMapiLib.mapi_get_dbname(mid.Ptr)));
 }
Ejemplo n.º 29
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static string MapiGetUser(MapiConnection mid)
 {
     return Marshal.PtrToStringAnsi(CMapiLib.mapi_get_user(mid.Ptr));
 }
Ejemplo n.º 30
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static string MapiGetMotd(MapiConnection mid)
 {
     return(Marshal.PtrToStringAnsi(CMapiLib.mapi_get_motd(mid.Ptr)));
 }
Ejemplo n.º 31
0
 /// <summary>
 /// Move the query to a newly allocated query handle (which is returned). 
 /// Possibly interact with the back-end to prepare the query for execution.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="command"></param>
 /// <returns></returns>
 public static MapiHdl MapiPrepare(MapiConnection mid, string command)
 {
     return new MapiHdl(CMapiLib.mapi_prepare(mid.Ptr, command));
 }
Ejemplo n.º 32
0
 /// <summary>
 /// Set the autocommit flag (default is on). 
 /// This only has an effect when the language is SQL. 
 /// In that case, the server commits after each statement sent to the server.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="autocommit"></param>
 /// <returns></returns>
 public static MapiMsg MapiSetAutocommit(MapiConnection mid, int autocommit)
 {
     return new MapiMsg(CMapiLib.mapi_setAutocommit(mid.Ptr, autocommit));
 }
Ejemplo n.º 33
0
 /// <summary>
 /// Send the Command to the database server replacing the placeholders (?) by the string arguments presented.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="command"></param>
 /// <param name="args"></param>
 /// <returns></returns>
 public static MapiHdl MapiQueryArray(MapiConnection mid, string command, string[] args)
 {
     return new MapiHdl(CMapiLib.mapi_query_array(mid.Ptr, command, args));
 }
Ejemplo n.º 34
0
 /// <summary>
 /// Return a list of accessible database tables.
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static string[] MapiTables(MapiConnection mid)
 {
     var pptr = CMapiLib.mapi_tables(mid.Ptr);
     var ptr = Marshal.ReadIntPtr(pptr);
     var exploded = new List<string>();
     do
     {
         exploded.Add(Marshal.PtrToStringAnsi(ptr));
         pptr = new IntPtr((int)pptr + IntPtr.Size);
         ptr = Marshal.ReadIntPtr(pptr);
     } while (ptr != IntPtr.Zero);
     return exploded.ToArray();
 }
Ejemplo n.º 35
0
 /// <summary>
 /// Close the current channel (if still open) and re-establish a fresh connection. 
 /// This will remove all global session variables.
 /// </summary>
 /// <param name="mapi"></param>
 /// <returns></returns>
 public static MapiMsg MapiReconnect(MapiConnection mapi)
 {
     return new MapiMsg(CMapiLib.mapi_reconnect(mapi.Ptr));
 }
Ejemplo n.º 36
0
 /// <summary>
 /// Similar to mapi_query_array(), except that the response of the
 /// server is not analyzed, but shipped immediately to the file indicated.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="command"></param>
 /// <param name="args"></param>
 /// <param name="fs"></param>
 /// <returns></returns>
 public static MapiHdl MapiQuickQueryArray(MapiConnection mid, string command, string[] args, FileStream fs)
 {
     return(new MapiHdl(CMapiLib.mapi_quick_query_array(mid.Ptr, command, args, fs.SafeFileHandle)));
 }
Ejemplo n.º 37
0
 /// <summary>
 /// Send the request for processing and fetch a limited number of tuples 
 /// (determined by the window size) to assess any erroneous situation. 
 /// Thereafter, prepare for continual reading of tuples from the stream, 
 /// until an error occurs. Each time a tuple arrives, the cache is shifted one.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="command"></param>
 /// <param name="windowSize"></param>
 /// <returns></returns>
 public static MapiHdl MapiStreamQuery(MapiConnection mid, string command, int windowSize)
 {
     return new MapiHdl(CMapiLib.mapi_stream_query(mid.Ptr, command, windowSize));
 }
Ejemplo n.º 38
0
 /// <summary>
 /// Test availability of the server. Returns zero upon success.
 /// </summary>
 /// <param name="mapi"></param>
 /// <returns></returns>
 public static MapiMsg MapiPing(MapiConnection mapi)
 {
     return(new MapiMsg(CMapiLib.mapi_ping(mapi.Ptr)));
 }
Ejemplo n.º 39
0
 /// <summary>
 /// Set the trace flag to monitor interaction with the server.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="flag"></param>
 /// <returns></returns>
 public static MapiMsg MapiTrace(MapiConnection mid, int flag)
 {
     return new MapiMsg(CMapiLib.mapi_trace(mid.Ptr, flag));
 }
Ejemplo n.º 40
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="connection"></param>
 public static void CloseConnectionHandle(MapiConnection connection)
 {
     MapiLib.MapiDisconnect(connection);
     MapiLib.MapiDestroy(connection);
 }
Ejemplo n.º 41
0
 /// <summary>
 /// A limited number of tuples are pre-fetched after each execute(). 
 /// If maxrows is negative, all rows will be fetched before the application is 
 /// permitted to continue. Once the cache is filled, a number of tuples are shuffled to 
 /// make room for new ones, but taking into account non-read elements. 
 /// Filling the cache quicker than reading leads to an error.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="maxrows"></param>
 /// <returns></returns>
 public static MapiMsg MapiCacheLimit(MapiConnection mid, int maxrows)
 {
     return new MapiMsg(CMapiLib.mapi_cache_limit(mid.Ptr, maxrows));
 }
Ejemplo n.º 42
0
 /// <summary>
 /// Send the Command to the database server represented by mid.
 /// This function returns a query handle with which the results of the
 /// query can be retrieved. The handle should be closed with mapi_close_handle().
 /// The command response is buffered for consumption, c.f. mapi\_fetch\_row().
 /// </summary>
 /// <param name="mapi"></param>
 /// <param name="command"></param>
 /// <returns></returns>
 public static MapiHdl MapiQuery(MapiConnection mapi, string command)
 {
     return(new MapiHdl(CMapiLib.mapi_query(mapi.Ptr, command)));
 }
Ejemplo n.º 43
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="connection"></param>
 public static void CloseConnectionHandle(MapiConnection connection)
 {
     MapiLib.MapiDisconnect(connection);
     MapiLib.MapiDestroy(connection);
 }
Ejemplo n.º 44
0
 /// <summary>
 /// Terminate the session described by  mid if not already done so, and free all resources. 
 /// The handle cannot be used anymore.
 /// </summary>
 /// <param name="mapi"></param>
 /// <returns></returns>
 public static MapiMsg MapiDestroy(MapiConnection mapi)
 {
     return new MapiMsg(CMapiLib.mapi_destroy(mapi.Ptr));
 }
Ejemplo n.º 45
0
 /// <summary>
 /// Return the last error code or 0 if there is no error.
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static MapiMsg MapiError(MapiConnection mid)
 {
     return new MapiMsg(CMapiLib.mapi_error(mid.Ptr));
 }
Ejemplo n.º 46
0
 /// <summary>
 /// Return a pointer to the last error message.
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static string MapiErrorString(MapiConnection mid)
 {
     return Marshal.PtrToStringAnsi(CMapiLib.mapi_error_str(mid.Ptr));
 }
Ejemplo n.º 47
0
        /// <summary>
        /// 
        /// </summary>
        public void Open()
        {
            if (State == ConnectionState.Open)
                throw new MonetDbException("Connection already open.");

            _connection = MapiFactory.GetConnectionhandle(_database.ConnectionInfo);

            State = ConnectionState.Open;
        }
Ejemplo n.º 48
0
 /// <summary>
 /// Terminate the session described by  mid if not already done so, and free all resources.
 /// The handle cannot be used anymore.
 /// </summary>
 /// <param name="mapi"></param>
 /// <returns></returns>
 public static MapiMsg MapiDestroy(MapiConnection mapi)
 {
     return(new MapiMsg(CMapiLib.mapi_destroy(mapi.Ptr)));
 }