An alternative to UBB.threads
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using MySql.Data.MySqlClient;
|
|
|
|
|
using FLocal.Core;
|
|
|
|
|
|
|
|
|
|
namespace FLocal.MySQLConnector {
|
|
|
|
|
class Transaction : Core.DB.Transaction {
|
|
|
|
|
|
|
|
|
|
internal MySqlConnection sqlconnection;
|
|
|
|
|
internal MySqlTransaction sqltransaction;
|
|
|
|
|
|
|
|
|
|
public bool finalizedImpl {
|
|
|
|
|
get;
|
|
|
|
|
private set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Transaction(Connection connection, System.Data.IsolationLevel iso) : base() {
|
|
|
|
|
this.sqlconnection = connection.createConnection();
|
|
|
|
|
try {
|
|
|
|
|
this.sqltransaction = this.sqlconnection.BeginTransaction(iso);
|
|
|
|
|
} catch(Exception e) {
|
|
|
|
|
this.close();
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void do_Commit() {
|
|
|
|
|
lock(this) {
|
|
|
|
|
if(this.finalizedImpl) throw new CriticalException("Already finalized");
|
|
|
|
|
this.sqltransaction.Commit();
|
|
|
|
|
this.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void do_Rollback() {
|
|
|
|
|
lock(this) {
|
|
|
|
|
if(this.finalizedImpl) throw new CriticalException("Already finalized");
|
|
|
|
|
this.sqltransaction.Rollback();
|
|
|
|
|
this.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void close() {
|
|
|
|
|
this.sqlconnection.Close();
|
|
|
|
|
this.sqlconnection.Dispose();
|
|
|
|
|
this.finalizedImpl = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|