Merge branch 'hotfix/#160_#161' into develop

This commit is contained in:
Christian Fiedler
2013-08-21 15:43:21 +02:00
33 changed files with 301 additions and 233 deletions

View File

@@ -4,7 +4,7 @@
// </copyright>
// <author>fiedlchr</author>
// <sience>01.07.2013</sience>
//----------------------------------------------------------------------using System;
//----------------------------------------------------------------------
namespace CampusAppWP8.Feed.Departments
{
using System.IO;
@@ -26,8 +26,8 @@ namespace CampusAppWP8.Feed.Departments
public DepartmentFavoriteFeed(bool autoLoad = true)
: base(ModelType.File, Constants.FileDepartment_Favorite_Name, string.Empty)
{
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnSave);
this.IsFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
this.IsFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnSave);
if (autoLoad == true)
{

View File

@@ -27,9 +27,9 @@ namespace CampusAppWP8.Feed.Departments
public DepartmentFeed(bool autoLoad = true)
: base(ModelType.FileAndFeed, Constants.FileDepartment_Name, Constants.UrlDepartment_Addr)
{
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnSave);
this.isModelUpToDateOnLoad += 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)
{

View File

@@ -25,9 +25,9 @@ namespace CampusAppWP8.Feed.Events
public EventFeed(bool autoLoad = true)
: base(ModelType.FileAndFeed, Constants.FileEvents_Name, Constants.UrlEvents_Addr)
{
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnSave);
this.isModelUpToDateOnLoad += 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)
{

View File

@@ -27,9 +27,9 @@ namespace CampusAppWP8.Feed.Link
public ClubLinkFeed()
: base(ModelType.FileAndFeed, Constants.FileLink_ClubLinks, Constants.UrlLink_ClubLinks)
{
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.isModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.IsFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.IsModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
this.IsFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate);
}
#endregion

View File

@@ -27,9 +27,9 @@ namespace CampusAppWP8.Feed.Link
public CommonLinkFeed()
: base(ModelType.FileAndFeed, Constants.FileLink_CommonLinks, Constants.UrlLink_CommonLinks)
{
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.isModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
this.IsFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.IsFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.IsModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
}
#endregion

View File

@@ -27,9 +27,9 @@ namespace CampusAppWP8.Feed.Mensa
protected MensaFeed(string fileName, string feedUrl)
: base(ModelType.FileAndFeed, fileName, feedUrl)
{
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.isModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.IsFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.IsModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
this.IsFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate);
}
#endregion

View File

@@ -25,9 +25,9 @@ namespace CampusAppWP8.Feed.News
public NewsFeed(bool autoLoad = true)
: base(ModelType.FileAndFeed, Constants.FileNews_Name, Constants.UrlNews_Addr)
{
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnSave);
this.isModelUpToDateOnLoad += 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)
{

View File

@@ -26,9 +26,9 @@ namespace CampusAppWP8.Feed.Openinghours
public OpeninghoursFeed()
: base(ModelType.FileAndFeed, Constants.FileOpeningHours_OpeningHours, Constants.UrlOpeningHours_OpeningHours)
{
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnSave);
this.isModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
this.IsFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
this.IsFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnSave);
this.IsModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
}
#endregion

View File

@@ -27,9 +27,9 @@ namespace CampusAppWP8.Feed.StudentCouncil
public StudentCouncilFeed()
: base(ModelType.FileAndFeed, Constants.FileStudentCouncil_StudentCouncils, Constants.UrlStudentCouncil_StudentCouncils)
{
this.isFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.isModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
this.isFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.IsFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.IsModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
this.IsFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate);
}
#endregion

View File

@@ -1,14 +1,27 @@
using CampusAppWP8.Resources;
//-----------------------------------------------------------------------------
// <copyright file="LocalizedStrings.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <sience>16.07.2013</sience>
//-----------------------------------------------------------------------------
namespace CampusAppWP8
{
/// <summary>
/// Bietet Zugriff auf Zeichenfolgenressourcen.
/// </summary>
using CampusAppWP8.Resources;
/// <summary>Localized strings. </summary>
public class LocalizedStrings
{
private static AppResources _localizedResources = new AppResources();
/// <summary>The localized resources. </summary>
private static AppResources localizedResources = new AppResources();
public AppResources LocalizedResources { get { return _localizedResources; } }
/// <summary>Gets the localized resources. </summary>
/// <value>The localized resources. </value>
public AppResources LocalizedResources
{
get
{
return localizedResources;
}
}
}
}

View File

@@ -97,24 +97,9 @@ namespace CampusAppWP8
}
/// <summary>
/// Delegate of the OnLoading callback function.
/// Delegate of the OnIO callback function.
/// </summary>
public delegate void OnLoading();
/// <summary>
/// Delegate of the OnLoaded callback function.
/// </summary>
public delegate void OnLoaded();
/// <summary>
/// Delegate of the OnSaving callback function.
/// </summary>
public delegate void OnSaving();
/// <summary>
/// Delegate of the OnSaved callback function.
/// </summary>
public delegate void OnSaved();
public delegate void OnIO();
/// <summary>
/// Delegate of the OnFailed(File/Web) callback function.
@@ -139,64 +124,64 @@ namespace CampusAppWP8
/// <summary>
/// Callback pointer, called before loading.
/// </summary>
public event OnLoading onLoading = null;
public event OnIO OnLoading = null;
/// <summary>
/// Callback pointer, called after loading.
/// </summary>
public event OnLoaded onLoaded = null;
public event OnIO OnLoaded = null;
/// <summary>
/// Callback pointer, called before saving.
/// </summary>
public event OnSaving onSaving = null;
public event OnIO OnSaving = null;
/// <summary>
/// Callback pointer, called after saving.
/// </summary>
public event OnSaved onSaved = null;
public event OnIO OnSaved = null;
/// <summary>
/// Callback pointer, called after failed file loading.
/// </summary>
public event OnFailed onFailedFile = null;
public event OnFailed OnFailedFile = null;
/// <summary>
/// Callback pointer, called after failed web loading.
/// </summary>
public event OnFailed onFailedWeb = null;
public event OnFailed OnFailedWeb = null;
/// <summary>
/// Callback pointer, called after failed file or web loading, if there
/// is no specialized onFailed callback set.
/// </summary>
public event OnFailed onFailed = null;
public event OnFailed OnFailedLoad = null;
/// <summary>
/// Callback pointer, called after failed saving data to file.
/// </summary>
public event OnFailed onFailedSave = null;
public event OnFailed OnFailedSave = null;
/// <summary>
/// Callback pointer, for checking if file is up to date at loading.
/// </summary>
public event IsFileUpToDate isFileUpToDateOnLoad = null;
public event IsFileUpToDate IsFileUpToDateOnLoad = null;
/// <summary>
/// Callback pointer, for checking if file is up to date at saving.
/// </summary>
public event IsFileUpToDate isFileUpToDateOnSave = 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;
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;
public event IsModelUpToDate IsModelUpToDateOnSave = null;
/// <summary>
/// Specifies the I/O type of the model.
@@ -224,6 +209,19 @@ namespace CampusAppWP8
FileAndFeed = 3
}
/// <summary>Values that represent ForceType for load function.</summary>
public enum ForceType
{
/// <summary>An enumeration constant representing the invalid/default/unset option.</summary>
INVALID = 0,
/// <summary>An enumeration constant representing the force file option.</summary>
FORCE_FILE = 1,
/// <summary>An enumeration constant representing the force web option.</summary>
FORCE_WEB = 2
}
/// <summary>
/// Gets or sets the Model.
/// </summary>
@@ -253,15 +251,7 @@ namespace CampusAppWP8
/// </summary>
public void ForceWebUpdate()
{
if (this.api != null)
{
if (this.onLoading != null)
{
this.onLoading();
}
this.api.HttpGet(this.httpApiUri, this.OnLoadDataComplete);
}
this.LoadData(ForceType.FORCE_WEB);
}
/// <summary>
@@ -269,80 +259,60 @@ namespace CampusAppWP8
/// </summary>
public void ForceReadFile()
{
if (this.file != null)
{
if (this.onLoading != null)
{
this.onLoading();
}
string data = this.file.ReadFile();
if (data == null)
{
if (this.onFailedFile != null)
{
this.onFailedFile();
}
else if (this.onFailed != null)
{
this.onFailed();
}
}
else if (!data.Equals(string.Empty))
{
this.DeserializeModel(Encoding.UTF8.GetBytes(data));
}
if ((data != null) && (this.onLoaded != null))
{
this.onLoaded();
}
}
this.LoadData(ForceType.FORCE_FILE);
}
/// <summary>
/// Load the data if necessary, from web or from file, regarding if
/// the file data is up to date.
/// </summary>
public void LoadData()
/// <param name="force">if set/not invalid/not default, force to load from web or file</param>
public void LoadData(ForceType force = ForceType.INVALID)
{
bool loadFromFile = true;
if (this.onLoading != null)
this.RunOnIOCallback(this.OnLoading);
// check which source is used for loading the data
if (force == ForceType.INVALID)
{
this.onLoading();
}
if (((this.isModelUpToDateOnLoad == null)
|| (this.isModelUpToDateOnLoad(this.model) == false))
&& ((this.file != null) || this.api != null))
{
if (this.file != null)
// if the model is not up to date
if (this.CheckIsNotUpToDate(this.IsModelUpToDateOnLoad) == true)
{
if ((this.file.Exist() == false)
|| (this.file.GetFileInfo().Length == 0))
force = ForceType.FORCE_FILE;
if (this.file != null)
{
loadFromFile = false;
// if the file does not exist or is size of 0 or is not
// up to date, then load from web
if ((this.file.Exist() == false)
|| (this.file.GetFileInfo().Length == 0)
|| (this.CheckIsNotUpToDate(this.IsFileUpToDateOnLoad) == true))
{
force = ForceType.FORCE_WEB;
}
}
else
{
// if the file object does not exist, load from web
force = ForceType.FORCE_WEB;
}
if (((this.isFileUpToDateOnLoad != null) && (this.isFileUpToDateOnLoad(this.model, this.file.GetFileInfo()) == false))
|| (this.isFileUpToDateOnLoad == null))
// if the web object does not exist, load from file
if (this.api == null)
{
loadFromFile = false;
force = ForceType.FORCE_FILE;
}
}
else
{
loadFromFile = false;
// if it is up to date, nothing has to be loaded
this.RunOnIOCallback(this.OnLoaded);
}
}
if (this.api == null)
{
loadFromFile = true;
}
if (loadFromFile == false)
// load from web
if (force == ForceType.FORCE_WEB)
{
if (this.api != null)
{
if (this.paramizedUri != null)
{
@@ -354,32 +324,37 @@ namespace CampusAppWP8
}
}
else
{
// if web object does not exist, call OnFailed callbacks
this.RunOnFailedCallback(this.OnFailedWeb, this.OnFailedLoad);
}
}
// load from file
if (force == ForceType.FORCE_FILE)
{
if (this.file != null)
{
string data = this.file.ReadFile();
if (data == null)
{
if (this.onFailedFile != null)
{
this.onFailedFile();
}
else if (this.onFailed != null)
{
this.onFailed();
}
this.RunOnFailedCallback(this.OnFailedFile, this.OnFailedLoad);
}
else if (!data.Equals(string.Empty))
else
{
this.DeserializeModel(Encoding.UTF8.GetBytes(data));
if (!data.Equals(string.Empty))
{
this.DeserializeModel(Encoding.UTF8.GetBytes(data));
}
this.RunOnIOCallback(this.OnLoaded);
}
}
}
if (loadFromFile == true)
{
if (this.onLoaded != null)
else
{
this.onLoaded();
// if file object does not exist, call OnFailed callbacks
this.RunOnFailedCallback(this.OnFailedFile, this.OnFailedLoad);
}
}
}
@@ -391,40 +366,28 @@ namespace CampusAppWP8
public void SaveData(bool force = false)
{
if ((this.file != null)
&& ((this.isFileUpToDateOnSave == null)
|| (this.isFileUpToDateOnSave(this.model, this.file.GetFileInfo()) == false)
|| (force == true)))
&& ((this.CheckIsNotUpToDate(this.IsFileUpToDateOnSave) == true) || (force == true)))
{
if (this.onSaving != null)
{
this.onSaving();
}
this.RunOnIOCallback(this.OnSaving);
byte[] data = this.SerializeModel();
if ((this.onSaved != null) && (this.onFailedSave != null))
if ((this.OnSaved != null) && (this.OnFailedSave != null))
{
this.file.WriteFile(data, delegate() { this.onSaved(); }, delegate() { this.onFailedSave(); });
this.file.WriteFile(data, delegate { this.OnSaved(); }, delegate { this.OnFailedSave(); });
}
else if (this.onSaved != null)
else if (this.OnSaved != null)
{
this.file.WriteFile(data, delegate() { this.onSaved(); }, null);
this.file.WriteFile(data, delegate { this.OnSaved(); }, null);
}
else if (this.onFailedSave != null)
else if (this.OnFailedSave != null)
{
this.file.WriteFile(data, null, delegate() { this.onFailedSave(); });
this.file.WriteFile(data, null, delegate { this.OnFailedSave(); });
}
else
{
this.file.WriteFile(data, null, null);
}
/*
if (this.onSaved != null)
{
this.onSaved();
}
*/
}
}
@@ -529,7 +492,7 @@ namespace CampusAppWP8
this.fileName = fileName;
if ((this.IsFile() == true)
&& (fileName.Equals(string.Empty) == false))
&& (fileName.Equals(string.Empty) == false))
{
this.InitFile(CampusAppWP8.Utility.File.IOTypeRead.ReadSync, CampusAppWP8.Utility.File.IOTypeWrite.WriteAsync);
}
@@ -546,7 +509,9 @@ namespace CampusAppWP8
/// </summary>
/// <param name="readType">read io type (Default: sync)</param>
/// <param name="writeType">write io type (Default: async)</param>
private void InitFile(CampusAppWP8.Utility.File.IOTypeRead readType = CampusAppWP8.Utility.File.IOTypeRead.ReadSync, CampusAppWP8.Utility.File.IOTypeWrite writeType = CampusAppWP8.Utility.File.IOTypeWrite.WriteAsync)
private void InitFile(
CampusAppWP8.Utility.File.IOTypeRead readType = CampusAppWP8.Utility.File.IOTypeRead.ReadSync,
CampusAppWP8.Utility.File.IOTypeWrite writeType = CampusAppWP8.Utility.File.IOTypeWrite.WriteAsync)
{
if ((this.IsFile() == true)
&& (this.file == null))
@@ -577,28 +542,75 @@ namespace CampusAppWP8
Exception downloadError = e.Error;
if (downloadError != null)
{
if (this.onFailedWeb != null)
this.RunOnFailedCallback(this.OnFailedWeb, this.OnFailedLoad);
}
else
{
string downloadResult = e.Result;
if (downloadResult != null && !downloadResult.Equals(string.Empty))
{
this.onFailedWeb();
}
else if (this.onFailed != null)
{
this.onFailed();
this.DeserializeModel(Encoding.UTF8.GetBytes(downloadResult));
}
return;
this.RunOnIOCallback(this.OnLoaded);
}
}
/// <summary>
/// Executes the on i/o callback operation.
/// </summary>
/// <param name="callbackFunc">The callback function.</param>
private void RunOnIOCallback(OnIO callbackFunc)
{
if (callbackFunc != null)
{
callbackFunc();
}
}
/// <summary>Executes the on failed callback operation.</summary>
/// <param name="specialFunc">The special function.</param>
/// <param name="defaultFunc">The default function.</param>
private void RunOnFailedCallback(OnFailed specialFunc, OnFailed defaultFunc)
{
if (specialFunc != null)
{
specialFunc();
}
else if (defaultFunc != null)
{
defaultFunc();
}
}
/// <summary>Check if model or file is not up to date.</summary>
/// <param name="checkFunc">The check function.</param>
/// <returns>true if model or file is not up to date, false if it is.</returns>
private bool CheckIsNotUpToDate(object checkFunc)
{
bool retValue = false;
// if there is no check function, the model or file is not up to date
if (checkFunc == null)
{
retValue = true;
}
else
{
Type funcType = checkFunc.GetType();
if (funcType.Equals(typeof(IsFileUpToDate)))
{
retValue = !(checkFunc as IsFileUpToDate)(this.model, this.file.GetFileInfo());
}
else if (funcType.Equals(typeof(IsModelUpToDate)))
{
retValue = !(checkFunc as IsModelUpToDate)(this.model);
}
}
string downloadResult = e.Result;
if (downloadResult != null && !downloadResult.Equals(string.Empty))
{
this.DeserializeModel(Encoding.UTF8.GetBytes(downloadResult));
}
if (this.onLoaded != null)
{
this.onLoaded();
}
return retValue;
}
}
}

View File

@@ -20,6 +20,7 @@
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ProgressBar x:Name="progressBar" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="Collapsed" IsIndeterminate="True"/>
<!--TitlePanel enthält den Namen der Anwendung und den Seitentitel-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}"/>

View File

@@ -53,6 +53,7 @@ namespace CampusAppWP8.Pages.Departments
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
this.progressBar.Visibility = Visibility.Visible;
if (this.isNewInstance)
{
@@ -80,6 +81,8 @@ namespace CampusAppWP8.Pages.Departments
this.ContentPanel.ItemsSource = DepartmentIndexPage.GetFavoriteFeed().GetModel().Faculties[0].Chairs;
this.isSourceSet = true;
}
this.progressBar.Visibility = Visibility.Collapsed;
}
/// <summary>

View File

@@ -22,6 +22,7 @@
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ProgressBar x:Name="progressBar" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="Collapsed" IsIndeterminate="True"/>
<!--TitlePanel enthält den Namen der Anwendung und den Seitentitel-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}"/>

View File

@@ -37,6 +37,7 @@ namespace CampusAppWP8.Pages.Departments
public DepartmentIndexPage()
{
this.InitializeComponent();
this.progressBar.Visibility = Visibility.Visible;
//// init feed objects
if (DepartmentIndexPage.feed == null)
@@ -44,9 +45,9 @@ namespace CampusAppWP8.Pages.Departments
DepartmentIndexPage.feed = new DepartmentFeed(false);
}
DepartmentIndexPage.feed.onLoaded += new DepartmentFeed.OnLoaded(this.SetupFacultyList);
DepartmentIndexPage.feed.onFailedWeb += new DepartmentFeed.OnFailed(this.FeedIsFailWeb);
DepartmentIndexPage.feed.onFailedFile += new DepartmentFeed.OnFailed(this.FeedIsFailFile);
DepartmentIndexPage.feed.OnLoaded += new DepartmentFeed.OnIO(this.SetupFacultyList);
DepartmentIndexPage.feed.OnFailedWeb += new DepartmentFeed.OnFailed(this.FeedIsFailedWeb);
DepartmentIndexPage.feed.OnFailedFile += new DepartmentFeed.OnFailed(this.FeedIsFailedFile);
DepartmentIndexPage.feed.LoadData();
if (DepartmentIndexPage.favorite == null)
@@ -54,8 +55,7 @@ namespace CampusAppWP8.Pages.Departments
DepartmentIndexPage.favorite = new DepartmentFavoriteFeed(false);
}
DepartmentIndexPage.favorite.onLoaded += new DepartmentFavoriteFeed.OnLoaded(this.CheckFavoriteFeed);
DepartmentIndexPage.favorite.onFailedFile += new DepartmentFavoriteFeed.OnFailed(this.FeedIsFailFile);
DepartmentIndexPage.favorite.OnFailedFile += new DepartmentFavoriteFeed.OnFailed(this.CheckFavoriteFeed);
DepartmentIndexPage.favorite.LoadData();
}
@@ -159,6 +159,7 @@ namespace CampusAppWP8.Pages.Departments
private void SetupFacultyList()
{
this.FacultyList.ItemsSource = DepartmentIndexPage.feed.GetModel().Faculties;
this.progressBar.Visibility = Visibility.Collapsed;
}
/// <summary>
@@ -213,7 +214,7 @@ namespace CampusAppWP8.Pages.Departments
/// <summary>
/// Method will be execute if the feed is failed
/// </summary>
private void FeedIsFailWeb()
private void FeedIsFailedWeb()
{
MessageBoxResult result = MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadWeb);
DepartmentIndexPage.feed.ForceReadFile();
@@ -222,8 +223,9 @@ namespace CampusAppWP8.Pages.Departments
/// <summary>
/// Method will be execute if the feed is failed
/// </summary>
private void FeedIsFailFile()
private void FeedIsFailedFile()
{
this.progressBar.Visibility = Visibility.Collapsed;
MessageBoxResult result = MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadFile);
}
}

View File

@@ -20,6 +20,8 @@
<Grid.DataContext>
<viewModel:DepartmentModel />
</Grid.DataContext>
<ProgressBar x:Name="progressBar" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="Collapsed" IsIndeterminate="True"/>
<!-- Pivot -->
<phone:Pivot x:Name="DepartmentPivot" Title="{Binding Path=LocalizedResources.DepartmentApp_Title, Source={StaticResource LocalizedStrings}}" ItemsSource="{Binding Faculties}">
<!-- Pivotitem template -->

View File

@@ -54,6 +54,7 @@ namespace CampusAppWP8.Pages.Departments
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
this.progressBar.Visibility = Visibility.Visible;
if (this.isNewInstance)
{
@@ -99,6 +100,8 @@ namespace CampusAppWP8.Pages.Departments
MessageBox.Show("ERROR: pivotIndex out of range!!!");
}
}
this.progressBar.Visibility = Visibility.Collapsed;
}
/// <summary>

View File

@@ -21,6 +21,7 @@
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ProgressBar x:Name="progressBar" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="Collapsed" IsIndeterminate="True"/>
<!-- Title and headline -->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}"/>

View File

@@ -32,6 +32,7 @@ namespace CampusAppWP8.Pages.Events
public EventIndexPage()
{
this.InitializeComponent();
this.progressBar.Visibility = Visibility.Visible;
ApplicationBarIconButton updateBtn = new ApplicationBarIconButton();
updateBtn.IconUri = new Uri(Icons.Update, UriKind.Relative);
@@ -44,9 +45,9 @@ namespace CampusAppWP8.Pages.Events
EventIndexPage.eventFeed = new EventFeed(false);
}
EventIndexPage.eventFeed.onLoaded += new EventFeed.OnLoaded(this.SetupEventPageList);
EventIndexPage.eventFeed.onFailedWeb += new EventFeed.OnFailed(this.FeedIsFailWeb);
EventIndexPage.eventFeed.onFailedFile += new EventFeed.OnFailed(this.FeedIsFailFile);
EventIndexPage.eventFeed.OnLoaded += new EventFeed.OnIO(this.SetupEventPageList);
EventIndexPage.eventFeed.OnFailedWeb += new EventFeed.OnFailed(this.FeedIsFailedWeb);
EventIndexPage.eventFeed.OnFailedFile += new EventFeed.OnFailed(this.FeedIsFailedFile);
EventIndexPage.eventFeed.LoadData();
}
@@ -95,6 +96,7 @@ namespace CampusAppWP8.Pages.Events
private void SetupEventPageList()
{
this.EventList.ItemsSource = EventIndexPage.eventFeed.Model.Channel[0].Item;
this.progressBar.Visibility = Visibility.Collapsed;
}
/// <summary>
@@ -105,24 +107,26 @@ namespace CampusAppWP8.Pages.Events
/// <param name="e">event args</param>
private void EventForceUpdate_Click(object sender, EventArgs e)
{
this.progressBar.Visibility = Visibility.Visible;
EventIndexPage.eventFeed.ForceWebUpdate();
}
/// <summary>
/// Method will be execute if the feed is failed
/// </summary>
private void FeedIsFailWeb()
private void FeedIsFailedWeb()
{
MessageBoxResult result = MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadWeb);
EventIndexPage.eventFeed.ForceReadFile();
EventIndexPage.eventFeed.ForceReadFile();
}
/// <summary>
/// Method will be execute if the feed is failed
/// </summary>
private void FeedIsFailFile()
private void FeedIsFailedFile()
{
MessageBoxResult result = MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadFile);
this.progressBar.Visibility = Visibility.Collapsed;
}
}
}

View File

@@ -19,6 +19,8 @@
</phone:PhoneApplicationPage.Resources>
<!-- LayoutRoot -->
<Grid x:Name="LayoutRoot" Background="Transparent">
<ProgressBar x:Name="progressBar" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="Collapsed" IsIndeterminate="True"/>
<!-- Pivotpage -->
<phone:Pivot x:Name="EventPivot" Title="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" SelectionChanged="OnPivotSelectionChange">
<!-- Pivotitem template -->

View File

@@ -64,6 +64,7 @@ namespace CampusAppWP8.Pages.Events
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
this.progressBar.Visibility = Visibility.Visible;
if (this.isNewInstance)
{
@@ -117,6 +118,8 @@ namespace CampusAppWP8.Pages.Events
MessageBox.Show("ERROR: pivotIndex out of range!!! (" + o + ")");
}
}
this.progressBar.Visibility = Visibility.Collapsed;
}
/// <summary>

View File

@@ -166,8 +166,8 @@ namespace CampusAppWP8.Pages.Lecture
private void SendRequest(object sender, RoutedEventArgs e)
{
this.api = new LectureApi();
this.api.onLoaded += new LectureApi.OnLoaded(this.ApiIsReady);
this.api.onFailed += new LectureApi.OnFailed(this.ApiIsFail);
this.api.OnLoaded += new LectureApi.OnIO(this.ApiIsReady);
this.api.OnFailedLoad += new LectureApi.OnFailed(this.ApiIsFail);
this.ProgressBar.Visibility = System.Windows.Visibility.Visible;
List<UrlParamModel> parameterList = this.CreateUrlParameter();
this.api.SetUriParams(parameterList);

View File

@@ -105,9 +105,9 @@ namespace CampusAppWP8.Pages.Links
private void InitializeCommonLinkFeed()
{
this.commonLinkFeed = new CommonLinkFeed();
this.commonLinkFeed.onLoaded += new CommonLinkFeed.OnLoaded(this.CommonLinkFeedIsReady);
this.commonLinkFeed.onFailedWeb += new CommonLinkFeed.OnFailed(this.CommonLinkFeedIsFailWeb);
this.commonLinkFeed.onFailedFile += new CommonLinkFeed.OnFailed(this.FeedIsFailFile);
this.commonLinkFeed.OnLoaded += new CommonLinkFeed.OnIO(this.CommonLinkFeedIsReady);
this.commonLinkFeed.OnFailedWeb += new CommonLinkFeed.OnFailed(this.CommonLinkFeedIsFailWeb);
this.commonLinkFeed.OnFailedFile += new CommonLinkFeed.OnFailed(this.FeedIsFailFile);
}
/// <summary>
@@ -116,9 +116,9 @@ namespace CampusAppWP8.Pages.Links
private void InitializeClubLinkFeed()
{
this.clubLinkFeed = new ClubLinkFeed();
this.clubLinkFeed.onLoaded += new ClubLinkFeed.OnLoaded(this.ClubLinkFeedIsReady);
this.clubLinkFeed.onFailedWeb += new ClubLinkFeed.OnFailed(this.ClubLinkFeedIsFailWeb);
this.clubLinkFeed.onFailedFile += new ClubLinkFeed.OnFailed(this.FeedIsFailFile);
this.clubLinkFeed.OnLoaded += new ClubLinkFeed.OnIO(this.ClubLinkFeedIsReady);
this.clubLinkFeed.OnFailedWeb += new ClubLinkFeed.OnFailed(this.ClubLinkFeedIsFailWeb);
this.clubLinkFeed.OnFailedFile += new ClubLinkFeed.OnFailed(this.FeedIsFailFile);
}
/// <summary>

View File

@@ -125,8 +125,8 @@ namespace CampusAppWP8.Pages.Mensa
private void DeterminCurrentCampusAndLoadFeed()
{
this.campusApi = new CampusSpsApi();
this.campusApi.onLoaded += new SpsApi.OnLoaded(this.SpsApiIsReady);
this.campusApi.onFailed += new SpsApi.OnFailed(this.SpsApiIsFail);
this.campusApi.OnLoaded += new SpsApi.OnIO(this.SpsApiIsReady);
this.campusApi.OnFailedLoad += new SpsApi.OnFailed(this.SpsApiIsFail);
this.campusApi.SetupCurrentCampusRequest();
this.campusApi.LoadData();
}
@@ -138,9 +138,9 @@ namespace CampusAppWP8.Pages.Mensa
private void InitializeFeed(CampusAppWP8.Model.Setting.UserProfilModel.Campus campus)
{
this.feed = MensaFeed.CreateCampusMensaFeed(campus);
this.feed.onLoaded += new MensaFeed.OnLoaded(this.FeedIsReady);
this.feed.onFailedWeb += new MensaFeed.OnFailed(this.FeedIsFailWeb);
this.feed.onFailedFile += new MensaFeed.OnFailed(this.FeedIsFailFile);
this.feed.OnLoaded += new MensaFeed.OnIO(this.FeedIsReady);
this.feed.OnFailedWeb += new MensaFeed.OnFailed(this.FeedIsFailWeb);
this.feed.OnFailedFile += new MensaFeed.OnFailed(this.FeedIsFailFile);
this.CalcSelectedIndex();
if (this.forceLoad)

View File

@@ -21,6 +21,7 @@
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ProgressBar x:Name="progressBar" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="Collapsed" IsIndeterminate="True"/>
<!-- Title and headline -->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}"/>

View File

@@ -32,6 +32,7 @@ namespace CampusAppWP8.Pages.News
public NewsIndexPage()
{
this.InitializeComponent();
this.progressBar.Visibility = Visibility.Collapsed;
ApplicationBarIconButton updateBtn = new ApplicationBarIconButton();
updateBtn.IconUri = new Uri(Icons.Update, UriKind.Relative);
@@ -44,9 +45,9 @@ namespace CampusAppWP8.Pages.News
NewsIndexPage.newsFeed = new NewsFeed(false);
}
NewsIndexPage.newsFeed.onLoaded += new NewsFeed.OnLoaded(this.SetupNewsPageList);
NewsIndexPage.newsFeed.onFailedWeb += new NewsFeed.OnFailed(this.FeedIsFailWeb);
NewsIndexPage.newsFeed.onFailedFile += new NewsFeed.OnFailed(this.FeedIsFailFile);
NewsIndexPage.newsFeed.OnLoaded += new NewsFeed.OnIO(this.SetupNewsPageList);
NewsIndexPage.newsFeed.OnFailedWeb += new NewsFeed.OnFailed(this.FeedIsFailWeb);
NewsIndexPage.newsFeed.OnFailedFile += new NewsFeed.OnFailed(this.FeedIsFailFile);
NewsIndexPage.newsFeed.LoadData();
}
@@ -95,6 +96,7 @@ namespace CampusAppWP8.Pages.News
private void SetupNewsPageList()
{
this.NewsList.ItemsSource = NewsIndexPage.newsFeed.Model.Channel[0].Item;
this.progressBar.Visibility = Visibility.Collapsed;
}
/// <summary>
@@ -105,6 +107,7 @@ namespace CampusAppWP8.Pages.News
/// <param name="e">event args</param>
private void NewsForceUpdate_Click(object sender, EventArgs e)
{
this.progressBar.Visibility = Visibility.Visible;
NewsIndexPage.newsFeed.ForceWebUpdate();
}
@@ -122,6 +125,7 @@ namespace CampusAppWP8.Pages.News
/// </summary>
private void FeedIsFailFile()
{
this.progressBar.Visibility = Visibility.Collapsed;
MessageBoxResult result = MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadFile);
}
}

