private void Log_in_button_Click(object sender, RoutedEventArgs e)
        {
            if (Models_Combobox.SelectedIndex < 0)
            {
                MessageBox.Show("Выберите модель из списка");
                return;
            }
            string model     = Models_Combobox.SelectedItem.ToString();
            string Cur_dir   = Directory.GetCurrentDirectory();
            string model_dir = Cur_dir + "\\" + model;

            if (!Directory.Exists(model_dir))
            {
                MessageBox.Show("Модель не существует!");
                Models.Remove(model);
                return;
            }
            if (!Is_Model_Valid(model_dir))
            {
                if (MessageBox.Show("Модель повреждена! Удалить каталог?", "Ошибка модели",
                                    MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    Directory.Delete(model_dir, true);
                    Models.Remove(model);
                }
                else
                {
                    Models.Remove(model);
                }
                return;
            }
            string login = Login_textbox.Text;
            List <Model_Subject> subjects = JsonConvert.DeserializeObject <List <Model_Subject> >
                                                (File.ReadAllText(model_dir + "\\Subject_list.json"));
            Model_Subject subject = subjects.Find(s => s.Login == login);

            if (subject == null || Model_Subject.Get_Hash(Passwordbox.Password) != subject.Password_hash)
            {
                MessageBox.Show("Неверный логин или пароль!");
                return;
            }
            Passwordbox.Clear();

            this.Visibility = Visibility.Hidden;
            if (subject.Security_Level == 0)
            {
                Administrator_Window administrator_Window = new Administrator_Window(subject, model);
                administrator_Window.ShowDialog();
            }
            else
            {
                User_Window user_Window = new User_Window(subject, model);
                user_Window.ShowDialog();
            }
            this.Visibility = Visibility.Visible;
            Login_textbox.Clear();
        }
Ejemplo n.º 2
0
 private void Create_button_Click(object sender, RoutedEventArgs e)
 {
     Name_textbox.Focus();
     if (Subject_radiobutton.IsChecked == true)
     {
         Model.Create_Subject(Name_textbox.Text, Security_level_textbox.Text, Subjects, Model_Subject.Get_Hash(Passwordbox.Password));
         Passwordbox.Clear();
     }
     else
     {
         Model.Create_Object(Name_textbox.Text, Security_level_textbox.Text, Objects, Model_Name, Current_User);
     }
     Name_textbox.Clear();
     Security_level_textbox.Clear();
 }