Merge branch 'release/#r128#130#131' into develmaster

This commit is contained in:
stubbfel
2013-07-23 11:55:23 +02:00
18 changed files with 99 additions and 299 deletions

View File

@@ -11,6 +11,7 @@ namespace CampusAppWP8.Feed.Lecture
using CampusAppWP8.Model.Lecture;
using CampusAppWP8.Resources;
using CampusAppWP8.Utility;
using CampusAppWP8.Model;
/// <summary>
/// Class for the feed of the Lecture
@@ -18,13 +19,13 @@ namespace CampusAppWP8.Feed.Lecture
/// <remarks>
/// need the XmlAPI
/// </remarks>
public class LectureApi : XmlApi<LectureList>
public class LectureApi : XmlModel<LectureList>
{
/// <summary>
/// Initializes a new instance of the <see cref="LectureApi" /> class.
/// </summary>
public LectureApi()
: base(new Uri(Constants.UrlLecture_ApiBaseAddr))
: base(ModelType.Feed, Constants.UrlLecture_ApiBaseAddr)
{
this.ValidRootName = Constants.LectureXmlValidRootName;
}

View File

@@ -206,8 +206,6 @@
<DependentUpon>Constants.resx</DependentUpon>
</Compile>
<Compile Include="ThemelizedIcons.cs" />
<Compile Include="Utility\Api.cs" />
<Compile Include="Utility\ApiEventHandler.cs" />
<Compile Include="Utility\File.cs" />
<Compile Include="Utility\Logger.cs" />
<Compile Include="Utility\HttpRequest.cs" />
@@ -221,7 +219,6 @@
<Compile Include="Utility\Utilities.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Utility\XmlApi.cs" />
<Compile Include="Utility\XmlManager.cs" />
</ItemGroup>
<ItemGroup>

View File

@@ -27,8 +27,9 @@ namespace CampusAppWP8.Feed.Link
public ClubLinkFeed()
: base(ModelType.FileAndFeed, Constants.FileLink_ClubLinks, Constants.UrlLink_ClubLinks)
{
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.isModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate);
}
#endregion
@@ -59,8 +60,13 @@ namespace CampusAppWP8.Feed.Link
/// <param name="model">reference of the FeedModel</param>
/// <param name="fileInfo">info about the file</param>
/// <returns>true, if file is up-to-date, otherwise false</returns>
private bool CheckIsFileUpToDateOnLoad(LinkListModel model, FileInfo fileInfo)
private bool CheckIsFileUpToDate(LinkListModel model, FileInfo fileInfo)
{
if (fileInfo == null || !fileInfo.Exists)
{
return false;
}
DateTime lastModified = fileInfo.LastWriteTime;
return this.CheckIsUpToDate(lastModified);
}

View File

@@ -27,8 +27,8 @@ namespace CampusAppWP8.Feed.Link
public CommonLinkFeed()
: base(ModelType.FileAndFeed, Constants.FileLink_CommonLinks, Constants.UrlLink_CommonLinks)
{
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.isModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
}
@@ -60,12 +60,19 @@ namespace CampusAppWP8.Feed.Link
/// <param name="model">reference of the FeedModel</param>
/// <param name="fileInfo">info about the file</param>
/// <returns>true, if file is up-to-date, otherwise false</returns>
private bool CheckIsFileUpToDateOnLoad(LinkListModel model, FileInfo fileInfo)
private bool CheckIsFileUpToDate(LinkListModel model, FileInfo fileInfo)
{
if (fileInfo == null || !fileInfo.Exists)
{
return false;
}
DateTime lastModified = fileInfo.LastWriteTime;
return this.CheckIsUpToDate(lastModified);
}
/// <summary>
/// Check if the model or file is up-to-date.
/// </summary>

View File

@@ -27,8 +27,9 @@ namespace CampusAppWP8.Feed.Mensa
public MensaFeed()
: base(ModelType.FileAndFeed, Constants.FileMensa_Shedule, Constants.UrlMensa_Week)
{
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.isModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate);
}
#endregion
@@ -59,8 +60,13 @@ namespace CampusAppWP8.Feed.Mensa
/// <param name="model">reference of the FeedModel</param>
/// <param name="fileInfo">info about the file</param>
/// <returns>true, if file is up-to-date, otherwise false</returns>
private bool CheckIsFileUpToDateOnLoad(MenuWeekModel model, FileInfo fileInfo)
private bool CheckIsFileUpToDate(MenuWeekModel model, FileInfo fileInfo)
{
if (fileInfo == null || !fileInfo.Exists)
{
return false;
}
DateTime lastModified = fileInfo.LastWriteTime;
return this.CheckIsUpToDate(lastModified);
}

