Ejemplo n.º 1
0
        private bool CheckSolvedSessions()
        {
            if (testSession.SettingsId.HasValue == false)
            {
                return(false);
            }

            var solvedSession = NaOtvetClient.GetSolvedTestSession(testSession.SettingsId.Value);

            if (solvedSession is null)
            {
                return(false);
            }

            if (client.IsCorrectTestDocument(testSession, solvedSession.TestDocumentId, out FlashCard[] flashCards))
Ejemplo n.º 2
0
        private void FindTestDocument()
        {
            IsStopped = false;

            for (int i = StartIndex; i < StartIndex + IterationsCount && !IsStopped; i++)
            {
                for (int j = 0; j < 2 && !IsStopped; j++)
                {
                    if (i == 0)
                    {
                        j = 1;
                    }

                    int         testDocumentId = (j % 2 == 0) ? StartId + i : StartId - i;
                    bool        isCorrectTestDocument;
                    FlashCard[] flashCards;

                    try
                    {
                        isCorrectTestDocument = client.IsCorrectTestDocument(TestSession, testDocumentId, out flashCards);
                    }
                    catch (Exception exception)
                    {
                        OnError?.Invoke(this, new OnErrorArgs(exception));
                        break;
                    }

                    CheckedDocumentsCount++;

                    if (isCorrectTestDocument)
                    {
                        OnTestDocumentIsFound.Invoke(this, new OnTestDocumentIsFoundArgs(testDocumentId, TestSession, flashCards));
                        Stop();
                        break;
                    }
                    else
                    {
                        OnNewTestDocument.Invoke(this, new OnNewTestDocumentArgs(testDocumentId));
                        continue;
                    }
                }
            }

            Stop();
            OnEnd.Invoke(this, new EventArgs());
        }
        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 _));
        }