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); }
/// <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)); } }
public List <Resource> GetAllResources() { using (IDbConnection conn = DAOFactory.Instance.OpenConnection()) { IResourceDAO dao = DAOFactory.Instance.CreateResourceDAO(); return(dao.SelectAllResource(conn)); } }
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); }
/// <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; } } }