예제 #1
0
        private void cmdLogin_Click(object sender, System.EventArgs e)
        {
            try
            {
                var model = new LoginModel();
                model.Email     = txtLoginEMail.Text;
                model.Password  = txtLoginPassword.Text;
                model.MachineID = SecurityHelper.GetMachineID();
                var result = VersionHelper.AuthenticateUser(model);
                if (result.Success)
                {
                    AddinAppData.Instance.PremiumValidated = false;
                    //if (!string.IsNullOrEmpty(txtPremium.Text))
                    //{
                    //    var result = service.VerifyPremiumKey(txtLoginEMail.Text, txtLoginPassword.Text, SecurityHelper.GetMachineID(), txtPremium.Text);
                    //    if (string.IsNullOrEmpty(result))
                    //    {
                    //        AddinAppData.Instance.PremiumValidated = true;
                    //        MessageBox.Show("The premium key has been verified and applied. All application features have been enabled.", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //    }
                    //    else
                    //    {
                    //        //Display the reason for the error
                    //        MessageBox.Show("An error has occurred while verifying your premium key. The failure reason is listed below.\n\n'" + result + "'", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //        return;
                    //    }
                    //}

                    MessageBox.Show("The login has been validated.", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    //service.ResetStatistics(txtLoginEMail.Text, chkStat.Checked);
                    AddinAppData.Instance.Key        = result.Text;
                    AddinAppData.Instance.PremiumKey = txtPremium.Text;
                    AddinAppData.Instance.AllowStats = chkStat.Checked;
                    AddinAppData.Instance.Save();

                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    //MessageBox.Show("The login could not be validated.", "Invalid Login!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MessageBox.Show(result.Text, "Invalid Login!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error trying to register. Please visit the main nHydrate site to register: http://www.nHydrate.org.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }