/// <summary> /// Get a Timetable for a given Element /// </summary> /// <param name="elementId">The ID of the Element</param> /// <param name="elementType">The type of the Element (1 = klasse, 2 = teacher, 3 = subject, 4 = room, 5 = student)</param> /// <param name="startDate">The Start Date of the Timetable</param> /// <param name="endDate">The End Date of the Timetable</param> /// <returns>The returned Timetable</returns> public async Task <TimetableResult> GetTimetableForElement(int elementId, int elementType, long startDate, long endDate) { //Get the JSON TimetableForElement timetable = new TimetableForElement() { @params = new TimetableForElement.Params() { id = elementId, type = elementType, startDate = startDate, endDate = endDate } }; //Send and receive JSON from WebUntis string requestJson = JsonConvert.SerializeObject(timetable); string responseJson = await SendJsonAndWait(requestJson, _url, SessionId); //Parse JSON to Class TimetableResult result = JsonConvert.DeserializeObject <TimetableResult>(responseJson); string errorMsg = wus.LastError.Message; if (!SuppressErrors && errorMsg != null) { Logger.Append(Logger.LogLevel.Error, errorMsg); throw new WebUntisException(errorMsg); } //Return the Timetable for the Element return(result); }
private void btnSearch_Click(object sender, EventArgs e) { if (!firstCityValid && !secondCityValid) { if (!secondCityValid) { this.ActiveControl = secondCity; secondCityError.SetError(secondCity, "Podana stacja nie istnieje w naszej bazie"); } if (!firstCityValid) { this.ActiveControl = firstCity; firstCityError.SetError(firstCity, "Podana stacja nie istnieje w naszej bazie"); } } else { timetable = DataBase.FindRoute(firstCity.Text, secondCity.Text, new StationTime(dateTime.Value.Hour, dateTime.Value.Minute), dateDate.Value.Day % 7); if (timetable != null) { timetableSearchResult1.FullfillLabels(timetable); timetableSearchResult1.Visible = true; timetableSearchResult1.BringToFront(); exit.Visible = true; btnRaport.Visible = true; exit.BringToFront(); btnRaport.BringToFront(); } else { MessageBox.Show("Przepraszamy ale nie udalo się znaleźć pociągu dla podanego połączenia"); } } }
private void exit_Click(object sender, EventArgs e) { timetableSearchResult1.Visible = false; exit.Visible = false; btnRaport.Visible = false; timetableSearchResult1.Reset(); timetable = null; }
public void FullfillLabels(TimetableResult timetable) { for (int i = 0; i < timetable.timetable.Count; i++) { labels[i][0].Text = DataBase.trains.Find(x => x.TrainID == timetable.timetable[i].TrainID).ToString(); labels[i][1].Text = timetable.timetable[i].Hours.Find(x => x.StationID == timetable.startStationID).ToString(); labels[i][2].Text = timetable.timetable[i].Hours.Find(x => x.StationID == timetable.endStationID).ToString(); backs[i].Visible = true; } }
public void Reset() { firstCity.Text = ""; secondCity.Text = ""; firstCityValid = false; secondCityValid = false; firstCityError.SetError(firstCity, ""); secondCityError.SetError(secondCity, ""); timetableSearchResult1.Visible = false; timetableSearchResult1.Reset(); exit.Visible = false; btnRaport.Visible = false; dateDate.Value = DateTime.Now; dateTime.Value = DateTime.Now; timetable = null; }