예제 #1
0
        public IResourceDAO CreateResourceDAO()
        {
            IResourceDAO dao = null;

            if (_DbType == DatabaseType.SqlServer)
            {
                dao = new SqlServer.ResourceDAO();
            }
            else if (_DbType == DatabaseType.MySql)
            {
                dao = new SqlServer.ResourceDAO();
            }
            else if (_DbType == DatabaseType.Oracole)
            {
                dao = new SqlServer.ResourceDAO();
            }
            else if (_DbType == DatabaseType.DB2)
            {
                dao = new SqlServer.ResourceDAO();
            }
            else if (_DbType == DatabaseType.Postgre)
            {
                dao = new SqlServer.ResourceDAO();
            }
            return(dao);
        }
예제 #2
0
 /// <summary>
 /// 获取用户权限
 /// </summary>
 /// <param name="user">需要获取权限用户</param>
 /// <returns></returns>
 public List <Resource> GetUserResource(User user)
 {
     using (IDbConnection conn = DAOFactory.Instance.OpenConnection())
     {
         IResourceDAO dao = DAOFactory.Instance.CreateResourceDAO();
         return(dao.SelectResource(user.ID, conn));
     }
 }
예제 #3
0
 public List <Resource> GetAllResources()
 {
     using (IDbConnection conn = DAOFactory.Instance.OpenConnection())
     {
         IResourceDAO dao = DAOFactory.Instance.CreateResourceDAO();
         return(dao.SelectAllResource(conn));
     }
 }
예제 #4
0
        public IResourceDAO CreateResourceDAO()
        {
            IResourceDAO dao = null;

            if (_DbType == DatabaseType.SqlServer)
            {
                dao = new SqlServer.ResourceDAO();
            }
            else if (_DbType == DatabaseType.MySQL)
            {
                //dao = new MySQL.EventLogDAO();
            }
            return(dao);
        }
예제 #5
0
 /// <summary>
 /// 初始化所有资源列表
 /// </summary>
 /// <param name="res"></param>
 /// <returns></returns>
 public void InitResources(List <Resource> res)
 {
     using (IDbConnection conn = DAOFactory.Instance.OpenConnection())
     {
         IDbTransaction trans = conn.BeginTransaction();
         try
         {
             IResourceDAO dao = DAOFactory.Instance.CreateResourceDAO();
             foreach (Resource r in res)
             {
                 dao.InsertResource(r, conn, trans);
             }
             trans.Commit();
         }
         catch (Exception)
         {
             trans.Rollback();
             throw;
         }
     }
 }