Esempio n. 1
0
        private async void ViewOpened(IStartView sender, OpenExamEventArgs e)
        {
            Exam             exam      = null;
            IExamSaver       loaded    = null;
            ExamsListService examsList = ExamsListService.GetInstance();

            try
            {
                loaded = new FileExamSaver(e.FilePath, e.Password, sender.CurrentExamSaver.SaverName);
                int index = examsList.ExamSavers.IndexOf(loaded);
                if (index >= 0)
                {
                    sender.CurrentExamSaver = examsList.ExamSavers[index];
                    currentExamSaver        = examsList.ExamSavers[index];
                    return;
                }
            }
            catch
            { }
            loaded = new FileExamSaver(e.FilePath, e.Password, "");
            exam   = await Task.Run(() => loaded.GetExam());

            if (exam != null)
            {
                loaded = new FileExamSaver(e.FilePath, e.Password, exam.Name);
                examsList.Add(loaded);
                sender.CurrentExam = exam;
                currentExamSaver   = loaded;
            }
            else
            {
                sender.ShowError($"Не удалось открыть экзамен. {loaded.LastExceptionMessage}");
            }
        }
Esempio n. 2
0
        private async void ViewFileOpened(IImportView sender, OpenExamEventArgs e)
        {
            Exam             exam      = null;
            IExamSaver       loaded    = null;
            ExamsListService examsList = ExamsListService.GetInstance();

            try
            {
                loaded = new FileExamSaver(e.FilePath, e.Password, sender.CurrentExamSaver.SaverName);
                int index = examsList.ExamSavers.IndexOf(loaded);
                if (index >= 0)
                {
                    sender.CurrentExamSaver = examsList.ExamSavers[index];
                    currentExamSaver        = examsList.ExamSavers[index];
                    return;
                }
            }
            catch
            { }
            loaded = new FileExamSaver(e.FilePath, e.Password, "");
            exam   = await Task.Run(() => loaded.GetExam());

            if (exam != null)
            {
                loaded = new FileExamSaver(e.FilePath, e.Password, exam.Name);
                examsList.Add(loaded);
                List <Question> questions = new List <Question>();
                for (int i = 0; i < exam.Tickets.Count; i++)
                {
                    questions.AddRange(exam.Tickets[i].GetQuestions());
                }
                sender.Questions = questions;
                currentExamSaver = loaded;
            }
            else
            {
                sender.ShowError($"Не удалось открыть экзамен.{ Environment.NewLine }Ошибка: { loaded.LastExceptionMessage }");
            }
        }