private async void Button3_Click(object sender, EventArgs e) { _logger.Info("Нажата кнопка '{0}'", button3.Text); try { await Task.Factory.StartNew(() => { InvokeUI(() => { listStatementLine.Clear(); var reposStudent = RepositoryFactory <Student> .Create(); this.comboBoxListGroups.SelectedIndexChanged += new EventHandler(ComboboxListGroup_SelectedIndexChanged); var _idGroup = reposStudent.GetIdGroupForStudent(GroupName); var _idCp = WorkWithDB.GetIdCp(CpName, _idGroup, DisciplineName, TermName); var _cp = reposCP.Get(_idCp); if (_idCp != 0 && _cp.DisciplineId == WorkWithDB.GetDisciplineId(DisciplineName)) { foreach (var item in StatementLine.GetListStatementLine(_idCp, WorkWithDB.GetDisciplineId(DisciplineName), Convert.ToInt32(reposGroup.GetIdGroupDisciplineGroup(GroupName)), WorkWithDB.GetIdTermForCp(TermName)).AsParallel()) { listStatementLine.Add(item); } var repCp = reposCP.Get(_idCp); tbCountLek.Text = Convert.ToString(repCp.CountLek); tbCountLab.Text = Convert.ToString(repCp.CountLab); tbCountPrac.Text = Convert.ToString(repCp.CountPrac); ShowInformationAboutCp(_idCp); _logger.Info("Информация загружена."); } else if (_idCp == 0) { _logger.Debug("Не удалось получить id контрольной точки!"); } else { MessageBox.Show($"Для данной группы отсутствует '{CpName}' точка!"); _logger.Info("Данные не были загружены, так как у группы {0} отсутствует {1} точка по дисциплине {2} в семестре {3}", GroupName, CpName, DisciplineName, TermName); } }); }); } catch (Exception ex) { _logger.Error("Произошла ошибка ({0}) при загрузке записей", ex.Message); } }
private async void button3_Click(object sender, EventArgs e) { await Task.Factory.StartNew(() => { InvokeUI(() => { listStatementLine.Clear(); var reposStudent = RepositoryFactory <Student> .Create(); this.comboBoxListGroups.SelectedIndexChanged += new EventHandler(comboboxListGroup_SelectedIndexChanged); var _idGroup = reposStudent.GetIdGroupForStudent(GroupName); var _idCp = WorkWithDB.GetIdCp(CpName, _idGroup, DisciplineName, TermName); var _cp = reposCP.Get(_idCp); if (_idCp != 0 && _cp.DisciplineId == WorkWithDB.GetDisciplineId(DisciplineName)) { foreach (var item in StatementLine.GetListStatementLine(_idCp, WorkWithDB.GetDisciplineId(DisciplineName), Convert.ToInt32(reposGroup.GetIdGroupDisciplineGroup(GroupName)), WorkWithDB.GetIdTermForCp(TermName)).AsParallel()) { listStatementLine.Add(item); } var repCp = reposCP.Get(_idCp); tbCountLek.Text = Convert.ToString(repCp.CountLek); tbCountLab.Text = Convert.ToString(repCp.CountLab); tbCountPrac.Text = Convert.ToString(repCp.CountPrac); ShowInformationAboutCp(_idCp); } else { MessageBox.Show($"Для данной группы отсутствует '{CpName}' точка!"); } }); }); }