Exemplo n.º 1
0
        public bool DropTable()
        {
            var sql = new System.Text.StringBuilder();

            sql.Append("DROP TALBE IF EXISTS AppConfig");
            try
            {
                DbConnector.ExecuteNonQuery(sql.ToString());
                Logger.Debug("Succecc Drop Table AppConfig");
                return(true);
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
                return(false);
            }
        }
Exemplo n.º 2
0
        public bool CreateTable()
        {
            var sql = new System.Text.StringBuilder();

            sql.Append("CREATE TABLE IF NOT EXISTS " + TableName + "( Id INTEGER NOT NULL, Key TEXT NOT NULL, Value TEXT NOT NULL, Description TEXT, PRIMARY KEY(Id) ) ");
            try
            {
                DbConnector.ExecuteNonQuery(sql.ToString());
                Logger.Debug("Succecc Create Table " + TableName);
                return(true);
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
                return(false);
            }
        }
Exemplo n.º 3
0
        public bool Truncate()
        {
            var  sql = new System.Text.StringBuilder();
            bool ret;

            sql.Append("DELETE FROM " + TableName);
            try
            {
                DbConnector.ExecuteNonQuery(sql.ToString());
                ret = true;
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message + " " + sql.ToString());
                throw new Exception(ex.Message);
            }
            return(ret);
        }
Exemplo n.º 4
0
        public bool Delete(AppConfig entity)
        {
            var  sql = new System.Text.StringBuilder();
            bool ret;

            sql.Append("DELETE FROM " + TableName + " WHERE Id = @Id ");
            try
            {
                DbConnector.ExecuteNonQuery(sql.ToString(), entity.ToDictionary());
                Logger.Debug(sql.ToString() + " " + entity.ToStringData());
                ret = true;
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message + " " + sql.ToString() + " " + entity.ToStringData());
                throw new Exception(ex.Message);
            }
            return(ret);
        }
Exemplo n.º 5
0
        public bool Insert(AppConfig entity)
        {
            var  sql = new System.Text.StringBuilder();
            bool ret;

            sql.Append("INSERT INTO " + TableName + " (Key, Value, Description) VALUES ( @Key, @Value, @Description ) ");
            try
            {
                DbConnector.ExecuteNonQuery(sql.ToString(), entity.ToDictionary());
                Logger.Debug(sql.ToString() + " " + entity.ToStringData());
                ret = true;
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message + " " + sql.ToString() + " " + entity.ToStringData());
                throw new Exception(ex.Message);
            }
            return(ret);
        }
Exemplo n.º 6
0
        public bool Update(AppConfig entity)
        {
            var  sql = new System.Text.StringBuilder();
            bool ret;

            sql.Append("UPDATE " + TableName);
            sql.Append(" SET Key = @Key, Value = @Value, Description = @Description ");
            sql.Append(" WHERE Id = @Id ");
            try
            {
                DbConnector.ExecuteNonQuery(sql.ToString(), entity.ToDictionary());
                Logger.Debug(sql.ToString() + " " + entity.ToStringData());
                ret = true;
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message + " " + sql.ToString() + " " + entity.ToStringData());
                throw new Exception(ex.Message);
            }
            return(ret);
        }