Merge branch 'hotfix/#118' into develmaster

This commit is contained in:
Christian Fiedler
2013-07-22 11:46:45 +02:00
6 changed files with 148 additions and 67 deletions

View File

@@ -28,7 +28,8 @@ namespace CampusAppWP8.Feed.Departments
public DepartmentFavoriteFeed(bool autoLoad = true)
: base(ModelType.File, Constants.FileDepartment_Favorite_Name, string.Empty)
{
this.isFileUpToDate += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnSave);
if (autoLoad == true)
{
@@ -68,7 +69,7 @@ namespace CampusAppWP8.Feed.Departments
/// <param name="model">model object</param>
/// <param name="info">file info object</param>
/// <returns>true, if file is up-to-date, otherwise false</returns>
private bool CheckIsFileUpToDate(DepartmentModel model, FileInfo info)
private bool CheckIsFileUpToDateOnLoad(DepartmentModel model, FileInfo info)
{
bool retValue = false;
@@ -76,11 +77,22 @@ namespace CampusAppWP8.Feed.Departments
{
retValue = true;
}
else
{
retValue = (model.HasChanged() == false) ? true : false;
}
return retValue;
}
/// <summary>
/// Method implement CheckIsFileUpToDate()-Method <see cref="Pages"/>.
/// </summary>
/// <param name="model">model object</param>
/// <param name="info">file info object</param>
/// <returns>true, if file is up-to-date, otherwise false</returns>
private bool CheckIsFileUpToDateOnSave(DepartmentModel model, FileInfo info)
{
bool retValue = false;
retValue = (model.HasChanged() == false) ? true : false;
return retValue;
}

View File

@@ -27,8 +27,9 @@ namespace CampusAppWP8.Feed.Departments
public DepartmentFeed(bool autoLoad = true)
: base(ModelType.FileAndFeed, Constants.FileDepartment_Name, Constants.UrlDepartment_Addr)
{
this.isFileUpToDate += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.isModelUpToDate += new IsModelUpToDate(this.CheckIsModelUpToDate);
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnSave);
this.isModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
if (autoLoad == true)
{
@@ -70,7 +71,7 @@ namespace CampusAppWP8.Feed.Departments
/// <param name="model">model object</param>
/// <param name="info">file info object</param>
/// <returns>true, if file is up-to-date, otherwise false</returns>
private bool CheckIsFileUpToDate(DepartmentModel model, FileInfo info)
private bool CheckIsFileUpToDateOnLoad(DepartmentModel model, FileInfo info)
{
bool retValue = true;
@@ -82,19 +83,30 @@ namespace CampusAppWP8.Feed.Departments
retValue = Utilities.DayDifference(Utilities.DifferenceType.Less, info.LastWriteTime, 7.0);
}
}
else
{
// at saving
if ((info.Exists == false)
|| (info.Length == 0))
{
retValue = false;
}
}
return retValue;
}
/// <summary>
/// Method implement CheckIsFileUpToDate()-Method <see cref="Pages"/>.
/// </summary>
/// <param name="model">model object</param>
/// <param name="info">file info object</param>
/// <returns>true, if file is up-to-date, otherwise false</returns>
private bool CheckIsFileUpToDateOnSave(DepartmentModel model, FileInfo info)
{
bool retValue = true;
// at saving
if ((info.Exists == false)
|| (info.Length == 0))
{
retValue = false;
}
return retValue;
}
// Protedted
#endregion

View File

