async private void LoginAll_OnClick(object sender, RoutedEventArgs e) { this.progressRing.IsActive = true; var api = new MemberService(); int count = 0; var repository = new RepositoryAsync(); var users = await repository.User.Where(u=>u.UserId==null).ToListAsync(); foreach (var item in users) { var sessionInfo = await api.Login(item.Account, "123456",item.DeviceId); if (sessionInfo != null) { item.UserId = sessionInfo.userid; item.SessionId = sessionInfo.sid; count++; await repository.UpdateUserAsync(item); } } this.progressRing.IsActive = false; await new MessageDialog($"{count}个用户成功登录").ShowAsync(); }
async private void Login_OnClick(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(txtName.Text) || string.IsNullOrEmpty(txtPwd.Password)) { await new MessageDialog("用户名、密码不能为空").ShowAsync(); return; } var api = new MemberService(); var result = await api.Login(txtName.Text, txtPwd.Password,Guid.NewGuid().ToString()); if (result != null) { await new MessageDialog("登录成功").ShowAsync(); } else { await new MessageDialog("登录失败").ShowAsync(); } //if (result.Success) //{ // await new MessageDialog("登录成功").ShowAsync(); //} //else //{ // await new MessageDialog(result.Msg).ShowAsync(); //} }