Beispiel #1
0
        public Timetable GetTimetable(VulcanAccount account, DateTime date)
        {
            account.SwitchToSymbol(School.SchoolSymbol);
            account.RestClient.BaseUrl = new Uri(new UrlGenerator(account.UrlGenerator.Host, School.SchoolSymbol, School.SchoolId).Generate(UrlGenerator.Site.STUDENT));
            var request = new RestRequest("PlanZajec.mvc/Get/", Method.POST);

            request.RequestFormat = DataFormat.Json;
            request.AddJsonBody(new { data = date.ToString("s") });

            request.AddCookie("idBiezacyDziennik", Diary.DiaryId.ToString());
            request.AddCookie("idBiezacyDziennikPrzedszkole", Diary.KindergartenDiaryId.ToString());
            request.AddCookie("idBiezacyUczen", StudentId.ToString());

            var result = account.RestClient.Execute(request);

            if (result.IsSuccessful)
            {
                var response = JsonConvert.DeserializeObject <ApiResponse <TimetableResponse> >(result.Content);
                if (response.Success)
                {
                    return(new Timetable(response.Data));
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        public void StudentsTest(LoginConfig login)
        {
            var account = new VulcanAccount(login);

            account.InitializeStudents();

            Assert.True(account.Students.Count > 0);
        }
Beispiel #3
0
        public void TimetableTest(LoginConfig login)
        {
            var account = new VulcanAccount(login);

            account.InitializeStudents();

            var timetable = account.Students[0].GetTimetable(account, DateTime.Today);

            Assert.NotNull(timetable);
            Assert.NotEmpty(timetable.Days);
            Assert.NotEmpty(timetable.Days[0].Lessons);
        }
Beispiel #4
0
        public void LoginTest(LoginConfig login)
        {
            var account = new VulcanAccount(login);

            account.LoginService.Login(login.Email, login.Password, out var certificate, out var sendCertificate);

            Assert.NotNull(certificate);
            Assert.True(certificate.IsValid());

            Assert.NotNull(sendCertificate);
            Assert.True(sendCertificate.IsValid());

            _output.WriteLine($"Successfuly logged with {login.Email}, {sendCertificate.StudentSchools.Count} students, {certificate.Wresult.Symbols.Count} symbols");
        }
        protected override void OnAppearing()
        {
            Task.Run(async() =>
            {
                await Task.Delay(TimeSpan.FromSeconds(0.5));

                var account = new VulcanAccount(new LoginConfig("fakelog.cf", "Default", "*****@*****.**", "jan123", false));
                account.InitializeStudents();

                Device.BeginInvokeOnMainThread(() => {
                    Navigation.InsertPageBefore(new LuckyNumberPage($"Logged account with {account.Students.Count} students"), Navigation.NavigationStack[0]);
                    Navigation.PopToRootAsync(false);
                });
            });
        }
Beispiel #6
0
        public void LuckyNumberTest(LoginConfig login)
        {
            var account = new VulcanAccount(login);

            account.InitializeStudents();

            foreach (var school in account.Students.Select(x => x.School).DistinctBy(x => x.SchoolId))
            {
                var luckyNumber = school.GetLuckyNumber(account);
                if (login.IsTestLog)
                {
                    Assert.Equal(DateTime.Now.Hour <= 7 ? -1 : DateTime.Today.Day, luckyNumber);
                }
                _output.WriteLine($"{school.SchoolSymbol} have lucky {luckyNumber} today");
            }
        }
Beispiel #7
0
        public int GetLuckyNumber(VulcanAccount account)
        {
            account.RestClient.BaseUrl = new Uri(new UrlGenerator(account.UrlGenerator.Host, SchoolSymbol).Generate(UrlGenerator.Site.HOME));
            var request = new RestRequest("Start.mvc/Index", Method.GET);

            var result = account.RestClient.Execute(request);

            if (result.IsSuccessful)
            {
                return(HtmlConvert.HtmlConvert.DeserializeObject <LuckyNumberResponse>(result.Content).LuckyNumer);
            }
            else
            {
                return(-1);
            }
        }
Beispiel #8
0
 protected BaseService(VulcanAccount vulcanAccount)
 {
     this.Account = vulcanAccount;
 }
Beispiel #9
0
 public DiaryService(VulcanAccount vulcanAccount) : base(vulcanAccount)
 {
 }
 public LoginService(VulcanAccount vulcanAccount) : base(vulcanAccount)
 {
 }