Beispiel #1
0
 /// <summary>
 /// Checks the authentication.
 /// </summary>
 /// <param name="name">模块名称.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 public static bool CheckAuth(string name)
 {
     try
     {
         if (ConstDef.curUser == null)
         {
             return(false);
         }
         Authority auth = Find(string.Format("name = '{0}'", name));
         if (auth == null)
         {
             return(false);
         }
         if (ConstDef.curUser.RoleId > auth.Role.Id)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         LogMan.Log2File(null, ex);
         return(false);
     }
 }
Beispiel #2
0
 /// <summary>
 /// 初始化数据库.
 /// </summary>
 public void InitDatabase()
 {
     try
     {
         SQLiteConnection.CreateFile(dbName);
         this.Open("Data Source=" + dbName + ";Version=3;");
         this.InitTables();
         this.InitRoleData();
         this.InitUserData();
         this.InitAuthData();
     }
     catch (Exception ex)
     {
         LogMan.Log2File(null, ex);
     }
 }
Beispiel #3
0
        /// <summary>
        /// 执行sql事务
        /// </summary>
        /// <param name="sql">The SQL.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public bool ExecuteNonQuery(string sql)
        {
            SQLiteCommand     sQLiteCommand     = new SQLiteCommand(sql, this.connection);
            SQLiteTransaction sQLiteTransaction = this.connection.BeginTransaction();

            try
            {
                sQLiteCommand.ExecuteNonQuery();
                sQLiteTransaction.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                sQLiteTransaction.Rollback();
                LogMan.Log2File(null, ex);
                return(false);
            }
            finally
            {
                this.Close();
            }
        }