示例#1
0
文件: BaseManager.cs 项目: Bobom/anan
 private void GetPermission()
 {
     AccountManager accMgr = new AccountManager();
     this.Permission = accMgr.GetUserPermission(this.CurrentUser.ID);
 }
示例#2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public Permission GetUserPermission(int userId)
        {
            Permission permission = new Permission();

            AnanEntities db = new AnanEntities();
            try
            {
                Admin_Super ad = (from auser in db.Admin_Super where auser.user_id == userId select auser).FirstOrDefault<Admin_Super>();
                if (ad != null)
                {
                    System.Reflection.FieldInfo[] fields = permission.GetType().GetFields();
                    if (fields != null)
                    {
                        foreach (System.Reflection.FieldInfo field in fields)
                        {
                            field.SetValue(permission, 1);
                        }
                    }
                }
                else
                {
                    //TBD
                }
            }
            catch
            {
            }
            finally
            {
                if (db != null)
                {
                    db.Dispose();
                }
            }

            return permission;
        }