Browse Source

支持多种Role

master
yibo 7 years ago
parent
commit
c3ab050323
2 changed files with 18 additions and 4 deletions
  1. +0
    -1
      ButcherFactory.BO/Utils/AppContext.cs
  2. +18
    -3
      ButcherFactory.BO/Utils/LoginUtil.cs

+ 0
- 1
ButcherFactory.BO/Utils/AppContext.cs View File

@ -21,7 +21,6 @@ namespace ButcherFactory.BO.Utils
_user = LoginUtil.InitUserFromLocal();
return _user;
}
set { _user = value; }
}
}


+ 18
- 3
ButcherFactory.BO/Utils/LoginUtil.cs View File

@ -81,10 +81,25 @@ namespace ButcherFactory.BO.Utils
public static void Login(string userName, string pwd)
{
RpcFacade.Login(userName, pwd);
AppContext.User = new WpfUser();
AppContext.User.Login = true;
if (userName == AppContext.User.Name)
{
var oldRole = AppContext.User.RoleList.ToList();
AppContext.User.RoleList.Clear();
foreach (var item in oldRole)
{
if (UserIsInRole(item))
AppContext.User.RoleList.Add(item);
}
AppContext.User.Role = string.Join(" ", AppContext.User.RoleList);
}
else
{
AppContext.User.RoleList.Clear();
AppContext.User.Role = null;
}
AppContext.User.Name = userName;
FillUserEmpInfo(userName);
FillUserID(userName);
AppContext.User.Password = EncodePwd(pwd);
using (var session = Dmo.NewSession(AppContext.ConnectInfo.SqlConnection))
{
@ -96,7 +111,7 @@ namespace ButcherFactory.BO.Utils
}
}
static void FillUserEmpInfo(string name)
static void FillUserID(string name)
{
const string wpfUserMethod = "/MainSystem/B3ClientService/Rpcs/UserInfoRpc/GetUserID";
AppContext.User.ID = RpcFacade.Call<long>(wpfUserMethod);


Loading…
Cancel
Save