add exams model and page

This commit is contained in:
stubbfel
2013-09-02 16:44:33 +02:00
parent 6276542c6c
commit 557f861774
11 changed files with 410 additions and 28 deletions

View File

@@ -100,6 +100,7 @@
</Compile>
<Compile Include="Feed\Departments\DepartmentFavoriteFeed.cs" />
<Compile Include="Const.cs" />
<Compile Include="Feed\Exams\ExamFeed.cs" />
<Compile Include="Feed\Mensa\MensaFeedSBFMain.cs" />
<Compile Include="Feed\Mensa\MensaFeedCBSouth.cs" />
<Compile Include="Feed\Mensa\MensaFeedCBNorth.cs" />
@@ -108,6 +109,8 @@
<Compile Include="Model\Campusmap\CurrentPositionPinModel.cs" />
<Compile Include="Model\Campusmap\HiddenPinPlaceModel.cs" />
<Compile Include="Model\Campusmap\SearchPlacePinModel.cs" />
<Compile Include="Model\Exams\ExamListModel.cs" />
<Compile Include="Model\Exams\ExamModel.cs" />
<Compile Include="Model\GeoDb\PlaceInformation.cs" />
<Compile Include="Model\GeoDb\PlaceModel.cs" />
<Compile Include="Model\GeoDb\PlaceService.cs" />

View File

@@ -0,0 +1,59 @@
//-----------------------------------------------------------------------
// <copyright file="ExamFeed.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>02.09.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Feed.Exams
{
using System.IO;
using CampusAppWP8.Model;
using CampusAppWP8.Model.Exams;
using CampusAppWP8.Resources;
/// <summary>Exam feed.</summary>
/// <remarks>Stubbfel, 02.09.2013.</remarks>
public class ExamFeed : XmlModel<ExamListModel>
{
/// <summary>Initializes a new instance of the ExamFeed class.</summary>
/// <remarks>Stubbfel, 02.09.2013.</remarks>
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;
}
/// <summary>Check is model up to date.</summary>
/// <remarks>Stubbfel, 02.09.2013.</remarks>
/// <param name="model">The model.</param>
/// <returns>true if it succeeds, false if it fails.</returns>
private bool CheckIsModelUpToDate(ExamListModel model)
{
if (model == null)
{
return false;
}
return true;
}
/// <summary>Check is file up to date.</summary>
/// <remarks>Stubbfel, 02.09.2013.</remarks>
/// <param name="model"> The model.</param>
/// <param name="fileInfo">Information describing the file.</param>
/// <returns>true if it succeeds, false if it fails.</returns>
private bool CheckIsFileUpToDate(ExamListModel model, FileInfo fileInfo)
{
if (fileInfo == null || !fileInfo.Exists || fileInfo.Length < 1)
{
return false;
}
return true;
}
}
}

View File

@@ -0,0 +1,23 @@
//-----------------------------------------------------------------------
// <copyright file="ExamlistModel.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>02.09.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Model.Exams
{
using System.Collections.ObjectModel;
using System.Xml.Serialization;
/// <summary>Exam list model.</summary>
/// <remarks>Stubbfel, 02.09.2013.</remarks>
[XmlRoot("links")]
public class ExamListModel
{
/// <summary>Gets or sets the exams.</summary>
/// <value>The exams.</value>
[XmlElement("link")]
public ObservableCollection<ExamModel> Exams { get; set; }
}
}

View File

@@ -0,0 +1,67 @@
//-----------------------------------------------------------------------
// <copyright file="ExamModel.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>02.09.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Model.Exams
{
using CampusAppWP8.Utility;
using System.Xml.Serialization;
/// <summary>Exam model.</summary>
/// <remarks>Stubbfel, 02.09.2013.</remarks>
public class ExamModel
{
/// <summary>Gets or sets the course number.</summary>
/// <value>The course number.</value>
[XmlAttribute("stg")]
public string CourseNumber { get; set; }
/// <summary>Gets or sets the course text.</summary>
/// <value>The course text.</value>
[XmlAttribute("stgtext")]
public string CourseText { get; set; }
/// <summary>Gets or sets the degree number.</summary>
/// <value>The degree number.</value>
[XmlAttribute("abschl")]
public string DegreeNumber { get; set; }
/// <summary>Gets or sets the version.</summary>
/// <value>The version.</value>
[XmlAttribute("pversion")]
public string Version { get; set; }
/// <summary>Gets or sets the type.</summary>
/// <value>The type.</value>
[XmlAttribute("typ")]
public string Type { get; set; }
/// <summary>Gets or sets the title.</summary>
/// <value>The title.</value>
[XmlAttribute("dtxt")]
public string Title { get; set; }
/// <summary>Gets or sets the date.</summary>
/// <value>The date.</value>
[XmlAttribute("datum")]
public string Date { get; set; }
/// <summary>Gets or sets the link.</summary>
/// <value>The link.</value>
[XmlAttribute("link")]
public string Link { get; set; }
/// <summary>Gets the caption.</summary>
/// <value>The caption.</value>
public string Caption
{
get
{
return StringManager.StripHTML(this.CourseText + " (" + this.Type + "/" + this.Version + ")");
}
}
}
}

