Esempio n. 1
0
        private void PlayerReadyButton(object sender, RoutedEventArgs e)
        {
            Random rnd          = new Random();
            int    passwordTake = (int)((PasswordAmount)this.PasswordsComboBox.SelectedItem);

            for (int i = 0; i < passwordTake; i++)
            {
                int elementIndex = rnd.Next(0, PasswordCollection.Count - 1);
                PasswordGameCollection.Add(PasswordCollection.ElementAt(elementIndex));
                PasswordCollection.RemoveAt(elementIndex);
            }

            Passwordclass PasswordList = new Passwordclass();

            PasswordList = PasswordGameCollection.ElementAt(0);
            PasswordGameCollection.RemoveAt(0);
            PasswordLabelContent = PasswordList.Name;
            CategoryLabelContent = PasswordList.Category;

            PasswordAmountToQuess = passwordTake;

            playerReady = true;

            StackReadyPanel.Visibility = Visibility.Hidden;
            TimerTextBlock.Visibility  = Visibility.Visible;
            TimeForClock = TimeChoosen;
            Timer.Start();
        }
Esempio n. 2
0
 public ActionResult Save(Bam.Net.UserAccounts.Data.Password[] values)
 {
     try
     {
         PasswordCollection saver = new PasswordCollection();
         saver.AddRange(values);
         saver.Save();
         return(Json(new { Success = true, Message = "", Dao = "" }));
     }
     catch (Exception ex)
     {
         return(GetErrorResult(ex));
     }
 }
Esempio n. 3
0
        public override bool DeleteUser(string username, bool deleteAllRelatedData)
        {
            User user   = User.GetByUserName(username);
            bool result = false;

            try
            {
                if (user != null)
                {
                    user.IsDeleted  = true;
                    user.IsApproved = false;
                    user.Save();
                    if (deleteAllRelatedData)
                    {
                        UserRoleCollection         roles     = UserRole.Where(c => c.UserId == user.Id);
                        AccountCollection          accounts  = Account.Where(c => c.UserId == user.Id);
                        PasswordCollection         passwords = Password.Where(c => c.UserId == user.Id);
                        PasswordResetCollection    resets    = PasswordReset.Where(c => c.UserId == user.Id);
                        PasswordFailureCollection  failures  = PasswordFailure.Where(c => c.UserId == user.Id);
                        LockOutCollection          lockouts  = LockOut.Where(c => c.UserId == user.Id);
                        LoginCollection            logins    = Login.Where(c => c.UserId == user.Id);
                        PasswordQuestionCollection questions = PasswordQuestion.Where(c => c.UserId == user.Id);
                        SettingCollection          settings  = Setting.Where(c => c.UserId == user.Id);

                        SessionCollection session = Session.Where(c => c.UserId == user.Id);

                        Database         db  = Db.For <User>();
                        SqlStringBuilder sql = db.ServiceProvider.Get <SqlStringBuilder>();
                        roles.WriteDelete(sql);
                        accounts.WriteDelete(sql);
                        passwords.WriteDelete(sql);
                        resets.WriteDelete(sql);
                        failures.WriteDelete(sql);
                        lockouts.WriteDelete(sql);
                        logins.WriteDelete(sql);
                        questions.WriteDelete(sql);
                        settings.WriteDelete(sql);
                        session.WriteDelete(sql);

                        sql.Execute(db);
                    }
                }
            }
            catch (Exception ex)
            {
                result = false;
                Log.AddEntry("{0}.{1}::{2}", ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.Message);
            }
            return(result);
        }
Esempio n. 4
0
        private void RemoveSelected(object sender, RoutedEventArgs e)
        {
            while (PasswordListWiev.SelectedItems.Count > 0)

            {
                Passwordclass item = (Passwordclass)PasswordListWiev.SelectedItem;

                PasswordCollection.Remove(PasswordCollection.Single(x => x.Id == item.Id));

                int id = 1;

                foreach (var Password in PasswordCollection)
                {
                    Password.Id = id;
                    id++;
                }

                Passworded.UpdateXmlData(PasswordCollection);
            }
        }