View File

@@ -19,7 +19,9 @@
</phone:PhoneApplicationPage.Resources>
<!-- LayoutRoot -->
<Grid x:Name="LayoutRoot" Background="Transparent">
<!-- Pivotpage -->
<ProgressBar x:Name="progressBar" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="Collapsed" IsIndeterminate="True"/>
<phone:Pivot x:Name="NewsPivot" Title="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" SelectionChanged="OnPivotSelectionChange">
<!-- Pivotitem template -->
<phone:Pivot.HeaderTemplate>

View File

@@ -45,7 +45,7 @@ namespace CampusAppWP8.Pages.News
public NewsPage()
{
this.InitializeComponent();
ApplicationBarIconButton linkBtn = new ApplicationBarIconButton();
linkBtn.IconUri = new Uri(Icons.Link, UriKind.Relative);
linkBtn.Text = AppResources.NewsLinkBtn;
@@ -64,6 +64,7 @@ namespace CampusAppWP8.Pages.News
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
this.progressBar.Visibility = Visibility.Visible;
if (this.isNewInstance)
{
@@ -110,6 +111,8 @@ namespace CampusAppWP8.Pages.News
MessageBox.Show("ERROR: pivotIndex out of range!!!");
}
}
this.progressBar.Visibility = Visibility.Collapsed;
}
/// <summary>

