edite checkisupdate method
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
//----------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Feed.Departments
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using CampusAppWP8.Model;
|
||||
using CampusAppWP8.Model.Departments;
|
||||
@@ -59,7 +60,7 @@ namespace CampusAppWP8.Feed.Departments
|
||||
}
|
||||
else
|
||||
{
|
||||
retValue = Utilities.DayDifference(Utilities.DifferenceType.Less, model.CreateTime, 7.0);
|
||||
retValue = this.CheckIsUpToDate(model.CreateTime);
|
||||
}
|
||||
|
||||
return retValue;
|
||||
@@ -80,7 +81,7 @@ namespace CampusAppWP8.Feed.Departments
|
||||
// at loading
|
||||
if (info.Exists == true)
|
||||
{
|
||||
retValue = Utilities.DayDifference(Utilities.DifferenceType.Less, info.LastWriteTime, 7.0);
|
||||
retValue = this.CheckIsUpToDate(info.LastWriteTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,10 +104,24 @@ namespace CampusAppWP8.Feed.Departments
|
||||
{
|
||||
retValue = false;
|
||||
}
|
||||
|
||||
|
||||
if (model != null && model.HasChanged())
|
||||
{
|
||||
retValue = false;
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/// <summary>Check if the model or file is up-to-date.</summary>
|
||||
/// <remarks>Stubbfel, 12.09.2013.</remarks>
|
||||
/// <param name="lastModified">Date of the last modification.</param>
|
||||
/// <returns>true, if is up-to-date, otherwise false.</returns>
|
||||
private bool CheckIsUpToDate(DateTime lastModified)
|
||||
{
|
||||
return Utilities.DayDifference(Utilities.DifferenceType.Less, lastModified, 30);
|
||||
}
|
||||
|
||||
// Protedted
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//----------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Feed.Events
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using CampusAppWP8.Model;
|
||||
using CampusAppWP8.Model.RSS;
|
||||
@@ -50,7 +51,7 @@ namespace CampusAppWP8.Feed.Events
|
||||
}
|
||||
else
|
||||
{
|
||||
retValue = Utilities.DayDifference(Utilities.DifferenceType.Less, model.CreateTime, 1.0);
|
||||
retValue = this.CheckIsUpToDate(model.CreateTime);
|
||||
}
|
||||
|
||||
return retValue;
|
||||
@@ -71,7 +72,7 @@ namespace CampusAppWP8.Feed.Events
|
||||
// at loading
|
||||
if (info.Exists == true)
|
||||
{
|
||||
retValue = Utilities.DayDifference(Utilities.DifferenceType.Less, info.LastWriteTime, 1.0);
|
||||
retValue = this.CheckIsUpToDate(info.LastWriteTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,8 +94,22 @@ namespace CampusAppWP8.Feed.Events
|
||||
{
|
||||
retValue = false;
|
||||
}
|
||||
|
||||
if (model != null)
|
||||
{
|
||||
retValue = this.CheckIsUpToDate(info.LastWriteTime);
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/// <summary>Check if the model or file is up-to-date.</summary>
|
||||
/// <remarks>Stubbfel, 12.09.2013.</remarks>
|
||||
/// <param name="lastModified">Date of the last modification.</param>
|
||||
/// <returns>true, if is up-to-date, otherwise false.</returns>
|
||||
private bool CheckIsUpToDate(DateTime lastModified)
|
||||
{
|
||||
return Utilities.DayDifference(Utilities.DifferenceType.Less, lastModified, 1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace CampusAppWP8.Feed.Exams
|
||||
using CampusAppWP8.Model;
|
||||
using CampusAppWP8.Model.Exams;
|
||||
using CampusAppWP8.Resources;
|
||||
using CampusAppWP8.Utility;
|
||||
|
||||
/// <summary>Exam feed.</summary>
|
||||
/// <remarks>Stubbfel, 02.09.2013.</remarks>
|
||||
@@ -53,6 +54,11 @@ namespace CampusAppWP8.Feed.Exams
|
||||
return false;
|
||||
}
|
||||
|
||||
if (model != null)
|
||||
{
|
||||
return Utilities.DayDifference(Utilities.DifferenceType.Less, fileInfo.LastWriteTime, 30.0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Feed.News
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using CampusAppWP8.Model;
|
||||
using CampusAppWP8.Model.RSS;
|
||||
@@ -50,7 +51,7 @@ namespace CampusAppWP8.Feed.News
|
||||
}
|
||||
else
|
||||
{
|
||||
retValue = Utilities.DayDifference(Utilities.DifferenceType.Less, model.CreateTime, 1.0);
|
||||
retValue = this.CheckIsUpToDate(model.CreateTime);
|
||||
}
|
||||
|
||||
return retValue;
|
||||
@@ -70,7 +71,7 @@ namespace CampusAppWP8.Feed.News
|
||||
{
|
||||
if (info.Exists == true)
|
||||
{
|
||||
retValue = Utilities.DayDifference(Utilities.DifferenceType.Less, info.LastWriteTime, 1.0);
|
||||
retValue = this.CheckIsUpToDate(info.LastWriteTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,8 +93,22 @@ namespace CampusAppWP8.Feed.News
|
||||
{
|
||||
retValue = false;
|
||||
}
|
||||
|
||||
|
||||
if (model != null)
|
||||
{
|
||||
retValue = this.CheckIsUpToDate(info.LastWriteTime);
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/// <summary>Check if the model or file is up-to-date.</summary>
|
||||
/// <remarks>Stubbfel, 12.09.2013.</remarks>
|
||||
/// <param name="lastModified">Date of the last modification.</param>
|
||||
/// <returns>true, if is up-to-date, otherwise false.</returns>
|
||||
private bool CheckIsUpToDate(DateTime lastModified)
|
||||
{
|
||||
return Utilities.DayDifference(Utilities.DifferenceType.Less, lastModified, 1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//----------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Feed.Openinghours
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using CampusAppWP8.Model;
|
||||
using CampusAppWP8.Model.Openinghours;
|
||||
@@ -52,7 +53,7 @@ namespace CampusAppWP8.Feed.Openinghours
|
||||
}
|
||||
else
|
||||
{
|
||||
retValue = Utilities.DayDifference(Utilities.DifferenceType.Less, model.CreateTime, 7.0);
|
||||
retValue = this.CheckIsUpToDate(model.CreateTime);
|
||||
}
|
||||
|
||||
return retValue;
|
||||
@@ -72,7 +73,7 @@ namespace CampusAppWP8.Feed.Openinghours
|
||||
{
|
||||
if (info.Exists == true)
|
||||
{
|
||||
retValue = Utilities.DayDifference(Utilities.DifferenceType.Less, info.LastWriteTime, 7.0);
|
||||
retValue = this.CheckIsUpToDate(info.LastWriteTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,9 +96,23 @@ namespace CampusAppWP8.Feed.Openinghours
|
||||
retValue = false;
|
||||
}
|
||||
|
||||
if (model != null)
|
||||
{
|
||||
retValue = this.CheckIsUpToDate(info.LastWriteTime);
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/// <summary>Check if the model or file is up-to-date.</summary>
|
||||
/// <remarks>Stubbfel, 12.09.2013.</remarks>
|
||||
/// <param name="lastModified">Date of the last modification.</param>
|
||||
/// <returns>true, if is up-to-date, otherwise false.</returns>
|
||||
private bool CheckIsUpToDate(DateTime lastModified)
|
||||
{
|
||||
return Utilities.DayDifference(Utilities.DifferenceType.Less, lastModified, 7.0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -11,49 +11,11 @@ namespace CampusAppWP8.Feed.Utility
|
||||
using CampusAppWP8.Model;
|
||||
using CampusAppWP8.Model.Exams;
|
||||
using CampusAppWP8.Resources;
|
||||
using CampusAppWP8.Feed.Exams;
|
||||
|
||||
/// <summary>Course Feed.</summary>
|
||||
/// <remarks>Stubbfel, 02.09.2013.</remarks>
|
||||
public class CourseFeed : XmlModel<ExamListModel>
|
||||
public class CourseFeed : ExamFeed
|
||||
{
|
||||
/// <summary>Initializes a new instance of the CourseFeed class.</summary>
|
||||
/// <remarks>Stubbfel, 02.09.2013.</remarks>
|
||||
public CourseFeed()
|
||||
: 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user