public User GetUserByUsername(string userName) { string key = string.Format(USER_BY_USERNAME_KEY, userName.Trim().ToLowerInvariant()); return(Cache.Get(key, () => { User user = null; WCFExtension.Using(new PMSServiceClient(), serviceClient => { user = serviceClient.GetUserInfo(userName, SystemCode).ToLocal(); }); return user; })); }
public User ValidateUser(string loginName, string password, out string msg) { if (!string.IsNullOrEmpty(loginName)) { loginName = loginName.Trim(); } msg = string.Empty; string strMsg = string.Empty; try { User result = null; WCFExtension.Using(new PMSServiceClient(), clientService => { UserLoginResponse response = clientService.UserLogin(new UserLoginInfo { UserName = loginName, Password = password.ToMD5(), SystemCode = SystemCode }); if (response.Success) { result = response.UserInfo.ToLocal(); } else { strMsg = response.Message; } }); msg = strMsg; if (result != null) { string key = string.Format(USER_BY_USERNAME_KEY, result.UserUame.Trim().ToLowerInvariant()); Cache.Add(key, result); _permissionService.RefreshSystemPermissionCache(); } return(result); } catch (Exception ex) { throw new Exception("UserService.ValidateUser", ex); } }
public void RefreshSystemPermissionCache() { IList <Permission> lstResult = new List <Permission>(); WCFExtension.Using(new PMSServiceClient(), serviceClient => { PermissionsResponse response = serviceClient.GetPermissionsBySystemCode(SystemCode); if (response.Success) { response.Permissions.Each(p => lstResult.Add(p.ToLocal())); } else { throw new Exception(response.Message); } }); string key = string.Format(PERMISSIONS_BY_SYSTEMCODE_KEY, SystemCode); Cache.Add(key, lstResult); }
public IList <Permission> GetAllPermission() { string key = string.Format(PERMISSIONS_BY_SYSTEMCODE_KEY, SystemCode); return(Cache.Get(key, () => { IList <Permission> lstResult = new List <Permission>(); WCFExtension.Using(new PMSServiceClient(), serviceClient => { PermissionsResponse response = serviceClient.GetPermissionsBySystemCode(SystemCode); if (response.Success) { response.Permissions.Each(p => lstResult.Add(p.ToLocal())); } else { throw new Exception(response.Message); } }); return lstResult; })); }