private void Window_Loaded(object sender, RoutedEventArgs e) { this.Title = $"{Model_Name}: пользователь {Current_User.Login}"; if (!Authorization_Window.Is_Model_Valid($"{Directory.GetCurrentDirectory()}\\{Model_Name}")) { if (MessageBox.Show("Модель повреждена! Удалить?", "Модель повреждена", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { Directory.Delete(Model_Name, true); } this.Close(); } All_Objects = JsonConvert.DeserializeObject <ObservableCollection <Model_Object> >(File.ReadAllText($"{Model_Name}\\Object_list.json")); if (All_Objects == null) { All_Objects = new ObservableCollection <Model_Object>(); } else { foreach (Model_Object o in All_Objects) { if (o.Security_Level >= Current_User.Security_Level) { Objects.Add(o); } } } Object_combobox.ItemsSource = Objects; }
public static void Save_Model(string Model_Name, ObservableCollection<Model_Object> Objects, ObservableCollection<Model_Subject> Subjects = null) { Authorization_Window.Get_Subj_Obj_Dir(Model_Name, out string obj_dir, out string subj_dir); File.WriteAllText(obj_dir, JsonConvert.SerializeObject(Objects)); if (Subjects != null) File.WriteAllText(subj_dir, JsonConvert.SerializeObject(Subjects)); }
private void Window_Loaded(object sender, RoutedEventArgs e) { Title = $"{Model_Name}: администратор {Current_User.Login}"; if (!Authorization_Window.Is_Model_Valid($"{Directory.GetCurrentDirectory()}\\{Model_Name}")) { if (MessageBox.Show("Модель повреждена! Удалить?", "Модель повреждена", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { Directory.Delete(Model_Name, true); } this.Close(); } Subjects = JsonConvert.DeserializeObject <ObservableCollection <Model_Subject> >(File.ReadAllText($"{Model_Name}\\Subject_list.json")); Objects = JsonConvert.DeserializeObject <ObservableCollection <Model_Object> >(File.ReadAllText($"{Model_Name}\\Object_list.json")); if (Objects == null) { Objects = new ObservableCollection <Model_Object>(); } Subject_combobox.ItemsSource = Subjects; Object_combobox.ItemsSource = Objects; }