private void _buttonGetSerialNumber_Click(object sender, EventArgs e) { try { if ((!string.IsNullOrEmpty(_textBoxStuNo.Text.Trim()) && !Register.Info.IsRegistered) && string.IsNullOrEmpty(_textBoxSerialNumber.Text)) { var info = new RegisterInfo { MachineSerialNumber = Convert.ToBase64String( ClassEncrypt.Encrypt( ClassRegister.GetCpu() + ClassRegister.GetHardWare() + ClassRegister.GetBaseBoard() + ClassTime.GetNetWorkTime() ) ), UserCode = _textBoxStuNo.Text.Trim() }; var encryptStr = JsonConvert.SerializeObject(info); Register.Info.Register = Convert.ToBase64String(ClassEncrypt.Encrypt(encryptStr)); _textBoxSerialNumber.Text = Register.Info.Register; Register.SetRegInfo(); } else if (_textBoxStuNo.Text.Trim().Length == 0) { MessageBox.Show("请先输入注册学号!"); } else if (Register.Info.IsRegistered) { MessageBox.Show("软件已注册,若试用期满请联系作者!"); } else { MessageBox.Show("机器码已存在!"); } } catch (Exception exception) { MessageBox.Show(exception.Message); } }
/// <summary> 存储用户信息.</summary> /// <remarks> windawings, 12/21/2015.</remarks> private void ControlToValue() { userInfo.Info.ImgUrl = _textBoxUrl.Text.Trim(); userInfo.Info.PictureType = _textBoxPictureType.Text.Trim(); userInfo.Info.CaptchaType = ReturnCaptchaType(); if (String.IsNullOrEmpty(userInfo.Info.ImgUrl) == false) { var url = userInfo.Info.ImgUrl[userInfo.Info.ImgUrl.Length - 1]; if (url != '/' && url != '\\') { userInfo.Info.ImgUrl += "/"; } } userInfo.SetRegInfo(); }