View File

@@ -27,8 +27,9 @@ namespace CampusAppWP8.Feed.StudentCouncil
public StudentCouncilFeed()
: base(ModelType.FileAndFeed, Constants.FileStudentCouncil_StudentCouncils, Constants.UrlStudentCouncil_StudentCouncils)
{
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.isModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate);
}
#endregion
@@ -59,8 +60,13 @@ namespace CampusAppWP8.Feed.StudentCouncil
/// <param name="model">reference of the FeedModel</param>
/// <param name="fileInfo">info about the file</param>
/// <returns>true, if file is up-to-date, otherwise false</returns>
private bool CheckIsFileUpToDateOnLoad(StudentCouncilListModel model, FileInfo fileInfo)
private bool CheckIsFileUpToDate(StudentCouncilListModel model, FileInfo fileInfo)
{
if (fileInfo == null || !fileInfo.Exists)
{
return false;
}
DateTime lastModified = fileInfo.LastWriteTime;
return this.CheckIsUpToDate(lastModified);
}

View File

@@ -60,6 +60,17 @@ namespace CampusAppWP8.Model.Utility
return this.key;
}
}
/// <summary>
/// Gets or sets the token, which indicate that tha paramterlist started
/// </summary>
public string ParamToken
{
get
{
return "?";
}
}
#endregion
#region Methods

View File

@@ -26,6 +26,7 @@ namespace CampusAppWP8.Model
public XmlModel(ModelType modelType, string fileName, string url)
: base(modelType, fileName, url)
{
this.ValidRootName = Constants.XMLRootElementName;
}
/// <summary>
@@ -39,6 +40,11 @@ namespace CampusAppWP8.Model
{
}
/// <summary>
/// Gets or sets for the name of the root-tag
/// </summary>
protected string ValidRootName { get; set; }
/// <summary>
/// Create the model from a xml byte array.
/// </summary>
@@ -50,7 +56,7 @@ namespace CampusAppWP8.Model
string data = Encoding.UTF8.GetString(modelData, 0, modelData.Length);
T tempModel = XmlManager.DeserializationToModel<T>(data, Constants.XMLRootElementName);
T tempModel = XmlManager.DeserializationToModel<T>(data, this.ValidRootName);
if (tempModel != null)
{
this.Model = tempModel;

View File

@@ -167,10 +167,11 @@ namespace CampusAppWP8.Pages.Lecture
private void SendRequest(object sender, RoutedEventArgs e)
{
this.api = new LectureApi();
this.api.EventHandler.ApiIsReadyEvent += new ApiEventHandler.ApiReadyHandler(this.ApiIsReady);
this.api.onLoaded += new LectureApi.OnLoaded(this.ApiIsReady);
this.ProgressBar.Visibility = System.Windows.Visibility.Visible;
List<UrlParamModel> parameterList = this.CreateUrlParameter();
this.api.ApiGet(parameterList);
this.api.SetUriParams(parameterList);
this.api.LoadData();
}
/// <summary>

View File

@@ -57,9 +57,11 @@
<StackPanel Tag="{Binding Path=Constants.ToggleContent, Source={StaticResource Const}}" Visibility="Collapsed">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<lui:NavigateButton toolkit:TiltEffect.IsTiltEnabled="True" Name="Link" Url="{Binding Path=Constants.PathLecture_ModulWebPage, Source={StaticResource Const}}" QuerryStringValue="{Binding Modul.Number}" QuerryStringName="{Binding Path=Constants.ParamModelLecture_ModulNumber, Source={StaticResource Const}}">
<Image Source="{Binding Path=ThemelizedIcon.Link, Source={StaticResource ThemelizedIcons}}" Height="50"/>
<Image Source="{Binding Path=ThemelizedIcon.Link, Source={StaticResource ThemelizedIcons}}" Height="60"/>
</lui:NavigateButton>
<lui:NavigateButton toolkit:TiltEffect.IsTiltEnabled="True" Name="Details" Url="{Binding Path=Constants.PathLecture_ResultDetailPage, Source={StaticResource Const}}" QuerryStringValue="{Binding Id}" QuerryStringName="{Binding Path=Constants.ParamModelLecture_ActivityId, Source={StaticResource Const}}">
<Image Source="{Binding Path=ThemelizedIcon.Info, Source={StaticResource ThemelizedIcons}}" Height="60"/>
</lui:NavigateButton>
<lui:NavigateButton toolkit:TiltEffect.IsTiltEnabled="True" Name="Details" Content="Details" Url="{Binding Path=Constants.PathLecture_ResultDetailPage, Source={StaticResource Const}}" QuerryStringValue="{Binding Id}" QuerryStringName="{Binding Path=Constants.ParamModelLecture_ActivityId, Source={StaticResource Const}}"/>
</StackPanel>
</StackPanel>
</StackPanel>

View File

@@ -68,7 +68,7 @@ namespace CampusAppWP8.Pages.Links
}
/// <summary>
/// Override the OnNavigatedTo method
/// Override the OnNavigatedFrom method
/// </summary>
/// <param name="e">Arguments of navigation</param>
protected override void OnNavigatedFrom(NavigationEventArgs e)
@@ -76,6 +76,7 @@ namespace CampusAppWP8.Pages.Links
this.clubLinkFeed.SaveData();
this.commonLinkFeed.SaveData();
}
#endregion
#region private