View File

@@ -21,13 +21,13 @@
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ProgressBar x:Name="progressBar" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="Collapsed" IsIndeterminate="True"/>
<!-- Title and headline -->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="{Binding Path=LocalizedResources.OpenHoursApp_Title, Source={StaticResource LocalizedStrings}}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" FontSize="64"/>
</StackPanel>
<!-- Content -->
<ProgressBar Name="ProgressBar" Grid.Row="1" Visibility="Collapsed" IsIndeterminate="True"/>
<ListBox x:Name="InstitutionPanel" Grid.Row="1">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">

View File

@@ -43,13 +43,14 @@ namespace CampusAppWP8.Pages.Openinghours
public OpeninghoursPage()
{
this.InitializeComponent();
this.progressBar.Visibility = Visibility.Visible;
if (this.feed == null)
{
this.feed = new OpeninghoursFeed();
this.feed.onLoaded += new OpeninghoursFeed.OnLoaded(this.FeedIsReady);
this.feed.onFailedWeb += new OpeninghoursFeed.OnFailed(this.FeedIsFailWeb);
this.feed.onFailedFile += new OpeninghoursFeed.OnFailed(this.FeedIsFailFile);
this.feed.OnLoaded += new OpeninghoursFeed.OnIO(this.FeedIsReady);
this.feed.OnFailedWeb += new OpeninghoursFeed.OnFailed(this.FeedIsFailedWeb);
this.feed.OnFailedFile += new OpeninghoursFeed.OnFailed(this.FeedIsFailedFile);
this.feed.LoadData();
}
@@ -117,8 +118,8 @@ namespace CampusAppWP8.Pages.Openinghours
private void FeedIsReady()
{
this.InstitutionPanel.ItemsSource = this.feed.Model.Institutions;
this.progressBar.Visibility = Visibility.Collapsed;
// this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed;
// this.feed.SaveData(true);
}
@@ -130,14 +131,14 @@ namespace CampusAppWP8.Pages.Openinghours
/// <param name="e">event args</param>
private void OpenHoursForceUpdate_Click(object sender, EventArgs e)
{
// this.ProgressBar.Visibility = System.Windows.Visibility.Visible;
this.progressBar.Visibility = Visibility.Visible;
this.feed.ForceWebUpdate();
}
/// <summary>
/// Method will be execute if the feed is failed
/// </summary>
private void FeedIsFailWeb()
private void FeedIsFailedWeb()
{
MessageBoxResult result = MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadWeb);
this.feed.ForceReadFile();
@@ -146,8 +147,9 @@ namespace CampusAppWP8.Pages.Openinghours
/// <summary>
/// Method will be execute if the feed is failed
/// </summary>
private void FeedIsFailFile()
private void FeedIsFailedFile()
{
this.progressBar.Visibility = Visibility.Collapsed;
MessageBoxResult result = MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadFile);
}

