Exemplo n.º 1
0
        public void Close()
        {
            DB_CONNECTION_MUTEX.WaitOne();
            Tuple <bool, Mutex, SQLiteConnection> connection = DB_CONNECTIONS[DB_PATH];

            SharedUtils.RetryOnException(() => connection.Item3.Close());
            connection.Item2.Dispose();
            DB_CONNECTIONS.Remove(DB_PATH);
            DB_CONNECTION_MUTEX.ReleaseMutex();
        }
Exemplo n.º 2
0
 public int InsertOrReplace(object obj)
 {
     try
     {
         return(SharedUtils.RetryOnException(() => DB_CONNECTIONS[DB_PATH].Item3.InsertOrReplace(obj)));;
     }
     catch (Exception e)
     {
         Logger.Error("Failed to execute DB insert or replace!", e);
         return(-1);
     }
 }
Exemplo n.º 3
0
 public List <T> ExecuteCommand <T>(bool readOnly, SQLiteCommand cmd) where T : new()
 {
     try
     {
         return(SharedUtils.RetryOnException(() => cmd.ExecuteQuery <T>()));
     }
     catch (Exception e)
     {
         Logger.Error("Failed to execute DB execute command!", e);
         return(new List <T>());
     }
 }
Exemplo n.º 4
0
 public int DeleteAll <T>()
 {
     try
     {
         return(SharedUtils.RetryOnException(() => DB_CONNECTIONS[DB_PATH].Item3.DeleteAll <T>()));
     }
     catch (Exception e)
     {
         Logger.Error("Failed to execute DB delete all!", e);
         return(-1);
     }
 }
Exemplo n.º 5
0
        public void BeginTransaction()
        {
            Tuple <bool, Mutex, SQLiteConnection> connection = DB_CONNECTIONS[DB_PATH];

            connection.Item2.WaitOne();
            if (connection.Item1)
            {
                SharedUtils.RetryOnException(() => connection.Item3.BeginTransaction());
                DB_CONNECTIONS[DB_PATH] = new Tuple <bool, Mutex, SQLiteConnection>(true, connection.Item2, connection.Item3);
            }
            connection.Item2.ReleaseMutex();
        }
Exemplo n.º 6
0
 /// <param name="readOnly">Unused/placeholder!</param>
 public List <T> Query <T>(bool readOnly, string query, params object[] args) where T : new()
 {
     try
     {
         return(SharedUtils.RetryOnException(() => DB_CONNECTIONS[DB_PATH].Item3.Query <T>(query, args)));
     }
     catch (Exception e)
     {
         Logger.Error("Failed to execute DB query!", e);
         return(new List <T>());
     }
 }
Exemplo n.º 7
0
 public int Execute(string query, params object[] args)
 {
     try
     {
         return(SharedUtils.RetryOnException(() => DB_CONNECTIONS[DB_PATH].Item3.Execute(query, args)));
     }
     catch (Exception e)
     {
         Logger.Error("Failed to execute DB execute!", e);
         return(-1);
     }
 }
Exemplo n.º 8
0
 public int InsertAll(IEnumerable <object> objects, bool runInTransaction = true)
 {
     try
     {
         return(SharedUtils.RetryOnException(() => DB_CONNECTIONS[DB_PATH].Item3.InsertAll(objects)));
     }
     catch (Exception e)
     {
         Logger.Error("Failed to execute DB insert all!", e);
         return(-1);
     }
 }
Exemplo n.º 9
0
        //--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\
        #region --Set-, Get- Methods--


        #endregion
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--
        public SQLiteCommand CreateCommand(string cmdText, params object[] args)
        {
            return(SharedUtils.RetryOnException(() => DB_CONNECTIONS[DB_PATH].Item3.CreateCommand(cmdText, args)));
        }
Exemplo n.º 10
0
 public CreateTableResult RecreateTable <T>() where T : new()
 {
     SharedUtils.RetryOnException(() => DB_CONNECTIONS[DB_PATH].Item3.DropTable <T>());
     return(SharedUtils.RetryOnException(() => DB_CONNECTIONS[DB_PATH].Item3.CreateTable <T>()));
 }
Exemplo n.º 11
0
 public int DropTable <T>() where T : new()
 {
     return(SharedUtils.RetryOnException(() => DB_CONNECTIONS[DB_PATH].Item3.DropTable <T>()));
 }