add Api to LecturePage
This commit is contained in:
@@ -111,11 +111,11 @@
|
||||
<Compile Include="Model\Lecture\LectureModule.cs" />
|
||||
<Compile Include="Model\Mensa\MenuModel.cs" />
|
||||
<Compile Include="Model\Mensa\MenuWeekModel.cs" />
|
||||
<Compile Include="Model\Utility\URLParamModel.cs" />
|
||||
<Compile Include="Model\Utility\UrlParamModel.cs" />
|
||||
<Compile Include="Pages\Campusmap\CampusMapPage.xaml.cs">
|
||||
<DependentUpon>CampusMapPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Feed\Lecture\LectureFeed.cs" />
|
||||
<Compile Include="Feed\Lecture\LectureApi.cs" />
|
||||
<Compile Include="Feed\Departments\DepartmentFeed.cs" />
|
||||
<Compile Include="Pages\Departments\DepartmentPage.xaml.cs">
|
||||
<DependentUpon>DepartmentPage.xaml</DependentUpon>
|
||||
|
||||
33
CampusAppWP8/CampusAppWP8/Feed/Lecture/LectureApi.cs
Normal file
33
CampusAppWP8/CampusAppWP8/Feed/Lecture/LectureApi.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="LectureFeed.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>13.06.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Feed.Lecture
|
||||
{
|
||||
using System;
|
||||
using CampusAppWP8.Model.Lecture;
|
||||
using CampusAppWP8.Utility;
|
||||
using CampusAppWP8.Resources;
|
||||
|
||||
/// <summary>
|
||||
/// Class for the feed of the Lecture
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// need the XmlAPI
|
||||
/// </remarks>
|
||||
public class LectureApi : XmlApi<LectureList>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LectureApi" /> class.
|
||||
/// </summary>
|
||||
/// <param name="url">the RequestUrl</param>
|
||||
public LectureApi()
|
||||
: base(new Uri(Constants.UrlLectureApiBaseAddr))
|
||||
{
|
||||
this.validRootName = "lsf_auszug";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="LectureFeed.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>13.06.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Feed.Lecture
|
||||
{
|
||||
using System;
|
||||
using CampusAppWP8.Model.Lecture;
|
||||
using CampusAppWP8.Utility;
|
||||
|
||||
/// <summary>
|
||||
/// Class for the feed of the Lecture
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// need the XmlAPI
|
||||
/// </remarks>
|
||||
public class LectureFeed : XmlFeed<LectureList>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LectureFeed" /> class.
|
||||
/// </summary>
|
||||
/// <param name="url">the RequestUrl</param>
|
||||
public LectureFeed(Uri url)
|
||||
: base(url, "Lecture.xml")
|
||||
{
|
||||
this.validRootName = "lsf_auszug";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method create the RequestUrl
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// have to refactors
|
||||
/// </remarks>
|
||||
/// <param name="semester">value of the semester</param>
|
||||
/// <param name="degree">value of the degree</param>
|
||||
/// <param name="course">value of the course</param>
|
||||
/// <param name="from">value of the from</param>
|
||||
/// <param name="to">value of the to</param>
|
||||
/// <returns>return the requestUrl</returns>
|
||||
public static Uri CreateFeedUrl(string semester, string degree, string course, string from, string to)
|
||||
{
|
||||
return new Uri("http://www.zv.tu-cottbus.de/LSFveranst/LSF4?Semester=" + semester + "&Abschluss=" + degree + "&Studiengang=" + course + "&Von=" + from + "&Bis=" + to);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method implement CheckIsModelUpToDate()-Method <see cref="Pages"/>
|
||||
/// </summary>
|
||||
/// <returns>true, if model is up-to-date, otherwise false</returns>
|
||||
protected override bool CheckIsModelUpToDate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method implement CheckIsFileUpToDate()-Method <see cref="Pages"/>
|
||||
/// </summary>
|
||||
/// <returns>true, if file is up-to-date, otherwise false</returns>
|
||||
protected override bool CheckIsFileUpToDate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ namespace CampusAppWP8.Pages.Lecture
|
||||
/// <summary>
|
||||
/// actual LectureFeed
|
||||
/// </summary>
|
||||
private LectureFeed feed;
|
||||
private LectureApi api;
|
||||
|
||||
/// <summary>
|
||||
/// List for the courses of the BTU
|
||||
@@ -141,25 +141,37 @@ namespace CampusAppWP8.Pages.Lecture
|
||||
/// <param name="sender">sender of this event</param>
|
||||
/// <param name="e"> events arguments</param>
|
||||
private void SendRequest(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.api = new LectureApi();
|
||||
this.api.EventHandler.ApiIsReadyEvent += new ApiEventHandler.ApiReadyHandler(this.ApiIsReady);
|
||||
this.ProgressBar.Visibility = System.Windows.Visibility.Visible;
|
||||
List<UrlParamModel> parameterList = this.CreateUrlParameter();
|
||||
this.api.XMLHttpGet(parameterList);
|
||||
}
|
||||
|
||||
private List<UrlParamModel> CreateUrlParameter()
|
||||
{
|
||||
ListPickerItemModel semester = (ListPickerItemModel)this.Semester.SelectedItem;
|
||||
ListPickerItemModel degree = (ListPickerItemModel)this.Degree.SelectedItem;
|
||||
ListPickerItemModel course = (ListPickerItemModel)this.Course.SelectedItem;
|
||||
ListPickerItemModel from = (ListPickerItemModel)this.From.SelectedItem;
|
||||
ListPickerItemModel to = (ListPickerItemModel)this.To.SelectedItem;
|
||||
Uri request = LectureFeed.CreateFeedUrl(semester.Value, degree.Value, course.Value, from.Value, to.Value);
|
||||
this.feed = new LectureFeed(request);
|
||||
this.feed.EventHandler.FeedIsReadyEvent += new FeedEventHandler.FeedReadyHandler(this.FeedIsReady);
|
||||
this.ProgressBar.Visibility = System.Windows.Visibility.Visible;
|
||||
this.feed.LoadFeed();
|
||||
}
|
||||
|
||||
List<UrlParamModel> parameterList = new List<UrlParamModel>();
|
||||
parameterList.Add(new UrlParamModel("Semester",semester.Value));
|
||||
parameterList.Add(new UrlParamModel("Abschluss", degree.Value));
|
||||
parameterList.Add(new UrlParamModel("Studiengang", course.Value));
|
||||
parameterList.Add(new UrlParamModel("Von", from.Value));
|
||||
parameterList.Add(new UrlParamModel("Bis", to.Value));
|
||||
return parameterList;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Method will be execute if the feed is ready
|
||||
/// </summary>
|
||||
private void FeedIsReady()
|
||||
private void ApiIsReady()
|
||||
{
|
||||
App.SaveToIsolatedStorage<LectureList>(Constants.IsolatedStorageLectureModel, this.feed.Model);
|
||||
App.SaveToIsolatedStorage<LectureList>(Constants.IsolatedStorageLectureModel, this.api.Model);
|
||||
this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed;
|
||||
Uri url = new Uri(Constants.PathResultPage, UriKind.Relative);
|
||||
NavigationService.Navigate(url);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<Capability Name="ID_CAP_ISV_CAMERA" />
|
||||
</Capabilities>
|
||||
<Tasks>
|
||||
<DefaultTask Name="_default" NavigationPage="pages/StartPage.xaml" />
|
||||
<DefaultTask Name="_default" NavigationPage="pages/Lecture/LecturePage.xaml" />
|
||||
</Tasks>
|
||||
<Tokens>
|
||||
<PrimaryToken TokenID="CampusAppWP8Token" TaskName="_default">
|
||||
|
||||
@@ -123,6 +123,15 @@ namespace CampusAppWP8.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die http://www.zv.tu-cottbus.de/LSFveranst/LSF4 ähnelt.
|
||||
/// </summary>
|
||||
internal static string UrlLectureApiBaseAddr {
|
||||
get {
|
||||
return ResourceManager.GetString("UrlLectureApiBaseAddr", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die https://www.tu-cottbus.de/modul/ ähnelt.
|
||||
/// </summary>
|
||||
|
||||
@@ -147,4 +147,7 @@
|
||||
<data name="PathResultPage" xml:space="preserve">
|
||||
<value>/Pages/Lecture/ResultPage.xaml</value>
|
||||
</data>
|
||||
<data name="UrlLectureApiBaseAddr" xml:space="preserve">
|
||||
<value>http://www.zv.tu-cottbus.de/LSFveranst/LSF4</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -7,7 +7,9 @@
|
||||
//----------------------------------------------------------------------using System;
|
||||
namespace CampusAppWP8.Utility
|
||||
{
|
||||
using CampusAppWP8.Model.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
|
||||
/// <summary>
|
||||
@@ -60,6 +62,21 @@ namespace CampusAppWP8.Utility
|
||||
this.client.DownloadStringAsync(url);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method create the Url for the http-get-method
|
||||
/// </summary>
|
||||
/// <param name="parameters"> list of parameters</param>
|
||||
/// <returns></returns>
|
||||
public Uri CreateGetUrl(List<UrlParamModel> parameters)
|
||||
{
|
||||
string paramterStr = string.Empty;
|
||||
foreach(UrlParamModel parameter in parameters){
|
||||
paramterStr += parameter.ToString();
|
||||
}
|
||||
string getUrlStr = client.BaseAddress + "?" + paramterStr;
|
||||
return new Uri(getUrlStr, UriKind.Absolute);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method realize the http-delete-method
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using CampusAppWP8.Resources;
|
||||
using CampusAppWP8.Model.Utility;
|
||||
using CampusAppWP8.Resources;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -76,6 +77,17 @@ namespace CampusAppWP8.Utility
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Method realize the http-get-method resource
|
||||
/// </summary>
|
||||
/// <param name="url">Url of the resource</param>
|
||||
/// <param name="action">callback method</param>
|
||||
public void XMLHttpGet(List<UrlParamModel> parameters)
|
||||
{
|
||||
Uri getUrl = this.CreateGetUrl(parameters);
|
||||
this.HttpGet(getUrl, this.DownloadCompleted);
|
||||
}
|
||||
/// <summary>
|
||||
/// Method create the model of the feed
|
||||
/// </summary>
|
||||
@@ -95,7 +107,7 @@ namespace CampusAppWP8.Utility
|
||||
/// Method implement the deserialization a Xml-feed
|
||||
/// </summary>
|
||||
/// <param name="feedString">content of the feed</param>
|
||||
protected override void Deserialization(string feedString)
|
||||
protected void Deserialization(string feedString)
|
||||
{
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(T));
|
||||
XDocument document = XDocument.Parse(feedString);
|
||||
|
||||
Reference in New Issue
Block a user