async private void Register_OnClick(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(txtName.Text) || string.IsNullOrEmpty(txtPwd.Password)) { await new MessageDialog("用户名、密码不能为空").ShowAsync(); return; } var repository = new RepositoryAsync(); var deviceId = Guid.NewGuid().ToString(); var api = new MemberService(); var result = await api.Register(txtName.Text, txtPwd.Password, deviceId); if (result.Success) { await repository.InsertUserAsync(new User() { NickName = txtName.Text, Account = txtName.Text, DeviceId = deviceId }); await new MessageDialog("注册成功").ShowAsync(); } else { await new MessageDialog(result.Msg).ShowAsync(); } }
private async void RegisterAll_OnClick(object sender, RoutedEventArgs e) { this.progressRing.IsActive = true; var repository = new RepositoryAsync(); var api = new MemberService(); int count = 0; var userNames = FileHelper.GetUserNameWithNickName(); foreach (var item in userNames) { var deviceId = Guid.NewGuid().ToString(); var result = await api.Register(item["username"], "123456", deviceId); if (result.Success) { await repository.InsertUserAsync(new User() { NickName = item["nickname"], Account = item["username"], DeviceId = deviceId }); count = count + 1; } } this.progressRing.IsActive = false; await new MessageDialog($"总共注册用户数:{count}").ShowAsync(); }