Esempio n. 5
0
        // -------------------------------------------------------------------------------------------------------------------------------------------

        #region GeneratePasswords

        private void pbGenerate_Click(object sender, EventArgs e)
        {
            PasswordGeneratorOptions options = PasswordGeneratorOptions.None;

            if (rbCapitalsFirst.Checked)
            {
                options |= PasswordGeneratorOptions.Capitals | PasswordGeneratorOptions.CapitalsFirstInChunks;
            }
            else if (rbCapitalsLast.Checked)
            {
                options |= PasswordGeneratorOptions.Capitals | PasswordGeneratorOptions.CapitalsLastInChunks;
            }
            else if (rbCapitalsRandom.Checked)
            {
                options |= PasswordGeneratorOptions.Capitals;
            }

            // if (cbCapitals.Checked)
            //    options |= PasswordGeneratorOptions.Capitals;
            if (cbSpecials.Checked)
            {
                options |= PasswordGeneratorOptions.Specials;
                if (!cbBlanks.Checked)
                {
                    options |= PasswordGeneratorOptions.SpecialsNotBlank;
                }
            }

            if (string.IsNullOrEmpty(tbFixedSeparator.Text))
            {
                tbFixedSeparator.Text = PasswordGenerator.SeparatorsDefault.Substring(0, 1);
            }

            char fixedSeparator = tbFixedSeparator.Text[0];

            if (cbSeparators.Checked)
            {
                options |= PasswordGeneratorOptions.Separators;
                if (cbRotSeparators.Checked)
                {
                    options |= PasswordGeneratorOptions.SeparatorRotation;
                }
            }

            PasswordGeneratorOptionsEx optionsEx = new PasswordGeneratorOptionsEx()
            {
                Options             = options,
                CapitalsMinimum     = 1,
                CapitalsMaximum     = (int)nudCapitalsMax.Value,
                SpecialGroupSymbols = tbSpecials.Text,
                SpecialGroupsMin    = 1,
                SpecialGroupsMax    = (int)nudSpecialsMax.Value,
                FixedSeparatorChar  = fixedSeparator,
                RotatingSeparators  = tbSeparators.Text
            };


            PasswordCollection passwords = new PasswordCollection();

            for (int count = 0; count < nudPassToGen.Value; ++count)
            {
                string password = _passwordGenerator.Generate((int)nudPassLen.Value, optionsEx);
                passwords.Append(_passwordGenerator.LastPassword);
            }

            dgvPasswords.AutoGenerateColumns = false;

            var           bindingList = new SortableBindingList <PasswordCollectionItem>(passwords.Passwords);
            BindingSource source      = new BindingSource(bindingList, null);

            dgvPasswords.DataSource = source;
        }
        public static void DeleteAllPasswords()
        {
            PasswordCollection passwords = Password.LoadAll();

            passwords.Delete();
        }
Esempio n. 7
0
        public ObservableCollection <Passwordclass> SortCollection(ObservableCollection <Passwordclass> PasswordCollection, string valueToSort, string TypeofSort)
        {
            try
            {
                //I could be better , but I had problem with Func<TSampleClass, TPropertyType> etc..
                switch (TypeofSort)
                {
                case "up":
                    if (valueToSort == "NAZWA")
                    {
                        var PasswordsUp = PasswordCollection.OrderBy(x => x.Name);
                        PasswordCollection = new ObservableCollection <Passwordclass>(PasswordsUp);
                    }
                    else if (valueToSort == "KATEGORIA")
                    {
                        var PasswordsUp = PasswordCollection.OrderBy(x => x.Category);
                        PasswordCollection = new ObservableCollection <Passwordclass>(PasswordsUp);
                    }
                    else if (valueToSort == "POZIOM")
                    {
                        var PasswordsUp = PasswordCollection.OrderBy(x => x.Level);
                        PasswordCollection = new ObservableCollection <Passwordclass>(PasswordsUp);
                    }
                    else if (valueToSort == "ID")
                    {
                        var PasswordsUp = PasswordCollection.OrderBy(x => x.Id);
                        PasswordCollection = new ObservableCollection <Passwordclass>(PasswordsUp);
                    }

                    break;

                case "down":

                    if (valueToSort == "NAZWA")
                    {
                        var PasswordsUp = PasswordCollection.OrderByDescending(x => x.Name);
                        PasswordCollection = new ObservableCollection <Passwordclass>(PasswordsUp);
                    }
                    else if (valueToSort == "KATEGORIA")
                    {
                        var PasswordsUp = PasswordCollection.OrderByDescending(x => x.Category);
                        PasswordCollection = new ObservableCollection <Passwordclass>(PasswordsUp);
                    }
                    else if (valueToSort == "POZIOM")
                    {
                        var PasswordsUp = PasswordCollection.OrderByDescending(x => x.Level);
                        PasswordCollection = new ObservableCollection <Passwordclass>(PasswordsUp);
                    }
                    else if (valueToSort == "ID")
                    {
                        var PasswordsUp = PasswordCollection.OrderByDescending(x => x.Id);
                        PasswordCollection = new ObservableCollection <Passwordclass>(PasswordsUp);
                    }

                    break;

                default:

                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ups...\n" + ex.Message);
            }

            return(PasswordCollection);
        }