diff --git a/ButcherFactory.BO/Utils/AppContext.cs b/ButcherFactory.BO/Utils/AppContext.cs index 8e7f8d0..eb490c4 100644 --- a/ButcherFactory.BO/Utils/AppContext.cs +++ b/ButcherFactory.BO/Utils/AppContext.cs @@ -21,7 +21,6 @@ namespace ButcherFactory.BO.Utils _user = LoginUtil.InitUserFromLocal(); return _user; } - set { _user = value; } } } diff --git a/ButcherFactory.BO/Utils/LoginUtil.cs b/ButcherFactory.BO/Utils/LoginUtil.cs index 859f992..b4aa3fb 100644 --- a/ButcherFactory.BO/Utils/LoginUtil.cs +++ b/ButcherFactory.BO/Utils/LoginUtil.cs @@ -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(wpfUserMethod);