diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 1095c1f1..78353d3f 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -100,6 +100,7 @@ + @@ -108,6 +109,8 @@ + + diff --git a/CampusAppWP8/CampusAppWP8/Feed/Exams/ExamFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Exams/ExamFeed.cs new file mode 100644 index 00000000..c2dc6ccb --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Feed/Exams/ExamFeed.cs @@ -0,0 +1,59 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 02.09.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Feed.Exams +{ + using System.IO; + using CampusAppWP8.Model; + using CampusAppWP8.Model.Exams; + using CampusAppWP8.Resources; + + /// Exam feed. + /// Stubbfel, 02.09.2013. + public class ExamFeed : XmlModel + { + /// Initializes a new instance of the ExamFeed class. + /// Stubbfel, 02.09.2013. + public ExamFeed() + : base(ModelType.FileAndFeed, Constants.FileExamApp_ExamFeed, Constants.UrlExamApp_ExamFeed) + { + this.IsFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate); + this.IsModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate); + this.IsFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate); + this.ValidRootName = Constants.ExamXmlValidRootName; + } + + /// Check is model up to date. + /// Stubbfel, 02.09.2013. + /// The model. + /// true if it succeeds, false if it fails. + private bool CheckIsModelUpToDate(ExamListModel model) + { + if (model == null) + { + return false; + } + + return true; + } + + /// Check is file up to date. + /// Stubbfel, 02.09.2013. + /// The model. + /// Information describing the file. + /// true if it succeeds, false if it fails. + private bool CheckIsFileUpToDate(ExamListModel model, FileInfo fileInfo) + { + if (fileInfo == null || !fileInfo.Exists || fileInfo.Length < 1) + { + return false; + } + + return true; + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/Exams/ExamListModel.cs b/CampusAppWP8/CampusAppWP8/Model/Exams/ExamListModel.cs new file mode 100644 index 00000000..12cbb196 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Exams/ExamListModel.cs @@ -0,0 +1,23 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 02.09.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Model.Exams +{ + using System.Collections.ObjectModel; + using System.Xml.Serialization; + + /// Exam list model. + /// Stubbfel, 02.09.2013. + [XmlRoot("links")] + public class ExamListModel + { + /// Gets or sets the exams. + /// The exams. + [XmlElement("link")] + public ObservableCollection Exams { get; set; } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/Exams/ExamModel.cs b/CampusAppWP8/CampusAppWP8/Model/Exams/ExamModel.cs new file mode 100644 index 00000000..5b68c879 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Exams/ExamModel.cs @@ -0,0 +1,67 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 02.09.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Model.Exams +{ + using CampusAppWP8.Utility; + using System.Xml.Serialization; + + /// Exam model. + /// Stubbfel, 02.09.2013. + public class ExamModel + { + /// Gets or sets the course number. + /// The course number. + [XmlAttribute("stg")] + public string CourseNumber { get; set; } + + /// Gets or sets the course text. + /// The course text. + [XmlAttribute("stgtext")] + public string CourseText { get; set; } + + /// Gets or sets the degree number. + /// The degree number. + [XmlAttribute("abschl")] + public string DegreeNumber { get; set; } + + /// Gets or sets the version. + /// The version. + [XmlAttribute("pversion")] + public string Version { get; set; } + + /// Gets or sets the type. + /// The type. + [XmlAttribute("typ")] + public string Type { get; set; } + + /// Gets or sets the title. + /// The title. + [XmlAttribute("dtxt")] + public string Title { get; set; } + + /// Gets or sets the date. + /// The date. + [XmlAttribute("datum")] + public string Date { get; set; } + + /// Gets or sets the link. + /// The link. + [XmlAttribute("link")] + public string Link { get; set; } + + /// Gets the caption. + /// The caption. + public string Caption + { + get + { + return StringManager.StripHTML(this.CourseText + " (" + this.Type + "/" + this.Version + ")"); + } + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml b/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml index 04231637..d8774e03 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml @@ -6,6 +6,7 @@ xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:lui="clr-namespace:CampusAppWP8.Utility.Lui.Button" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" @@ -15,21 +16,75 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs index e66731e7..1fec754a 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs @@ -1,20 +1,146 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Navigation; -using Microsoft.Phone.Controls; -using Microsoft.Phone.Shell; - +// +// Company copyright tag. +// +// stubbfel +// 02.09.2013 +//---------------------------------------------------------------------- namespace CampusAppWP8.Pages.Exams { + using System.Linq; + using System.Windows; + using System.Windows.Navigation; + using CampusAppWP8.Feed.Exams; + using CampusAppWP8.Resources; + using CampusAppWP8.Utility; + using CampusAppWP8.Utility.Lui.MessageBoxes; + using Microsoft.Phone.Controls; + + /// Exams. + /// Stubbfel, 02.09.2013. public partial class Exams : PhoneApplicationPage { + /// The feed. + private ExamFeed feed; + + /// Initializes a new instance of the Exams class. + /// Stubbfel, 02.09.2013. public Exams() { - InitializeComponent(); + this.InitializeComponent(); + this.InitializeFeed(); + } + + /// Wird aufgerufen, wenn eine Seite die aktive Seite in einem Frame wird. + /// Stubbfel, 02.09.2013. + /// Ein Objekt, das die Ereignisdaten enthält. + protected override void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + if (this.feed == null) + { + this.InitializeFeed(); + } + + this.ProgressBar.Visibility = System.Windows.Visibility.Visible; + this.feed.LoadData(Utilities.getLoadModus()); + } + + /// + /// Wird aufgerufen, wenn eine Seite nicht mehr die aktive Seite in einem Frame ist. + /// + /// Stubbfel, 02.09.2013. + /// Ein Objekt, das die Ereignisdaten enthält. + protected override void OnNavigatedFrom(NavigationEventArgs e) + { + if (NavigationMode.Back == e.NavigationMode) + { + this.feed.SaveData(); + } + } + + /// Method initialize the Feed. + /// Stubbfel, 02.09.2013. + private void InitializeFeed() + { + this.feed = new ExamFeed(); + this.feed.OnLoaded += new ExamFeed.OnIO(this.FeedIsReady); + this.feed.OnFailedWeb += new ExamFeed.OnFailed(this.FeedIsFailWeb); + this.feed.OnFailedFile += new ExamFeed.OnFailed(this.FeedIsFailFile); + } + + /// Method will be execute if the feed is ready. + /// Stubbfel, 02.09.2013. + private void FeedIsReady() + { + this.SetupExamList(); + this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; + } + + /// Sets up the exam list. + /// Stubbfel, 02.09.2013. + private void SetupExamList() + { + var bachelorList = from exam in this.feed.Model.Exams + where exam.DegreeNumber.Equals(((int)CampusAppWP8.Model.Setting.UserProfilModel.DegreeType.BACHELOR).ToString()) + orderby exam.CourseText, exam.Version + select exam; + + var masterList = from exam in this.feed.Model.Exams + where exam.DegreeNumber.Equals(((int)CampusAppWP8.Model.Setting.UserProfilModel.DegreeType.MASTER).ToString()) + orderby exam.CourseText, exam.Version + select exam; + + var diplomaList = from exam in this.feed.Model.Exams + where exam.DegreeNumber.Equals(((int)CampusAppWP8.Model.Setting.UserProfilModel.DegreeType.DIPLOM).ToString()) + orderby exam.CourseText, exam.Version + select exam; + + this.BachelorPanel.ItemsSource = bachelorList; + this.MasterPanel.ItemsSource = masterList; + this.DiplomaPanel.ItemsSource = diplomaList; + this.ExamPivot.SelectedIndex = this.CalcSelectedIndex(); + } + + /// Calculates the selected index. + /// Stubbfel, 02.09.2013. + /// The calculated selected index. + private int CalcSelectedIndex() + { + int result = 0; + Model.Setting.UserProfilModel.DegreeType degree = Settings.UserProfil.Degree; + + switch (degree) + { + case Model.Setting.UserProfilModel.DegreeType.BACHELOR: + result = 0; + break; + case Model.Setting.UserProfilModel.DegreeType.MASTER: + result = 1; + break; + case Model.Setting.UserProfilModel.DegreeType.DIPLOM: + result = 2; + break; + default: + result = 0; + break; + } + return result; + } + + /// Method will be execute if the feed is failed. + /// Stubbfel, 02.09.2013. + private void FeedIsFailWeb() + { + MessageBoxResult result = MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadWeb); + this.feed.ForceReadFile(); + } + + /// Method will be execute if the feed is failed. + /// Stubbfel, 02.09.2013. + private void FeedIsFailFile() + { + MessageBoxResult result = MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadFile); + this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; } } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs index 06891e9a..86a670dd 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs @@ -222,6 +222,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Prüfungsordnungen ähnelt. + /// + public static string ExaminationApp_Header { + get { + return ResourceManager.GetString("ExaminationApp_Header", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Prüfungs- ordnungen ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx index 2a71e34a..43dcd186 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx @@ -422,4 +422,7 @@ Prüfungs- ordnungen + + Prüfungsordnungen + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs index c4d59f0c..bc4f1e44 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs @@ -132,6 +132,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die links ähnelt. + /// + public static string ExamXmlValidRootName { + get { + return ResourceManager.GetString("ExamXmlValidRootName", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die DepartmentFavoriteFeed.xml ähnelt. /// @@ -159,6 +168,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die examlist.xml ähnelt. + /// + public static string FileExamApp_ExamFeed { + get { + return ResourceManager.GetString("FileExamApp_ExamFeed", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die ClubLinks.xml ähnelt. /// @@ -825,6 +843,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die https://www.zv.tu-cottbus.de/CMS-Webservice/Pruefungsordnung/Uebersicht ähnelt. + /// + public static string UrlExamApp_ExamFeed { + get { + return ResourceManager.GetString("UrlExamApp_ExamFeed", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die http://www.zv.tu-cottbus.de/LSFveranst/LSF4 ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index 999143ae..cedfe545 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -438,4 +438,13 @@ /Pages/Exams/Exams.xaml + + links + + + examlist.xml + + + https://www.zv.tu-cottbus.de/CMS-Webservice/Pruefungsordnung/Uebersicht + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/StringManager.cs b/CampusAppWP8/CampusAppWP8/Utility/StringManager.cs index 2ead4228..2181dd89 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/StringManager.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/StringManager.cs @@ -31,8 +31,9 @@ namespace CampusAppWP8.Utility /// String with Html-Tags /// String without Html-Tags public static string StripHTML(string inputString) - { - return Regex.Replace(inputString, HtmlTagPattern, string.Empty); + { + string result = Regex.Replace(inputString, HtmlTagPattern, string.Empty); + return System.Net.HttpUtility.HtmlDecode(result); } ///