diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj
index 8a4bfa58..1c76561c 100644
--- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj
+++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj
@@ -212,6 +212,7 @@
+
diff --git a/CampusAppWP8/CampusAppWP8/Feed/Link/ClubLinkFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Link/ClubLinkFeed.cs
index 76f9d279..d6a0b9af 100644
--- a/CampusAppWP8/CampusAppWP8/Feed/Link/ClubLinkFeed.cs
+++ b/CampusAppWP8/CampusAppWP8/Feed/Link/ClubLinkFeed.cs
@@ -12,6 +12,7 @@ namespace CampusAppWP8.Feed.Link
using CampusAppWP8.Model;
using CampusAppWP8.Model.Link;
using CampusAppWP8.Resources;
+ using CampusAppWP8.Utility;
///
/// This Class is for ClubLinkFeeds
@@ -26,8 +27,8 @@ namespace CampusAppWP8.Feed.Link
public ClubLinkFeed()
: base(ModelType.FileAndFeed, Constants.FileLink_ClubLinks, Constants.UrlLink_ClubLinks)
{
- this.isFileUpToDate += new IsFileUpToDate(this.CheckIsFileUpToDate);
- this.isModelUpToDate += new IsModelUpToDate(this.CheckIsModelUpToDate);
+ this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
+ this.isModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
}
#endregion
@@ -58,7 +59,7 @@ namespace CampusAppWP8.Feed.Link
/// reference of the FeedModel
/// info about the file
/// true, if file is up-to-date, otherwise false
- private bool CheckIsFileUpToDate(LinkListModel model, FileInfo fileInfo)
+ private bool CheckIsFileUpToDateOnLoad(LinkListModel model, FileInfo fileInfo)
{
DateTime lastModified = fileInfo.LastWriteTime;
return this.CheckIsUpToDate(lastModified);
@@ -71,16 +72,7 @@ namespace CampusAppWP8.Feed.Link
/// true, if is up-to-date, otherwise false
private bool CheckIsUpToDate(DateTime lastModified)
{
- DateTime temp = lastModified.AddDays(1);
-
- int diff = temp.CompareTo(DateTime.Now);
-
- if (diff < 0)
- {
- return false;
- }
-
- return true;
+ return Utilities.DayDifference(Utilities.DifferenceType.Less, lastModified, 7.0);
}
#endregion
diff --git a/CampusAppWP8/CampusAppWP8/Feed/Link/CommonLinkFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Link/CommonLinkFeed.cs
index 35c1db36..721c5fc3 100644
--- a/CampusAppWP8/CampusAppWP8/Feed/Link/CommonLinkFeed.cs
+++ b/CampusAppWP8/CampusAppWP8/Feed/Link/CommonLinkFeed.cs
@@ -12,6 +12,7 @@ namespace CampusAppWP8.Feed.Link
using CampusAppWP8.Model;
using CampusAppWP8.Model.Link;
using CampusAppWP8.Resources;
+ using CampusAppWP8.Utility;
///
/// This Class is for CommonLinkFeeds
@@ -26,8 +27,9 @@ namespace CampusAppWP8.Feed.Link
public CommonLinkFeed()
: base(ModelType.FileAndFeed, Constants.FileLink_CommonLinks, Constants.UrlLink_CommonLinks)
{
- this.isFileUpToDate += new IsFileUpToDate(this.CheckIsFileUpToDate);
- this.isModelUpToDate += new IsModelUpToDate(this.CheckIsModelUpToDate);
+ this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
+ this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
+ this.isModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
}
#endregion
@@ -58,7 +60,7 @@ namespace CampusAppWP8.Feed.Link
/// reference of the FeedModel
/// info about the file
/// true, if file is up-to-date, otherwise false
- private bool CheckIsFileUpToDate(LinkListModel model, FileInfo fileInfo)
+ private bool CheckIsFileUpToDateOnLoad(LinkListModel model, FileInfo fileInfo)
{
DateTime lastModified = fileInfo.LastWriteTime;
return this.CheckIsUpToDate(lastModified);
@@ -71,16 +73,7 @@ namespace CampusAppWP8.Feed.Link
/// true, if is up-to-date, otherwise false
private bool CheckIsUpToDate(DateTime lastModified)
{
- DateTime temp = lastModified.AddDays(1);
-
- int diff = temp.CompareTo(DateTime.Now);
-
- if (diff < 0)
- {
- return false;
- }
-
- return true;
+ return Utilities.DayDifference(Utilities.DifferenceType.Less, lastModified, 7.0);
}
#endregion
diff --git a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeed.cs
index 265d1aca..9a1a2886 100644
--- a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeed.cs
+++ b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeed.cs
@@ -12,6 +12,7 @@ namespace CampusAppWP8.Feed.Mensa
using CampusAppWP8.Model;
using CampusAppWP8.Model.Mensa;
using CampusAppWP8.Resources;
+ using CampusAppWP8.Utility;
///
/// This Class is for MensaFeeds
@@ -26,8 +27,8 @@ namespace CampusAppWP8.Feed.Mensa
public MensaFeed()
: base(ModelType.FileAndFeed, Constants.FileMensa_Shedule, Constants.UrlMensa_Week)
{
- this.isFileUpToDate += new IsFileUpToDate(this.CheckIsFileUpToDate);
- this.isModelUpToDate += new IsModelUpToDate(this.CheckIsModelUpToDate);
+ this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
+ this.isModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
}
#endregion
@@ -58,7 +59,7 @@ namespace CampusAppWP8.Feed.Mensa
/// reference of the FeedModel
/// info about the file
/// true, if file is up-to-date, otherwise false
- private bool CheckIsFileUpToDate(MenuWeekModel model, FileInfo fileInfo)
+ private bool CheckIsFileUpToDateOnLoad(MenuWeekModel model, FileInfo fileInfo)
{
DateTime lastModified = fileInfo.LastWriteTime;
return this.CheckIsUpToDate(lastModified);
@@ -81,6 +82,7 @@ namespace CampusAppWP8.Feed.Mensa
return true;
}
+
#endregion
#endregion
diff --git a/CampusAppWP8/CampusAppWP8/Feed/StudentCouncil/StudentCouncilFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/StudentCouncil/StudentCouncilFeed.cs
index a2520fc3..caaddd5c 100644
--- a/CampusAppWP8/CampusAppWP8/Feed/StudentCouncil/StudentCouncilFeed.cs
+++ b/CampusAppWP8/CampusAppWP8/Feed/StudentCouncil/StudentCouncilFeed.cs
@@ -12,6 +12,7 @@ namespace CampusAppWP8.Feed.StudentCouncil
using CampusAppWP8.Model;
using CampusAppWP8.Model.StudentCouncil;
using CampusAppWP8.Resources;
+ using CampusAppWP8.Utility;
///
/// This Class is for StudentCouncilFeed
@@ -26,8 +27,8 @@ namespace CampusAppWP8.Feed.StudentCouncil
public StudentCouncilFeed()
: base(ModelType.FileAndFeed, Constants.FileStudentCouncil_StudentCouncils, Constants.UrlStudentCouncil_StudentCouncils)
{
- this.isFileUpToDate += new IsFileUpToDate(this.CheckIsFileUpToDate);
- this.isModelUpToDate += new IsModelUpToDate(this.CheckIsModelUpToDate);
+ this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
+ this.isModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
}
#endregion
@@ -58,7 +59,7 @@ namespace CampusAppWP8.Feed.StudentCouncil
/// reference of the FeedModel
/// info about the file
/// true, if file is up-to-date, otherwise false
- private bool CheckIsFileUpToDate(StudentCouncilListModel model, FileInfo fileInfo)
+ private bool CheckIsFileUpToDateOnLoad(StudentCouncilListModel model, FileInfo fileInfo)
{
DateTime lastModified = fileInfo.LastWriteTime;
return this.CheckIsUpToDate(lastModified);
@@ -71,16 +72,7 @@ namespace CampusAppWP8.Feed.StudentCouncil
/// true, if is up-to-date, otherwise false
private bool CheckIsUpToDate(DateTime lastModified)
{
- DateTime temp = lastModified.AddDays(1);
-
- int diff = temp.CompareTo(DateTime.Now);
-
- if (diff < 0)
- {
- return false;
- }
-
- return true;
+ return Utilities.DayDifference(Utilities.DifferenceType.Less, lastModified, 7.0);
}
#endregion
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Departments/DepartmentIndexPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Departments/DepartmentIndexPage.xaml
index 7cf96e78..8c1c6225 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Departments/DepartmentIndexPage.xaml
+++ b/CampusAppWP8/CampusAppWP8/Pages/Departments/DepartmentIndexPage.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}"
@@ -74,4 +75,9 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Departments/DepartmentIndexPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Departments/DepartmentIndexPage.xaml.cs
index 9c048b81..eab525bb 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Departments/DepartmentIndexPage.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/Departments/DepartmentIndexPage.xaml.cs
@@ -156,5 +156,16 @@ namespace CampusAppWP8.Pages.Departments
NavigationService.Navigate(new Uri(Constants.PathDepartment_DepartmentPage + "?pivotindex=" + tempElem.Tag, UriKind.Relative));
}
+
+ ///
+ /// On clicking the update button in the ApplicationBar.
+ /// Force a data update from the web.
+ ///
+ /// button object
+ /// event args
+ private void DeptForceUpdate_Click(object sender, EventArgs e)
+ {
+ DepartmentIndexPage.feed.ForceWebUpdate();
+ }
}
}
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Links/LinkPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Links/LinkPage.xaml
index f0378ecc..0057ec4c 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Links/LinkPage.xaml
+++ b/CampusAppWP8/CampusAppWP8/Pages/Links/LinkPage.xaml
@@ -58,5 +58,9 @@
-
+
+
+
+
+
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Links/LinkPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Links/LinkPage.xaml.cs
index f0ccccaa..e85a87b6 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Links/LinkPage.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/Links/LinkPage.xaml.cs
@@ -10,6 +10,7 @@ namespace CampusAppWP8.Pages.Links
using System.Windows.Navigation;
using CampusAppWP8.Feed.Link;
using Microsoft.Phone.Controls;
+ using System;
///
/// Class for the LinkPage
@@ -66,6 +67,15 @@ namespace CampusAppWP8.Pages.Links
this.clubLinkFeed.LoadData();
}
+ ///
+ /// Override the OnNavigatedTo method
+ ///
+ /// Arguments of navigation
+ protected override void OnNavigatedFrom(NavigationEventArgs e)
+ {
+ this.clubLinkFeed.SaveData();
+ this.commonLinkFeed.SaveData();
+ }
#endregion
#region private
@@ -113,8 +123,9 @@ namespace CampusAppWP8.Pages.Links
if (this.loadingFeeds < 1)
{
- this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed;
+ this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed;
}
+
}
///
@@ -127,7 +138,7 @@ namespace CampusAppWP8.Pages.Links
if (this.loadingFeeds < 1)
{
this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed;
- }
+ }
}
///
@@ -146,6 +157,19 @@ namespace CampusAppWP8.Pages.Links
this.ClubLinkPanel.ItemsSource = this.clubLinkFeed.Model.Links;
}
+ ///
+ /// On clicking the update button in the ApplicationBar.
+ /// Force a data update from the web.
+ ///
+ /// button object
+ /// event args
+ private void LinkForceUpdate_Click(object sender, EventArgs e)
+ {
+ this.loadingFeeds = 2;
+ this.ProgressBar.Visibility = System.Windows.Visibility.Visible;
+ this.commonLinkFeed.ForceWebUpdate();
+ this.clubLinkFeed.ForceWebUpdate();
+ }
#endregion
#endregion
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml
index aed38723..712adcde 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml
+++ b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.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"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
@@ -137,4 +138,9 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs
index 8b531f1b..cc42ef95 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs
@@ -88,6 +88,7 @@ namespace CampusAppWP8.Pages.Mensa
{
this.SetupMensaPivot();
this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed;
+ this.feed.SaveData();
}
///
@@ -130,7 +131,21 @@ namespace CampusAppWP8.Pages.Mensa
this.selectedIndex = todayIndex;
}
+
+ ///
+ /// On clicking the update button in the ApplicationBar.
+ /// Force a data update from the web.
+ ///
+ /// button object
+ /// event args
+ private void MensaForceUpdate_Click(object sender, EventArgs e)
+ {
+ this.ProgressBar.Visibility = System.Windows.Visibility.Visible;
+ this.feed.ForceWebUpdate();
+ }
+
#endregion
+
#endregion
}
}
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml
index 40dce836..32570e7c 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml
+++ b/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml
@@ -126,5 +126,9 @@
-
+
+
+
+
+
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml.cs
index 7d484a9b..b8c56c47 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml.cs
@@ -10,6 +10,7 @@ namespace CampusAppWP8.Pages.Openinghours
using System.Windows.Navigation;
using CampusAppWP8.Feed.Openinghours;
using Microsoft.Phone.Controls;
+ using System;
///
/// Opening hours page.
@@ -83,6 +84,7 @@ namespace CampusAppWP8.Pages.Openinghours
{
this.SetupInstitutionList();
this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed;
+ this.feed.SaveData();
}
///
@@ -93,6 +95,17 @@ namespace CampusAppWP8.Pages.Openinghours
this.InstitutionPanel.ItemsSource = this.feed.Model.Institutions;
}
+ ///
+ /// On clicking the update button in the ApplicationBar.
+ /// Force a data update from the web.
+ ///
+ /// button object
+ /// event args
+ private void OpenHoursForceUpdate_Click(object sender, EventArgs e)
+ {
+ this.ProgressBar.Visibility = System.Windows.Visibility.Visible;
+ this.feed.ForceWebUpdate();
+ }
// private
#endregion
// Method
diff --git a/CampusAppWP8/CampusAppWP8/Pages/StudentCouncil/StudentCouncilPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/StudentCouncil/StudentCouncilPage.xaml
index 6be59cd1..f4f7b52c 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/StudentCouncil/StudentCouncilPage.xaml
+++ b/CampusAppWP8/CampusAppWP8/Pages/StudentCouncil/StudentCouncilPage.xaml
@@ -52,5 +52,9 @@
-
+
+
+
+
+
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Pages/StudentCouncil/StudentCouncilPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/StudentCouncil/StudentCouncilPage.xaml.cs
index fa36d6a6..486d4611 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/StudentCouncil/StudentCouncilPage.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/StudentCouncil/StudentCouncilPage.xaml.cs
@@ -10,6 +10,7 @@ namespace CampusAppWP8.Pages.StudentCouncil
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using CampusAppWP8.Feed.StudentCouncil;
+ using System;
///
/// Class for the StudentCouncilPage
@@ -77,6 +78,7 @@ namespace CampusAppWP8.Pages.StudentCouncil
{
this.SetupStudentCouncilPivot();
this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed;
+ this.feed.SaveData();
}
///
@@ -87,6 +89,18 @@ namespace CampusAppWP8.Pages.StudentCouncil
this.StudentCouncilPivot.ItemsSource = this.feed.Model.GetStudentCouncilsGroupByFaculty();
}
+ ///
+ /// On clicking the update button in the ApplicationBar.
+ /// Force a data update from the web.
+ ///
+ /// button object
+ /// event args
+ private void StudentForceUpdate_Click(object sender, EventArgs e)
+ {
+ this.ProgressBar.Visibility = System.Windows.Visibility.Visible;
+ this.feed.ForceWebUpdate();
+ }
+
#endregion
#endregion
diff --git a/CampusAppWP8/CampusAppWP8/Utility/File.cs b/CampusAppWP8/CampusAppWP8/Utility/File.cs
index 8e6fcae3..b3e51dc0 100644
--- a/CampusAppWP8/CampusAppWP8/Utility/File.cs
+++ b/CampusAppWP8/CampusAppWP8/Utility/File.cs
@@ -220,11 +220,19 @@ namespace CampusAppWP8.Utility
/// data array
private async void WriteAsync(byte[] data)
{
- var file = await File.LocalFolder.CreateFileAsync(this.filename, CreationCollisionOption.ReplaceExisting);
-
- using (var s = await file.OpenStreamForWriteAsync())
+ try
{
- await s.WriteAsync(data, 0, data.Length);
+ var file = await File.LocalFolder.CreateFileAsync(this.filename, CreationCollisionOption.ReplaceExisting);
+
+ using (var s = await file.OpenStreamForWriteAsync())
+ {
+ await s.WriteAsync(data, 0, data.Length);
+ }
+ }
+ catch (Exception e)
+ {
+ // log write Error
+ Logger.LogException(e);
}
}
}
diff --git a/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs b/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs
index ebb30a38..665a004f 100644
--- a/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs
+++ b/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs
@@ -17,13 +17,12 @@ namespace CampusAppWP8.Utility
///
public class HttpRequest
{
- #region Members
+ #region Member
///
- /// the WebClient, which send the requests
+ /// BaseAddress of the webclient
///
- private WebClient client;
-
+ private string baseAddress;
#endregion
#region Constructor
@@ -33,7 +32,6 @@ namespace CampusAppWP8.Utility
///
public HttpRequest()
{
- this.client = new WebClient();
}
///
@@ -42,8 +40,7 @@ namespace CampusAppWP8.Utility
/// the url of the HttpRequest base address
public HttpRequest(Uri apiBaseAddress)
{
- this.client = new WebClient();
- this.client.BaseAddress = apiBaseAddress.AbsoluteUri;
+ baseAddress = apiBaseAddress.AbsoluteUri;
}
#endregion
@@ -58,8 +55,9 @@ namespace CampusAppWP8.Utility
/// callback method
public void HttpGet(Uri url, Action