Beispiel #1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            Task.Run(loadingForm.ShowDialog);

            try
            {
                if (!IsLastAppVersion())
                {
                    var oldVersionForm = new OldVersionForm();

                    loadingForm.Invoke(new Action(loadingForm.Close));
                    oldVersionForm.ShowDialog();

                    Environment.Exit(1);
                }

                LoadRemoteData();

                client = new NaUrokClient(naurokAccount.Login, naurokAccount.Password);
            }
            catch (Exception)
            {
                loadingForm.Invoke(new Action(loadingForm.Close));
                ThrowFatalError("Невозможно загрузить данные, возможно у вас нет доступа к интернету");

                Environment.Exit(1);
            }
        }
Beispiel #2
0
        public FinderSystem(NaUrokClient client, string testSessionUuId, int threadsCount, int finderIterationsCount)
        {
            if (client is null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            testDocumentFinders = new List <TestDocumentFinder>();
            this.client         = client;

            ThreadsCount          = threadsCount;
            FinderIterationsCount = finderIterationsCount;
            TestSessionUuId       = testSessionUuId;
            testSession           = client.GetTestSession(testSessionUuId);
        }
        public TestDocumentFinder(NaUrokClient client, TestSession testSession, int startId, int startIndex, int iterationsCount)
        {
            if (client is null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            if (testSession is null)
            {
                throw new ArgumentNullException(nameof(testSession));
            }

            this.client = client;

            TestSession     = testSession;
            StartId         = startId;
            StartIndex      = startIndex;
            IterationsCount = iterationsCount;
        }
        private bool IsCorrectSolvedSession(SolvedTestSession solvedSession)
        {
            if (solvedSession is null)
            {
                return(false);
            }

            var         naUrokAccount = context.WebSitesAccounts.First(account => account.WebSite == "https://naurok.com.ua");
            var         naUrokClient  = new NaUrokClient(naUrokAccount.Login, naUrokAccount.Password);
            TestSession testSession;

            try
            {
                testSession = naUrokClient.GetTestSession(solvedSession.Id);
            }
            catch (Exception)
            {
                return(false);
            }

            return(naUrokClient.IsCorrectTestDocument(testSession, solvedSession.TestDocumentId, out _));
        }
Beispiel #5
0
        private void UpdateInfo()
        {
            if (testSession.TestName != null)
            {
                TestNameText.Text = testSession.TestName;

                DefaultToolTip.SetToolTip(TestNameText, TestNameText.Text);
            }
            else
            {
                TestNameText.Text = "-";

                TestNameText.Enabled  = false;
                TestNameLabel.Enabled = false;
            }

            if (testSession.CreatorId.HasValue)
            {
                TeacherAccountLink.Click += (sender, args) => Process.Start(NaUrokClient.GetProfileUrl(testSession.CreatorId.Value));
            }
            else
            {
                TeacherAccountLink.Enabled = false;
                TeacherLabel.Enabled       = false;
            }

            if (testSession.TestStartDateTime.HasValue)
            {
                CreateDateTimeText.Text = testSession.TestStartDateTime.Value.ToString();
            }
            else
            {
                CreateDateTimeText.Text = "-";

                CreateDateTimeText.Enabled  = false;
                CreateDateTimeLabel.Enabled = false;
            }

            if (testSession.TestEndDateTime.HasValue)
            {
                EndDateTimeText.Text = testSession.TestEndDateTime.Value.ToString();
            }
            else
            {
                EndDateTimeText.Text = "-";

                EndDateTimeText.Enabled  = false;
                EndDateTimeLabel.Enabled = false;
            }

            StartDateTimeText.Text = testSession.StartDateTime.ToString();

            if (testSession.Duration.HasValue)
            {
                DurationText.Text = string.Empty;

                if (testSession.Duration.Value.Hours > 0)
                {
                    DurationText.Text += testSession.Duration.Value.Hours + "ч ";
                }

                DurationText.Text += testSession.Duration.Value.Minutes + "мин";
            }
            else
            {
                DurationText.Text = "-";

                DurationText.Enabled  = false;
                DurationLabel.Enabled = false;
            }

            QuestionsCountText.Text = testSession.TestQuestionsCount.ToString();
        }