示例#1
0
 public void SaveData()
 {
     if (validateEmptyFields() && ValidateData())
     {
         try {
             using (var client = new LismanService.AccountManagerClient()) {
                 String token       = Encrypter.EncodePassword(Guid.NewGuid().ToString());
                 var    accountSave = new LismanService.Account {
                     User              = textField_userName.Text,
                     Password          = Encrypter.EncodePassword(passwordBox_password.Password),
                     Registration_date = DateTime.Now.ToString(),
                     Key_confirmation  = token,
                     Player            = new LismanService.Player {
                         First_name = textField_name.Text,
                         Last_name  = textField_lastName.Text,
                         Email      = textField_email.Text,
                     }
                 };
                 if (client.AddAccount(accountSave) != -1)
                 {
                     SendEmail(accountSave.Player.Email, token);
                     var messageRegistrationSuccessful = Properties.Resources.message_registration_successful;
                     MessageBox.Show(messageRegistrationSuccessful);
                     MainWindow login = new MainWindow();
                     login.Show();
                     this.Close();
                 }
                 else
                 {
                     var messageRegistrationError = Properties.Resources.message_registration_error;
                     MessageBox.Show(messageRegistrationError);
                 }
             }
         } catch (Exception ex) {
             Logger.log.Error("Function SaveData, " + ex);
         }
     }
 }
示例#2
0
        public void LoginUser()
        {
            if (ValidateFields())
            {
                try
                {
                    using (var client = new LismanService.LoginManagerClient())
                    {
                        try
                        {
                            bool inSession = client.UserInSession(textField_user.Text);

                            if (!inSession)
                            {
                                LismanService.Account account = client.LoginAccount(textField_user.Text, Encrypter.EncodePassword(passwordBox_password.Password));
                                AccessManagement(account);
                            }
                            else
                            {
                                MessageBox.Show("Hay una sesion iniciada, por favor cerrarla");
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                            Logger.log.Error("Function LoginUser, " + ex.Message);
                        }
                    }
                } catch (CommunicationException ex)
                {
                    MessageBox.Show(Properties.Resources.server_connection_error);
                    Logger.log.Error("Function LoginUser, " + ex.Message);
                }
            }
        }