1
0
mirror of https://github.com/XFox111/GUTSchedule.git synced 2026-04-22 06:58:01 +03:00

- Fixed SSL error on Android

- Turned back on anonymous schedule export
This commit is contained in:
2021-10-06 17:22:00 +03:00
parent dc8dc2af6a
commit 425579fe66
11 changed files with 50 additions and 58 deletions
@@ -61,7 +61,7 @@ namespace GUTSchedule.Droid.Activities
AssignVariables();
/*faculty.SetList(this, Faculties.Select(i => i.name));
faculty.SetList(this, Faculties.Select(i => i.name));
int s = Faculties.FindIndex(i => i.id == prefs.GetString("Faculty", "-123"));
faculty.SetSelection(s == -1 ? 0 : s);
@@ -70,7 +70,7 @@ namespace GUTSchedule.Droid.Activities
// P.S. Fuck Android
await Task.Delay(100);
UpdateGroupsList(); */ // TODO: Temp
UpdateGroupsList();
AddEvents();
@@ -85,14 +85,14 @@ namespace GUTSchedule.Droid.Activities
reminder.SetSelection(prefs.GetInt("Reminder", 0));
calendar.SetList(this, Calendar.Calendars.Select(i => i.Name));
int s = Calendar.Calendars.FindIndex(i => i.Id == prefs.GetString("Calendar", "-123"));
s = Calendar.Calendars.FindIndex(i => i.Id == prefs.GetString("Calendar", "-123"));
calendar.SetSelection(s == -1 ? 0 : s);
end.Text = endDate.ToShortDateString();
start.Text = startDate.ToShortDateString();
groupTitle.Checked = prefs.GetBoolean("AddGroupToHeader", false);
authorize.Checked = true;// prefs.GetBoolean("Authorize", true); // TODO: Temp
authorize.Checked = prefs.GetBoolean("Authorize", true);
email.Text = prefs.GetString("email", "");
password.Text = prefs.GetString("password", "");
@@ -59,7 +59,7 @@ namespace GUT.Schedule.Droid.Activities
}
status.Text = Resources.GetText(Resource.String.facultiesLoadingStatus);
//MainActivity.Faculties = await Parser.GetFaculties(); // TODO: Temp
MainActivity.Faculties = await Parser.GetFaculties();
}
catch (HttpRequestException e)
{
@@ -14,7 +14,7 @@ namespace GUTSchedule.Droid
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "12.0.99.19")]
public partial class Resource
{
@@ -32,7 +32,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="true"
android:enabled="false"
android:text="@string/authorizeCheckbox"/>
<LinearLayout
@@ -65,7 +65,7 @@
<TextBlock x:Uid="scheduleParametersTitle" Style="{StaticResource SubtitleTextBlockStyle}" Text="Schedule parameters"/>
<CheckBox x:Uid="authorizeCheckbox" Content="Authorize via personal cabinet" Checked="ChangeAuthorizationMethod" Unchecked="ChangeAuthorizationMethod" IsChecked="True" IsEnabled="False" x:Name="authorize"/>
<CheckBox x:Uid="authorizeCheckbox" Content="Authorize via personal cabinet" Checked="ChangeAuthorizationMethod" Unchecked="ChangeAuthorizationMethod" IsChecked="True" x:Name="authorize"/>
<StackPanel x:Name="credentialMethod" Visibility="Visible">
<TextBox x:Uid="email" PlaceholderText="E-mail" x:Name="email" IsSpellCheckEnabled="False"/>
<PasswordBox x:Uid="password" PlaceholderText="Password" x:Name="password"/>
@@ -45,7 +45,7 @@ namespace GUTSchedule.UWP.Pages
PackageVersion ver = Package.Current.Id.Version;
version.Text = $"v{ver.Major}.{ver.Minor}.{ver.Build}.{ver.Revision}";
authorize.IsChecked = true;//(bool?)settings.Values["Authorize"] ?? true; // TODO: Temp
authorize.IsChecked = (bool?)settings.Values["Authorize"] ?? true;
if (vault.RetrieveAll() is IReadOnlyList<PasswordCredential> credentials && credentials.Count > 0)
{
email.Text = credentials.First().UserName;
@@ -54,7 +54,7 @@ namespace GUTSchedule.UWP.Pages
}
rememberCredential.IsChecked = (bool?)settings.Values["RememberCredential"] ?? true;
/*faculty.ItemsSource = (await Parser.GetFaculties()).Select(i => new ComboBoxItem // TODO: Temp
faculty.ItemsSource = (await Parser.GetFaculties()).Select(i => new ComboBoxItem
{
Content = i.name,
Tag = i.id,
@@ -63,7 +63,7 @@ namespace GUTSchedule.UWP.Pages
faculty.SelectedIndex = (faculty.ItemsSource as List<ComboBoxItem>).FindIndex(i => i.IsSelected);
if (faculty.SelectedIndex < 0)
faculty.SelectedIndex = 0;
course.SelectedIndex = (int?)settings.Values["Course"] ?? 0;*/
course.SelectedIndex = (int?)settings.Values["Course"] ?? 0;
startDate.Date = DateTime.Today;
endDate.Date = startDate.Date.Value.AddDays(6);
+34 -35
View File
@@ -15,6 +15,11 @@ namespace GUTSchedule
{
public static class Parser
{
private static readonly HttpClient client = new HttpClient(new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
});
public static async Task<HttpClient> VaildateAuthorization(string email, string password)
{
if (string.IsNullOrWhiteSpace(email))
@@ -22,8 +27,6 @@ namespace GUTSchedule
if (string.IsNullOrWhiteSpace(password))
throw new ArgumentNullException(nameof(password));
HttpClient client = new HttpClient();
await client.GetAsync("https://lk.sut.ru/cabinet/");
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://lk.sut.ru/cabinet/lib/autentificationok.php");
@@ -67,7 +70,7 @@ namespace GUTSchedule
}
else if (exportParameters is DefaultExportParameters args)
{
DateTime startDate = new DateTime(long.Parse(await new HttpClient().GetStringAsync("https://xfox111.net/API/GUTSchedule/SemesterOffsetDay")));
DateTime startDate = new DateTime(2021, 8, 30);
IHtmlDocument[] rawSchedule = await GetRawSchedule(args.FacultyId, args.Course, args.GroupId);
if(rawSchedule[0] != null)
schedule.AddRange(ParseRegularSchedule(startDate, rawSchedule[0]));
@@ -131,20 +134,17 @@ namespace GUTSchedule
private static async Task<List<(string id, string name)>> GetList(params (string key, string value)[] parameters)
{
List<(string id, string name)> list = new List<(string, string)>();
using (HttpClient client = new HttpClient())
{
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://cabinet.sut.ru/raspisanie_all_new.php");
request.SetContent(parameters);
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://cabinet.sut.ru/raspisanie_all_new.php");
request.SetContent(parameters);
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
HttpResponseMessage response = await client.SendAsync(request);
string responseBody = await response.Content.ReadAsStringAsync();
if (string.IsNullOrWhiteSpace(responseBody))
return list;
HttpResponseMessage response = await client.SendAsync(request);
string responseBody = await response.Content.ReadAsStringAsync();
if (string.IsNullOrWhiteSpace(responseBody))
return list;
foreach (string s in responseBody.Remove(responseBody.Length - 1).Split(';'))
list.Add((s.Split(',')[0], s.Split(',')[1]));
}
foreach (string s in responseBody.Remove(responseBody.Length - 1).Split(';'))
list.Add((s.Split(',')[0], s.Split(',')[1]));
return list;
}
@@ -185,29 +185,28 @@ namespace GUTSchedule
throw new ArgumentNullException(nameof(groupId));
IHtmlDocument[] docs = new IHtmlDocument[2];
using (HttpClient client = new HttpClient())
for(int k = 1; k < 3; k++)
{
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://cabinet.sut.ru/raspisanie_all_new");
request.SetContent(
("group_el", "0"),
("kurs", course),
("type_z", k.ToString()),
("faculty", facultyId),
("group", groupId),
("ok", "Показать"),
("schet", GetCurrentSemester()));
for (int k = 1; k < 3; k++)
{
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://cabinet.sut.ru/raspisanie_all_new");
request.SetContent(
("group_el", "0"),
("kurs", course),
("type_z", k.ToString()),
("faculty", facultyId),
("group", groupId),
("ok", "Показать"),
("schet", GetCurrentSemester()));
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
HttpResponseMessage response = await client.SendAsync(request);
string responseContent = await response.Content.ReadAsStringAsync();
if (string.IsNullOrWhiteSpace(responseContent))
docs[k - 1] = null;
HttpResponseMessage response = await client.SendAsync(request);
string responseContent = await response.Content.ReadAsStringAsync();
if (string.IsNullOrWhiteSpace(responseContent))
docs[k - 1] = null;
try { docs[k - 1] = new HtmlParser().ParseDocument(responseContent); }
catch (ArgumentException) { }
}
try { docs[k - 1] = new HtmlParser().ParseDocument(responseContent); }
catch (ArgumentException) { }
}
return docs;
}
@@ -1,3 +1,2 @@
- Anonymous schedule export is temporarly disabled
- Fixed export failing
- Remote lessons are now appropriately marked
- Fixed SSL error
- Turned back on anonymous schedule export
@@ -1,3 +1,2 @@
- Анонимный экспорт расписания временно отключен
- Исправлена проблема с экспортом расписания
- Теперь дистанционные пары отмечаются как "ДОТ"
- Исправлена проблема с SSL сетрификатами
- Анонимный экспорт расписания снова работает
@@ -1,3 +1 @@
- Anonymous schedule export is temporarly disabled
- Fixed export failing
- Remote lessons are now appropriately marked
- Turned back on anonymous schedule export
@@ -1,3 +1 @@
- Анонимный экспорт расписания временно отключен
- Исправлена проблема с экспортом расписания
- Теперь дистанционные пары отмечаются как "ДОТ"
- Анонимный экспорт расписания снова работает