private async void ResponceCode_LoadCompleted(object sender, NavigationEventArgs e) { if (count == 0) { string functionString = String.Format("document.getElementById('uname').innerText = '{0}';", obj.eclassUsername); await ResponceCode.InvokeScriptAsync("eval", new string[] { functionString }); functionString = String.Format("document.getElementById('pass').innerText = '{0}';", obj.eclassPass); await ResponceCode.InvokeScriptAsync("eval", new string[] { functionString }); functionString = String.Format("document.getElementsByTagName('button')[document.getElementsByTagName('button').length-1].click();"); await ResponceCode.InvokeScriptAsync("eval", new[] { functionString }); count++; } else if (count == 1) { ResponceCode.Navigate(new Uri("https://eclass.aueb.gr/modules/announcements/?course=" + courseCodeRequested)); count++; } else if (count == 2) { var scode = await ResponceCode.InvokeScriptAsync("eval", new string[] { "document.documentElement.outerHTML;" }); var doc = new HtmlDocument(); doc.LoadHtml(scode); var value = doc.DocumentNode.Descendants("a").Where(x => x.Attributes.Contains("href")); var myval = value.Where(y => y.Attributes["href"].Value.Contains("/modules/announcements/rss.php")); if (eclassUID.Equals("")) { eclassUID = (myval.First().Attributes["href"].Value.Split('&').GetValue(1).ToString()).Split('=').Last().ToString(); await StoreUserIdAsync(eclassUID); } else { announcementToken = new Model.AnnouncementToken() { ID = courseCodeRequested, Token = (myval.First().Attributes["href"].Value.Split('&').GetValue(2).ToString()).Split('=').Last().ToString() }; } count++; ResponceCode.Navigate(new Uri("https://eclass.aueb.gr/")); } else if (count == 3) { if (!eclassUID.Equals("")) { correctCourses(); } count++; } }
private async void correctCourses() { CoursesViewer.IsHitTestVisible = false; ProgressUpdate.IsActive = true; ProgressUpdate.Visibility = Visibility.Visible; CoursesViewer.Visibility = Visibility.Collapsed; if (obj.eclassUID == null) { obj.eclassUID = eclassUID; } foreach (Course course in Ycourses) { if (course.MyAnnouncements.Count == 0) { try { var url = "http://auebunofficialapi.azurewebsites.net/Announcements/Details/" + course.Id; Model.AnnouncementToken announcement; var response = await url.GetAsync().ReceiveString(); announcement = JsonConvert.DeserializeObject <Model.AnnouncementToken>(response); course.Ans = c = new EclassRssParser("https://eclass.aueb.gr/modules/announcements/rss.php?c=" + course.Id + "&uid=" + obj.eclassUID + "&token=" + announcement.Token); course.MyAnnouncements = c.Announcements; } catch (FlurlHttpException) { courseCodeRequested = course.Id; var url = "https://eclass.aueb.gr/modules/announcements/?course=" + course.Id; count = 2; ResponceCode.Navigate(new Uri(url)); await Task.Delay(1400); course.Ans = c = new EclassRssParser("https://eclass.aueb.gr/modules/announcements/rss.php?c=" + announcementToken.ID + "&uid=" + obj.eclassUID + "&token=" + announcementToken.Token); course.MyAnnouncements = c.Announcements; var urlCreate = "http://auebunofficialapi.azurewebsites.net/Announcements/Create/"; var response = await urlCreate.PostUrlEncodedAsync(new { ID = announcementToken.ID, Token = announcementToken.Token }); } } } CoursesViewer.IsHitTestVisible = true; ProgressUpdate.IsActive = false; ProgressUpdate.Visibility = Visibility.Collapsed; CoursesViewer.Visibility = Visibility.Visible; }
private async void An_LoadedAsync(object sender, RoutedEventArgs d) { await FilCoursesAsync(); ResponceCode.Navigate(new Uri("https://eclass.aueb.gr")); }