View File

@@ -67,6 +67,16 @@ namespace CampusAppWP8.Pages.Mensa
this.ProgressBar.Visibility = System.Windows.Visibility.Visible;
this.feed.LoadData();
}
/// <summary>
/// Override the OnNavigatedFrom method
/// </summary>
/// <param name="e">Arguments of navigation</param>
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
this.feed.SaveData();
}
#endregion
#region private
@@ -88,7 +98,6 @@ namespace CampusAppWP8.Pages.Mensa
{
this.SetupMensaPivot();
this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed;
this.feed.SaveData();
}
/// <summary>

View File

@@ -63,6 +63,15 @@ namespace CampusAppWP8.Pages.Openinghours
this.feed.LoadData();
}
/// <summary>
/// Override the OnNavigatedFrom method
/// </summary>
/// <param name="e">Arguments of navigation</param>
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
this.feed.SaveData();
}
// protected
#endregion
@@ -84,7 +93,6 @@ namespace CampusAppWP8.Pages.Openinghours
{
this.SetupInstitutionList();
this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed;
this.feed.SaveData();
}
/// <summary>

View File

@@ -59,6 +59,15 @@ namespace CampusAppWP8.Pages.StudentCouncil
this.feed.LoadData();
}
/// <summary>
/// Override the OnNavigatedFrom method
/// </summary>
/// <param name="e">Arguments of navigation</param>
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
this.feed.SaveData();
}
#endregion
#region private
@@ -78,7 +87,6 @@ namespace CampusAppWP8.Pages.StudentCouncil
{
this.SetupStudentCouncilPivot();
this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed;
this.feed.SaveData();
}
/// <summary>

View File

