diff --git a/Common/Common.csproj b/Common/Common.csproj index b276843..af20f39 100644 --- a/Common/Common.csproj +++ b/Common/Common.csproj @@ -53,6 +53,10 @@ {6F532626-E9F8-498E-9683-1538E7CD62CB} Core + + {E38DE5B1-F9C2-43BA-A5DF-0743ABD4DFC7} + MySQLConnector + + \ No newline at end of file diff --git a/MySQLConnector/ParamsHolder.cs b/MySQLConnector/ParamsHolder.cs new file mode 100644 index 0000000..08c9511 --- /dev/null +++ b/MySQLConnector/ParamsHolder.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace FLocal.MySQLConnector { + class ParamsHolder { + + public Dictionary data = new Dictionary(); + + private int index = 1; + + public string Add(string value) { + lock(this) { + string name = "param" + index; + this.data.Add(name, value); + this.index++; + return name; + } + } + + } +} diff --git a/MySQLConnector/Properties/AssemblyInfo.cs b/MySQLConnector/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e67fbbe --- /dev/null +++ b/MySQLConnector/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("MySQLConnector")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("MySQLConnector")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b1f8928c-947d-45e1-a6e8-e758c1985a5c")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MySQLConnector/Transaction.cs b/MySQLConnector/Transaction.cs new file mode 100644 index 0000000..0fe0c45 --- /dev/null +++ b/MySQLConnector/Transaction.cs @@ -0,0 +1,52 @@ +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; + } + + } +}