public void BeginTransaction(TransactionParameterBuffer tpb) { lock (stateSyncRoot) { if (this.state != TransactionState.NoTransaction) { throw GetNoValidTransactionException(); } try { GenericResponse response; lock (this.database.SyncObject) { this.database.Write(IscCodes.op_transaction); this.database.Write(this.database.Handle); this.database.WriteBuffer(tpb.ToArray()); this.database.Flush(); response = this.database.ReadGenericResponse(); this.database.TransactionCount++; } this.handle = response.ObjectHandle; this.state = TransactionState.Active; } catch (IOException) { throw new IscException(IscCodes.isc_net_read_err); } } }
public void BeginTransaction(TransactionParameterBuffer tpb) { lock (_stateSyncRoot) { if (_state != TransactionState.NoTransaction) { throw GetNoValidTransactionException(); } try { GenericResponse response; lock (_database.SyncObject) { _database.XdrStream.Write(IscCodes.op_transaction); _database.XdrStream.Write(_database.Handle); _database.XdrStream.WriteBuffer(tpb.ToArray()); _database.XdrStream.Flush(); response = _database.ReadGenericResponse(); _database.TransactionCount++; } _handle = response.ObjectHandle; _state = TransactionState.Active; } catch (IOException ex) { throw IscException.ForErrorCode(IscCodes.isc_net_read_err, ex); } } }
public void BeginTransaction(TransactionParameterBuffer tpb) { lock (this.db) { if (this.state != TransactionState.NoTransaction) { throw new IscException( IscCodes.isc_arg_gds, IscCodes.isc_tra_state, this.handle, "no valid"); } IscTeb teb = new IscTeb(); IntPtr tebData = IntPtr.Zero; try { this.state = TransactionState.TrasactionStarting; // Set db handle teb.dbb_ptr = Marshal.AllocHGlobal(4); Marshal.WriteInt32(teb.dbb_ptr, this.db.Handle); // Set tpb length teb.tpb_len = tpb.Length; // Set TPB data teb.tpb_ptr = Marshal.AllocHGlobal(tpb.Length); Marshal.Copy(tpb.ToArray(), 0, teb.tpb_ptr, tpb.Length); // Alloc memory for the IscTeb structure int size = Marshal.SizeOf(typeof(IscTeb)); tebData = Marshal.AllocHGlobal(size); Marshal.StructureToPtr(teb, tebData, true); int[] statusVector = FesConnection.GetNewStatusVector(); int trHandle = this.handle; FbClient.isc_start_multiple( statusVector, ref trHandle, 1, tebData); this.handle = trHandle; // Parse status vector this.db.ParseStatusVector(statusVector); // Update transaction state this.state = TransactionState.TransactionStarted; // Update transaction count this.db.TransactionCount++; } catch (Exception) { throw; } finally { // Free memory if (teb.dbb_ptr != IntPtr.Zero) { Marshal.FreeHGlobal(teb.dbb_ptr); } if (teb.tpb_ptr != IntPtr.Zero) { Marshal.FreeHGlobal(teb.tpb_ptr); } if (tebData != IntPtr.Zero) { Marshal.DestroyStructure(tebData, typeof(IscTeb)); Marshal.FreeHGlobal(tebData); } } } }
public void BeginTransaction(TransactionParameterBuffer tpb) { if (this.state != TransactionState.NoTransaction) { throw new IscException(IscCodes.isc_arg_gds, IscCodes.isc_tra_state, this.handle, "no valid"); } lock (this.database.SyncObject) { try { this.database.Write(IscCodes.op_transaction); this.database.Write(this.database.Handle); this.database.WriteBuffer(tpb.ToArray()); this.database.Flush(); GenericResponse response = this.database.ReadGenericResponse(); this.handle = response.ObjectHandle; this.state = TransactionState.Active; this.database.TransactionCount++; } catch (IOException) { throw new IscException(IscCodes.isc_net_read_err); } } }
public void BeginTransaction(TransactionParameterBuffer tpb) { if (_state != TransactionState.NoTransaction) { throw IscException.ForTypeErrorCodeIntParamStrParam(IscCodes.isc_arg_gds, IscCodes.isc_tra_state, _handle, "no valid"); } lock (_db) { IscTeb teb = new IscTeb(); IntPtr tebData = IntPtr.Zero; try { // Clear the status vector ClearStatusVector(); // Set db handle teb.dbb_ptr = Marshal.AllocHGlobal(4); Marshal.WriteInt32(teb.dbb_ptr, _db.Handle); // Set tpb length teb.tpb_len = tpb.Length; // Set TPB data teb.tpb_ptr = Marshal.AllocHGlobal(tpb.Length); Marshal.Copy(tpb.ToArray(), 0, teb.tpb_ptr, tpb.Length); // Alloc memory for the IscTeb structure int size = Marshal.SizeOf(typeof(IscTeb)); tebData = Marshal.AllocHGlobal(size); Marshal.StructureToPtr(teb, tebData, true); int trHandle = _handle; _db.FbClient.isc_start_multiple( _statusVector, ref trHandle, 1, tebData); _handle = trHandle; // Parse status vector _db.ParseStatusVector(_statusVector); // Update transaction state _state = TransactionState.Active; // Update transaction count _db.TransactionCount++; } catch { throw; } finally { // Free memory if (teb.dbb_ptr != IntPtr.Zero) { Marshal.FreeHGlobal(teb.dbb_ptr); } if (teb.tpb_ptr != IntPtr.Zero) { Marshal.FreeHGlobal(teb.tpb_ptr); } if (tebData != IntPtr.Zero) { Marshal.DestroyStructure(tebData, typeof(IscTeb)); Marshal.FreeHGlobal(tebData); } } } }
public void BeginTransaction(TransactionParameterBuffer tpb) { lock (this.db) { if (this.state != TransactionState.NoTransaction) { throw new IscException( IscCodes.isc_arg_gds, IscCodes.isc_tra_state, this.handle, "no valid"); } this.state = TransactionState.TrasactionStarting; try { this.db.Send.Write(IscCodes.op_transaction); this.db.Send.Write(this.db.Handle); this.db.Send.WriteBuffer(tpb.ToArray()); this.db.Send.Flush(); this.handle = db.ReadGenericResponse().ObjectHandle; this.state = TransactionState.TransactionStarted; this.db.TransactionCount++; } catch (IOException) { throw new IscException(IscCodes.isc_net_read_err); } } }