protected void LoadLastLoginInfo() { string login = PharmacyClientConfig.Config.LastAccount; if (!string.IsNullOrWhiteSpace(login)) { this.txtName.Text = login; } string pwd = PharmacyClientConfig.Config.LastPwd; if (!string.IsNullOrWhiteSpace(pwd)) { try { pwd = EncodeHelper.Base64Decode(EncodeHelper.Base64Decode(pwd)); } catch (Exception ex) { pwd = string.Empty; } this.txtPassword.Text = pwd; } bool b = PharmacyClientConfig.Config.Pswcheck; this.checkBox1.Checked = b; }
public override void Test() { var numbers = "123456"; //Base64 var base64 = EncodeHelper.Base64Encode(numbers); Console.WriteLine("Base64Encode:{0}", base64); Console.WriteLine("Base64Decode:{0}", EncodeHelper.Base64Decode(base64)); //Unicode var character = "这是Unicode编码"; var unicode = EncodeHelper.UnicodeEncode(character); Console.WriteLine("UnicodeEncode:{0}", unicode); Console.WriteLine("UnicodeDecode:{0}", EncodeHelper.UnicodeDecode(unicode)); }
public async Task <IActionResult> ConfirmEmail(ConfirmUserRequest request) { var user = await _userManager.FindByIdAsync(request.UserId); if (user == null) { _logger.LogInformation($"User with id: {request.UserId} was not found."); return(StatusCode((int)HttpStatusCode.NotFound, new ErrorResponse(ErrorReasons.NotFound, "User was not found."))); } var result = await _userManager.ConfirmEmailAsync(user, EncodeHelper.Base64Decode(request.Code)); if (result.Succeeded) { return(StatusCode((int)HttpStatusCode.OK, "User confirmed")); } return(StatusCode((int)HttpStatusCode.BadRequest, new ErrorResponse(ErrorReasons.BadRequest, ErrorReasons.BadRequest))); }
public async Task <IActionResult> ResetPassword([FromBody] ResetPasswordRequest request) { var shopUser = await _userManager.FindByIdAsync(request.UserId); if (shopUser != null) { var decodedToken = EncodeHelper.Base64Decode(request.Token); var resetPasswordResult = await _userManager.ResetPasswordAsync(shopUser, decodedToken, request.Password); if (resetPasswordResult.Succeeded) { return(StatusCode((int)HttpStatusCode.OK, "Password was reset")); } return(StatusCode((int)HttpStatusCode.BadRequest, new ErrorResponse(ErrorReasons.BadRequest, resetPasswordResult.Errors.Select(e => e.Description).FirstOrDefault()))); } return(StatusCode((int)HttpStatusCode.NotFound, new ErrorResponse(ErrorReasons.NotFound, "User was not found."))); }
//根据DataGridViewRow设置控件值 或者 获取控件值 或者清空控件值 public Dictionary <string, object> ValueControlsMap(DataGridViewRow dr = null, bool refresh = false, bool fromSearch = false) { Dictionary <string, object> values = new Dictionary <string, object>(); try { //获取查询模块控件值 Control parentControl; if (fromSearch) { parentControl = searchGroupBox; } else { parentControl = tabPageEdit; } foreach (Control c in parentControl.Controls) { if (!string.IsNullOrEmpty(c.Name)) { if (refresh == true) { //清空控件值 switch (c.GetType().Name) { case "CoolTextBox": ((CoolTextBox)c).Text = ""; break; //case "CheckBox": // //((CheckBox)c).Checked = false; // break; case "DateTimePicker": ((DateTimePicker)c).Format = DateTimePickerFormat.Custom; ((DateTimePicker)c).CustomFormat = ""; break; case "ComboBox": if (((ComboBox)c).Items.Count > 0) { ((ComboBox)c).SelectedIndex = 0; } break; case "RichTextBox": ((RichTextBox)c).Text = ""; break; } } else if (dr == null) { //获取控件值 string name = fromSearch ? c.Name.Replace(_SEARCHPREFIX, "") : c.Name; switch (c.GetType().Name) { case "CoolTextBox": values.Add(name, ((CoolTextBox)c).Text); break; case "CheckBox": values.Add(name, ((CheckBox)c).Checked); break; case "DateTimePicker": values.Add(name, ((DateTimePicker)c).Value); break; case "ComboBox": if (((ComboBox)c).SelectedItem != null) { values.Add(name, ((ListItem)((((ComboBox)c)).SelectedItem)).ID); } break; case "RichTextBox": values.Add(name, ((RichTextBox)c).Text); break; case "FromToDateTime": values.Add(ResourceStrings.Common_StartTime, ((FromToDateTime)c).StartTime); values.Add(ResourceStrings.Common_EndTime, ((FromToDateTime)c).EndTime); break; } } else if (dr.Cells[c.Name].Value != null) { //设置控件值 switch (c.GetType().Name) { case "CoolTextBox": //对密码解密 var pwd = (CoolTextBox)c; if (pwd.IsPwd) { ((CoolTextBox)c).Text = EncodeHelper.Base64Decode((dr.DataBoundItem as User).Pwd); } else { ((CoolTextBox)c).Text = dr.Cells[c.Name].Value.ToString(); } break; case "CheckBox": ((CheckBox)c).Checked = (Boolean)dr.Cells[c.Name].Value; break; case "DateTimePicker": ((DateTimePicker)c).Value = (DateTime)dr.Cells[c.Name].Value; break; case "ComboBox": //((ComboBox)c).ValueMember = dr.Cells[c.Name].Value.ToString(); ComboBox cb = (ComboBox)c; ListItem listItem = new ListItem(); foreach (ListItem li in cb.Items) { if (li.Name == dr.Cells[c.Name].Value.ToString() || li.ID == dr.Cells[c.Name].Value.ToString()) { listItem = li; } } cb.SelectedItem = listItem; break; case "RichTextBox": ((RichTextBox)c).Text = dr.Cells[c.Name].Value.ToString(); break; } } } } } catch { MessageBox.Show("系统发生问题,请联系管理员"); } return(values); }