@@ -25,8 +25,9 @@ namespace CampusAppWP8.Feed.Events
public EventFeed(bool autoLoad = true)
: base(ModelType.FileAndFeed, Constants.FileEvents_Name, Constants.UrlEvents_Addr)
{
this.isFileUpToDate += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.isModelUpToDate += new IsModelUpToDate(this.CheckIsModelUpToDate);
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnSave);
this.isModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
if (autoLoad == true)
{
@@ -61,7 +62,7 @@ namespace CampusAppWP8.Feed.Events
/// <param name="model">model object</param>
/// <param name="info">file info object</param>
/// <returns>true, if file is up-to-date, otherwise false</returns>
private bool CheckIsFileUpToDate(RSSViewModel model, FileInfo info)
private bool CheckIsFileUpToDateOnLoad(RSSViewModel model, FileInfo info)
{
bool retValue = true;
@@ -73,16 +74,26 @@ namespace CampusAppWP8.Feed.Events
retValue = Utilities.DayDifference(Utilities.DifferenceType.Less, info.LastWriteTime, 1.0);
}
}
else
{
// at saving
if ((info.Exists == false)
|| (info.Length == 0))
{
retValue = false;
}
}
return retValue;
}
/// <summary>
/// Method implement CheckIsFileUpToDate()-Method <see cref="Pages"/>
/// </summary>
/// <param name="model">model object</param>
/// <param name="info">file info object</param>
/// <returns>true, if file is up-to-date, otherwise false</returns>
private bool CheckIsFileUpToDateOnSave(RSSViewModel model, FileInfo info)
{
bool retValue = true;
if ((info.Exists == false)
|| (info.Length == 0))
{
retValue = false;
}
return retValue;
}
}

View File

@@ -25,8 +25,9 @@ namespace CampusAppWP8.Feed.News
public NewsFeed(bool autoLoad = true)
: base(ModelType.FileAndFeed, Constants.FileNews_Name, Constants.UrlNews_Addr)
{
this.isFileUpToDate += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.isModelUpToDate += new IsModelUpToDate(this.CheckIsModelUpToDate);
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnSave);
this.isModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
if (autoLoad == true)
{
@@ -61,28 +62,37 @@ namespace CampusAppWP8.Feed.News
/// <param name="model">model object</param>
/// <param name="info">info object of the file</param>
/// <returns>true, if file is up-to-date, otherwise false</returns>
private bool CheckIsFileUpToDate(RSSViewModel model, FileInfo info)
private bool CheckIsFileUpToDateOnLoad(RSSViewModel model, FileInfo info)
{
bool retValue = true;
if (model == null)
{
// at loading
if (info.Exists == true)
{
retValue = Utilities.DayDifference(Utilities.DifferenceType.Less, info.LastWriteTime, 1.0);
}
}
else
{
// at saving
if ((info.Exists == false)
|| (info.Length == 0))
{
retValue = false;
}
}
return retValue;
}
/// <summary>
/// Method implement CheckIsFileUpToDate()-Method <see cref="Pages"/>
/// </summary>
/// <param name="model">model object</param>
/// <param name="info">info object of the file</param>
/// <returns>true, if file is up-to-date, otherwise false</returns>
private bool CheckIsFileUpToDateOnSave(RSSViewModel model, FileInfo info)
{
bool retValue = true;
if ((info.Exists == false)
|| (info.Length == 0))
{
retValue = false;
}
return retValue;
}
}

View File