View File

@@ -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 @@
<!--LayoutRoot ist das Stammraster, in dem alle anderen Seiteninhalte platziert werden-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel enthält den Namen der Anwendung und den Seitentitel-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="MEINE ANWENDUNG" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="Seitenname" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - zusätzliche Inhalte hier platzieren-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
</Grid>
<ProgressBar Name="ProgressBar" Visibility="Collapsed" IsIndeterminate="True"/>
<phone:Pivot Name="ExamPivot" Title="{Binding Path=LocalizedResources.ExaminationApp_Header, Source={StaticResource LocalizedStrings}}">
<phone:PivotItem Header="{Binding Path=LocalizedResources.Degree_Bachelor, Source={StaticResource LocalizedStrings}}">
<ListBox x:Name="BachelorPanel" ItemsSource="{Binding Value}">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<lui:ToggleButton ToggleContentTag="{Binding Path=Constants.ToggleContent, Source={StaticResource Const}}" Style="{StaticResource ListButtonStyle}">
<TextBlock Text="{Binding Caption}" TextWrapping="Wrap"/>
</lui:ToggleButton>
<StackPanel Tag="{Binding Path=Constants.ToggleContent, Source={StaticResource Const}}" Orientation="Horizontal" HorizontalAlignment="Center" Visibility="Collapsed">
<lui:LinkButton Height="75" Url="{Binding Link}" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</phone:PivotItem>
<phone:PivotItem Header="{Binding Path=LocalizedResources.Degree_Master, Source={StaticResource LocalizedStrings}}">
<ListBox x:Name="MasterPanel" ItemsSource="{Binding Value}">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<lui:ToggleButton ToggleContentTag="{Binding Path=Constants.ToggleContent, Source={StaticResource Const}}" Style="{StaticResource ListButtonStyle}">
<TextBlock Text="{Binding Caption}" TextWrapping="Wrap"/>
</lui:ToggleButton>
<StackPanel Tag="{Binding Path=Constants.ToggleContent, Source={StaticResource Const}}" Orientation="Horizontal" HorizontalAlignment="Center" Visibility="Collapsed">
<lui:LinkButton Height="75" Url="{Binding Link}" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</phone:PivotItem>
<phone:PivotItem Header="{Binding Path=LocalizedResources.Degree_Diploma, Source={StaticResource LocalizedStrings}}">
<ListBox x:Name="DiplomaPanel" ItemsSource="{Binding Value}">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<lui:ToggleButton ToggleContentTag="{Binding Path=Constants.ToggleContent, Source={StaticResource Const}}" Style="{StaticResource ListButtonStyle}">
<TextBlock Text="{Binding Caption}" TextWrapping="Wrap"/>
</lui:ToggleButton>
<StackPanel Tag="{Binding Path=Constants.ToggleContent, Source={StaticResource Const}}" Orientation="Horizontal" HorizontalAlignment="Center" Visibility="Collapsed">
<lui:LinkButton Height="75" Url="{Binding Link}" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</phone:PivotItem>
</phone:Pivot>
</Grid>
</phone:PhoneApplicationPage>

View File