@@ -1,144 +0,0 @@
//-----------------------------------------------------------------------
// <copyright file="Api.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>19.06.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Utility
{
using System;
using System.Collections.Generic;
using System.Net;
using CampusAppWP8.Model.Utility;
/// <summary>
/// This abstract Class is for API
/// </summary>
/// <typeparam name="T">Type for model of the API</typeparam>
public abstract class Api<T> : HttpRequest
{
#region Members
/// <summary>
/// EventHandler of the API
/// </summary>
private readonly ApiEventHandler eventHandler;
/// <summary>
/// The model of the API
/// </summary>
private T model;
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="Api{T}" /> class.
/// </summary>
/// <param name="apiBaseAddress">BaseUrl of the API</param>
public Api(Uri apiBaseAddress)
: base(apiBaseAddress)
{
this.eventHandler = new ApiEventHandler();
}
#endregion
#region Proberty
/// <summary>
/// Gets or sets for the model of the API
/// </summary>
public T Model
{
get
{
return this.model;
}
set
{
if ((value == null && this.model != null) || !value.Equals(this.model))
{
this.model = value;
}
}
}
/// <summary>
/// Gets for the event-handler of the API
/// </summary>
public ApiEventHandler EventHandler
{
get { return this.eventHandler; }
}
#endregion
#region Methods
#region public
/// <summary>
/// Method send an HTTP-Get for an API
/// </summary>
/// <param name="parameters">list of GetParameter</param>
public void ApiGet(List<UrlParamModel> parameters)
{
Uri getUrl = this.CreateGetUrl(parameters);
this.HttpGet(getUrl, this.DownloadCompleted);
}
#endregion
#region protected
/// <summary>
/// Method implement the deserialization a Xml-API
/// </summary>
/// <param name="xmlString">content of the API</param>
protected abstract void Deserialization(string xmlString);
#endregion
#region private
/// <summary>
/// Method create the model of the API
/// </summary>
/// <param name="resultString">content of the API</param>
private void CreateModel(string resultString)
{
if (resultString == null || resultString == string.Empty)
{
return;
}
this.Deserialization(resultString);
this.EventHandler.FireApiReadyevent();
}
/// <summary>
/// Method will be execute if the download of the API is completed and create the model
/// </summary>
/// <param name="sender">Sender of the event</param>
/// <param name="e">Arguments of the event</param>
private void DownloadCompleted(object sender, DownloadStringCompletedEventArgs e)
{
Exception downloadError = e.Error;
if (downloadError != null)
{
return;
}
string downloadResult = e.Result;
if (downloadResult != null && !downloadResult.Equals(string.Empty))
{
this.CreateModel(downloadResult);
}
}
#endregion
#endregion
}
}

View File

@@ -1,47 +0,0 @@
//-----------------------------------------------------------------------
// <copyright file="ApiEventHandler.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>17.06.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Utility
{
/// <summary>
/// This class handle the events of a API <see cref="RestApi{T}"/>
/// </summary>
public class ApiEventHandler
{
/// <summary>
/// Initializes a new instance of the <see cref="ApiEventHandler" /> class.
/// </summary>
public ApiEventHandler()
{
}
#region Delegate&Events
/// <summary>
/// Delegate for the ready event
/// </summary>
public delegate void ApiReadyHandler();
/// <summary>
/// The ready event
/// </summary>
public event ApiReadyHandler ApiIsReadyEvent;
#endregion
#region Method
/// <summary>
/// Method fire a ready event
/// </summary>
public void FireApiReadyevent()
{
this.ApiIsReadyEvent();
}
#endregion
}
}

View File

@@ -68,12 +68,18 @@ namespace CampusAppWP8.Utility
public Uri CreateGetUrl(List<UrlParamModel> parameters)
{
string paramterStr = string.Empty;
string seperator = string.Empty;
foreach (UrlParamModel parameter in parameters)
{
if (string.Empty.Equals(seperator))
{
seperator = parameter.ParamToken;
}
paramterStr += parameter.ToString();
}
string getUrlStr = baseAddress + "?" + paramterStr;
string getUrlStr = baseAddress + seperator + paramterStr;
return new Uri(getUrlStr, UriKind.Absolute);
}

View File

@@ -1,84 +0,0 @@
//-----------------------------------------------------------------------
// <copyright file="XmlApi.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>13.06.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Utility
{
using System;
using System.Collections.Generic;
using System.Net;
using CampusAppWP8.Model.Utility;
using CampusAppWP8.Resources;
/// <summary>
/// This abstract Class is for Xml-API
/// </summary>
/// <typeparam name="T">Type for model of the API</typeparam>
public abstract class XmlApi<T> : Api<T>
{
#region Members
/// <summary>
/// Variable for the name of the root-tag
/// </summary>
private string validRootName;
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="XmlApi{T}" /> class.
/// </summary>
/// <param name="apiBaseAddress">BaseUrl of the API</param>
public XmlApi(Uri apiBaseAddress)
: base(apiBaseAddress)
{
this.validRootName = Constants.XMLRootElementName;
}
#endregion
#region Proberty
/// <summary>
/// Gets or sets the ValidRootName of the API
/// </summary>
protected string ValidRootName
{
get
{
return this.validRootName;
}
set
{
if (value != this.validRootName)
{
this.validRootName = value;
}
}
}
#endregion
#region Methods
/// <summary>
/// Method implement the deserialization a Xml-API
/// </summary>
/// <param name="xmlString">content of the API</param>
protected override void Deserialization(string xmlString)
{
T model = XmlManager.DeserializationToModel<T>(xmlString, this.ValidRootName);
if (model != null)
{
this.Model = model;
}
}
#endregion
}
}