diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 190ec908..ed296e29 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -111,11 +111,11 @@ - + CampusMapPage.xaml - + DepartmentPage.xaml diff --git a/CampusAppWP8/CampusAppWP8/Feed/Lecture/LectureApi.cs b/CampusAppWP8/CampusAppWP8/Feed/Lecture/LectureApi.cs new file mode 100644 index 00000000..3f80c5e2 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Feed/Lecture/LectureApi.cs @@ -0,0 +1,33 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 13.06.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Feed.Lecture +{ + using System; + using CampusAppWP8.Model.Lecture; + using CampusAppWP8.Utility; + using CampusAppWP8.Resources; + + /// + /// Class for the feed of the Lecture + /// + /// + /// need the XmlAPI + /// + public class LectureApi : XmlApi + { + /// + /// Initializes a new instance of the class. + /// + /// the RequestUrl + public LectureApi() + : base(new Uri(Constants.UrlLectureApiBaseAddr)) + { + this.validRootName = "lsf_auszug"; + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Feed/Lecture/LectureFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Lecture/LectureFeed.cs deleted file mode 100644 index b635d51b..00000000 --- a/CampusAppWP8/CampusAppWP8/Feed/Lecture/LectureFeed.cs +++ /dev/null @@ -1,67 +0,0 @@ -//----------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 13.06.2013 -//---------------------------------------------------------------------- -namespace CampusAppWP8.Feed.Lecture -{ - using System; - using CampusAppWP8.Model.Lecture; - using CampusAppWP8.Utility; - - /// - /// Class for the feed of the Lecture - /// - /// - /// need the XmlAPI - /// - public class LectureFeed : XmlFeed - { - /// - /// Initializes a new instance of the class. - /// - /// the RequestUrl - public LectureFeed(Uri url) - : base(url, "Lecture.xml") - { - this.validRootName = "lsf_auszug"; - } - - /// - /// Method create the RequestUrl - /// - /// - /// have to refactors - /// - /// value of the semester - /// value of the degree - /// value of the course - /// value of the from - /// value of the to - /// return the requestUrl - 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); - } - - /// - /// Method implement CheckIsModelUpToDate()-Method - /// - /// true, if model is up-to-date, otherwise false - protected override bool CheckIsModelUpToDate() - { - return false; - } - - /// - /// Method implement CheckIsFileUpToDate()-Method - /// - /// true, if file is up-to-date, otherwise false - protected override bool CheckIsFileUpToDate() - { - return false; - } - } -} diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs index f88b2de0..9602344f 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs @@ -26,7 +26,7 @@ namespace CampusAppWP8.Pages.Lecture /// /// actual LectureFeed /// - private LectureFeed feed; + private LectureApi api; /// /// List for the courses of the BTU @@ -141,25 +141,37 @@ namespace CampusAppWP8.Pages.Lecture /// sender of this event /// events arguments 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 parameterList = this.CreateUrlParameter(); + this.api.XMLHttpGet(parameterList); + } + + private List 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 parameterList = new List(); + 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; + + } /// /// Method will be execute if the feed is ready /// - private void FeedIsReady() + private void ApiIsReady() { - App.SaveToIsolatedStorage(Constants.IsolatedStorageLectureModel, this.feed.Model); + App.SaveToIsolatedStorage(Constants.IsolatedStorageLectureModel, this.api.Model); this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; Uri url = new Uri(Constants.PathResultPage, UriKind.Relative); NavigationService.Navigate(url); diff --git a/CampusAppWP8/CampusAppWP8/Properties/WMAppManifest.xml b/CampusAppWP8/CampusAppWP8/Properties/WMAppManifest.xml index f4b319d3..b65e09d5 100644 --- a/CampusAppWP8/CampusAppWP8/Properties/WMAppManifest.xml +++ b/CampusAppWP8/CampusAppWP8/Properties/WMAppManifest.xml @@ -13,7 +13,7 @@ - + diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs index 89fc3666..9171dccc 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs @@ -123,6 +123,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die http://www.zv.tu-cottbus.de/LSFveranst/LSF4 ähnelt. + /// + internal static string UrlLectureApiBaseAddr { + get { + return ResourceManager.GetString("UrlLectureApiBaseAddr", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die https://www.tu-cottbus.de/modul/ ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index 6ec52b15..cbf64ad2 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -147,4 +147,7 @@ /Pages/Lecture/ResultPage.xaml + + http://www.zv.tu-cottbus.de/LSFveranst/LSF4 + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/RestApi.cs b/CampusAppWP8/CampusAppWP8/Utility/RestApi.cs index f179c448..1b61a137 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/RestApi.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/RestApi.cs @@ -7,7 +7,9 @@ //----------------------------------------------------------------------using System; namespace CampusAppWP8.Utility { + using CampusAppWP8.Model.Utility; using System; + using System.Collections.Generic; using System.Net; /// @@ -60,6 +62,21 @@ namespace CampusAppWP8.Utility this.client.DownloadStringAsync(url); } + /// + /// Method create the Url for the http-get-method + /// + /// list of parameters + /// + public Uri CreateGetUrl(List parameters) + { + string paramterStr = string.Empty; + foreach(UrlParamModel parameter in parameters){ + paramterStr += parameter.ToString(); + } + string getUrlStr = client.BaseAddress + "?" + paramterStr; + return new Uri(getUrlStr, UriKind.Absolute); + } + /// /// Method realize the http-delete-method /// diff --git a/CampusAppWP8/CampusAppWP8/Utility/XmlApi.cs b/CampusAppWP8/CampusAppWP8/Utility/XmlApi.cs index fc700f3c..64218571 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/XmlApi.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/XmlApi.cs @@ -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 } } + + /// + /// Method realize the http-get-method resource + /// + /// Url of the resource + /// callback method + public void XMLHttpGet(List parameters) + { + Uri getUrl = this.CreateGetUrl(parameters); + this.HttpGet(getUrl, this.DownloadCompleted); + } /// /// Method create the model of the feed /// @@ -95,7 +107,7 @@ namespace CampusAppWP8.Utility /// Method implement the deserialization a Xml-feed /// /// content of the feed - protected override void Deserialization(string feedString) + protected void Deserialization(string feedString) { XmlSerializer serializer = new XmlSerializer(typeof(T)); XDocument document = XDocument.Parse(feedString);