@@ -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;
// <copyright file="Exams.xaml.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>02.09.2013</sience>
//----------------------------------------------------------------------
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;
/// <summary>Exams.</summary>
/// <remarks>Stubbfel, 02.09.2013.</remarks>
public partial class Exams : PhoneApplicationPage
{
/// <summary>The feed.</summary>
private ExamFeed feed;
/// <summary>Initializes a new instance of the Exams class.</summary>
/// <remarks>Stubbfel, 02.09.2013.</remarks>
public Exams()
{
InitializeComponent();
this.InitializeComponent();
this.InitializeFeed();
}
/// <summary>Wird aufgerufen, wenn eine Seite die aktive Seite in einem Frame wird.</summary>
/// <remarks>Stubbfel, 02.09.2013.</remarks>
/// <param name="e">Ein Objekt, das die Ereignisdaten enthält.</param>
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<Model.Exams.ExamListModel>());
}
/// <summary>
/// Wird aufgerufen, wenn eine Seite nicht mehr die aktive Seite in einem Frame ist.
/// </summary>
/// <remarks>Stubbfel, 02.09.2013.</remarks>
/// <param name="e">Ein Objekt, das die Ereignisdaten enthält.</param>
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
if (NavigationMode.Back == e.NavigationMode)
{
this.feed.SaveData();
}
}
/// <summary>Method initialize the Feed.</summary>
/// <remarks>Stubbfel, 02.09.2013.</remarks>
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);
}
/// <summary>Method will be execute if the feed is ready.</summary>
/// <remarks>Stubbfel, 02.09.2013.</remarks>
private void FeedIsReady()
{
this.SetupExamList();
this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed;
}
/// <summary>Sets up the exam list.</summary>
/// <remarks>Stubbfel, 02.09.2013.</remarks>
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();
}
/// <summary>Calculates the selected index.</summary>
/// <remarks>Stubbfel, 02.09.2013.</remarks>
/// <returns>The calculated selected index.</returns>
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;
}
/// <summary>Method will be execute if the feed is failed.</summary>
/// <remarks>Stubbfel, 02.09.2013.</remarks>
private void FeedIsFailWeb()
{
MessageBoxResult result = MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadWeb);
this.feed.ForceReadFile();
}
/// <summary>Method will be execute if the feed is failed.</summary>
/// <remarks>Stubbfel, 02.09.2013.</remarks>
private void FeedIsFailFile()
{
MessageBoxResult result = MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadFile);
this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed;
}
}
}

View File

@@ -222,6 +222,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Prüfungsordnungen ähnelt.
/// </summary>
public static string ExaminationApp_Header {
get {
return ResourceManager.GetString("ExaminationApp_Header", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Prüfungs- ordnungen ähnelt.
/// </summary>

View File

@@ -422,4 +422,7 @@
<data name="ExaminationApp_Title" xml:space="preserve">
<value>Prüfungs- ordnungen</value>
</data>
<data name="ExaminationApp_Header" xml:space="preserve">
<value>Prüfungsordnungen</value>
</data>
</root>

View File

@@ -132,6 +132,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die links ähnelt.
/// </summary>
public static string ExamXmlValidRootName {
get {
return ResourceManager.GetString("ExamXmlValidRootName", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die DepartmentFavoriteFeed.xml ähnelt.
/// </summary>
@@ -159,6 +168,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die examlist.xml ähnelt.
/// </summary>
public static string FileExamApp_ExamFeed {
get {
return ResourceManager.GetString("FileExamApp_ExamFeed", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die ClubLinks.xml ähnelt.
/// </summary>
@@ -825,6 +843,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die https://www.zv.tu-cottbus.de/CMS-Webservice/Pruefungsordnung/Uebersicht ähnelt.
/// </summary>
public static string UrlExamApp_ExamFeed {
get {
return ResourceManager.GetString("UrlExamApp_ExamFeed", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die http://www.zv.tu-cottbus.de/LSFveranst/LSF4 ähnelt.
/// </summary>

View File

@@ -438,4 +438,13 @@
<data name="PathExams_ExamsPage" xml:space="preserve">
<value>/Pages/Exams/Exams.xaml</value>
</data>
<data name="ExamXmlValidRootName" xml:space="preserve">
<value>links</value>
</data>
<data name="FileExamApp_ExamFeed" xml:space="preserve">
<value>examlist.xml</value>
</data>
<data name="UrlExamApp_ExamFeed" xml:space="preserve">
<value>https://www.zv.tu-cottbus.de/CMS-Webservice/Pruefungsordnung/Uebersicht</value>
</data>
</root>

View File

@@ -31,8 +31,9 @@ namespace CampusAppWP8.Utility
/// <param name="inputString">String with Html-Tags</param>
/// <returns>String without Html-Tags</returns>
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);
}
/// <summary>