//A0.01 public Boolean createUserFunc(string user_id, string func_code)
        public Boolean createUserFunc(string user_grp, string func_code)  //A).01
        {
            DBConnection_EF conn = null;

            try
            {
                conn = DBConnection_EF.GetContext();
                conn.BeginTransaction();

                UASUFNC userFunc = new UASUFNC();
                //A0.01 userFunc.UserFuncPK.User_ID = user_id.Trim();
                userFunc.USER_GRP  = user_grp.Trim(); //A0.01
                userFunc.FUNC_CODE = func_code.Trim();

                userFuncDao.createUserFunc(conn, userFunc);

                conn.Commit();
            }
            catch (Exception ex)
            {
                //A0.01 Start
                logger.Warn("Insert User Function Failed to UASUFNC [user_grp:{0}][func_code:{1}]",
                            user_grp, func_code, ex);
                //logger.Warn("Insert User Function Failed to UASUFNC [user_id:{0}][func_code:{1}]",
                //    user_id, func_code, ex);
                //A0.01 End
                if (conn != null)
                {
                    try
                    {
                        conn.Rollback();
                    }
                    catch (Exception exception)
                    {
                        logger.Warn("Rollback Failed.", exception);
                    }
                }
                return(false);
            }
            finally
            {
                if (conn != null)
                {
                    try
                    {
                        conn.Close();
                    }
                    catch (Exception exception)
                    {
                        logger.Warn("Close Connection Failed.", exception);
                    }
                }
            }
            return(true);
        }
 public void deleteUserFunc(DBConnection_EF conn, UASUFNC userFunc)
 {
     try
     {
         conn.UASUFNC.Remove(userFunc);
         conn.SaveChanges();
     }
     catch (Exception ex)
     {
         logger.Warn(ex);
         throw;
     }
 }
        public Boolean checkUserAuthority(string user_id, string function_code)
        {
            DBConnection_EF conn   = null;
            Boolean         result = true;

            try
            {
                conn = DBConnection_EF.GetContext();
                conn.BeginTransaction();
                UASUSR loginUser = userDao.getUser(conn, false, user_id);
                if (loginUser == null)
                {
                    result = false;
                }
                else if (loginUser.isPowerUser())
                {
                    result = true;
                }
                else
                {
                    //A0.01 UserFunc userFunc = userFuncDao.getUserFunc(conn, user_id, function_code);
                    UASUFNC userFunc = userFuncDao.getUserFunc(conn, loginUser.USER_GRP, function_code);
                    if (userFunc == null)
                    {
                        result = false;
                    }
                }
                conn.Commit();
            }
            catch (Exception ex)
            {
                logger.Warn("Load User Function Failed from UASUFNC [user_id:{0}]",
                            user_id, ex);
                result = false;
            }
            finally
            {
                if (conn != null)
                {
                    try
                    {
                        conn.Close();
                    }
                    catch (Exception exception)
                    {
                        logger.Warn("Close Connection Failed.", exception);
                    }
                }
            }
            return(result);
        }
        public UASUFNC getUserFunc(DBConnection_EF conn, string user_grp, string function_code)
        {
            UASUFNC rtnObj = null;

            try
            {
                var query = from userFun in conn.UASUFNC
                            where userFun.USER_GRP == user_grp.Trim() &&
                            userFun.FUNC_CODE == function_code.Trim()
                            select userFun;

                rtnObj = query.FirstOrDefault();
            }
            catch (Exception ex)
            {
                logger.Warn(ex);
                throw;
            }
            return(rtnObj);
        }