Exemplo n.º 1
0
        //
        // Session Hadling (Framework)
        // Within a session all Db state events are not propegated to the clients (Peformance Issue)
        //
        public void SessionStart(object owner)
        {
            if (connectString == null)
                throw new BizDataAccessException("BizDataBaseHandler: Connectstring must be specified properly!");

            if (SESSION_OWNER == null && owner != null)
            {
                if (SESSION != null)
                {
                    throw new BizDataAccessException("Data Access Error", "Trying to start Transaction while one is in progress!");
                }
                SESSION = BizDBSession.Create(connectString);
                SESSION_OWNER = owner;
                DisableDBStateEvents = true;
                try
                {
                    DateTime currentDate;
                    string stmt = "SET DATEFORMAT dmy";
                    ExecuteStmt(stmt);
                }
                catch (BizDataAccessException e)
                {
                    throw new BizDataAccessException("Data Access Error", "Cannot set SET DATEFORMAT dmy!");
                }
            }
        }
Exemplo n.º 2
0
 public void SessionClose(object owner, bool doCommit)
 {
     if (owner != null && SESSION_OWNER == owner)
     {
         if (SESSION == null)
         {
             DisableDBStateEvents = false;
             throw new BizDataAccessException("Data Access Error", "Trying to close Transaction while no one is in progress!");
         }
         try
         {
             if (doCommit)
                 SESSION.Commit();
             else
                 SESSION.Close();
             DisableDBStateEvents = false;
         }
         finally
         {
             SESSION = null;
             SESSION_OWNER = null;
             DisableDBStateEvents = false;
         }
     }
     DisableDBStateEvents = false;
 }
Exemplo n.º 3
0
 public void SessionRollback(object owner)
 {
     if (owner != null && SESSION_OWNER == owner)
     {
         if (SESSION != null)
         {
             try
             {
                 SESSION.Rollback();
                 DisableDBStateEvents = false;
             }
             finally
             {
                 SESSION = null;
                 SESSION_OWNER = null;
                 DisableDBStateEvents = false;
             }
         }
         DisableDBStateEvents = false;
     }
 }
Exemplo n.º 4
0
 public static BizDBSession Create(string connectString)
 {
     BizDBSession newTransaction = new BizDBSession();
     newTransaction.SqlConn = new SqlConnection(connectString);
     newTransaction.SqlConn.Open();
     newTransaction.SqlTrans = newTransaction.SqlConn.BeginTransaction();
     return newTransaction;
 }