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

- Fixed cases when app crashes on the second launch after entered credentials

- Fixed export errors
- Professors' schedule is now marked with 📚
- You can now add your group number to event title when using cabinet authorization
This commit is contained in:
Michael Gordeev
2020-01-31 14:49:23 +03:00
parent af532fc788
commit 9f56a9db92
7 changed files with 33 additions and 18 deletions
@@ -40,11 +40,11 @@ namespace GUT.Schedule
{
List<CabinetSubject> schedule = new List<CabinetSubject>();
for (DateTime d = Data.StartDate; int.Parse($"{d.Year}{d.Month:00}") <= int.Parse($"{Data.EndDate.Year}{Data.EndDate.Month:00}"); d = d.AddMonths(1))
for(DateTime d = Data.StartDate; d <= Data.EndDate; d = d.AddMonths(1))
schedule.AddRange(await Parser.GetCabinetSchedule(Data.DataSet.HttpClient, d, false)); // Even though the user can be professor he can be also PhD student (and have his student schedule)
if(Data.DataSet.IsProfessor == true)
for (DateTime d = Data.StartDate; int.Parse($"{d.Year}{d.Month:00}") <= int.Parse($"{Data.EndDate.Year}{Data.EndDate.Month:00}"); d = d.AddMonths(1))
for (DateTime d = Data.StartDate; d <= Data.EndDate; d = d.AddMonths(1))
schedule.AddRange(await Parser.GetCabinetSchedule(Data.DataSet.HttpClient, d, true));
schedule = schedule.FindAll(i => i.StartTime.Date >= Data.StartDate && i.StartTime.Date <= Data.EndDate); // Filtering schedule according to export range
@@ -128,7 +128,7 @@ namespace GUT.Schedule
HttpResponseMessage verificationResponse = await client.GetAsync("https://cabs.itut.ru/cabinet/?login=yes");
export.Enabled = true;
IHtmlDocument doc = new HtmlParser().ParseDocument(await verificationResponse.GetString());
if (doc.QuerySelectorAll("nobr").Any(i => i.TextContent.Contains("Ведомости")))
if (doc.QuerySelectorAll("option").Any(i => i.TextContent.Contains("Сотрудник")))
isProf = true;
else
isProf = false;
@@ -142,8 +142,8 @@ namespace GUT.Schedule
// что творится на серверах Бонча (я не шучу, там все ОЧЕНЬ плохо)
// Ну и в-третьих: Андроид - это пиздец и настоящий ад разработчика. И если бы была моя воля, я бы под него никогда не писал #FuckAndroid
// З.Ы. Помнишь про второй пункт? Так вот, если ты используешь такой же пароль как в ЛК где-то еще, настоятельно рекомендую его поменять
PreferenceManager.GetDefaultSharedPreferences(this).Edit().PutBoolean("email", groupTitle.Checked).Apply();
PreferenceManager.GetDefaultSharedPreferences(this).Edit().PutBoolean("password", groupTitle.Checked).Apply();
PreferenceManager.GetDefaultSharedPreferences(this).Edit().PutString("email", email.Text).Apply();
PreferenceManager.GetDefaultSharedPreferences(this).Edit().PutString("password", password.Text).Apply();
}
else
{
@@ -249,13 +249,11 @@ namespace GUT.Schedule
if (e.IsChecked)
{
studentParams.Visibility = ViewStates.Gone;
groupTitle.Visibility = ViewStates.Gone;
profParams.Visibility = ViewStates.Visible;
}
else
{
studentParams.Visibility = ViewStates.Visible;
groupTitle.Visibility = ViewStates.Visible;
profParams.Visibility = ViewStates.Gone;
}
};
+2 -1
View File
@@ -95,7 +95,8 @@ namespace GUT.Schedule
eventValues.Put(CalendarContract.Events.InterfaceConsts.CalendarId, data.Calendar);
eventValues.Put(CalendarContract.Events.InterfaceConsts.Title, string.Format("{0}. {1} ({2})",
eventValues.Put(CalendarContract.Events.InterfaceConsts.Title, string.Format("{0}{1}. {2} ({3})",
item.ProfessorSchedule ? "📚 " : (data.AddGroupToTitle ? $"[{data.Group}] " : ""),
item.Order,
item.Name,
item.Type));
@@ -11,13 +11,15 @@ namespace GUT.Schedule.Models
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public string Opponent { get; set; }
public bool ProfessorSchedule { get; set; }
public CabinetSubject(string name, string type, string cabinet, string opponent, int year, int month, int day, string schedule)
public CabinetSubject(string name, string type, string cabinet, string opponent, int year, int month, int day, string schedule, bool profSchedule)
{
Name = name;
Type = type;
Cabinet = cabinet;
Opponent = opponent;
ProfessorSchedule = profSchedule;
string[] time = schedule.Split('-');
+12 -8
View File
@@ -126,7 +126,7 @@ namespace GUT.Schedule
{
using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, $"https://cabs.itut.ru/cabinet/project/cabinet/forms/{(checkProfSchedule ? "pr_" : "")}raspisanie_kalendar.php");
request.SetContent(
("month", date.Month.ToString("0:00")),
("month", date.Month.ToString()),
("year", date.Year.ToString()),
("type_z", "0"));
@@ -138,19 +138,23 @@ namespace GUT.Schedule
IHtmlDocument doc = new HtmlParser().ParseDocument(responseContent);
List<CabinetSubject> schedule = new List<CabinetSubject>();
foreach(var i in doc.QuerySelectorAll("td").Where(i => i.GetAttribute("style") == "text-align: center; vertical-align: top"))
if(!checkProfSchedule)
Data.DataSet.Group = doc.QuerySelector(".style_gr b").TextContent;
foreach (var i in doc.QuerySelectorAll("td").Where(i => i.GetAttribute("style") == "text-align: center; vertical-align: top"))
for (int k = 0; k < i.QuerySelectorAll("i").Length; k++)
{
CabinetSubject item = new CabinetSubject(
name: i.QuerySelectorAll("b")[k * 2 + 1].TextContent,
type: i.QuerySelectorAll("i")[k].TextContent,
cabinet: i.ChildNodes[k * 13 + 11].TextContent,
opponent: i.ChildNodes[k * 13 + 6].TextContent,
cabinet: i.ChildNodes[checkProfSchedule ? (k * 13 + 12) : (k * 12 + 11)].TextContent,
opponent: i.ChildNodes[checkProfSchedule ? (k * 13 + 7) : (k * 12 + 6)].TextContent,
year: date.Year,
month: date.Month,
day: int.Parse(i.ChildNodes[0].TextContent),
schedule: i.QuerySelectorAll("b")[k * 2 + 2].TextContent
);
schedule: i.QuerySelectorAll("b")[k * 2 + 2].TextContent,
checkProfSchedule);
schedule.Add(item);
}
@@ -161,8 +165,8 @@ namespace GUT.Schedule
schedule[k - 1].Name == schedule[k].Name &&
schedule[k - 1].Type == schedule[k].Type)
{
schedule[k - 1].Opponent += "; " + schedule[k].Opponent;
schedule[k - 1].Cabinet += ";\n" + schedule[k].Cabinet;
schedule[k - 1].Opponent += ";\n" + schedule[k].Opponent;
schedule[k - 1].Cabinet += "; " + schedule[k].Cabinet;
schedule.RemoveAt(k--);
}
@@ -190,6 +190,12 @@
android:layout_height="wrap_content"
android:text="Добавить номер группы в заголовок"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="(i) Не касается расписания преподавателя"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
+5 -1
View File
@@ -1,4 +1,8 @@
Version 1.0.8
- Student now can authorize with SPbSUT Cabinet credential
- Introduced both work and study schedule export for PhD students
- Duplicating schedule entries (when group splits in two) are now mergeg into one
- Duplicating schedule entries (when group splits in two) are now mergeg into one
- Fixed cases when app crashes on the second launch after entered credentials
- Fixed export errors
- Professors' schedule is now marked with 📚
- You can now add your group number to event title when using cabinet authorization