/// <summary> /// 登录系统 /// </summary> private async void Login() { try { if (string.IsNullOrWhiteSpace(UserName) || string.IsNullOrWhiteSpace(PassWord)) { this.Report = "请输入用户名密码!"; return; } UpdateDialog(true, "验证登陆中..."); var br = await userService.LoginAsync(UserName, PassWord); if (br == null || !br.success) { this.Report = br == null ? "远程服务器无法连接!" : br.message; return; } UpdateDialog(true, "加载首页..."); Messenger.Default.Send(true, "NavigationHome"); } catch (Exception ex) { } finally { UpdateDialog(false); } }
/// <summary> /// 登录系统 /// </summary> private async void Login() { try { if (DialogIsOpen) { return; } if (string.IsNullOrWhiteSpace(UserName) || string.IsNullOrWhiteSpace(PassWord)) { SnackBar("请输入用户名密码!"); return; } DialogIsOpen = true; await Task.Delay(200); var r = await service.LoginAsync(UserName, PassWord); if (r == null || !r.success) { SnackBar(r == null ? "远程服务器无法连接!" : r.message); return; } var authResult = await service.GetAuthListAsync(); if (authResult == null || !authResult.success) { SnackBar("获取模块清单异常!"); return; } #region 关联用户信息/缓存 Contract.Account = r.dynamicObj.User.Account; Contract.UserName = r.dynamicObj.User.UserName; Contract.IsAdmin = r.dynamicObj.User.FlagAdmin == 1; Contract.Menus = r.dynamicObj.Menus; //用户包含的权限信息 Contract.AuthItems = authResult.dynamicObj; #endregion //这行代码会发射到首页,Center中会定义所有的Messenger Messenger.Default.Send(true, "NavigationPage"); } catch (Exception ex) { SnackBar(ex.Message); Log.Error(ex.Message); } finally { DialogIsOpen = false; } }
/// <summary> /// 登录系统 /// </summary> private async void Login() { try { if (string.IsNullOrWhiteSpace(UserName) || string.IsNullOrWhiteSpace(PassWord)) { this.Report = "请输入用户名密码!"; return; } UpdateDialog(true, "验证登陆中..."); var r = await service.LoginAsync(UserName, PassWord); if (r == null || !r.success) { this.Report = r == null ? "远程服务器无法连接!" : r.message; return; } UpdateDialog(true, "获取模块清单..."); var authResult = await service.GetAuthListAsync(); if (authResult == null || !authResult.success) { this.Report = r == null ? "获取模块清单异常!" : r.message; return; } #region 关联用户信息/缓存 Loginer.Current.Account = r.dynamicObj.User.Account; Loginer.Current.UserName = r.dynamicObj.User.UserName; Loginer.Current.IsAdmin = r.dynamicObj.User.FlagAdmin == 1; Loginer.Current.Menus = r.dynamicObj.Menus; //用户包含的权限信息 Loginer.Current.AuthItems = authResult.dynamicObj; #endregion UpdateDialog(true, "加载首页..."); Messenger.Default.Send(true, "NavigationPage"); } catch (Exception ex) { Log.Error(ex.Message); } finally { UpdateDialog(false); } }