View File

@@ -80,9 +80,9 @@ namespace CampusAppWP8.Pages.StudentCouncil
private void InitializeFeed()
{
this.feed = new StudentCouncilFeed();
this.feed.onLoaded += new StudentCouncilFeed.OnLoaded(this.FeedIsReady);
this.feed.onFailedWeb += new StudentCouncilFeed.OnFailed(this.FeedIsFailWeb);
this.feed.onFailedFile += new StudentCouncilFeed.OnFailed(this.FeedIsFailFile);
this.feed.OnLoaded += new StudentCouncilFeed.OnIO(this.FeedIsReady);
this.feed.OnFailedWeb += new StudentCouncilFeed.OnFailed(this.FeedIsFailWeb);
this.feed.OnFailedFile += new StudentCouncilFeed.OnFailed(this.FeedIsFailFile);
}
/// <summary>

View File

@@ -406,6 +406,7 @@
</data>
<data name="MsgBox_ErrorMainModelLoadWeb" xml:space="preserve">
<value>Es konnte kein neuer Inhalt aus den Web geladen werden</value>
</data>
<data name="PrimCamNotSupported" xml:space="preserve">
<value>Die primäre Kamera steht nicht zur Verfügung.</value>
</data>

View File

@@ -50,6 +50,11 @@ namespace CampusAppWP8.Utility
this.writeType = write;
}
/// <summary>
/// Delegation of the write callback function prototype.
/// </summary>
public delegate void WriteCallbackFunc();
/// <summary>
/// IO read type ENUM.
/// </summary>
@@ -97,11 +102,6 @@ namespace CampusAppWP8.Utility
ReadOnly = 3
}
/// <summary>
/// Delegation of the write callback function prototype.
/// </summary>
public delegate void WriteCallbackFunc();
/// <summary>
/// Read data from file to a string.
/// </summary>
@@ -137,8 +137,10 @@ namespace CampusAppWP8.Utility
/// <summary>
/// Write bytes to the file.
/// </summary>
/// <param name="data">data byte array</param>
/// <param name="ioType">write type</param>
/// <param name="data">data byte array.</param>
/// <param name="onSavedCallback">callback function, called after writing is done.</param>
/// <param name="onFailedCallback">callback function, called when writing failed.</param>
/// <param name="ioType">write type.</param>
public void WriteFile(byte[] data, WriteCallbackFunc onSavedCallback, WriteCallbackFunc onFailedCallback, IOTypeWrite ioType = IOTypeWrite.INVALID)
{
IOTypeWrite tempType = ioType;
@@ -162,7 +164,6 @@ namespace CampusAppWP8.Utility
Thread th = new Thread(delegate() { this.WriteAsync(data, onSavedCallback, onFailedCallback); });
th.Start();
//this.WriteAsync(data, onSavedCallback, onFailedCallback);
}
/// <summary>
@@ -229,7 +230,9 @@ namespace CampusAppWP8.Utility
/// <summary>
/// Write data asynchronous to file.
/// </summary>
/// <param name="data">data array</param>
/// <param name="data">data array.</param>
/// <param name="onSavedCallback">callback function, called when writing is done.</param>
/// <param name="onFailedCallback">callback function, called when writing failed.</param>
private async void WriteAsync(byte[] data, WriteCallbackFunc onSavedCallback, WriteCallbackFunc onFailedCallback)
{
Logger.LogMsg("writeasync file: " + this.filename);
@@ -257,10 +260,12 @@ namespace CampusAppWP8.Utility
{
onFailedCallback();
}
return;
}
counter = 0;
// try to get a stream on the file
while ((s == null) && (counter < 10))
{
@@ -281,6 +286,7 @@ namespace CampusAppWP8.Utility
{
onFailedCallback();
}
return;
}
@@ -296,8 +302,10 @@ namespace CampusAppWP8.Utility
{
onFailedCallback();
}
Logger.LogException(e);
s.Dispose();
return;
}