Beispiel #1
0
        /// <summary>
        /// One simple async Task for logging in and receiveing the Exams informations
        /// </summary>
        /// <returns></returns>
        private async Task TryLoginAsync()
        {
            bool   loggedIn = false;
            string valueOut;
            Bitmap outBmp;

            while (loggedIn == false)
            {
                // 1 - Get the Captcha
                Bitmap bmp = await _observer.GetLoginCaptchaAsync().ConfigureAwait(false);

                // 2 - Try to extract text. Getting the extracted text and the captcha
                (outBmp, valueOut) = await CaptchaSolver.CaptchaSolver.DeCaptchAsync(bmp).ConfigureAwait(false);

                // 3 - Await the login attempt
                loggedIn = await _observer.LoginAsync(valueOut).ConfigureAwait(false);

                // 4 - If successfull, try to getting the Exams informations
                if (loggedIn == true)
                {
                    List <SubjectMarks> marks = new List <SubjectMarks>();
                    marks = await _observer.GetExamInformationAsync().ConfigureAwait(false);

                    // Dispatch to UI
                    Application.Current.Dispatcher.Invoke(new Action(() => { SubjectMarks = marks; }));
                }

                //Not used because i dont show any infos about the captchas now
                //Application.Current.Dispatcher.Invoke(new Action(() => { Captcha = BitmapConversion.BitmapToBitmapSource(bmp); }));
                //Application.Current.Dispatcher.Invoke(new Action(() => { CaptchaFiltered = BitmapConversion.BitmapToBitmapSource(outBmp); }));
                //Application.Current.Dispatcher.Invoke(new Action(() => { CaptchaText = valueOut; }));
            }
        }
Beispiel #2
0
        private async Task <IEnumerable <SubjectMarks> > GetResultsAsync()
        {
            // TODO (MG): Improve this
            string welcome = "https://ausbildung.ihk.de/pruefungsinfos/Peo/Willkommen.aspx?knr=155";
            string login   = "******";
            string results = "https://ausbildung.ihk.de/pruefungsinfos/Peo/Ergebnisse.aspx";

            Observer.IhkObserver observer = new Observer.IhkObserver(welcome, login, results, Credentials);
            string captcha = string.Empty;

            do
            {
                captcha = (await CaptchaSolver.CaptchaSolver.DeCaptchAsync(
                               await observer.GetLoginCaptchaAsync())).Item2;
            } while (!await observer.LoginAsync(captcha));

            return(await observer.GetExamInformationAsync());
        }
Beispiel #3
0
        public static async Task LoginAsync()
        {
            bool   loggedIn = false;
            string valueOut;
            Bitmap outBmp;


            while (loggedIn == false)
            {
                // 1 - Get the Captcha
                Bitmap bmp = await _observer.GetLoginCaptchaAsync().ConfigureAwait(false);

                var bmpCopy = (Bitmap)bmp.Clone();

                // Fire event
                OnCaptchaReceived?.Invoke(new CaptchaEventArgs(bmpCopy));


                // 2 - Try to extract text. Getting the extracted text and the captcha
                (outBmp, valueOut) = await CaptchaSolver.CaptchaSolver.DeCaptchAsync(bmp).ConfigureAwait(false);

                // Fire event
                OnCaptchaSolvedReceived?.Invoke(new CaptchaSolvedEventArgs(outBmp, valueOut));

                // 3 - Await the login attempt
                loggedIn = await _observer.LoginAsync(valueOut).ConfigureAwait(false);

                OnLoginStatusReceived?.Invoke(new LoginStatusEventArgs(loggedIn));

                // 4 - If successfull, try to getting the Exams informations
                if (loggedIn == true)
                {
                    List <SubjectMarks> marks = new List <SubjectMarks>();
                    marks = await _observer.GetExamInformationAsync().ConfigureAwait(false);

                    OnExamsInformationReceived?.Invoke(new ExamsInformationEventArgs(marks));
                }
            }
        }