@@ -12,7 +12,8 @@ namespace CampusAppWP8.Feed.Openinghours
using CampusAppWP8.Model;
using CampusAppWP8.Model.Openinghours;
using CampusAppWP8.Resources;
using CampusAppWP8.Utility;
/// <summary>
/// This Class is for MesaFeeds
/// </summary>
@@ -26,8 +27,9 @@ namespace CampusAppWP8.Feed.Openinghours
public OpeninghoursFeed()
: base(ModelType.FileAndFeed, Constants.FileOpeningHours_OpeningHours, Constants.UrlOpeningHours_OpeningHours)
{
this.isFileUpToDate += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.isModelUpToDate += new IsModelUpToDate(this.CheckIsModelUpToDate);
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnSave);
this.isModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
}
#endregion
@@ -43,35 +45,58 @@ namespace CampusAppWP8.Feed.Openinghours
/// <returns>true, if model is up-to-date, otherwise false</returns>
private bool CheckIsModelUpToDate(OpeninghoursModel model)
{
bool retValue = true;
if (model == null)
{
return false;
retValue = false;
}
else
{
retValue = Utilities.DayDifference(Utilities.DifferenceType.Less, model.CreateTime, 7.0);
}
DateTime lastModified = model.CreateTime;
return this.CheckIsUpToDate(lastModified);
return retValue;
}
/// <summary>
/// Method check if the FeedFile is up-to-date
/// </summary>
/// <param name="model">reference of the FeedModel</param>
/// <param name="fileInfo">info about the file</param>
/// <param name="info">info about the file</param>
/// <returns>true, if file is up-to-date, otherwise false</returns>
private bool CheckIsFileUpToDate(OpeninghoursModel model, FileInfo fileInfo)
private bool CheckIsFileUpToDateOnLoad(OpeninghoursModel model, FileInfo info)
{
DateTime lastModified = fileInfo.LastWriteTime;
return this.CheckIsUpToDate(lastModified);
bool retValue = true;
if (model == null)
{
if (info.Exists == true)
{
retValue = Utilities.DayDifference(Utilities.DifferenceType.Less, info.LastWriteTime, 7.0);
}
}
return retValue;
}
/// <summary>
/// Check if the model or file is up-to-date.
/// Method check if the FeedFile is up-to-date
/// </summary>
/// <param name="lastModified">Date of the last modification</param>
/// <returns>true, if is up-to-date, otherwise false</returns>
private bool CheckIsUpToDate(DateTime lastModified)
/// <param name="model">reference of the FeedModel</param>
/// <param name="info">info about the file</param>
/// <returns>true, if file is up-to-date, otherwise false</returns>
private bool CheckIsFileUpToDateOnSave(OpeninghoursModel model, FileInfo info)
{
return true;
bool retValue = true;
if ((info.Exists == false)
|| (info.Length == 0))
{
retValue = false;
}
return retValue;
}
#endregion

View File

@@ -143,14 +143,25 @@ namespace CampusAppWP8
public event OnSaved onSaved = null;
/// <summary>
/// Callback pointer, for checking if file is up to date.
/// Callback pointer, for checking if file is up to date at loading.
/// </summary>
public event IsFileUpToDate isFileUpToDate = null;
public event IsFileUpToDate isFileUpToDateOnLoad = null;
/// <summary>
/// Callback pointer, for checking if model is up to date.
/// Callback pointer, for checking if file is up to date at saving.
/// </summary>
public event IsModelUpToDate isModelUpToDate = null;
public event IsFileUpToDate isFileUpToDateOnSave = null;
/// <summary>
/// Callback pointer, for checking if model is up to date at loading.
/// </summary>
public event IsModelUpToDate isModelUpToDateOnLoad = null;
/// <summary>
/// Callback pointer, for checking if model is up to date at saving.
/// (currently unused)
/// </summary>
public event IsModelUpToDate isModelUpToDateOnSave = null;
/// <summary>
/// Specifies the I/O type of the model.
@@ -231,8 +242,8 @@ namespace CampusAppWP8
this.onLoading();
}
if (((this.isModelUpToDate == null)
|| (this.isModelUpToDate(this.model) == false))
if (((this.isModelUpToDateOnLoad == null)
|| (this.isModelUpToDateOnLoad(this.model) == false))
&& ((this.file != null) || this.api != null))
{
if (this.file != null)
@@ -243,8 +254,8 @@ namespace CampusAppWP8
loadFromFile = false;
}
if (((this.isFileUpToDate != null) && (this.isFileUpToDate(this.model, this.file.GetFileInfo()) == false))
|| (this.isFileUpToDate == null))
if (((this.isFileUpToDateOnLoad != null) && (this.isFileUpToDateOnLoad(this.model, this.file.GetFileInfo()) == false))
|| (this.isFileUpToDateOnLoad == null))
{
loadFromFile = false;
}
@@ -289,7 +300,7 @@ namespace CampusAppWP8
public void SaveData()
{
if ((this.file != null)
&& ((this.isFileUpToDate == null) || (this.isFileUpToDate(this.model, this.file.GetFileInfo()) == false)))
&& ((this.isFileUpToDateOnSave == null) || (this.isFileUpToDateOnSave(this.model, this.file.GetFileInfo()) == false)))
{
if (this.onSaving != null)
{