private async void ExecuteDoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                using (me = new MedicalModel(ConfigurationManager.Connect()))
                {
                    await me.Database.Connection.OpenAsync();

                    RegistrationM.PriviledgesID = me.priviledges.Where(b => b.NameP == RegistrationM.PriviledgesSelected).Select(b => b.IdP).Single();
                    accountdata ad = new accountdata();
                    ad.UserNameAD = RegistrationM.Username;
                    PasswordManager pwm = new PasswordManager();
                    RegistrationM.PassSalt = pwm.GetSaltString();
                    ad.PassSaltAD          = RegistrationM.PassSalt;
                    ad.PasswordAD          = pwm.GenerateHashWithSalt(RegistrationM.Password, RegistrationM.PassSalt);
                    ad.PriviledgesIdAD     = RegistrationM.PriviledgesID;
                    ad.RegistrateTimeAD    = DateTime.Now;
                    me.accountdata.Add(ad);
                    await me.SaveChangesAsync();
                }
                workingConn = true;
            }
            catch (Exception ex)
            {
                Log.WriteException(ex);
                workingConn = false;
            }
        }
 private void ExecuteDoWork(object sender, DoWorkEventArgs e)
 {
     if (!string.IsNullOrEmpty(SecurityM.NewSecurityUser))
     {
         ConfigurationManager.ConfigurationManagerM.SecurityUsername = SecurityM.NewSecurityUser;
     }
     if (!string.IsNullOrEmpty(SecurityM.NewSecurityPass))
     {
         ConfigurationManager.ConfigurationManagerM.SecurityPasswordSalt = PasswordManager.GetSaltString();
         ConfigurationManager.ConfigurationManagerM.SecurityPassword     = PasswordManager.GenerateHashWithSalt
                                                                               (SecurityM.NewSecurityPass, ConfigurationManager.ConfigurationManagerM.SecurityPasswordSalt);
     }
     ConfigurationManager.Save();
 }
Esempio n. 3
0
        private async void ExecuteDoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                using (me = new MedicalModel(ConfigurationManager.Connect()))
                {
                    await me.Database.Connection.OpenAsync();

                    accountdata ad = new accountdata();
                    ad = me.accountdata.Where(b => b.IdAD == GlobalVM.GlobalM.AccountID).Single();
                    PasswordManager pwm = new PasswordManager();
                    PassChangeM.NewPassSalt = pwm.GetSaltString();
                    ad.PassSaltAD           = PassChangeM.NewPassSalt;
                    ad.PasswordAD           = pwm.GenerateHashWithSalt(PassChangeM.NewPassword, PassChangeM.NewPassSalt);
                    await me.SaveChangesAsync();
                }
                workingConn = true;
            }
            catch (Exception ex)
            {
                Log.WriteException(ex);
                workingConn = false;
            }
        }
        private void NewPassThreadDoWork(object sender, DoWorkEventArgs e)
        {
            PasswordManager pwm = new PasswordManager();

            UsersMViewElements.UserDatas.Where(b => b.UserNameAD == UsersMDataSet.SelectedRow.UserName).Single().PassSaltAD = pwm.GetSaltString();
            UsersMViewElements.UserDatas.Where(b => b.UserNameAD == UsersMDataSet.SelectedRow.UserName).Single().PasswordAD = pwm.GenerateHashWithSalt(newPass.NewPassVM.Pass(),
                                                                                                                                                       UsersMViewElements.UserDatas.Where(b => b.UserNameAD == UsersMDataSet.SelectedRow.UserName).Select(b => b.PassSaltAD).Single());
            UsersMViewElements.Users.Where(b => b.UserName == UsersMDataSet.SelectedRow.UserName).Single().PassModified = true;
        }