From e5bde7a95bded8b5d09343dd2ed17916bfff7d77 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Mon, 16 Sep 2013 16:32:39 +0200 Subject: [PATCH 1/9] add TileCreator --- CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 1 + .../CampusAppWP8/Pages/StartPage.xaml | 19 +++++++- .../CampusAppWP8/Pages/StartPage.xaml.cs | 29 ++++++++++++ .../Utility/Lui/Tiles/TileCreator.cs | 46 +++++++++++++++++++ 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 CampusAppWP8/CampusAppWP8/Utility/Lui/Tiles/TileCreator.cs diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 7fab7caa..f9b3930d 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -146,6 +146,7 @@ ShowPad.xaml + diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml index 2502caf2..baeefd07 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml @@ -7,6 +7,7 @@ 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" + xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" @@ -94,7 +95,7 @@ - + @@ -112,6 +113,15 @@ + + + + + + + + + @@ -120,6 +130,13 @@ + + + + + + + diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs index 3bd7cdc6..3313910f 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs @@ -8,6 +8,7 @@ namespace CampusAppWP8.Pages { using System; + using System.Linq; using System.Threading; using System.Windows; using System.Windows.Controls; @@ -19,6 +20,7 @@ namespace CampusAppWP8.Pages using Microsoft.Phone.Controls; using Microsoft.Phone.Shell; using CampusAppWP8.File.Places; + using CampusAppWP8.Utility.Lui.Tiles; /// /// Class for the StartPage @@ -278,6 +280,33 @@ namespace CampusAppWP8.Pages #endregion + private void PintoStart_Click(object sender, RoutedEventArgs e) + { + TileCreator.CreateMensaTile(); + } + + private void PintoStart_Click2(object sender, RoutedEventArgs e) + { + IconicTileData oIcontile = new IconicTileData(); + oIcontile.Title = "WebmailPage"; + + oIcontile.IconImage = new Uri(Icons.Mensa, UriKind.Relative); + oIcontile.SmallIconImage = new Uri(Icons.Mensa, UriKind.Relative); + + // find the tile object for the application tile that using "Iconic" contains string in it. + ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("WebmailPage".ToString())); + + if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains("WebmailPage")) + { + TileToFind.Delete(); + ShellTile.Create(new Uri(Constants.PathMail_WebMailPage, UriKind.Relative), oIcontile, true); + } + else + { + ShellTile.Create(new Uri(Constants.PathMail_WebMailPage, UriKind.Relative), oIcontile, true); + } + } + #endregion } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Tiles/TileCreator.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Tiles/TileCreator.cs new file mode 100644 index 00000000..6a783363 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Tiles/TileCreator.cs @@ -0,0 +1,46 @@ +using CampusAppWP8.Resources; +using Microsoft.Phone.Shell; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CampusAppWP8.Utility.Lui.Tiles +{ + public class TileCreator + { + public static void CreateIconicTile(string title, string path, string iconUrl, string smallIcon, string wContent1 = null, string wContent2 = null, string wContent3 = null) + { + + IconicTileData oIcontile = new IconicTileData(); + oIcontile.Title = title; + oIcontile.WideContent1 = wContent1; + oIcontile.WideContent2 = wContent2; + oIcontile.WideContent3 = wContent3; + + oIcontile.IconImage = new Uri(iconUrl, UriKind.Relative); + oIcontile.SmallIconImage = new Uri(smallIcon, UriKind.Relative); + + // find the tile object for the application tile that using "Iconic" contains string in it. + ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(path)); + + if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(path)) + { + TileToFind.Delete(); + } + + ShellTile.Create(new Uri(path, UriKind.Relative), oIcontile, true); + } + + public static void CreateMensaTile() + { + TileCreator.CreateIconicTile(AppResources.MensaApp_Title, Constants.PathMensa_MensaPage, Icons.Mensa, Icons.Mensa); + } + + public static void CreateWebMailTile() + { + TileCreator.CreateIconicTile(AppResources.MensaApp_Title, Constants.PathMensa_MensaPage, Icons.Mensa, Icons.Mensa); + } + } +} From b0a8b8f6af6d646e585d04c291c5b91eb478d79c Mon Sep 17 00:00:00 2001 From: stubbfel Date: Mon, 16 Sep 2013 19:11:05 +0200 Subject: [PATCH 2/9] add shcedulagent --- CampusAppWP8/CampusAppW8.sln | 24 ++ CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 7 +- .../Utility/Lui/Tiles/TileCreator.cs | 43 ++++ .../CampusAppWP8ScheduledTaskAgent.csproj | 134 +++++++++++ .../Model/Mensa/MealModel.cs | 185 +++++++++++++++ .../Model/Mensa/MenuModel.cs | 94 ++++++++ .../Model/Mensa/MenuWeekModel.cs | 104 +++++++++ .../Model/Utility/CleanUrlParamModel.cs | 66 ++++++ .../Model/Utility/URLParamModel.cs | 108 +++++++++ .../Properties/AssemblyInfo.cs | 37 +++ .../Resources/AppResources.Designer.cs | 162 +++++++++++++ .../Resources/AppResources.resx | 153 +++++++++++++ .../Resources/Constants.Designer.cs | 117 ++++++++++ .../Resources/Constants.resx | 138 +++++++++++ .../ScheduledAgent.cs | 109 +++++++++ .../Utility/HttpRequest.cs | 216 ++++++++++++++++++ .../Utility/Logger.cs | 35 +++ .../Utility/StringManager.cs | 59 +++++ .../Utility/XmlManager.cs | 88 +++++++ .../CampusAppWPortalLib8.csproj | 3 + 20 files changed, 1881 insertions(+), 1 deletion(-) create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/CampusAppWP8ScheduledTaskAgent.csproj create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Mensa/MealModel.cs create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Mensa/MenuModel.cs create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Mensa/MenuWeekModel.cs create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Utility/CleanUrlParamModel.cs create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Utility/URLParamModel.cs create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Properties/AssemblyInfo.cs create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.Designer.cs create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.resx create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.Designer.cs create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.resx create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/HttpRequest.cs create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/Logger.cs create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/StringManager.cs create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/XmlManager.cs diff --git a/CampusAppWP8/CampusAppW8.sln b/CampusAppWP8/CampusAppW8.sln index f65bd6ee..479bc0b1 100644 --- a/CampusAppWP8/CampusAppW8.sln +++ b/CampusAppWP8/CampusAppW8.sln @@ -11,6 +11,8 @@ Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "IconCreator", "IconCreator\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CampusAppDLL", "CampusAppDLL\CampusAppDLL.csproj", "{E4EC5B95-06FC-4304-97E2-9E3F9B980303}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CampusAppWP8ScheduledTaskAgent", "CampusAppWP8ScheduledTaskAgent\CampusAppWP8ScheduledTaskAgent.csproj", "{2A51FA6C-791B-4935-B869-FDBA9ED774D7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -139,6 +141,28 @@ Global {E4EC5B95-06FC-4304-97E2-9E3F9B980303}.Release|Win32.ActiveCfg = Release|Any CPU {E4EC5B95-06FC-4304-97E2-9E3F9B980303}.Release|x64.ActiveCfg = Release|Any CPU {E4EC5B95-06FC-4304-97E2-9E3F9B980303}.Release|x86.ActiveCfg = Release|Any CPU + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Debug|ARM.ActiveCfg = Debug|ARM + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Debug|ARM.Build.0 = Debug|ARM + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Debug|Win32.ActiveCfg = Debug|x86 + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Debug|Win32.Build.0 = Debug|x86 + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Debug|x64.ActiveCfg = Debug|Any CPU + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Debug|x86.ActiveCfg = Debug|x86 + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Debug|x86.Build.0 = Debug|x86 + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Release|Any CPU.Build.0 = Release|Any CPU + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Release|ARM.ActiveCfg = Release|ARM + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Release|ARM.Build.0 = Release|ARM + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Release|Mixed Platforms.Build.0 = Release|x86 + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Release|Win32.ActiveCfg = Release|x86 + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Release|Win32.Build.0 = Release|x86 + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Release|x64.ActiveCfg = Release|Any CPU + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Release|x86.ActiveCfg = Release|x86 + {2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index f9b3930d..c3eae64f 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -548,7 +548,12 @@ - + + + {2A51FA6C-791B-4935-B869-FDBA9ED774D7} + CampusAppWP8ScheduledTaskAgent + + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Mensa/MealModel.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Mensa/MealModel.cs new file mode 100644 index 00000000..278f4568 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Mensa/MealModel.cs @@ -0,0 +1,185 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 06.08.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8ScheduledTaskAgent.Model.Mensa +{ + using System.Xml.Serialization; + using CampusAppWP8ScheduledTaskAgent.Resources; + using CampusAppWP8ScheduledTaskAgent.Utility; + + /// + /// Model for a meal + /// + public class MealModel + { + #region Members + + /// + /// Constant for the vegetarian icon + /// + private const string MealIconNameVegetarian = "CARROTTE"; + + /// + /// Constant for the free icon + /// + private const string MealIconNameFree = "FREI"; + + /// + /// Constant for the pig icon + /// + private const string MealIconNamePig = "SCHWEIN"; + + /// + /// Constant for the cow icon + /// + private const string MealIconNameCow = "RIND"; + + /// + /// Constant for the fowl icon + /// + private const string MealIconNameFowl = "GEFL"; + + /// + /// Constant for the cow-pig icon + /// + private const string MealIconNameCowPig = "RINDSCHWEIN"; + + /// + /// Constant for the fish icon + /// + private const string MealIconNameFish = "FISCH"; + + /// + /// Constant for the wild icon + /// + private const string MealIconNameWild = "WILD"; + + /// + /// Constant for the lamb icon + /// + private const string MealIconNameLamb = "LAMM"; + + /// + /// Variable for the id of the meal + /// + /// + /// ValueRange : 0 - 7 + /// + private int mealId; + + /// + /// Name of the meal + /// + private string mealName; + + /// + /// Description of the meal + /// + private string mealDesc; + + #endregion + + #region Proberty + + /// + /// Gets or sets the mealId + /// + /// + /// ValueRange : 0 - 7 + /// + [XmlAttribute("id")] + public int MealId + { + get + { + return this.mealId; + } + + set + { + if (value > -1 && value < 8) + { + this.mealId = value; + this.CreateMealName(); + } + } + } + + /// + /// Gets the mealName + /// + public string MealName + { + get + { + return this.mealName; + } + } + + /// + /// Gets or sets the mealDescription + /// + [XmlAttribute("desc")] + public string MealDesc + { + get + { + return this.mealDesc; + } + + set + { + if (value != this.mealDesc) + { + this.mealDesc = StringManager.StripHTML(value); + } + } + } + + #endregion + + #region Methods + + /// + /// Method create depends of the mealId the mealName + /// + private void CreateMealName() + { + switch (this.mealId) + { + case 0: + this.mealName = AppResources.MensaApp_Soup; + break; + case 1: + this.mealName = AppResources.MensaApp_Dinner1; + break; + case 2: + this.mealName = AppResources.MensaApp_Dinner2; + break; + case 3: + this.mealName = AppResources.MensaApp_Dinner3; + break; + case 4: + this.mealName = AppResources.MensaApp_Dinner4; + break; + case 5: + this.mealName = AppResources.MensaApp_Dinner5; + break; + case 6: + this.mealName = AppResources.MensaApp_Bio; + break; + case 7: + this.mealName = AppResources.MensaApp_Action; + break; + default: + this.mealName = string.Empty; + break; + } + } + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Mensa/MenuModel.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Mensa/MenuModel.cs new file mode 100644 index 00000000..d51b9927 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Mensa/MenuModel.cs @@ -0,0 +1,94 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 04.05.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8ScheduledTaskAgent.Model.Mensa +{ + using System; + using System.Collections.ObjectModel; + using System.Xml.Serialization; + + /// + /// Model for menu + /// + public class MenuModel + { + #region Member + + /// + /// Name of the day + /// + private string dayName; + + /// + /// DateTime of the day + /// + private string date; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + public MenuModel() + { + } + + #endregion + + #region Property + + /// + /// Gets or sets the menus for the week + /// + [XmlElement("Meal")] + public ObservableCollection Meals { get; set; } + + /// + /// Gets or sets the WeekDay + /// + [XmlAttribute("day")] + public string Day + { + get + { + return this.dayName; + } + + set + { + if (value != this.dayName) + { + this.dayName = value; + } + } + } + + /// + /// Gets or sets of Date + /// + [XmlAttribute("date")] + public string Date + { + get + { + return this.date.ToString(); + } + + set + { + if (value != this.date) + { + this.date = value; + } + } + } + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Mensa/MenuWeekModel.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Mensa/MenuWeekModel.cs new file mode 100644 index 00000000..7e033766 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Mensa/MenuWeekModel.cs @@ -0,0 +1,104 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 03.05.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8ScheduledTaskAgent.Model.Mensa +{ + using CampusAppWP8ScheduledTaskAgent.Utility; + using System; + using System.Collections.ObjectModel; + using System.Xml.Serialization; + + /// + /// Model for menus in one week + /// + [XmlRoot("root")] + public class MenuWeekModel + { + #region Members + /// + /// Time when the model was created + /// + private readonly DateTime createTime; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + public MenuWeekModel() + { + this.createTime = DateTime.Now; + } + + #endregion + + #region Proberty + + /// + /// Gets or sets the menus for the week + /// + [XmlArray("Mealplan")] + [XmlArrayItem("Menu")] + public ObservableCollection Menus { get; set; } + + /// + /// Gets the creation time of the model + /// + public DateTime CreateTime + { + get + { + return this.createTime; + } + } + + #endregion + + #region Methods + + public string MealToString(string date) + { + string mealString = string.Empty; + + foreach (MenuModel menu in this.Menus) + { + if (menu.Date.Equals(date)) + { + foreach (MealModel meal in menu.Meals) + { + int lenght = meal.MealDesc.Length; + if (lenght > 30) { + lenght = 30; + } + mealString += meal.MealName + ": " + meal.MealDesc.Substring(0, lenght) +"..."; + mealString = StringManager.AddNewLine(mealString); + } + return mealString; + } + } + + return mealString; + } + + public int GetMealCount(string date) + { + foreach (MenuModel menu in this.Menus) + { + if (menu.Date.Equals(date)) + { + return menu.Meals.Count; + } + } + + return 0; + } + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Utility/CleanUrlParamModel.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Utility/CleanUrlParamModel.cs new file mode 100644 index 00000000..7e35cd1a --- /dev/null +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Utility/CleanUrlParamModel.cs @@ -0,0 +1,66 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 06.08.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8ScheduledTaskAgent.Model.Utility +{ + /// + /// This class is a Model for the URLParameter like GET-Parameter + /// + public class CleanUrlParamModel : UrlParamModel + { + #region Constructor + + /// Initializes a new instance of the CleanUrlParamModel class. + /// Stubbfel, 12.09.2013. + /// the key for the parameter. + public CleanUrlParamModel(string key) + : base(key) + { + } + + /// Initializes a new instance of the CleanUrlParamModel class. + /// Stubbfel, 12.09.2013. + /// the key for the parameter. + /// The value. + public CleanUrlParamModel(string key, string value) + : base(key, value) + { + } + #endregion + + #region Proberty + + /// + /// Gets the token, which indicate that the parameterList started + /// + public override string ParamToken + { + get + { + return string.Empty; + } + } + #endregion + + #region Methods + + /// + /// Method return a formatted string like Key=Value + /// + /// return formatted string + public override string ToString() + { + if (!this.IsParamValid()) + { + return string.Empty; + } + + return "/" + this.key + "/" + this.Value; + } + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Utility/URLParamModel.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Utility/URLParamModel.cs new file mode 100644 index 00000000..b7090214 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Utility/URLParamModel.cs @@ -0,0 +1,108 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 17.06.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8ScheduledTaskAgent.Model.Utility +{ + /// + /// This class is a Model for the URLParameter like GET-Parameter + /// + public class UrlParamModel + { + #region Members + + /// + /// Variable of the key + /// + protected readonly string key; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + /// the key for the parameter + public UrlParamModel(string key) + { + this.key = key; + } + + /// + /// Initializes a new instance of the class. + /// + /// the key for the parameter> + /// value of the parameter + public UrlParamModel(string key, string value) + { + this.key = key; + this.Value = value; + } + #endregion + + #region Proberty + + /// + /// Gets or sets the value of the Parameter + /// + public string Value { get; set; } + + /// + /// Gets the key of the parameter + /// + public string Key + { + get + { + return this.key; + } + } + + /// + /// Gets the token, which indicate that the parameterList started + /// + public virtual string ParamToken + { + get + { + return "?"; + } + } + #endregion + + #region Methods + + /// + /// Method check if the parameter is valid + /// + /// true if is it valid, otherwise false + public virtual bool IsParamValid() + { + if (this.key == null || string.Empty.Equals(this.key) || string.Empty.Equals(this.Value)) + { + return false; + } + + return true; + } + + /// + /// Method return a formatted string like Key=Value + /// + /// return formatted string + public override string ToString() + { + if (!this.IsParamValid()) + { + return string.Empty; + } + + return "&" + this.key + "=" + this.Value; + } + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Properties/AssemblyInfo.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..b1d78706 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Properties/AssemblyInfo.cs @@ -0,0 +1,37 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Resources; + +// Allgemeine Informationen über eine Assembly werden über die folgende +// Attributgruppe gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die einer Assembly zugeordnet sind. +[assembly: AssemblyTitle("CampusAppWP8ScheduledTaskAgent")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CampusAppWP8ScheduledTaskAgent")] +[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly +// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von +// COM aus zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. +[assembly: ComVisible(false)] + +// Die folgende GUID ist für die ID der typelib, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("2a51fa6c-791b-4935-b869-fdba9ed774d7")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder die Standardwerte für Revisions- und Buildnummer verwenden +// übernehmen, indem Sie "*" wie folgt verwenden: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: NeutralResourcesLanguageAttribute("de-DE")] diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.Designer.cs new file mode 100644 index 00000000..c252dfd4 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.Designer.cs @@ -0,0 +1,162 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion:4.0.30319.18051 +// +// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +// der Code erneut generiert wird. +// +//------------------------------------------------------------------------------ + +namespace CampusAppWP8ScheduledTaskAgent.Resources { + using System; + + + /// + /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// + // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class AppResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal AppResources() { + } + + /// + /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CampusAppWP8ScheduledTaskAgent.Resources.AppResources", typeof(AppResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Aktion ähnelt. + /// + public static string MensaApp_Action { + get { + return ResourceManager.GetString("MensaApp_Action", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Bio ähnelt. + /// + public static string MensaApp_Bio { + get { + return ResourceManager.GetString("MensaApp_Bio", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Essen 1 ähnelt. + /// + public static string MensaApp_Dinner1 { + get { + return ResourceManager.GetString("MensaApp_Dinner1", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Essen 2 ähnelt. + /// + public static string MensaApp_Dinner2 { + get { + return ResourceManager.GetString("MensaApp_Dinner2", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Essen 3 ähnelt. + /// + public static string MensaApp_Dinner3 { + get { + return ResourceManager.GetString("MensaApp_Dinner3", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Essen 4 ähnelt. + /// + public static string MensaApp_Dinner4 { + get { + return ResourceManager.GetString("MensaApp_Dinner4", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Essen 5 ähnelt. + /// + public static string MensaApp_Dinner5 { + get { + return ResourceManager.GetString("MensaApp_Dinner5", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die 84 ähnelt. + /// + public static string MensaApp_DinnerLabelW { + get { + return ResourceManager.GetString("MensaApp_DinnerLabelW", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Heute nicht im Angbot ähnelt. + /// + public static string MensaApp_NotToday { + get { + return ResourceManager.GetString("MensaApp_NotToday", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Suppe ähnelt. + /// + public static string MensaApp_Soup { + get { + return ResourceManager.GetString("MensaApp_Soup", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Mensaplan ähnelt. + /// + public static string MensaApp_Title { + get { + return ResourceManager.GetString("MensaApp_Title", resourceCulture); + } + } + } +} diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.resx new file mode 100644 index 00000000..a47731a4 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.resx @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Mensaplan + + + Aktion + + + Bio + + + Essen 1 + + + Essen 2 + + + Essen 3 + + + Essen 4 + + + Heute nicht im Angbot + + + 84 + + + Essen 5 + + + Suppe + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.Designer.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.Designer.cs new file mode 100644 index 00000000..44c40bb1 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.Designer.cs @@ -0,0 +1,117 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion:4.0.30319.18051 +// +// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +// der Code erneut generiert wird. +// +//------------------------------------------------------------------------------ + +namespace CampusAppWP8ScheduledTaskAgent.Resources { + using System; + + + /// + /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// + // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Constants { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Constants() { + } + + /// + /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CampusAppWP8ScheduledTaskAgent.Resources.Constants", typeof(Constants).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die /Pages/Mensa/MensaPage.xaml ähnelt. + /// + public static string PathMensa_MensaPage { + get { + return ResourceManager.GetString("PathMensa_MensaPage", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1 ähnelt. + /// + public static string UrlMensa_Week_CBMain { + get { + return ResourceManager.GetString("UrlMensa_Week_CBMain", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1 ähnelt. + /// + public static string UrlMensa_Week_CBNorth { + get { + return ResourceManager.GetString("UrlMensa_Week_CBNorth", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusHL&v=1 ähnelt. + /// + public static string UrlMensa_Week_CBSouth { + get { + return ResourceManager.GetString("UrlMensa_Week_CBSouth", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=Senftenberg&v=1 ähnelt. + /// + public static string UrlMensa_Week_SBFMain { + get { + return ResourceManager.GetString("UrlMensa_Week_SBFMain", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die root ähnelt. + /// + public static string XMLRootElementName { + get { + return ResourceManager.GetString("XMLRootElementName", resourceCulture); + } + } + } +} diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.resx new file mode 100644 index 00000000..c6c49152 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.resx @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + root + + + http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1 + + + http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1 + + + http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusHL&v=1 + + + http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=Senftenberg&v=1 + + + /Pages/Mensa/MensaPage.xaml + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs new file mode 100644 index 00000000..a847cb83 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs @@ -0,0 +1,109 @@ +using System.Diagnostics; +using System.Windows; +using Microsoft.Phone.Scheduler; +using CampusAppWP8ScheduledTaskAgent.Utility; +using System; +using CampusAppWP8ScheduledTaskAgent.Resources; +using CampusAppWP8ScheduledTaskAgent.Model.Mensa; +using Microsoft.Phone.Shell; +using System.Linq; +using System.Collections.Generic; +using System.Globalization; + +namespace CampusAppWP8ScheduledTaskAgent +{ + public class ScheduledAgent : ScheduledTaskAgent + { + private static List MealList; + + private static string LastMensaUpdate; + + /// + /// ScheduledAgent-Konstruktor, initialisiert den UnhandledException-Handler + /// + static ScheduledAgent() + { + // Handler für verwaltete Ausnahmen abonnieren + Deployment.Current.Dispatcher.BeginInvoke(delegate + { + Application.Current.UnhandledException += UnhandledException; + }); + } + + /// Code, der bei nicht behandelten Ausnahmen ausgeführt wird + private static void UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) + { + if (Debugger.IsAttached) + { + // Eine nicht behandelte Ausnahme ist aufgetreten. Unterbrechen und Debugger öffnen + Debugger.Break(); + } + } + + /// + /// Agent zum Ausführen einer geplanten Aufgabe + /// + /// + /// Die aufgerufene Aufgabe + /// + /// + /// Diese Methode wird aufgerufen, wenn eine regelmäßige oder ressourcenintensive Aufgabe aufgerufen wird + /// + protected override void OnInvoke(ScheduledTask task) + { + if (task.Name.Equals("MensaTask")) + { + //TODO: Code zum Ausführen der Aufgabe im Hintergrund hinzufügen + if (ScheduledAgent.LastMensaUpdate == null || !ScheduledAgent.LastMensaUpdate.Equals(DateTime.Now.ToShortDateString())) + { + HttpRequest api = new HttpRequest(); + Uri url = new Uri(Constants.UrlMensa_Week_CBMain, UriKind.Absolute); + api.HttpGet(url, this.GetIsReady); + } + else + { + ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(Constants.PathMensa_MensaPage)); + + if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(Constants.PathMensa_MensaPage)) + { + IconicTileData data = new IconicTileData(); + DateTime now = DateTime.Now; + Random random = new Random(); + int randomNumber = random.Next(0, ScheduledAgent.MealList.Count - 1); + data.WideContent3 = ScheduledAgent.MealList[randomNumber]; + TileToFind.Update(data); + } + } + + } + + } + + private void GetIsReady(object arg1, System.Net.DownloadStringCompletedEventArgs arg2) + { + if (arg2.Result != null) + { + MenuWeekModel week = XmlManager.DeserializationToModel(arg2.Result, Constants.XMLRootElementName); + ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(Constants.PathMensa_MensaPage)); + + if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(Constants.PathMensa_MensaPage)) + { + IconicTileData data = new IconicTileData(); + DateTime now = DateTime.Now; + data.WideContent1 = CultureInfo.CurrentCulture.DateTimeFormat.DayNames[(int)DateTime.Now.DayOfWeek]; + data.WideContent2 = now.Date.ToShortDateString(); + string mealString = week.MealToString(now.Date.ToShortDateString()); + ScheduledAgent.MealList = mealString.Split('\n').ToList(); + Random random = new Random(); + int randomNumber = random.Next(0, ScheduledAgent.MealList.Count - 1); + + data.WideContent3 = ScheduledAgent.MealList[randomNumber]; + data.Count = week.GetMealCount(now.Date.ToShortDateString()); + ScheduledAgent.LastMensaUpdate = now.Date.ToShortDateString(); + TileToFind.Update(data); + } + } + NotifyComplete(); + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/HttpRequest.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/HttpRequest.cs new file mode 100644 index 00000000..4750cb3f --- /dev/null +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/HttpRequest.cs @@ -0,0 +1,216 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 10.06.2013 +//----------------------------------------------------------------------using System; +namespace CampusAppWP8ScheduledTaskAgent.Utility +{ + using System; + using System.Collections.Generic; + using System.Net; + using CampusAppWP8ScheduledTaskAgent.Model.Utility; + + /// + /// Class realize the access of restful HttpRequest + /// + public class HttpRequest + { + #region Member + + /// + /// BaseAddress of the webClient + /// + private string baseAddress; + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + public HttpRequest() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// the url of the HttpRequest base address + public HttpRequest(Uri apiBaseAddress) + { + this.baseAddress = apiBaseAddress.AbsoluteUri; + } + + #endregion + + #region Methods + #region public + + /// + /// Method realize the http-get-method resource + /// + /// Url of the resource + /// callback method + public void HttpGet(Uri url, Action action) + { + WebClient client = new WebClient(); + client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(action); + client.DownloadStringAsync(url); + } + + /// Method realize the http-get-method resource. + /// Stubbfel, 03.09.2013. + /// Url of the resource. + /// The action. + public void HttpGet(Uri url, Action action) + { + WebClient client = new WebClient(); + client.OpenReadCompleted += new OpenReadCompletedEventHandler(action); + client.OpenReadAsync(url); + } + + /// + /// Method create the Url for the http-get-method + /// + /// list of parameters + /// absolute API-Url include GetParameter + public Uri CreateGetUrl(List 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 = this.baseAddress + seperator + paramterStr; + return new Uri(getUrlStr, UriKind.Absolute); + } + + /// + /// Method realize the http-delete-method + /// + /// + /// is not supported by WebClient + /// + /// Url of the resource + /// callback method + public void HttpDelete(Uri url, Action action) + { + throw new NotSupportedException(); + } + + /// + /// Method realize the http-head-method + /// + /// + /// is not supported by WebClient + /// + /// Url of the resource + /// callback method + public void HttpHead(Uri url, Action action) + { + throw new NotSupportedException(); + } + + /// + /// Method realize the http-options-method + /// + /// + /// is not supported by WebClient + /// + /// Url of the resource + /// callback method + public void HttpOptions(Uri url, Action action) + { + throw new NotSupportedException(); + } + + /// + /// Method realize the http-connect-method + /// + /// + /// is not supported by WebClient + /// + /// Url of the resource + /// callback method + public void HttpConnect(Uri url, Action action) + { + throw new NotSupportedException(); + } + + /// + /// Method realize the http-trace-method + /// + /// + /// is not supported by WebClient + /// + /// Url of the resource + /// callback method + public void HttpTrace(Uri url, Action action) + { + throw new NotSupportedException(); + } + + /// + /// Method realize the http-post-method + /// + /// Url of the resource + /// callback method + /// Data which are sending via post to the HttpRequest + public void HttpPost(Uri url, Action action, string postData) + { + this.UploadData(url, action, "POST", postData); + } + + /// + /// Method realize the http-put-method + /// + /// Url of the resource + /// callback method + /// Data which are sending via put to the HttpRequest + public void HttpPut(Uri url, Action action, string putData) + { + this.UploadData(url, action, "PUT", putData); + } + + /// + /// Method realize the http-patch-method + /// + /// Url of the resource + /// callback method + /// Data which are sending via patch to the HttpRequest + public void HttpPatch(Uri url, Action action, string patchData) + { + this.UploadData(url, action, "PATCH", patchData); + } + + #endregion + + #region private + + /// + /// Method uploaded Data to the HttpRequest + /// + /// Url of the resource + /// callback method + /// name of APIMethod, how the data will be uploaded + /// Data which are sending to the HttpRequest + private void UploadData(Uri url, Action action, string method, string data) + { + WebClient client = new WebClient(); + client.UploadStringCompleted += new UploadStringCompletedEventHandler(action); + client.UploadStringAsync(url, method, data); + } + #endregion + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/Logger.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/Logger.cs new file mode 100644 index 00000000..6007319e --- /dev/null +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/Logger.cs @@ -0,0 +1,35 @@ +//-------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 03.05.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8ScheduledTaskAgent.Utility +{ + using System; + + /// + /// This Class creates logs for the app + /// + public class Logger + { + /// + /// Method log a Exception + /// + /// exception which has to log + public static void LogException(Exception exception) + { + // Console.WriteLine(exception); + } + + /// + /// Log a message. + /// + /// to be logged message + public static void LogMsg(string msg) + { + // Console.WriteLine(msg); + } + } +} diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/StringManager.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/StringManager.cs new file mode 100644 index 00000000..199dacd2 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/StringManager.cs @@ -0,0 +1,59 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 06.06.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8ScheduledTaskAgent.Utility +{ + using System.Text.RegularExpressions; + + /// + /// Class provides some special StringMethods + /// + public static class StringManager + { + #region Members + + /// + /// Patter for Html-Tags + /// + private static readonly string HtmlTagPattern = "<.*?>"; + + #endregion + + #region Methods + + /// + /// Method removes Html-Tag of a String + /// + /// String with Html-Tags + /// String without Html-Tags + public static string StripHTML(string inputString) + { + return Regex.Replace(inputString, HtmlTagPattern, string.Empty); + } + + /// + /// Method add an Newline to a string + /// + /// input string + /// input string + newline + public static string AddNewLine(string str) + { + return str.ToString() + "\n"; + } + + /// + /// Method remove(TrimEND!) an Newline to a string + /// + /// input string + /// input string - newline +// Company copyright tag. +// +// stubbfel +// 18.06.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8ScheduledTaskAgent.Utility +{ + using System.IO; + using System.Xml.Linq; + using System.Xml.Serialization; + + /// + /// Class provides some Xml-methods + /// + public class XmlManager + { + /// + /// Method deserialization a string to a Model + /// + /// the model + /// the XmlString + /// name of the RootTag + /// return the deserialization of the model + public static T DeserializationToModel(string xmlString, string validRootName) + { + XmlSerializer serializer = new XmlSerializer(typeof(T)); + XDocument document = XDocument.Parse(xmlString); + if (!document.Root.Name.ToString().Equals(validRootName)) + { + XElement content = document.Root; + document = new XDocument(); + document.Add(new XElement(validRootName, content)); + } + + T model = (T)serializer.Deserialize(document.CreateReader()); + return model; + } + + /// Deserialization a xml file to a model. + /// Stubbfel, 20.08.2013. + /// Generic type parameter. + /// Path to the a XmlFile. + /// model of the XmlFile. + public static T DeserializationFileToModel(string xmlFilePath) + { + XmlSerializer serializer = new XmlSerializer(typeof(T)); + XDocument document = XDocument.Load(xmlFilePath); + T model = (T)serializer.Deserialize(document.CreateReader()); + return model; + } + + /// + /// Method serializes a model to a string. + /// + /// type of the model + /// model object + /// serialized string + public static string SerializationToString(T model) + { + string retValue = string.Empty; + + XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); + ns.Add(string.Empty, string.Empty); + + XmlSerializer serializer = new XmlSerializer(typeof(T)); + TextWriter writer = new StringWriter(); + + serializer.Serialize(writer, model, ns); + + retValue = writer.ToString(); + + if (retValue.StartsWith(""); + retValue = retValue.Substring(endTag + 2); + + if (retValue.StartsWith("\r\n") == true) + { + retValue = retValue.Substring(2); + } + } + + return retValue; + } + } +} diff --git a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj index 8d9e3e15..252a56ef 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj +++ b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj @@ -39,7 +39,10 @@ + + + From 98d8a43961e04fb9895c8d4b0be6dcc1eb625943 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Tue, 17 Sep 2013 13:48:37 +0200 Subject: [PATCH 3/9] add event and news task --- CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 1 + .../CampusAppWP8/Pages/StartPage.xaml | 88 +++++- .../CampusAppWP8/Pages/StartPage.xaml.cs | 56 +++- .../Resources/AppResources.Designer.cs | 9 + .../CampusAppWP8/Resources/AppResources.resx | 3 + .../CampusAppWP8/Utility/BackgroundTasks.cs | 78 +++++ .../Utility/Lui/Tiles/TileCreator.cs | 101 +++--- .../CampusAppWP8ScheduledTaskAgent.csproj | 12 +- .../Model/Mensa/MealModel.cs | 14 + .../Model/Mensa/MenuWeekModel.cs | 42 +-- .../Model/RSS/RSSChannelModel.cs | 82 +++++ .../Model/RSS/RSSModel.cs | 276 ++++++++++++++++ .../Model/RSS/RSSViewModel.cs | 83 +++++ .../Resources/AppResources.Designer.cs | 36 +++ .../Resources/AppResources.resx | 12 + .../Resources/Constants.resx | 21 ++ ...nts.Designer.cs => Constants1.Designer.cs} | 63 ++++ .../ScheduledAgent.cs | 295 ++++++++++++++---- .../Utility/BackgroundTasks.cs | 49 +++ .../Utility/StringManager.cs | 10 + .../CampusAppWPortalLib8.csproj | 3 - 21 files changed, 1172 insertions(+), 162 deletions(-) create mode 100644 CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/RSS/RSSChannelModel.cs create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/RSS/RSSModel.cs create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/RSS/RSSViewModel.cs rename CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/{Constants.Designer.cs => Constants1.Designer.cs} (69%) create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/BackgroundTasks.cs diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index c3eae64f..4e9814f4 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -145,6 +145,7 @@ ShowPad.xaml + diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml index baeefd07..7a3c07a2 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml @@ -51,6 +51,12 @@ + + + + + + @@ -58,6 +64,12 @@ + + + + + + @@ -83,6 +95,12 @@ + + + + + + @@ -90,6 +108,12 @@ + + + + + + @@ -107,22 +131,25 @@ + + + + + + - + - - - - - - - - - + + + + + + @@ -132,9 +159,7 @@ - - - + @@ -155,6 +180,12 @@ + + + + + + @@ -162,6 +193,12 @@ + + + + + + @@ -172,6 +209,12 @@ + + + + + + @@ -190,6 +233,12 @@ + + + + + + @@ -197,12 +246,25 @@ + + + + + + + + + + + + + diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs index 3313910f..9f58635d 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs @@ -282,7 +282,61 @@ namespace CampusAppWP8.Pages private void PintoStart_Click(object sender, RoutedEventArgs e) { - TileCreator.CreateMensaTile(); + FrameworkElement elment = sender as FrameworkElement; + if (elment == null) + { + return; + } + + string tagButtonName = elment.Tag as string; + if (tagButtonName == null) + { + return; + } + + switch (tagButtonName) + { + case "MensaAppButton": + TileCreator.CreateMensaTile(); + break; + case "MailAppButton": + TileCreator.CreateWebMailTile(); + break; + case "NewsAppButton": + TileCreator.CreateNewsTile(); + break; + case "LectureAppButton": + TileCreator.CreateLectureTile(); + break; + case "EventAppButton": + TileCreator.CreateEventTile(); + break; + case "CampusMapAppButton": + TileCreator.CreateCampusMapTile(); + break; + case "DepartmentAppButton": + TileCreator.CreateDepartmentTile(); + break; + case "OpenHoursAppButton": + TileCreator.CreateOpeningHoursTile(); + break; + case "LinkAppButton": + TileCreator.CreateLinkTile(); + break; + case "OSAAppButton": + TileCreator.CreateStudentCouncilTile(); + break; + case "examinationAppButton": + TileCreator.CreateExamsTile(); + break; + case "personAppButton": + TileCreator.CreatePersonTile(); + break; + case "placeNewsAppButton": + TileCreator.CreatePlaceNewsTile(); + break; + } + } private void PintoStart_Click2(object sender, RoutedEventArgs e) diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs index 1840f04c..ddfc70cb 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs @@ -150,6 +150,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Auf Startseite ähnelt. + /// + public static string ContextMenu_PinToStart { + get { + return ResourceManager.GetString("ContextMenu_PinToStart", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Bachelor ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx index 3fd4d90c..44a33210 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx @@ -464,4 +464,7 @@ Beschreibung + + Auf Startseite + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs b/CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs new file mode 100644 index 00000000..561f0bb5 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs @@ -0,0 +1,78 @@ +using CampusAppWP8ScheduledTaskAgent.Resources; +using Microsoft.Phone.Scheduler; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CampusAppWP8.Utility +{ + public class BackgroundTasks + { + public static void StartPerodicTask(string taskName, string taskDesc) { + BackgroundTasks.StopPerodicTask(taskName); + + PeriodicTask periodicTask = new PeriodicTask(taskName); + // load description from localized strings + periodicTask.Description = taskDesc; + + try + { + ScheduledActionService.Add(periodicTask); + } + catch (Exception e) + { + Logger.LogException(e); + } + } + + public static void StopPerodicTask(string taskName) + { + PeriodicTask periodicTask = ScheduledActionService.Find(taskName) as PeriodicTask; + if (periodicTask != null) + { + try + { + ScheduledActionService.Remove(taskName); + } + catch (Exception e) + { + Logger.LogException(e); + } + } + } + + public static void StartMensaTask() + { + int campusId = (int)Settings.UserProfil.DefaultCampus; + BackgroundTasks.StartPerodicTask(Constants.BackgroundTask_Mensa, AppResources.BackGroundTaskDesc_Mensa + " - Feed " + campusId); + } + + public static void StopMensaTask() + { + BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_Mensa); + } + + public static void StartEventTask() + { + BackgroundTasks.StartPerodicTask(Constants.BackgroundTask_Event, AppResources.BackGroundTaskDesc_Event); + } + + public static void StopEventTask() + { + BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_Event); + } + + + public static void StartNewsTask() + { + BackgroundTasks.StartPerodicTask(Constants.BackgroundTask_News, AppResources.BackGroundTaskDesc_News); + } + + public static void StopNewsTask() + { + BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_News); + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Tiles/TileCreator.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Tiles/TileCreator.cs index ef0f85b2..031643c4 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Tiles/TileCreator.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Tiles/TileCreator.cs @@ -37,53 +37,70 @@ namespace CampusAppWP8.Utility.Lui.Tiles public static void CreateMensaTile() { TileCreator.CreateIconicTile(AppResources.MensaApp_Title, Constants.PathMensa_MensaPage, Icons.Mensa, Icons.Mensa); - PeriodicTask periodicTask = ScheduledActionService.Find("MensaTask") as PeriodicTask; - if (periodicTask != null) - { - try - { - ScheduledActionService.Remove("MensaTask"); - } - catch (Exception) - { - } - } + // create a new task - periodicTask = new PeriodicTask("MensaTask"); - // load description from localized strings - periodicTask.Description = "Load MensaFeed :" + Settings.UserProfil.DefaultCampus.ToString(); - - try - { - // add thas to scheduled action service - ScheduledActionService.Add(periodicTask); - - ScheduledActionService.LaunchForTest("MensaTask", TimeSpan.FromSeconds(10)); - System.Diagnostics.Debug.WriteLine("Periodic task is started: " + "MensaTask"); - - - } - catch (InvalidOperationException exception) - { - if (exception.Message.Contains("BNS Error: The action is disabled")) - { - // load error text from localized strings - //MessageBox.Show("Background agents for this application have been disabled by the user."); - } - if (exception.Message.Contains("BNS Error: The maximum number of ScheduledActions of this type have already been added.")) - { - // No user action required. The system prompts the user when the hard limit of periodic tasks has been reached. - } - } - catch (SchedulerServiceException) - { - // No user action required. - } + BackgroundTasks.StartMensaTask(); } public static void CreateWebMailTile() { - TileCreator.CreateIconicTile(AppResources.MensaApp_Title, Constants.PathMensa_MensaPage, Icons.Mensa, Icons.Mensa); + TileCreator.CreateIconicTile(AppResources.MailApp_Title, Constants.PathMail_WebMailPage, Icons.WebMail, Icons.WebMail); + } + + public static void CreateNewsTile() + { + TileCreator.CreateIconicTile(AppResources.NewsApp_Title, Constants.PathNews_NewsIndexPage, Icons.News, Icons.News); + } + + public static void CreateLectureTile() + { + TileCreator.CreateIconicTile(AppResources.LectureApp_Title, Constants.PathLecture_LecturePage, Icons.Lectures, Icons.Lectures); + } + + public static void CreateEventTile() + { + TileCreator.CreateIconicTile(AppResources.EventApp_Title, Constants.PathEvents_EventsIndexPage, Icons.News, Icons.News); + BackgroundTasks.StartEventTask(); + } + + public static void CreateDepartmentTile() + { + TileCreator.CreateIconicTile(AppResources.DepartmentApp_Title, Constants.PathDepartment_DepartmentIndexPage, Icons.Departments, Icons.Departments); + } + + public static void CreateOpeningHoursTile() + { + TileCreator.CreateIconicTile(AppResources.OpenHoursApp_Title, Constants.PathOpeninghours_OpeninghoursPage, Icons.Openhours, Icons.Openhours); + } + + public static void CreateLinkTile() + { + TileCreator.CreateIconicTile(AppResources.LinkApp_Title, Constants.PathLinks_LinkPage, Icons.Link, Icons.Link); + } + + public static void CreateStudentCouncilTile() + { + TileCreator.CreateIconicTile(AppResources.OSAApp_Title, Constants.PathStudentCouncil_StudentCouncilPage, Icons.StudentCouncil, Icons.StudentCouncil); + } + + public static void CreateExamsTile() + { + TileCreator.CreateIconicTile(AppResources.ExaminationApp_Header, Constants.PathExams_ExamsPage, Icons.Exams, Icons.Exams); + } + + public static void CreatePersonTile() + { + TileCreator.CreateIconicTile(AppResources.PersonApp_Title, Constants.PathPerson_Person, Icons.Person, Icons.Person); + } + + public static void CreatePlaceNewsTile() + { + TileCreator.CreateIconicTile(AppResources.PlaceNewsApp_Title, Constants.PathPlaceNews_PlaceNewsPage, Icons.News, Icons.News); + } + + public static void CreateCampusMapTile() + { + TileCreator.CreateIconicTile(AppResources.CampusMapApp_Title, Constants.PathCampusmap_Campusmap, Icons.Campus, Icons.Campus); } } } diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/CampusAppWP8ScheduledTaskAgent.csproj b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/CampusAppWP8ScheduledTaskAgent.csproj index 8787e9fc..ac3a8489 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/CampusAppWP8ScheduledTaskAgent.csproj +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/CampusAppWP8ScheduledTaskAgent.csproj @@ -87,6 +87,9 @@ + + + @@ -94,13 +97,14 @@ True True - - Constants.resx + True True + Constants.resx + @@ -113,9 +117,9 @@ Designer - PublicResXFileCodeGenerator - Constants.Designer.cs Designer + Constants1.Designer.cs + PublicResXFileCodeGenerator diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Mensa/MealModel.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Mensa/MealModel.cs index 278f4568..a5f7879b 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Mensa/MealModel.cs +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Mensa/MealModel.cs @@ -144,6 +144,20 @@ namespace CampusAppWP8ScheduledTaskAgent.Model.Mensa #region Methods + #region public + + public string MealToShortString() + { + string shortDesc = this.mealDesc; + if (shortDesc.Length > 30) + { + shortDesc = shortDesc.Substring(0, 30) + "..."; + + } + return this.MealName + ": " + shortDesc; + } + #endregion + /// /// Method create depends of the mealId the mealName /// diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Mensa/MenuWeekModel.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Mensa/MenuWeekModel.cs index 7e033766..f2801c7d 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Mensa/MenuWeekModel.cs +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Mensa/MenuWeekModel.cs @@ -62,41 +62,21 @@ namespace CampusAppWP8ScheduledTaskAgent.Model.Mensa #region Methods - public string MealToString(string date) - { - string mealString = string.Empty; - foreach (MenuModel menu in this.Menus) + /// + /// Method calculate this day of the week, which its gets new menus + /// + /// Date of NewMenuWeekDay + public static DateTime CalcFirstWeekDay() + { + DateTime now = DateTime.Now; + while (now.DayOfWeek != DayOfWeek.Monday) { - if (menu.Date.Equals(date)) - { - foreach (MealModel meal in menu.Meals) - { - int lenght = meal.MealDesc.Length; - if (lenght > 30) { - lenght = 30; - } - mealString += meal.MealName + ": " + meal.MealDesc.Substring(0, lenght) +"..."; - mealString = StringManager.AddNewLine(mealString); - } - return mealString; - } + now = now.Subtract(new TimeSpan(1, 0, 0, 0)); } - return mealString; - } - - public int GetMealCount(string date) - { - foreach (MenuModel menu in this.Menus) - { - if (menu.Date.Equals(date)) - { - return menu.Meals.Count; - } - } - - return 0; + DateTime monday = new DateTime(now.Year, now.Month, now.Day); + return monday; } #endregion diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/RSS/RSSChannelModel.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/RSS/RSSChannelModel.cs new file mode 100644 index 00000000..36425a33 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/RSS/RSSChannelModel.cs @@ -0,0 +1,82 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 24.06.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8ScheduledTaskAgent.Model.RSS +{ + using System.Collections.ObjectModel; + using System.Collections.Specialized; + using System.Xml.Serialization; + + /// + /// Channel Model, which contains the RSS feed item list. + /// + public class RSSChannelModel + { + /// + /// RSS feed information item list. + /// + private ObservableCollection item; + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + public RSSChannelModel() + { + this.item = new ObservableCollection(); + this.item.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnListChanged); + } + + #endregion + + #region Property + + /// + /// Gets or sets the RSS feed item list. + /// + [XmlElement("item")] + public ObservableCollection Item + { + get + { + return this.item; + } + + set + { + if (value != this.item) + { + this.item = value; + } + } + } + + #endregion + + #region Method + + /// + /// Is called when the item list has changed. + /// Here used for the add event. + /// Set the index of the last list element. + /// + /// item list + /// event args + private void OnListChanged(object sender, NotifyCollectionChangedEventArgs e) + { + if (e.Action == NotifyCollectionChangedAction.Add) + { + ObservableCollection list = sender as ObservableCollection; + + list[list.Count - 1].Index = list.Count - 1; + } + } + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/RSS/RSSModel.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/RSS/RSSModel.cs new file mode 100644 index 00000000..fa8a5a54 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/RSS/RSSModel.cs @@ -0,0 +1,276 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 24.06.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8ScheduledTaskAgent.Model.RSS +{ + using System; + using System.Text; + using System.Xml.Serialization; + + /// + /// Contains the RSS feed information. + /// + public class RSSModel + { + #region Member + + /// + /// Index of this object. + /// + private int index = -1; + + /// + /// Title of the fees + /// + private string title; + + /// + /// Description text of the feed. + /// + private string text; + + /// + /// Timestamp (publication date) of the event or news. + /// + private DateTime timestamp; + + /// + /// Url of the feed. + /// + private string link; + + #endregion + + #region Property + + /// + /// Gets or sets the title of the feed. + /// + [XmlElement("title")] + public string Title + { + get + { + return this.title; + } + + set + { + if (this.title != value) + { + this.title = value; + } + } + } + + /// + /// Gets or sets the text of the feed. + /// + [XmlElement("description")] + public string Text + { + get + { + return this.text; + } + + set + { + if (this.text != this.HTMLUnicodeToString(value)) + { + this.text = this.HTMLUnicodeToString(value); + } + } + } + + /// + /// Gets or sets the timestamp of the feed as string. + /// + [XmlElement("pubDate")] + public string Timestamp + { + get + { + return this.timestamp.ToString("R"); + } + + set + { + if (this.timestamp != DateTime.Parse(value)) + { + this.timestamp = DateTime.Parse(value); + } + } + } + + /// + /// Gets or sets the timestamp of the feed as DateTime object. + /// + public DateTime DTTimestamp + { + get + { + return this.timestamp; + } + + set + { + this.timestamp = value; + } + } + + /// + /// Gets the date of the timestamp as string. + /// example: Mon, 25.06.2013. + /// + public string Date + { + get + { + return string.Format("{0:ddd, dd.MM.yyyy}", this.timestamp); + } + } + + /// + /// Gets the time of the timestamp as string. + /// example: 12:56. + /// + public string Time + { + get + { + return string.Format("{0:h:mm} Uhr", this.timestamp); + } + } + + /// + /// Gets or sets the link/url of the feed. + /// + [XmlElement("link")] + public string Link + { + get + { + return this.link; + } + + set + { + if (this.link != value) + { + this.link = value; + } + } + } + + /// + /// Gets or sets the ListIndex. + /// + public int Index + { + get + { + return this.index; + } + + set + { + this.index = value; + } + } + + #endregion + + #region Method + + #region public + + /// + /// Comparing function for DateTime timestamps. + /// (currently unused) + /// + /// first item + /// second item + /// -1 if item2 is older then item1, otherwise 0 + public static int CompareTimeStamp(RSSModel item1, RSSModel item2) + { + if (item1.DTTimestamp > item2.DTTimestamp) + { + return -1; + } + else + { + return 0; + } + } + + #endregion + + #region private + + /// + /// Remove or transform html-unicode specific tags into ASCII. + /// + /// html string + /// ASCII string + private string HTMLUnicodeToString(string htmluni) + { + StringBuilder retValue = new StringBuilder(); + + for (int i = 0; i < htmluni.Length; i++) + { + switch (htmluni[i]) + { + // beginning tag of the unicode + case '&': + int startOff = i + 2; + //// sear closing tag of the unicode + int endOff = htmluni.IndexOf(';', startOff); + //// get and parse value inbetween + string sub = htmluni.Substring(startOff, endOff - startOff); + int charVal = int.Parse(sub); + + switch (charVal) + { + // if the unicode value is 128 (€) + case 128: + retValue.Append('€'); + break; + + default: + retValue.Append((char)charVal); + break; + } + + // set the current index to the end of the unicode tag + i = endOff; + break; + + case '<': + // ignoring <..> html tags + i = htmluni.IndexOf('>', i); + break; + + case '\t': + // removing tabs + break; + + default: + // adding other characters to the return string + retValue.Append(htmluni[i]); + break; + } + } + + return retValue.ToString(); + } + + #endregion + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/RSS/RSSViewModel.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/RSS/RSSViewModel.cs new file mode 100644 index 00000000..d7dd0e8a --- /dev/null +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/RSS/RSSViewModel.cs @@ -0,0 +1,83 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// fiedlchr +// 24.06.2013 +//----------------------------------------------------------------------------- +namespace CampusAppWP8ScheduledTaskAgent.Model.RSS +{ + using System; + using System.Collections.ObjectModel; + using System.Xml.Serialization; + + /// + /// ViewModel of the RSS feed, containing the feed/channel object. + /// + [XmlRoot("root")] + public class RSSViewModel + { + #region Member + + /// + /// Object to store the time when the instance was created. + /// + private DateTime createTime; + + /// + /// Channel list for the RSS feeds. + /// + private ObservableCollection channel; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + public RSSViewModel() + { + this.channel = new ObservableCollection(); + this.createTime = DateTime.Now; + } + + #endregion + + #region Property + + /// + /// Gets or sets the channel list. + /// + [XmlArray("rss")] + [XmlArrayItem("channel")] + public ObservableCollection Channel + { + get + { + return this.channel; + } + + set + { + if (value != this.channel) + { + this.channel = value; + } + } + } + + /// + /// Gets the creation time. + /// + public DateTime CreateTime + { + get + { + return this.createTime; + } + } + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.Designer.cs index c252dfd4..59879025 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.Designer.cs +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.Designer.cs @@ -60,6 +60,33 @@ namespace CampusAppWP8ScheduledTaskAgent.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Hintergrunddienst für die BTU-Event-Feed ähnelt. + /// + public static string BackGroundTaskDesc_Event { + get { + return ResourceManager.GetString("BackGroundTaskDesc_Event", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Hintergrunddienst für die BTU-Mensa ähnelt. + /// + public static string BackGroundTaskDesc_Mensa { + get { + return ResourceManager.GetString("BackGroundTaskDesc_Mensa", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Hintergrunddienst für die BTU-News-Feed ähnelt. + /// + public static string BackGroundTaskDesc_News { + get { + return ResourceManager.GetString("BackGroundTaskDesc_News", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Aktion ähnelt. /// @@ -78,6 +105,15 @@ namespace CampusAppWP8ScheduledTaskAgent.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Die Mensa ist heute geschlossen ähnelt. + /// + public static string MensaApp_CloseMensa { + get { + return ResourceManager.GetString("MensaApp_CloseMensa", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Essen 1 ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.resx index a47731a4..31c1f5d6 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.resx +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.resx @@ -150,4 +150,16 @@ Suppe + + Hintergrunddienst für die BTU-Mensa + + + Die Mensa ist heute geschlossen + + + Hintergrunddienst für die BTU-Event-Feed + + + Hintergrunddienst für die BTU-News-Feed + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.resx index c6c49152..2710e40d 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.resx @@ -135,4 +135,25 @@ /Pages/Mensa/MensaPage.xaml + + MensaTask + + + /Pages/Events/EventIndexPage.xaml + + + http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_veranstaltungen.php + + + EventTask + + + NewsTask + + + /Pages/News/NewsIndexPage.xaml + + + http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_aktuelles.php + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.Designer.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants1.Designer.cs similarity index 69% rename from CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.Designer.cs rename to CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants1.Designer.cs index 44c40bb1..ed0806ae 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.Designer.cs +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants1.Designer.cs @@ -60,6 +60,42 @@ namespace CampusAppWP8ScheduledTaskAgent.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die EventTask ähnelt. + /// + public static string BackgroundTask_Event { + get { + return ResourceManager.GetString("BackgroundTask_Event", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die MensaTask ähnelt. + /// + public static string BackgroundTask_Mensa { + get { + return ResourceManager.GetString("BackgroundTask_Mensa", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die NewsTask ähnelt. + /// + public static string BackgroundTask_News { + get { + return ResourceManager.GetString("BackgroundTask_News", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die /Pages/Events/EventIndexPage.xaml ähnelt. + /// + public static string PathEvents_EventsIndexPage { + get { + return ResourceManager.GetString("PathEvents_EventsIndexPage", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die /Pages/Mensa/MensaPage.xaml ähnelt. /// @@ -69,6 +105,24 @@ namespace CampusAppWP8ScheduledTaskAgent.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die /Pages/News/NewsIndexPage.xaml ähnelt. + /// + public static string PathNews_NewsIndexPage { + get { + return ResourceManager.GetString("PathNews_NewsIndexPage", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_veranstaltungen.php ähnelt. + /// + public static string UrlEvents_Addr { + get { + return ResourceManager.GetString("UrlEvents_Addr", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1 ähnelt. /// @@ -105,6 +159,15 @@ namespace CampusAppWP8ScheduledTaskAgent.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_aktuelles.php ähnelt. + /// + public static string UrlNews_Addr { + get { + return ResourceManager.GetString("UrlNews_Addr", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die root ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs index a847cb83..c2f57b7d 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs @@ -1,109 +1,268 @@ -using System.Diagnostics; -using System.Windows; -using Microsoft.Phone.Scheduler; -using CampusAppWP8ScheduledTaskAgent.Utility; -using System; +using CampusAppWP8ScheduledTaskAgent.Model.Mensa; +using CampusAppWP8ScheduledTaskAgent.Model.RSS; using CampusAppWP8ScheduledTaskAgent.Resources; -using CampusAppWP8ScheduledTaskAgent.Model.Mensa; +using CampusAppWP8ScheduledTaskAgent.Utility; +using Microsoft.Phone.Scheduler; using Microsoft.Phone.Shell; -using System.Linq; -using System.Collections.Generic; +using System; +using System.Diagnostics; using System.Globalization; +using System.Linq; +using System.Windows; namespace CampusAppWP8ScheduledTaskAgent { public class ScheduledAgent : ScheduledTaskAgent { - private static List MealList; - private static string LastMensaUpdate; + private MenuWeekModel mensaModel; + + private RSSViewModel eventModel; + + private RSSViewModel newsModel; - /// - /// ScheduledAgent-Konstruktor, initialisiert den UnhandledException-Handler - /// static ScheduledAgent() { - // Handler für verwaltete Ausnahmen abonnieren Deployment.Current.Dispatcher.BeginInvoke(delegate { Application.Current.UnhandledException += UnhandledException; }); } - /// Code, der bei nicht behandelten Ausnahmen ausgeführt wird private static void UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) { if (Debugger.IsAttached) { - // Eine nicht behandelte Ausnahme ist aufgetreten. Unterbrechen und Debugger öffnen Debugger.Break(); } } - /// - /// Agent zum Ausführen einer geplanten Aufgabe - /// - /// - /// Die aufgerufene Aufgabe - /// - /// - /// Diese Methode wird aufgerufen, wenn eine regelmäßige oder ressourcenintensive Aufgabe aufgerufen wird - /// protected override void OnInvoke(ScheduledTask task) { - if (task.Name.Equals("MensaTask")) + switch (task.Name) { - //TODO: Code zum Ausführen der Aufgabe im Hintergrund hinzufügen - if (ScheduledAgent.LastMensaUpdate == null || !ScheduledAgent.LastMensaUpdate.Equals(DateTime.Now.ToShortDateString())) - { - HttpRequest api = new HttpRequest(); - Uri url = new Uri(Constants.UrlMensa_Week_CBMain, UriKind.Absolute); - api.HttpGet(url, this.GetIsReady); - } - else - { - ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(Constants.PathMensa_MensaPage)); + case "MensaTask": + this.HandleMensaTask(task); + break; - if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(Constants.PathMensa_MensaPage)) - { - IconicTileData data = new IconicTileData(); - DateTime now = DateTime.Now; - Random random = new Random(); - int randomNumber = random.Next(0, ScheduledAgent.MealList.Count - 1); - data.WideContent3 = ScheduledAgent.MealList[randomNumber]; - TileToFind.Update(data); - } - } + case "EventTask": + this.HandleEventTask(task); + break; + + case "NewsTask": + this.HandleNewsTask(task); + break; } - } - private void GetIsReady(object arg1, System.Net.DownloadStringCompletedEventArgs arg2) + private void HandleEventTask(ScheduledTask task) + { + if (this.eventModel == null || !this.CheckRssIsUpToDate(this.eventModel.CreateTime)) + { + HttpRequest api = new HttpRequest(); + Uri url = new Uri(Constants.UrlEvents_Addr, UriKind.Absolute); + api.HttpGet(url, this.GetEventIsReady); + } + else + { + this.updateEventTile(); + } + } + + private void HandleNewsTask(ScheduledTask task) + { + if (this.newsModel == null || !this.CheckRssIsUpToDate(this.newsModel.CreateTime)) + { + HttpRequest api = new HttpRequest(); + Uri url = new Uri(Constants.UrlNews_Addr, UriKind.Absolute); + api.HttpGet(url, this.GetNewsIsReady); + } + else + { + this.updateNewsTile(); + } + } + + private void GetEventIsReady(object arg1, System.Net.DownloadStringCompletedEventArgs arg2) { if (arg2.Result != null) { - MenuWeekModel week = XmlManager.DeserializationToModel(arg2.Result, Constants.XMLRootElementName); - ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(Constants.PathMensa_MensaPage)); - - if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(Constants.PathMensa_MensaPage)) - { - IconicTileData data = new IconicTileData(); - DateTime now = DateTime.Now; - data.WideContent1 = CultureInfo.CurrentCulture.DateTimeFormat.DayNames[(int)DateTime.Now.DayOfWeek]; - data.WideContent2 = now.Date.ToShortDateString(); - string mealString = week.MealToString(now.Date.ToShortDateString()); - ScheduledAgent.MealList = mealString.Split('\n').ToList(); - Random random = new Random(); - int randomNumber = random.Next(0, ScheduledAgent.MealList.Count - 1); - - data.WideContent3 = ScheduledAgent.MealList[randomNumber]; - data.Count = week.GetMealCount(now.Date.ToShortDateString()); - ScheduledAgent.LastMensaUpdate = now.Date.ToShortDateString(); - TileToFind.Update(data); - } + this.eventModel = XmlManager.DeserializationToModel(arg2.Result, Constants.XMLRootElementName); + this.updateEventTile(); } - NotifyComplete(); + } + + private void GetNewsIsReady(object arg1, System.Net.DownloadStringCompletedEventArgs arg2) + { + if (arg2.Result != null) + { + this.newsModel = XmlManager.DeserializationToModel(arg2.Result, Constants.XMLRootElementName); + this.updateNewsTile(); + } + } + + + private void updateNewsTile() + { + ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(Constants.PathNews_NewsIndexPage)); + + if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(Constants.PathNews_NewsIndexPage)) + { + IconicTileData data = new IconicTileData(); + Random random = new Random(); + int randomNumber = random.Next(0, this.eventModel.Channel[0].Item.Count); + RSSModel item = this.newsModel.Channel[0].Item[randomNumber]; + data.WideContent1 = item.Date; + data.WideContent2 = StringManager.ToShortString(item.Title, 30) + "..."; + data.WideContent3 = StringManager.ToShortString(item.Text, 30) + "..."; + data.Count = this.newsModel.Channel[0].Item.Count; + TileToFind.Update(data); + } + else + { + BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_News); + } + this.NotifyComplete(); + } + + private void updateEventTile() + { + ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(Constants.PathEvents_EventsIndexPage)); + + if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(Constants.PathEvents_EventsIndexPage)) + { + IconicTileData data = new IconicTileData(); + Random random = new Random(); + int randomNumber = random.Next(0, this.eventModel.Channel[0].Item.Count); + RSSModel item = this.eventModel.Channel[0].Item[randomNumber]; + data.WideContent1 = item.Date; + data.WideContent2 = StringManager.ToShortString(item.Title, 30) + "..."; + data.WideContent3 = StringManager.ToShortString(item.Text, 30) + "..."; + data.Count = this.eventModel.Channel[0].Item.Count; + TileToFind.Update(data); + } + else + { + BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_Event); + } + this.NotifyComplete(); + } + + private Uri CalcMensaUrl(string mensaTaskDesc) + { + Uri url; + char feedNumber = mensaTaskDesc[mensaTaskDesc.Length - 1]; + + switch (feedNumber) + { + case '1': + url = new Uri(Constants.UrlMensa_Week_CBMain, UriKind.Absolute); + break; + case '2': + url = new Uri(Constants.UrlMensa_Week_CBSouth, UriKind.Absolute); + break; + case '3': + url = new Uri(Constants.UrlMensa_Week_SBFMain, UriKind.Absolute); + break; + case '4': + url = new Uri(Constants.UrlMensa_Week_CBMain, UriKind.Absolute); + break; + default: + url = new Uri(Constants.UrlMensa_Week_CBMain, UriKind.Absolute); + break; + } + + return url; + } + private void HandleMensaTask(ScheduledTask task) + { + if (this.mensaModel == null || !this.CheckMensaIsUpToDate(this.mensaModel.CreateTime)) + { + HttpRequest api = new HttpRequest(); + Uri url = this.CalcMensaUrl(task.Description); + api.HttpGet(url, this.GetMensaIsReady); + } + else + { + this.updateMensaTile(); + } + } + + private void GetMensaIsReady(object arg1, System.Net.DownloadStringCompletedEventArgs arg2) + { + if (arg2.Result != null) + { + this.mensaModel = XmlManager.DeserializationToModel(arg2.Result, Constants.XMLRootElementName); + this.updateMensaTile(); + } + + } + + private void updateMensaTile() + { + ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(Constants.PathMensa_MensaPage)); + + if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(Constants.PathMensa_MensaPage)) + { + IconicTileData data = new IconicTileData(); + DateTime now = DateTime.Now; + int dayIndex = (int)DateTime.Now.DayOfWeek; + data.WideContent1 = CultureInfo.CurrentCulture.DateTimeFormat.DayNames[dayIndex]; + data.WideContent2 = now.Date.ToShortDateString(); + if (dayIndex == 0 || dayIndex > this.mensaModel.Menus.Count) + { + data.WideContent3 = AppResources.MensaApp_CloseMensa; + } + else + { + // correct index (week sart with monday not sunday + dayIndex--; + int mealCount = this.mensaModel.Menus[dayIndex].Meals.Count; + if (mealCount < 1) + { + data.WideContent3 = AppResources.MensaApp_CloseMensa; + } + else + { + Random random = new Random(); + int randomNumber = random.Next(0, mealCount); + data.WideContent3 = this.mensaModel.Menus[dayIndex].Meals[randomNumber].MealToShortString(); + data.Count = this.mensaModel.Menus[dayIndex].Meals.Count; + } + } + TileToFind.Update(data); + } + else + { + BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_Mensa); + } + this.NotifyComplete(); + } + + + private bool CheckMensaIsUpToDate(DateTime lastModified) + { + int diff = lastModified.CompareTo(MenuWeekModel.CalcFirstWeekDay()); + + if (diff < 0) + { + return false; + } + + return true; + } + + private bool CheckRssIsUpToDate(DateTime lastModified) + { + int diff = lastModified.CompareTo(DateTime.Now.AddDays(1)); + + if (diff < 0) + { + return false; + } + + return true; } } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/BackgroundTasks.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/BackgroundTasks.cs new file mode 100644 index 00000000..50b9034e --- /dev/null +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/BackgroundTasks.cs @@ -0,0 +1,49 @@ +using CampusAppWP8ScheduledTaskAgent.Resources; +using Microsoft.Phone.Scheduler; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CampusAppWP8ScheduledTaskAgent.Utility +{ + public class BackgroundTasks + { + public static void StartPerodicTask(string taskName, string taskDesc) { + BackgroundTasks.StopPerodicTask(taskName); + + PeriodicTask periodicTask = new PeriodicTask(taskName); + // load description from localized strings + periodicTask.Description = taskDesc; + + try + { + ScheduledActionService.Add(periodicTask); + + //ScheduledActionService.LaunchForTest(taskName, TimeSpan.FromSeconds(10)); + + } + catch (Exception e) + { + Logger.LogException(e); + } + } + + public static void StopPerodicTask(string taskName) + { + PeriodicTask periodicTask = ScheduledActionService.Find(taskName) as PeriodicTask; + if (periodicTask != null) + { + try + { + ScheduledActionService.Remove(taskName); + } + catch (Exception e) + { + Logger.LogException(e); + } + } + } + } +} diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/StringManager.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/StringManager.cs index 199dacd2..58cbe206 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/StringManager.cs +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/StringManager.cs @@ -54,6 +54,16 @@ namespace CampusAppWP8ScheduledTaskAgent.Utility { return str.TrimEnd('\n'); } + + public static string ToShortString(string longStr, int maxLenght) + { + string shortStr = longStr; + if (shortStr.Length > maxLenght) + { + shortStr = shortStr.Substring(0, maxLenght); + } + return shortStr; + } #endregion } } diff --git a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj index 252a56ef..8d9e3e15 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj +++ b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj @@ -39,10 +39,7 @@ - - - From ad9bbb2342a5632ad87f7eb8f74d25858bca0da6 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Tue, 17 Sep 2013 15:32:42 +0200 Subject: [PATCH 4/9] add rss and mensa model to plc --- .../CampusAppWP8/Api/GeoApi/PisApi.cs | 3 +- .../CampusAppWP8/Api/GeoApi/PssApi.cs | 1 + .../CampusAppWP8/Api/GeoApi/SpsApi.cs | 3 +- CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 6 +- CampusAppWP8/CampusAppWP8/Model/MainModel.cs | 4 +- .../Pages/Lecture/LecturePage.xaml.cs | 1 + .../Pages/Person/PersonPage.xaml.cs | 1 + .../CampusAppWP8/Utility/BackgroundTasks.cs | 12 +- .../CampusAppWP8/Utility/HttpRequest.cs | 1 + .../Utility/Lui/Tiles/TileCreator.cs | 1 + .../CampusAppWP8ScheduledTaskAgent.csproj | 17 +- .../Model/Utility/CleanUrlParamModel.cs | 66 ------ .../Model/Utility/URLParamModel.cs | 108 ---------- .../Resources/AppResources.Designer.cs | 99 --------- .../Resources/AppResources.resx | 39 +--- .../ScheduledAgent.cs | 7 +- .../Utility/BackgroundTasks.cs | 28 +-- .../Utility/HttpRequest.cs | 169 +-------------- .../Utility/Logger.cs | 35 --- .../Utility/StringManager.cs | 69 ------ .../Utility/XmlManager.cs | 88 -------- .../CampusAppWPortalLib8.csproj | 41 +++- .../Model/Campusmap/CBMainMapModel.cs | 45 ---- .../Model/Campusmap/MapModel.cs | 48 ----- .../Model/GeoDb/PlaceInformation.cs | 41 ---- .../Model/GeoDb/PlaceModel.cs | 167 --------------- .../Model/GeoDb/PlaceService.cs | 57 ----- .../Model/GeoDb/SpsModel.cs | 200 ------------------ .../Model/Mensa/MealModel.cs | 6 +- .../Model/Mensa/MenuModel.cs | 2 +- .../Model/Mensa/MenuWeekModel.cs | 5 +- .../Model/RSS/RSSChannelModel.cs | 2 +- .../Model/RSS/RSSModel.cs | 2 +- .../Model/RSS/RSSViewModel.cs | 2 +- .../Model/Utility/CleanUrlParamModel.cs | 2 +- .../Model/Utility/URLParamModel.cs | 2 +- .../Resources/AppResources.Designer.cs | 136 ++++++++++++ .../Resources/AppResources.resx | 144 +++++++++++++ .../Resources/Constants.resx | 120 +++++++++++ .../Resources/Constants1.Designer.cs | 64 ++++++ .../Utility/AbstractBackgroundTasks.cs | 7 + .../Utility/AbstractHttpRequest.cs | 75 +++++++ .../Utility/NDEF/NDEFMessage.cs | 154 -------------- .../Utility/NDEF/NDEFRecord.cs | 188 ---------------- .../Utility/NDEF/NDEFShortRecord.cs | 63 ------ .../Utility/StringManager.cs | 10 + 46 files changed, 644 insertions(+), 1697 deletions(-) delete mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Utility/CleanUrlParamModel.cs delete mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Utility/URLParamModel.cs delete mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/Logger.cs delete mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/StringManager.cs delete mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/XmlManager.cs delete mode 100644 CampusAppWP8/CampusAppWPortalLib8/Model/Campusmap/CBMainMapModel.cs delete mode 100644 CampusAppWP8/CampusAppWPortalLib8/Model/Campusmap/MapModel.cs delete mode 100644 CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/PlaceInformation.cs delete mode 100644 CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/PlaceModel.cs delete mode 100644 CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/PlaceService.cs delete mode 100644 CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/SpsModel.cs rename CampusAppWP8/{CampusAppWP8ScheduledTaskAgent => CampusAppWPortalLib8}/Model/Mensa/MealModel.cs (97%) rename CampusAppWP8/{CampusAppWP8ScheduledTaskAgent => CampusAppWPortalLib8}/Model/Mensa/MenuModel.cs (97%) rename CampusAppWP8/{CampusAppWP8ScheduledTaskAgent => CampusAppWPortalLib8}/Model/Mensa/MenuWeekModel.cs (95%) rename CampusAppWP8/{CampusAppWP8ScheduledTaskAgent => CampusAppWPortalLib8}/Model/RSS/RSSChannelModel.cs (97%) rename CampusAppWP8/{CampusAppWP8ScheduledTaskAgent => CampusAppWPortalLib8}/Model/RSS/RSSModel.cs (99%) rename CampusAppWP8/{CampusAppWP8ScheduledTaskAgent => CampusAppWPortalLib8}/Model/RSS/RSSViewModel.cs (97%) rename CampusAppWP8/{CampusAppWP8 => CampusAppWPortalLib8}/Model/Utility/CleanUrlParamModel.cs (97%) rename CampusAppWP8/{CampusAppWP8 => CampusAppWPortalLib8}/Model/Utility/URLParamModel.cs (98%) create mode 100644 CampusAppWP8/CampusAppWPortalLib8/Resources/AppResources.Designer.cs create mode 100644 CampusAppWP8/CampusAppWPortalLib8/Resources/AppResources.resx create mode 100644 CampusAppWP8/CampusAppWPortalLib8/Resources/Constants.resx create mode 100644 CampusAppWP8/CampusAppWPortalLib8/Resources/Constants1.Designer.cs create mode 100644 CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractBackgroundTasks.cs create mode 100644 CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractHttpRequest.cs delete mode 100644 CampusAppWP8/CampusAppWPortalLib8/Utility/NDEF/NDEFMessage.cs delete mode 100644 CampusAppWP8/CampusAppWPortalLib8/Utility/NDEF/NDEFRecord.cs delete mode 100644 CampusAppWP8/CampusAppWPortalLib8/Utility/NDEF/NDEFShortRecord.cs diff --git a/CampusAppWP8/CampusAppWP8/Api/GeoApi/PisApi.cs b/CampusAppWP8/CampusAppWP8/Api/GeoApi/PisApi.cs index 2409d10a..958ea718 100644 --- a/CampusAppWP8/CampusAppWP8/Api/GeoApi/PisApi.cs +++ b/CampusAppWP8/CampusAppWP8/Api/GeoApi/PisApi.cs @@ -12,7 +12,8 @@ namespace CampusAppWP8.Api.GeoApi using CampusAppWP8.Model; using CampusAppWP8.Model.GeoDb; using CampusAppWP8.Model.Utility; - using CampusAppWP8.Resources; + using CampusAppWP8.Resources; + using CampusAppWPortalLib8.Model.Utility; /// Pis api. /// Stubbfel, 09.09.2013. diff --git a/CampusAppWP8/CampusAppWP8/Api/GeoApi/PssApi.cs b/CampusAppWP8/CampusAppWP8/Api/GeoApi/PssApi.cs index b6cb614e..7ff2444c 100644 --- a/CampusAppWP8/CampusAppWP8/Api/GeoApi/PssApi.cs +++ b/CampusAppWP8/CampusAppWP8/Api/GeoApi/PssApi.cs @@ -13,6 +13,7 @@ namespace CampusAppWP8.Api.GeoApi using CampusAppWP8.Model.GeoDb; using CampusAppWP8.Model.Utility; using CampusAppWP8.Resources; + using CampusAppWPortalLib8.Model.Utility; /// Pss api. /// Stubbfel, 09.09.2013. diff --git a/CampusAppWP8/CampusAppWP8/Api/GeoApi/SpsApi.cs b/CampusAppWP8/CampusAppWP8/Api/GeoApi/SpsApi.cs index 18d727f7..2a0988ef 100644 --- a/CampusAppWP8/CampusAppWP8/Api/GeoApi/SpsApi.cs +++ b/CampusAppWP8/CampusAppWP8/Api/GeoApi/SpsApi.cs @@ -12,7 +12,8 @@ namespace CampusAppWP8.Api.GeoApi using CampusAppWP8.Model.GeoDb; using CampusAppWP8.Model.Utility; using CampusAppWP8.Resources; - using CampusAppWP8.Utility; + using CampusAppWP8.Utility; + using CampusAppWPortalLib8.Model.Utility; /// /// Class for SPSAPI diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 4e9814f4..79607bf7 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -131,7 +131,6 @@ - Exams.xaml @@ -198,7 +197,6 @@ - CampusMapPage.xaml @@ -554,6 +552,10 @@ {2A51FA6C-791B-4935-B869-FDBA9ED774D7} CampusAppWP8ScheduledTaskAgent + + {67D80BE2-0FB7-44C8-A495-7D44FC2AC262} + CampusAppWPortalLib8 + diff --git a/CampusAppWP8/CampusAppWP8/Model/MainModel.cs b/CampusAppWP8/CampusAppWP8/Model/MainModel.cs index 4123275f..fb55ccf4 100644 --- a/CampusAppWP8/CampusAppWP8/Model/MainModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/MainModel.cs @@ -7,12 +7,12 @@ //----------------------------------------------------------------------------- namespace CampusAppWP8 { + using CampusAppWP8.Utility; + using CampusAppWPortalLib8.Model.Utility; using System; using System.Collections.Generic; using System.IO; using System.Net; - using CampusAppWP8.Model.Utility; - using CampusAppWP8.Utility; /// /// Base model io handling class. diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs index ee02e75c..37f79f70 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml.cs @@ -17,6 +17,7 @@ namespace CampusAppWP8.Pages.Lecture using CampusAppWP8.Resources; using CampusAppWP8.Utility.Lui.MessageBoxes; using Microsoft.Phone.Controls; + using CampusAppWPortalLib8.Model.Utility; /// /// Class for the LecturePage diff --git a/CampusAppWP8/CampusAppWP8/Pages/Person/PersonPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Person/PersonPage.xaml.cs index b95c31e2..289d4ad4 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Person/PersonPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Person/PersonPage.xaml.cs @@ -18,6 +18,7 @@ namespace CampusAppWP8.Pages.Person using CampusAppWP8.Utility.Lui.MessageBoxes; using Microsoft.Phone.Controls; using Microsoft.Phone.Tasks; + using CampusAppWPortalLib8.Model.Utility; /// Person page. /// Stubbfel, 09.09.2013. diff --git a/CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs b/CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs index 561f0bb5..22a7814a 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs @@ -1,4 +1,5 @@ using CampusAppWP8ScheduledTaskAgent.Resources; +using CampusAppWPortalLib8.Utility; using Microsoft.Phone.Scheduler; using System; using System.Collections.Generic; @@ -8,9 +9,10 @@ using System.Threading.Tasks; namespace CampusAppWP8.Utility { - public class BackgroundTasks + public class BackgroundTasks : AbstractBackgroundTasks { public static void StartPerodicTask(string taskName, string taskDesc) { + BackgroundTasks.StopPerodicTask(BackgroundTasks.LastAddedTaskName); BackgroundTasks.StopPerodicTask(taskName); PeriodicTask periodicTask = new PeriodicTask(taskName); @@ -24,11 +26,19 @@ namespace CampusAppWP8.Utility catch (Exception e) { Logger.LogException(e); + return; } + + BackgroundTasks.LastAddedTaskName = taskName; } public static void StopPerodicTask(string taskName) { + if (taskName == null) + { + return; + } + PeriodicTask periodicTask = ScheduledActionService.Find(taskName) as PeriodicTask; if (periodicTask != null) { diff --git a/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs b/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs index e8cd4db7..2d3b73c1 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs @@ -11,6 +11,7 @@ namespace CampusAppWP8.Utility using System.Collections.Generic; using System.Net; using CampusAppWP8.Model.Utility; + using CampusAppWPortalLib8.Model.Utility; /// /// Class realize the access of restful HttpRequest diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Tiles/TileCreator.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Tiles/TileCreator.cs index 031643c4..52406b28 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Tiles/TileCreator.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Tiles/TileCreator.cs @@ -50,6 +50,7 @@ namespace CampusAppWP8.Utility.Lui.Tiles public static void CreateNewsTile() { TileCreator.CreateIconicTile(AppResources.NewsApp_Title, Constants.PathNews_NewsIndexPage, Icons.News, Icons.News); + BackgroundTasks.StartNewsTask(); } public static void CreateLectureTile() diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/CampusAppWP8ScheduledTaskAgent.csproj b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/CampusAppWP8ScheduledTaskAgent.csproj index ac3a8489..8f6f7018 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/CampusAppWP8ScheduledTaskAgent.csproj +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/CampusAppWP8ScheduledTaskAgent.csproj @@ -84,14 +84,6 @@ 4 - - - - - - - - AppResources.resx True @@ -106,9 +98,6 @@ - - - @@ -125,6 +114,12 @@ + + + {67D80BE2-0FB7-44C8-A495-7D44FC2AC262} + CampusAppWPortalLib8 + + diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Utility/CleanUrlParamModel.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Utility/CleanUrlParamModel.cs deleted file mode 100644 index 7e35cd1a..00000000 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Utility/CleanUrlParamModel.cs +++ /dev/null @@ -1,66 +0,0 @@ -//----------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 06.08.2013 -//---------------------------------------------------------------------- -namespace CampusAppWP8ScheduledTaskAgent.Model.Utility -{ - /// - /// This class is a Model for the URLParameter like GET-Parameter - /// - public class CleanUrlParamModel : UrlParamModel - { - #region Constructor - - /// Initializes a new instance of the CleanUrlParamModel class. - /// Stubbfel, 12.09.2013. - /// the key for the parameter. - public CleanUrlParamModel(string key) - : base(key) - { - } - - /// Initializes a new instance of the CleanUrlParamModel class. - /// Stubbfel, 12.09.2013. - /// the key for the parameter. - /// The value. - public CleanUrlParamModel(string key, string value) - : base(key, value) - { - } - #endregion - - #region Proberty - - /// - /// Gets the token, which indicate that the parameterList started - /// - public override string ParamToken - { - get - { - return string.Empty; - } - } - #endregion - - #region Methods - - /// - /// Method return a formatted string like Key=Value - /// - /// return formatted string - public override string ToString() - { - if (!this.IsParamValid()) - { - return string.Empty; - } - - return "/" + this.key + "/" + this.Value; - } - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Utility/URLParamModel.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Utility/URLParamModel.cs deleted file mode 100644 index b7090214..00000000 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Model/Utility/URLParamModel.cs +++ /dev/null @@ -1,108 +0,0 @@ -//----------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 17.06.2013 -//---------------------------------------------------------------------- -namespace CampusAppWP8ScheduledTaskAgent.Model.Utility -{ - /// - /// This class is a Model for the URLParameter like GET-Parameter - /// - public class UrlParamModel - { - #region Members - - /// - /// Variable of the key - /// - protected readonly string key; - - #endregion - - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - /// the key for the parameter - public UrlParamModel(string key) - { - this.key = key; - } - - /// - /// Initializes a new instance of the class. - /// - /// the key for the parameter> - /// value of the parameter - public UrlParamModel(string key, string value) - { - this.key = key; - this.Value = value; - } - #endregion - - #region Proberty - - /// - /// Gets or sets the value of the Parameter - /// - public string Value { get; set; } - - /// - /// Gets the key of the parameter - /// - public string Key - { - get - { - return this.key; - } - } - - /// - /// Gets the token, which indicate that the parameterList started - /// - public virtual string ParamToken - { - get - { - return "?"; - } - } - #endregion - - #region Methods - - /// - /// Method check if the parameter is valid - /// - /// true if is it valid, otherwise false - public virtual bool IsParamValid() - { - if (this.key == null || string.Empty.Equals(this.key) || string.Empty.Equals(this.Value)) - { - return false; - } - - return true; - } - - /// - /// Method return a formatted string like Key=Value - /// - /// return formatted string - public override string ToString() - { - if (!this.IsParamValid()) - { - return string.Empty; - } - - return "&" + this.key + "=" + this.Value; - } - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.Designer.cs index 59879025..e4e6fcca 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.Designer.cs +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.Designer.cs @@ -87,24 +87,6 @@ namespace CampusAppWP8ScheduledTaskAgent.Resources { } } - /// - /// Sucht eine lokalisierte Zeichenfolge, die Aktion ähnelt. - /// - public static string MensaApp_Action { - get { - return ResourceManager.GetString("MensaApp_Action", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die Bio ähnelt. - /// - public static string MensaApp_Bio { - get { - return ResourceManager.GetString("MensaApp_Bio", resourceCulture); - } - } - /// /// Sucht eine lokalisierte Zeichenfolge, die Die Mensa ist heute geschlossen ähnelt. /// @@ -113,86 +95,5 @@ namespace CampusAppWP8ScheduledTaskAgent.Resources { return ResourceManager.GetString("MensaApp_CloseMensa", resourceCulture); } } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die Essen 1 ähnelt. - /// - public static string MensaApp_Dinner1 { - get { - return ResourceManager.GetString("MensaApp_Dinner1", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die Essen 2 ähnelt. - /// - public static string MensaApp_Dinner2 { - get { - return ResourceManager.GetString("MensaApp_Dinner2", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die Essen 3 ähnelt. - /// - public static string MensaApp_Dinner3 { - get { - return ResourceManager.GetString("MensaApp_Dinner3", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die Essen 4 ähnelt. - /// - public static string MensaApp_Dinner4 { - get { - return ResourceManager.GetString("MensaApp_Dinner4", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die Essen 5 ähnelt. - /// - public static string MensaApp_Dinner5 { - get { - return ResourceManager.GetString("MensaApp_Dinner5", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die 84 ähnelt. - /// - public static string MensaApp_DinnerLabelW { - get { - return ResourceManager.GetString("MensaApp_DinnerLabelW", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die Heute nicht im Angbot ähnelt. - /// - public static string MensaApp_NotToday { - get { - return ResourceManager.GetString("MensaApp_NotToday", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die Suppe ähnelt. - /// - public static string MensaApp_Soup { - get { - return ResourceManager.GetString("MensaApp_Soup", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die Mensaplan ähnelt. - /// - public static string MensaApp_Title { - get { - return ResourceManager.GetString("MensaApp_Title", resourceCulture); - } - } } } diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.resx index 31c1f5d6..eeaa3432 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.resx +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.resx @@ -117,49 +117,16 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Mensaplan - - - Aktion - - - Bio - - - Essen 1 - - - Essen 2 - - - Essen 3 - - - Essen 4 - - - Heute nicht im Angbot - - - 84 - - - Essen 5 - - - Suppe - Hintergrunddienst für die BTU-Mensa - - Die Mensa ist heute geschlossen - Hintergrunddienst für die BTU-Event-Feed Hintergrunddienst für die BTU-News-Feed + + Die Mensa ist heute geschlossen + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs index c2f57b7d..56c2823a 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs @@ -1,7 +1,8 @@ -using CampusAppWP8ScheduledTaskAgent.Model.Mensa; -using CampusAppWP8ScheduledTaskAgent.Model.RSS; -using CampusAppWP8ScheduledTaskAgent.Resources; +using CampusAppWP8ScheduledTaskAgent.Resources; using CampusAppWP8ScheduledTaskAgent.Utility; +using CampusAppWPortalLib8.Model.Mensa; +using CampusAppWPortalLib8.Model.RSS; +using CampusAppWPortalLib8.Utility; using Microsoft.Phone.Scheduler; using Microsoft.Phone.Shell; using System; diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/BackgroundTasks.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/BackgroundTasks.cs index 50b9034e..a585873d 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/BackgroundTasks.cs +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/BackgroundTasks.cs @@ -1,35 +1,11 @@ -using CampusAppWP8ScheduledTaskAgent.Resources; +using CampusAppWPortalLib8.Utility; using Microsoft.Phone.Scheduler; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace CampusAppWP8ScheduledTaskAgent.Utility { - public class BackgroundTasks + public class BackgroundTasks : AbstractBackgroundTasks { - public static void StartPerodicTask(string taskName, string taskDesc) { - BackgroundTasks.StopPerodicTask(taskName); - - PeriodicTask periodicTask = new PeriodicTask(taskName); - // load description from localized strings - periodicTask.Description = taskDesc; - - try - { - ScheduledActionService.Add(periodicTask); - - //ScheduledActionService.LaunchForTest(taskName, TimeSpan.FromSeconds(10)); - - } - catch (Exception e) - { - Logger.LogException(e); - } - } - public static void StopPerodicTask(string taskName) { PeriodicTask periodicTask = ScheduledActionService.Find(taskName) as PeriodicTask; diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/HttpRequest.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/HttpRequest.cs index 4750cb3f..455fad0d 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/HttpRequest.cs +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/HttpRequest.cs @@ -7,24 +7,15 @@ //----------------------------------------------------------------------using System; namespace CampusAppWP8ScheduledTaskAgent.Utility { + using CampusAppWPortalLib8.Utility; using System; - using System.Collections.Generic; using System.Net; - using CampusAppWP8ScheduledTaskAgent.Model.Utility; /// /// Class realize the access of restful HttpRequest /// - public class HttpRequest + public class HttpRequest : AbstractHttpRequest { - #region Member - - /// - /// BaseAddress of the webClient - /// - private string baseAddress; - #endregion - #region Constructor /// @@ -40,13 +31,12 @@ namespace CampusAppWP8ScheduledTaskAgent.Utility /// the url of the HttpRequest base address public HttpRequest(Uri apiBaseAddress) { - this.baseAddress = apiBaseAddress.AbsoluteUri; + this.BaseAddress = apiBaseAddress.AbsoluteUri; } #endregion #region Methods - #region public /// /// Method realize the http-get-method resource @@ -58,158 +48,7 @@ namespace CampusAppWP8ScheduledTaskAgent.Utility WebClient client = new WebClient(); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(action); client.DownloadStringAsync(url); - } - - /// Method realize the http-get-method resource. - /// Stubbfel, 03.09.2013. - /// Url of the resource. - /// The action. - public void HttpGet(Uri url, Action action) - { - WebClient client = new WebClient(); - client.OpenReadCompleted += new OpenReadCompletedEventHandler(action); - client.OpenReadAsync(url); - } - - /// - /// Method create the Url for the http-get-method - /// - /// list of parameters - /// absolute API-Url include GetParameter - public Uri CreateGetUrl(List 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 = this.baseAddress + seperator + paramterStr; - return new Uri(getUrlStr, UriKind.Absolute); - } - - /// - /// Method realize the http-delete-method - /// - /// - /// is not supported by WebClient - /// - /// Url of the resource - /// callback method - public void HttpDelete(Uri url, Action action) - { - throw new NotSupportedException(); - } - - /// - /// Method realize the http-head-method - /// - /// - /// is not supported by WebClient - /// - /// Url of the resource - /// callback method - public void HttpHead(Uri url, Action action) - { - throw new NotSupportedException(); - } - - /// - /// Method realize the http-options-method - /// - /// - /// is not supported by WebClient - /// - /// Url of the resource - /// callback method - public void HttpOptions(Uri url, Action action) - { - throw new NotSupportedException(); - } - - /// - /// Method realize the http-connect-method - /// - /// - /// is not supported by WebClient - /// - /// Url of the resource - /// callback method - public void HttpConnect(Uri url, Action action) - { - throw new NotSupportedException(); - } - - /// - /// Method realize the http-trace-method - /// - /// - /// is not supported by WebClient - /// - /// Url of the resource - /// callback method - public void HttpTrace(Uri url, Action action) - { - throw new NotSupportedException(); - } - - /// - /// Method realize the http-post-method - /// - /// Url of the resource - /// callback method - /// Data which are sending via post to the HttpRequest - public void HttpPost(Uri url, Action action, string postData) - { - this.UploadData(url, action, "POST", postData); - } - - /// - /// Method realize the http-put-method - /// - /// Url of the resource - /// callback method - /// Data which are sending via put to the HttpRequest - public void HttpPut(Uri url, Action action, string putData) - { - this.UploadData(url, action, "PUT", putData); - } - - /// - /// Method realize the http-patch-method - /// - /// Url of the resource - /// callback method - /// Data which are sending via patch to the HttpRequest - public void HttpPatch(Uri url, Action action, string patchData) - { - this.UploadData(url, action, "PATCH", patchData); - } - - #endregion - - #region private - - /// - /// Method uploaded Data to the HttpRequest - /// - /// Url of the resource - /// callback method - /// name of APIMethod, how the data will be uploaded - /// Data which are sending to the HttpRequest - private void UploadData(Uri url, Action action, string method, string data) - { - WebClient client = new WebClient(); - client.UploadStringCompleted += new UploadStringCompletedEventHandler(action); - client.UploadStringAsync(url, method, data); - } - #endregion + } #endregion } diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/Logger.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/Logger.cs deleted file mode 100644 index 6007319e..00000000 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/Logger.cs +++ /dev/null @@ -1,35 +0,0 @@ -//-------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 03.05.2013 -//---------------------------------------------------------------------- -namespace CampusAppWP8ScheduledTaskAgent.Utility -{ - using System; - - /// - /// This Class creates logs for the app - /// - public class Logger - { - /// - /// Method log a Exception - /// - /// exception which has to log - public static void LogException(Exception exception) - { - // Console.WriteLine(exception); - } - - /// - /// Log a message. - /// - /// to be logged message - public static void LogMsg(string msg) - { - // Console.WriteLine(msg); - } - } -} diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/StringManager.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/StringManager.cs deleted file mode 100644 index 58cbe206..00000000 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/StringManager.cs +++ /dev/null @@ -1,69 +0,0 @@ -//----------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 06.06.2013 -//---------------------------------------------------------------------- -namespace CampusAppWP8ScheduledTaskAgent.Utility -{ - using System.Text.RegularExpressions; - - /// - /// Class provides some special StringMethods - /// - public static class StringManager - { - #region Members - - /// - /// Patter for Html-Tags - /// - private static readonly string HtmlTagPattern = "<.*?>"; - - #endregion - - #region Methods - - /// - /// Method removes Html-Tag of a String - /// - /// String with Html-Tags - /// String without Html-Tags - public static string StripHTML(string inputString) - { - return Regex.Replace(inputString, HtmlTagPattern, string.Empty); - } - - /// - /// Method add an Newline to a string - /// - /// input string - /// input string + newline - public static string AddNewLine(string str) - { - return str.ToString() + "\n"; - } - - /// - /// Method remove(TrimEND!) an Newline to a string - /// - /// input string - /// input string - newline maxLenght) - { - shortStr = shortStr.Substring(0, maxLenght); - } - return shortStr; - } - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/XmlManager.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/XmlManager.cs deleted file mode 100644 index 89ea46eb..00000000 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/XmlManager.cs +++ /dev/null @@ -1,88 +0,0 @@ -//----------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 18.06.2013 -//---------------------------------------------------------------------- -namespace CampusAppWP8ScheduledTaskAgent.Utility -{ - using System.IO; - using System.Xml.Linq; - using System.Xml.Serialization; - - /// - /// Class provides some Xml-methods - /// - public class XmlManager - { - /// - /// Method deserialization a string to a Model - /// - /// the model - /// the XmlString - /// name of the RootTag - /// return the deserialization of the model - public static T DeserializationToModel(string xmlString, string validRootName) - { - XmlSerializer serializer = new XmlSerializer(typeof(T)); - XDocument document = XDocument.Parse(xmlString); - if (!document.Root.Name.ToString().Equals(validRootName)) - { - XElement content = document.Root; - document = new XDocument(); - document.Add(new XElement(validRootName, content)); - } - - T model = (T)serializer.Deserialize(document.CreateReader()); - return model; - } - - /// Deserialization a xml file to a model. - /// Stubbfel, 20.08.2013. - /// Generic type parameter. - /// Path to the a XmlFile. - /// model of the XmlFile. - public static T DeserializationFileToModel(string xmlFilePath) - { - XmlSerializer serializer = new XmlSerializer(typeof(T)); - XDocument document = XDocument.Load(xmlFilePath); - T model = (T)serializer.Deserialize(document.CreateReader()); - return model; - } - - /// - /// Method serializes a model to a string. - /// - /// type of the model - /// model object - /// serialized string - public static string SerializationToString(T model) - { - string retValue = string.Empty; - - XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); - ns.Add(string.Empty, string.Empty); - - XmlSerializer serializer = new XmlSerializer(typeof(T)); - TextWriter writer = new StringWriter(); - - serializer.Serialize(writer, model, ns); - - retValue = writer.ToString(); - - if (retValue.StartsWith(""); - retValue = retValue.Substring(endTag + 2); - - if (retValue.StartsWith("\r\n") == true) - { - retValue = retValue.Substring(2); - } - } - - return retValue; - } - } -} diff --git a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj index 8d9e3e15..567280d1 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj +++ b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj @@ -33,23 +33,46 @@ 4 - - - - - - + + + + + + + + + + AppResources.resx + True + True + + + Constants.resx + True + True + + + - - - + + + PublicResXFileCodeGenerator + AppResources.Designer.cs + Designer + + + PublicResXFileCodeGenerator + Constants1.Designer.cs + Designer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Aktion + + + Bio + + + Essen 1 + + + Essen 2 + + + Essen 3 + + + Essen 4 + + + Essen 5 + + + Suppe + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants.resx b/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants.resx new file mode 100644 index 00000000..29dcb1b3 --- /dev/null +++ b/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants1.Designer.cs b/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants1.Designer.cs new file mode 100644 index 00000000..dd099688 --- /dev/null +++ b/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants1.Designer.cs @@ -0,0 +1,64 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion:4.0.30319.18051 +// +// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +// der Code erneut generiert wird. +// +//------------------------------------------------------------------------------ + +namespace CampusAppWPortalLib8.Resources { + using System; + using System.Reflection; + + + /// + /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// + // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Constants { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Constants() { + } + + /// + /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CampusAppWPortalLib8.Resources.Constants", typeof(Constants).GetTypeInfo().Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractBackgroundTasks.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractBackgroundTasks.cs new file mode 100644 index 00000000..6456db33 --- /dev/null +++ b/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractBackgroundTasks.cs @@ -0,0 +1,7 @@ +namespace CampusAppWPortalLib8.Utility +{ + public abstract class AbstractBackgroundTasks + { + protected static string LastAddedTaskName {get; set;} + } +} diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractHttpRequest.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractHttpRequest.cs new file mode 100644 index 00000000..f931f530 --- /dev/null +++ b/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractHttpRequest.cs @@ -0,0 +1,75 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 10.06.2013 +//---------------------------------------------------------------------- +namespace CampusAppWPortalLib8.Utility +{ + using System; + using System.Collections.Generic; + using System.Net; + using CampusAppWPortalLib8.Model.Utility; + + /// + /// Class realize the access of restful HttpRequest + /// + public abstract class AbstractHttpRequest + { + #region Member + + /// + /// BaseAddress of the webClient + /// + private string baseAddress; + + #endregion + + #region property + + protected string BaseAddress + { + get + { + return this.baseAddress; + } + + set + { + if (value != this.baseAddress) + { + this.baseAddress = value; + } + } + } + #endregion + + #region Methods + + /// + /// Method create the Url for the http-get-method + /// + /// list of parameters + /// absolute API-Url include GetParameter + public Uri CreateGetUrl(List 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 = this.baseAddress + seperator + paramterStr; + return new Uri(getUrlStr, UriKind.Absolute); + } + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/NDEF/NDEFMessage.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/NDEF/NDEFMessage.cs deleted file mode 100644 index 35b4f91c..00000000 --- a/CampusAppWP8/CampusAppWPortalLib8/Utility/NDEF/NDEFMessage.cs +++ /dev/null @@ -1,154 +0,0 @@ -//----------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 21.08.2013 -//---------------------------------------------------------------------- -namespace CampusAppWPortalLib8.Utility.NDEF -{ - using System.Collections.Generic; - using System.IO; - - /// Ndef message. - /// Stubbfel, 21.08.2013. - public class NDEFMessage - { - #region Members - - /// The records. - private List records; - - #endregion - - #region constructors - - /// Initializes a new instance of the NDEFMessage class. - /// Stubbfel, 21.08.2013. - /// The content. - /// The type. - /// (Optional) the tnf. - public NDEFMessage(string content, TYPEVAL type, NDEFRecord.TNFVAL tnf = NDEFRecord.TNFVAL.WKT) - { - this.records = new List(); - float recordsCount = (float)content.Length / NDEFRecord.MaxRecordPayLoad; - NDEFRecord tmpRecord = null; - string praefix = NDEFMessage.GetPraefix(type); - - for (int i = 0; recordsCount > 0; i++) - { - tmpRecord = new NDEFShortRecord(); - tmpRecord.Type = type; - tmpRecord.TNF = tnf; - tmpRecord.PayloadPraefix = praefix; - int recordsize = 255; - if (content.Length < (i + 1) * recordsize) - { - recordsize = content.Length - (i * recordsize); - } - - tmpRecord.Payload = content.Substring(i * 255, recordsize); - if (i == 0) - { - tmpRecord.MB = NDEFRecord.NDEFFlags.MBSET; - } - - this.records.Add(tmpRecord); - recordsCount--; - } - - this.records[this.records.IndexOf(tmpRecord)].ME = NDEFRecord.NDEFFlags.MESET; - } - - /// Initializes a new instance of the NDEFMessage class. - /// Stubbfel, 21.08.2013. - /// The array. - public NDEFMessage(byte[] array) - { - this.records = new List(); - - NDEFRecord tmpRecord = null; - for (int i = 0; i < array.Length; i += tmpRecord.RecordSize) - { - tmpRecord = new NDEFShortRecord(array, i); - - this.records.Add(tmpRecord); - } - } - - #endregion - - #region enum - - /// Values that represent TYPEVAL. - /// Stubbfel, 21.08.2013. - public enum TYPEVAL - { - /// An enum constant representing the empty option. - EMPTY = 0x00, - - /// An enum constant representing the URL option. - URL = 0x55, - - /// An enum constant representing the text option. - TEXT = 0x54, - } - - #endregion - - #region Methods - /// Gets a praefix. - /// Stubbfel, 21.08.2013. - /// The type. - /// The praefix. - public static string GetPraefix(TYPEVAL type) - { - string praefix = string.Empty; - - switch (type) - { - case TYPEVAL.TEXT: - praefix = "\x02" + "de"; - break; - case TYPEVAL.URL: - praefix = "\x01"; - break; - default: - break; - } - - return praefix; - } - - /// Gets the content. - /// Stubbfel, 21.08.2013. - /// The content. - public string GetContent() - { - string result = string.Empty; - - foreach (NDEFRecord record in this.records) - { - result += record.Payload; - } - - return result; - } - - /// Converts this object to a byte array. - /// Stubbfel, 21.08.2013. - /// This object as a byte[]. - public byte[] ToByteArray() - { - MemoryStream ms = new MemoryStream(); - foreach (NDEFRecord record in this.records) - { - ms.Write(record.ToByteArray(), 0, record.RecordSize); - } - - return ms.ToArray(); - } - - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/NDEF/NDEFRecord.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/NDEF/NDEFRecord.cs deleted file mode 100644 index 8defa143..00000000 --- a/CampusAppWP8/CampusAppWPortalLib8/Utility/NDEF/NDEFRecord.cs +++ /dev/null @@ -1,188 +0,0 @@ -//----------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 21.08.2013 -//---------------------------------------------------------------------- -namespace CampusAppWPortalLib8.Utility.NDEF -{ - using System.IO; - using System.Text; - - /// Ndef record of a NDEFMessage. - /// Stubbfel, 21.08.2013. - public abstract class NDEFRecord - { - #region Members - - /// The maximum record pay load. - public const int MaxRecordPayLoad = 255; - - /// Size of the type. - protected const byte TypeSize = 0x01; - - #endregion - - #region Constructors - /// Initializes a new instance of the NDEFRecord class. - /// Stubbfel, 21.08.2013. - public NDEFRecord() - { - } - - /// Initializes a new instance of the NDEFRecord class. - /// Stubbfel, 21.08.2013. - /// The array. - /// (Optional) zero-based index of the. - public NDEFRecord(byte[] array, int index = 0) - { - this.FormatFlags = array[index]; - } - - #endregion - - #region enum - - /// Values that represent NDEFFlags. - /// Stubbfel, 21.08.2013. - public enum NDEFFlags - { - /// An Enum constant representing the UNSET option. - UNSET = 0x00, - - /// An Enum constant representing the Message begin option. - MBSET = 0x80, - - /// An Enum constant representing the Message end option. - MESET = 0x40, - - /// An Enum constant representing the CHUNK FLAG option. - CFSET = 0x20, - - /// An Enum constant representing the Short Record set option. - SRSET = 0x10, - - /// An Enum constant representing the ID length option. - ILSET = 0x08, - - /// An enum constant representing the tnfset option. - TNFSET = 0x03 - } - - /// Values that represent TNFVAL. - /// Stubbfel, 21.08.2013. - public enum TNFVAL - { - /// An enum constant representing the empty option. - EMPTY = 0x00, - - /// An enum constant representing the Well-Know-Type option. - WKT = 0x01, - - /// An enum constant representing the MediaType option. - MEDIATYPE = 0x02, - - /// An enum constant representing the URI option. - URI = 0x03, - - /// An enum constant representing the NFCE option. - NFCE = 0x04, - - /// An enum constant representing the unknow option. - unknow = 0x05, - - /// An enum constant representing the unchanged option. - UNCHANGED = 0x06, - - /// An enum constant representing the reserved option. - RESERVED = 0x07 - } - - #endregion - - #region Properties - /// Gets or sets the MBFlag. - /// The MBFlag. - public NDEFFlags MB { get; set; } - - /// Gets or sets MEFlag. - /// The MEFlag . - public NDEFFlags ME { get; set; } - - /// Gets or sets the CFFlag. - /// The CFFlag. - public NDEFFlags CF { get; set; } - - /// Gets or sets the SRFlag. - /// The SRFlag. - public NDEFFlags SR { get; set; } - - /// Gets or sets the ILFlag. - /// The ILFlag. - public NDEFFlags IL { get; set; } - - /// Gets or sets the TNFField. - /// The TNFField. - public TNFVAL TNF { get; set; } - - /// Gets or sets the type. - /// The type. - public NDEFMessage.TYPEVAL Type { get; set; } - - /// Gets or sets the format flags. - /// The format flags. - public byte FormatFlags - { - get - { - return (byte)((byte)this.TNF | ((byte)this.MB) | ((byte)this.ME) | ((byte)this.CF) | ((byte)this.SR) | ((byte)this.IL)); - } - - protected set - { - this.TNF = (TNFVAL)(value & (byte)NDEFFlags.TNFSET); - this.MB = (NDEFFlags)(value & (byte)NDEFFlags.MBSET); - this.ME = (NDEFFlags)(value & (byte)NDEFFlags.MESET); - this.CF = (NDEFFlags)(value & (byte)NDEFFlags.CFSET); - this.SR = (NDEFFlags)(value & (byte)NDEFFlags.SRSET); - this.IL = (NDEFFlags)(value & (byte)NDEFFlags.ILSET); - } - } - - /// Gets or sets the payload. - /// The payload. - public string Payload { get; set; } - - /// Gets the size of the record. - /// The size of the record. - public int RecordSize - { - get - { - return this.HeaderSize + this.Payload.Length + this.PayloadPraefix.Length; - } - } - - /// Gets or sets the payload praefix. - /// The payload praefix. - public string PayloadPraefix { get; set; } - - /// Gets or sets the size of the header. - /// The size of the header. - protected int HeaderSize { get; set; } - - #endregion - - #region Methods - - /// Converts the record to a byte array. - /// Stubbfel, 21.08.2013. - /// This object as a byte[]. - public abstract byte[] ToByteArray(); - - #endregion - } -} - -// End of Utility\NDEF\NDEFRecord.cs diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/NDEF/NDEFShortRecord.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/NDEF/NDEFShortRecord.cs deleted file mode 100644 index 5a8f5fda..00000000 --- a/CampusAppWP8/CampusAppWPortalLib8/Utility/NDEF/NDEFShortRecord.cs +++ /dev/null @@ -1,63 +0,0 @@ -//----------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 21.08.2013 -//---------------------------------------------------------------------- -namespace CampusAppWPortalLib8.Utility.NDEF -{ - using System.Text; - - /// Ndef short record. - /// Stubbfel, 21.08.2013. - public class NDEFShortRecord : NDEFRecord - { - /// Initializes a new instance of the NDEFShortRecord class. - /// Stubbfel, 21.08.2013. - public NDEFShortRecord() - { - this.HeaderSize = 4; - this.SR = NDEFFlags.SRSET; - this.IL = NDEFFlags.UNSET; - this.CF = NDEFFlags.UNSET; - } - - /// Initializes a new instance of the NDEFShortRecord class. - /// Stubbfel, 21.08.2013. - /// The array. - /// (Optional) zero-based index of the. - public NDEFShortRecord(byte[] array, int index = 0) - : base(array) - { - this.HeaderSize = 4; - this.Type = (NDEFMessage.TYPEVAL)array[index + 3]; - this.PayloadPraefix = NDEFMessage.GetPraefix(this.Type); - int payLoadSize = array[index + 2] - this.PayloadPraefix.Length; - this.Payload = Encoding.UTF8.GetString(array, index + this.HeaderSize + this.PayloadPraefix.Length, payLoadSize); - } - - /// Converts this NDEFShortRecord to a byte array. - /// Stubbfel, 21.08.2013. - /// This object as a byte[]. - public override byte[] ToByteArray() - { - byte[] payloadAr = Encoding.UTF8.GetBytes(this.PayloadPraefix + this.Payload); - byte[] array = new byte[payloadAr.Length + this.HeaderSize]; - - array[0] = this.FormatFlags; - array[1] = NDEFRecord.TypeSize; - array[2] = (byte)(Payload.Length + this.PayloadPraefix.Length); - array[3] = (byte)this.Type; - - int i = this.HeaderSize; - foreach (byte b in payloadAr) - { - array[i] = b; - i++; - } - - return array; - } - } -} diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/StringManager.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/StringManager.cs index 17508b62..29b2f707 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Utility/StringManager.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Utility/StringManager.cs @@ -54,6 +54,16 @@ namespace CampusAppWPortalLib8.Utility { return str.TrimEnd('\n'); } + + public static string ToShortString(string longStr, int maxLenght) + { + string shortStr = longStr; + if (shortStr.Length > maxLenght) + { + shortStr = shortStr.Substring(0, maxLenght); + } + return shortStr; + } #endregion } } From b92208a9473f26ce566693f4628c7951dd338f8f Mon Sep 17 00:00:00 2001 From: stubbfel Date: Tue, 17 Sep 2013 15:42:42 +0200 Subject: [PATCH 5/9] rm mensa and rssmodel from other projects --- CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 6 - .../CampusAppWP8/Feed/Events/EventFeed.cs | 4 +- .../CampusAppWP8/Feed/Mensa/MensaFeed.cs | 2 +- .../CampusAppWP8/Feed/News/NewsFeed.cs | 2 +- .../CampusAppWP8/Model/Mensa/MealModel.cs | 268 ----------------- .../CampusAppWP8/Model/Mensa/MenuModel.cs | 100 ------- .../CampusAppWP8/Model/Mensa/MenuWeekModel.cs | 82 ------ .../CampusAppWP8/Model/RSS/RSSChannelModel.cs | 82 ------ .../CampusAppWP8/Model/RSS/RSSModel.cs | 276 ------------------ .../CampusAppWP8/Model/RSS/RSSViewModel.cs | 83 ------ .../Pages/Events/EventIndexPage.xaml.cs | 3 +- .../CampusAppWP8/Pages/Events/EventPage.xaml | 5 - .../Pages/Events/EventPage.xaml.cs | 2 +- .../Pages/Mensa/MensaPage.xaml.cs | 3 +- .../Pages/News/NewsIndexPage.xaml.cs | 3 +- .../CampusAppWP8/Pages/News/NewsPage.xaml | 5 - .../CampusAppWP8/Pages/News/NewsPage.xaml.cs | 2 +- 17 files changed, 12 insertions(+), 916 deletions(-) delete mode 100644 CampusAppWP8/CampusAppWP8/Model/Mensa/MealModel.cs delete mode 100644 CampusAppWP8/CampusAppWP8/Model/Mensa/MenuModel.cs delete mode 100644 CampusAppWP8/CampusAppWP8/Model/Mensa/MenuWeekModel.cs delete mode 100644 CampusAppWP8/CampusAppWP8/Model/RSS/RSSChannelModel.cs delete mode 100644 CampusAppWP8/CampusAppWP8/Model/RSS/RSSModel.cs delete mode 100644 CampusAppWP8/CampusAppWP8/Model/RSS/RSSViewModel.cs diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 79607bf7..d218c078 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -122,7 +122,6 @@ - @@ -179,8 +178,6 @@ - - @@ -191,8 +188,6 @@ - - @@ -249,7 +244,6 @@ NewsPage.xaml - OpeninghoursPage.xaml diff --git a/CampusAppWP8/CampusAppWP8/Feed/Events/EventFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Events/EventFeed.cs index ef800d52..56ceb088 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/Events/EventFeed.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/Events/EventFeed.cs @@ -9,10 +9,10 @@ namespace CampusAppWP8.Feed.Events { using System; using System.IO; - using CampusAppWP8.Model; - using CampusAppWP8.Model.RSS; + using CampusAppWP8.Model; using CampusAppWP8.Resources; using CampusAppWP8.Utility; + using CampusAppWPortalLib8.Model.RSS; /// /// Event Feed. diff --git a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeed.cs index 2fbd42cd..ff79851f 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeed.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeed.cs @@ -10,7 +10,7 @@ namespace CampusAppWP8.Feed.Mensa using System; using System.IO; using CampusAppWP8.Model; - using CampusAppWP8.Model.Mensa; + using CampusAppWPortalLib8.Model.Mensa; /// /// This Class is for MensaFeeds diff --git a/CampusAppWP8/CampusAppWP8/Feed/News/NewsFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/News/NewsFeed.cs index 145c9873..da60040f 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/News/NewsFeed.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/News/NewsFeed.cs @@ -10,9 +10,9 @@ namespace CampusAppWP8.Feed.News using System; using System.IO; using CampusAppWP8.Model; - using CampusAppWP8.Model.RSS; using CampusAppWP8.Resources; using CampusAppWP8.Utility; + using CampusAppWPortalLib8.Model.RSS; /// /// News Feed. diff --git a/CampusAppWP8/CampusAppWP8/Model/Mensa/MealModel.cs b/CampusAppWP8/CampusAppWP8/Model/Mensa/MealModel.cs deleted file mode 100644 index 1ff1d49a..00000000 --- a/CampusAppWP8/CampusAppWP8/Model/Mensa/MealModel.cs +++ /dev/null @@ -1,268 +0,0 @@ -//----------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 06.08.2013 -//---------------------------------------------------------------------- -namespace CampusAppWP8.Model.Mensa -{ - using System.Xml.Serialization; - using CampusAppWP8.Resources; - using CampusAppWP8.Utility; - - /// - /// Model for a meal - /// - public class MealModel - { - #region Members - - /// - /// Constant for the vegetarian icon - /// - private const string MealIconNameVegetarian = "CARROTTE"; - - /// - /// Constant for the free icon - /// - private const string MealIconNameFree = "FREI"; - - /// - /// Constant for the pig icon - /// - private const string MealIconNamePig = "SCHWEIN"; - - /// - /// Constant for the cow icon - /// - private const string MealIconNameCow = "RIND"; - - /// - /// Constant for the fowl icon - /// - private const string MealIconNameFowl = "GEFL"; - - /// - /// Constant for the cow-pig icon - /// - private const string MealIconNameCowPig = "RINDSCHWEIN"; - - /// - /// Constant for the fish icon - /// - private const string MealIconNameFish = "FISCH"; - - /// - /// Constant for the wild icon - /// - private const string MealIconNameWild = "WILD"; - - /// - /// Constant for the lamb icon - /// - private const string MealIconNameLamb = "LAMM"; - - /// - /// Variable for the id of the meal - /// - /// - /// ValueRange : 0 - 7 - /// - private int mealId; - - /// - /// Name of the meal - /// - private string mealName; - - /// - /// Name of the icon - /// - private string iconName; - - /// - /// Url of the icon - /// - private string iconUrl; - - /// - /// Description of the meal - /// - private string mealDesc; - - #endregion - - #region Proberty - - /// - /// Gets or sets the mealId - /// - /// - /// ValueRange : 0 - 7 - /// - [XmlAttribute("id")] - public int MealId - { - get - { - return this.mealId; - } - - set - { - if (value > -1 && value < 8) - { - this.mealId = value; - this.CreateMealName(); - } - } - } - - /// - /// Gets the mealName - /// - public string MealName - { - get - { - return this.mealName; - } - } - - /// - /// Gets or sets the iconName - /// - [XmlAttribute("icon")] - public string IconName - { - get - { - return this.iconName; - } - - set - { - if (value != this.iconName) - { - this.iconName = value; - this.CreateIconUrl(); - } - } - } - - /// - /// Gets the iconUrl - /// - public string IconUrl - { - get - { - return this.iconUrl; - } - } - - /// - /// Gets or sets the mealDescription - /// - [XmlAttribute("desc")] - public string MealDesc - { - get - { - return this.mealDesc; - } - - set - { - if (value != this.mealDesc) - { - this.mealDesc = StringManager.StripHTML(value); - } - } - } - - #endregion - - #region Methods - - /// - /// Method create depends of the mealId the mealName - /// - private void CreateMealName() - { - switch (this.mealId) - { - case 0: - this.mealName = AppResources.MensaApp_Soup; - break; - case 1: - this.mealName = AppResources.MensaApp_Dinner1; - break; - case 2: - this.mealName = AppResources.MensaApp_Dinner2; - break; - case 3: - this.mealName = AppResources.MensaApp_Dinner3; - break; - case 4: - this.mealName = AppResources.MensaApp_Dinner4; - break; - case 5: - this.mealName = AppResources.MensaApp_Dinner5; - break; - case 6: - this.mealName = AppResources.MensaApp_Bio; - break; - case 7: - this.mealName = AppResources.MensaApp_Action; - break; - default: - this.mealName = string.Empty; - break; - } - } - - /// - /// Method create depends of the iconUrl the iconName - /// - private void CreateIconUrl() - { - switch (this.iconName) - { - case MealModel.MealIconNameVegetarian: - this.iconUrl = Icons.Vegetarian; - break; - case MealModel.MealIconNameFree: - this.iconUrl = Icons.Free; - break; - case MealModel.MealIconNameCowPig: - this.iconUrl = Icons.CowPig; - break; - case MealModel.MealIconNameFish: - this.iconUrl = Icons.Fish; - break; - case MealModel.MealIconNameFowl: - this.iconUrl = Icons.Fowl; - break; - case MealModel.MealIconNameLamb: - this.iconUrl = Icons.Lamb; - break; - case MealModel.MealIconNamePig: - this.iconUrl = Icons.Pig; - break; - case MealModel.MealIconNameWild: - this.iconUrl = Icons.Wild; - break; - case MealModel.MealIconNameCow: - this.iconUrl = Icons.Cow; - break; - default: - this.iconUrl = string.Empty; - break; - } - } - - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWP8/Model/Mensa/MenuModel.cs b/CampusAppWP8/CampusAppWP8/Model/Mensa/MenuModel.cs deleted file mode 100644 index 3f5f48d0..00000000 --- a/CampusAppWP8/CampusAppWP8/Model/Mensa/MenuModel.cs +++ /dev/null @@ -1,100 +0,0 @@ -//----------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 04.05.2013 -//---------------------------------------------------------------------- -namespace CampusAppWP8.Model.Mensa -{ - using System; - using System.Collections.ObjectModel; - using System.Xml.Serialization; - - /// - /// Model for menu - /// - public class MenuModel - { - #region Member - - /// - /// Name of the day - /// - private string dayName; - - /// - /// DateTime of the day - /// - private string date; - - /// - /// DateTime of the monday - /// - private DateTime monday; - - #endregion - - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - public MenuModel() - { - this.monday = MenuWeekModel.CalcFirstWeekDay(); - } - - #endregion - - #region Property - - /// - /// Gets or sets the menus for the week - /// - [XmlElement("Meal")] - public ObservableCollection Meals { get; set; } - - /// - /// Gets or sets the WeekDay - /// - [XmlAttribute("day")] - public string Day - { - get - { - return this.dayName; - } - - set - { - if (value != this.dayName) - { - this.dayName = value; - } - } - } - - /// - /// Gets or sets of Date - /// - [XmlAttribute("date")] - public string Date - { - get - { - return this.date.ToString(); - } - - set - { - if (value != this.date) - { - this.date = value; - } - } - } - - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWP8/Model/Mensa/MenuWeekModel.cs b/CampusAppWP8/CampusAppWP8/Model/Mensa/MenuWeekModel.cs deleted file mode 100644 index 11cedc69..00000000 --- a/CampusAppWP8/CampusAppWP8/Model/Mensa/MenuWeekModel.cs +++ /dev/null @@ -1,82 +0,0 @@ -//----------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 03.05.2013 -//---------------------------------------------------------------------- -namespace CampusAppWP8.Model.Mensa -{ - using System; - using System.Collections.ObjectModel; - using System.Xml.Serialization; - - /// - /// Model for menus in one week - /// - [XmlRoot("root")] - public class MenuWeekModel - { - #region Members - /// - /// Time when the model was created - /// - private readonly DateTime createTime; - - #endregion - - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - public MenuWeekModel() - { - this.createTime = DateTime.Now; - } - - #endregion - - #region Proberty - - /// - /// Gets or sets the menus for the week - /// - [XmlArray("Mealplan")] - [XmlArrayItem("Menu")] - public ObservableCollection Menus { get; set; } - - /// - /// Gets the creation time of the model - /// - public DateTime CreateTime - { - get - { - return this.createTime; - } - } - - #endregion - - #region Methods - - /// - /// Method calculate this day of the week, which its gets new menus - /// - /// Date of NewMenuWeekDay - public static DateTime CalcFirstWeekDay() - { - DateTime now = DateTime.Now; - while (now.DayOfWeek != DayOfWeek.Monday) - { - now = now.Subtract(new TimeSpan(1, 0, 0, 0)); - } - - DateTime monday = new DateTime(now.Year, now.Month, now.Day); - return monday; - } - - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWP8/Model/RSS/RSSChannelModel.cs b/CampusAppWP8/CampusAppWP8/Model/RSS/RSSChannelModel.cs deleted file mode 100644 index fd0f0463..00000000 --- a/CampusAppWP8/CampusAppWP8/Model/RSS/RSSChannelModel.cs +++ /dev/null @@ -1,82 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Company copyright tag. -// -// fiedlchr -// 24.06.2013 -//----------------------------------------------------------------------------- -namespace CampusAppWP8.Model.RSS -{ - using System.Collections.ObjectModel; - using System.Collections.Specialized; - using System.Xml.Serialization; - - /// - /// Channel Model, which contains the RSS feed item list. - /// - public class RSSChannelModel - { - /// - /// RSS feed information item list. - /// - private ObservableCollection item; - - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - public RSSChannelModel() - { - this.item = new ObservableCollection(); - this.item.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnListChanged); - } - - #endregion - - #region Property - - /// - /// Gets or sets the RSS feed item list. - /// - [XmlElement("item")] - public ObservableCollection Item - { - get - { - return this.item; - } - - set - { - if (value != this.item) - { - this.item = value; - } - } - } - - #endregion - - #region Method - - /// - /// Is called when the item list has changed. - /// Here used for the add event. - /// Set the index of the last list element. - /// - /// item list - /// event args - private void OnListChanged(object sender, NotifyCollectionChangedEventArgs e) - { - if (e.Action == NotifyCollectionChangedAction.Add) - { - ObservableCollection list = sender as ObservableCollection; - - list[list.Count - 1].Index = list.Count - 1; - } - } - - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWP8/Model/RSS/RSSModel.cs b/CampusAppWP8/CampusAppWP8/Model/RSS/RSSModel.cs deleted file mode 100644 index ec341240..00000000 --- a/CampusAppWP8/CampusAppWP8/Model/RSS/RSSModel.cs +++ /dev/null @@ -1,276 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Company copyright tag. -// -// fiedlchr -// 24.06.2013 -//----------------------------------------------------------------------------- -namespace CampusAppWP8.Model.RSS -{ - using System; - using System.Text; - using System.Xml.Serialization; - - /// - /// Contains the RSS feed information. - /// - public class RSSModel - { - #region Member - - /// - /// Index of this object. - /// - private int index = -1; - - /// - /// Title of the fees - /// - private string title; - - /// - /// Description text of the feed. - /// - private string text; - - /// - /// Timestamp (publication date) of the event or news. - /// - private DateTime timestamp; - - /// - /// Url of the feed. - /// - private string link; - - #endregion - - #region Property - - /// - /// Gets or sets the title of the feed. - /// - [XmlElement("title")] - public string Title - { - get - { - return this.title; - } - - set - { - if (this.title != value) - { - this.title = value; - } - } - } - - /// - /// Gets or sets the text of the feed. - /// - [XmlElement("description")] - public string Text - { - get - { - return this.text; - } - - set - { - if (this.text != this.HTMLUnicodeToString(value)) - { - this.text = this.HTMLUnicodeToString(value); - } - } - } - - /// - /// Gets or sets the timestamp of the feed as string. - /// - [XmlElement("pubDate")] - public string Timestamp - { - get - { - return this.timestamp.ToString("R"); - } - - set - { - if (this.timestamp != DateTime.Parse(value)) - { - this.timestamp = DateTime.Parse(value); - } - } - } - - /// - /// Gets or sets the timestamp of the feed as DateTime object. - /// - public DateTime DTTimestamp - { - get - { - return this.timestamp; - } - - set - { - this.timestamp = value; - } - } - - /// - /// Gets the date of the timestamp as string. - /// example: Mon, 25.06.2013. - /// - public string Date - { - get - { - return string.Format("{0:ddd, dd.MM.yyyy}", this.timestamp); - } - } - - /// - /// Gets the time of the timestamp as string. - /// example: 12:56. - /// - public string Time - { - get - { - return string.Format("{0:h:mm} Uhr", this.timestamp); - } - } - - /// - /// Gets or sets the link/url of the feed. - /// - [XmlElement("link")] - public string Link - { - get - { - return this.link; - } - - set - { - if (this.link != value) - { - this.link = value; - } - } - } - - /// - /// Gets or sets the ListIndex. - /// - public int Index - { - get - { - return this.index; - } - - set - { - this.index = value; - } - } - - #endregion - - #region Method - - #region public - - /// - /// Comparing function for DateTime timestamps. - /// (currently unused) - /// - /// first item - /// second item - /// -1 if item2 is older then item1, otherwise 0 - public static int CompareTimeStamp(RSSModel item1, RSSModel item2) - { - if (item1.DTTimestamp > item2.DTTimestamp) - { - return -1; - } - else - { - return 0; - } - } - - #endregion - - #region private - - /// - /// Remove or transform html-unicode specific tags into ASCII. - /// - /// html string - /// ASCII string - private string HTMLUnicodeToString(string htmluni) - { - StringBuilder retValue = new StringBuilder(); - - for (int i = 0; i < htmluni.Length; i++) - { - switch (htmluni[i]) - { - // beginning tag of the unicode - case '&': - int startOff = i + 2; - //// sear closing tag of the unicode - int endOff = htmluni.IndexOf(';', startOff); - //// get and parse value inbetween - string sub = htmluni.Substring(startOff, endOff - startOff); - int charVal = int.Parse(sub); - - switch (charVal) - { - // if the unicode value is 128 (€) - case 128: - retValue.Append('€'); - break; - - default: - retValue.Append((char)charVal); - break; - } - - // set the current index to the end of the unicode tag - i = endOff; - break; - - case '<': - // ignoring <..> html tags - i = htmluni.IndexOf('>', i); - break; - - case '\t': - // removing tabs - break; - - default: - // adding other characters to the return string - retValue.Append(htmluni[i]); - break; - } - } - - return retValue.ToString(); - } - - #endregion - - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWP8/Model/RSS/RSSViewModel.cs b/CampusAppWP8/CampusAppWP8/Model/RSS/RSSViewModel.cs deleted file mode 100644 index 7f0b2691..00000000 --- a/CampusAppWP8/CampusAppWP8/Model/RSS/RSSViewModel.cs +++ /dev/null @@ -1,83 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Company copyright tag. -// -// fiedlchr -// 24.06.2013 -//----------------------------------------------------------------------------- -namespace CampusAppWP8.Model.RSS -{ - using System; - using System.Collections.ObjectModel; - using System.Xml.Serialization; - - /// - /// ViewModel of the RSS feed, containing the feed/channel object. - /// - [XmlRoot("root")] - public class RSSViewModel - { - #region Member - - /// - /// Object to store the time when the instance was created. - /// - private DateTime createTime; - - /// - /// Channel list for the RSS feeds. - /// - private ObservableCollection channel; - - #endregion - - #region Constructor - - /// - /// Initializes a new instance of the class. - /// - public RSSViewModel() - { - this.channel = new ObservableCollection(); - this.createTime = DateTime.Now; - } - - #endregion - - #region Property - - /// - /// Gets or sets the channel list. - /// - [XmlArray("rss")] - [XmlArrayItem("channel")] - public ObservableCollection Channel - { - get - { - return this.channel; - } - - set - { - if (value != this.channel) - { - this.channel = value; - } - } - } - - /// - /// Gets the creation time. - /// - public DateTime CreateTime - { - get - { - return this.createTime; - } - } - - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWP8/Pages/Events/EventIndexPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Events/EventIndexPage.xaml.cs index 46e246b1..73f8b349 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Events/EventIndexPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Events/EventIndexPage.xaml.cs @@ -16,6 +16,7 @@ namespace CampusAppWP8.Pages.Events using CampusAppWP8.Utility.Lui.MessageBoxes; using Microsoft.Phone.Controls; using Microsoft.Phone.Shell; + using CampusAppWPortalLib8.Model.RSS; /// /// Overview page of all events. @@ -55,7 +56,7 @@ namespace CampusAppWP8.Pages.Events 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(Utilities.GetLoadModus()); + EventIndexPage.eventFeed.LoadData(Utilities.GetLoadModus()); } #endregion diff --git a/CampusAppWP8/CampusAppWP8/Pages/Events/EventPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Events/EventPage.xaml index b020136e..fbc0b384 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Events/EventPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Events/EventPage.xaml @@ -6,17 +6,12 @@ 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:viewModel="clr-namespace:CampusAppWP8.Model.RSS" mc:Ignorable="d" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" SupportedOrientations="PortraitOrLandscape" Orientation="Portrait" shell:SystemTray.IsVisible="True"> - - - - diff --git a/CampusAppWP8/CampusAppWP8/Pages/Events/EventPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Events/EventPage.xaml.cs index 03f83d24..685568fa 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Events/EventPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Events/EventPage.xaml.cs @@ -13,12 +13,12 @@ namespace CampusAppWP8.Pages.Events using System.Windows; using System.Windows.Controls; using System.Windows.Navigation; - using CampusAppWP8.Model.RSS; using CampusAppWP8.Resources; using CampusAppWP8.Utility; using Microsoft.Phone.Controls; using Microsoft.Phone.Shell; using Windows.Phone.Speech.Synthesis; + using CampusAppWPortalLib8.Model.RSS; /// /// EventPage, where every event fees has his own PivotItem. diff --git a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs index 66988df9..013edcb0 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs @@ -18,6 +18,7 @@ namespace CampusAppWP8.Pages.Mensa using CampusAppWP8.Utility.Lui.MessageBoxes; using Microsoft.Phone.Controls; using Microsoft.Phone.Shell; + using CampusAppWPortalLib8.Model.Mensa; /// /// Class for the MensaPage @@ -177,7 +178,7 @@ namespace CampusAppWP8.Pages.Mensa } else { - this.feed.LoadData(Utilities.GetLoadModus()); + this.feed.LoadData(Utilities.GetLoadModus()); } } diff --git a/CampusAppWP8/CampusAppWP8/Pages/News/NewsIndexPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/News/NewsIndexPage.xaml.cs index 7b5f8e7e..69814293 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/News/NewsIndexPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/News/NewsIndexPage.xaml.cs @@ -16,6 +16,7 @@ namespace CampusAppWP8.Pages.News using CampusAppWP8.Utility.Lui.MessageBoxes; using Microsoft.Phone.Controls; using Microsoft.Phone.Shell; + using CampusAppWPortalLib8.Model.RSS; /// /// Overview page of all news. @@ -55,7 +56,7 @@ namespace CampusAppWP8.Pages.News 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(Utilities.GetLoadModus()); + NewsIndexPage.newsFeed.LoadData(Utilities.GetLoadModus()); } #endregion diff --git a/CampusAppWP8/CampusAppWP8/Pages/News/NewsPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/News/NewsPage.xaml index 36992213..85e6faf4 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/News/NewsPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/News/NewsPage.xaml @@ -6,17 +6,12 @@ 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:viewModel="clr-namespace:CampusAppWP8.Model.RSS" mc:Ignorable="d" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" SupportedOrientations="PortraitOrLandscape" Orientation="Portrait" shell:SystemTray.IsVisible="True"> - - - - diff --git a/CampusAppWP8/CampusAppWP8/Pages/News/NewsPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/News/NewsPage.xaml.cs index 3565b225..d6ab0753 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/News/NewsPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/News/NewsPage.xaml.cs @@ -13,12 +13,12 @@ namespace CampusAppWP8.Pages.News using System.Windows; using System.Windows.Controls; using System.Windows.Navigation; - using CampusAppWP8.Model.RSS; using CampusAppWP8.Resources; using CampusAppWP8.Utility; using Microsoft.Phone.Controls; using Microsoft.Phone.Shell; using Windows.Phone.Speech.Synthesis; + using CampusAppWPortalLib8.Model.RSS; /// /// EventPage, where every news fees has his own PivotItem. From a54b1aa09550ccea0b405a7799fb58a46f419f29 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Tue, 17 Sep 2013 16:05:17 +0200 Subject: [PATCH 6/9] refactor costasnt and appresource --- .../CampusAppWP8/Feed/Events/EventFeed.cs | 2 +- .../Feed/Mensa/MensaFeedCBMain.cs | 2 +- .../Feed/Mensa/MensaFeedCBNorth.cs | 2 +- .../Feed/Mensa/MensaFeedCBSouth.cs | 2 +- .../Feed/Mensa/MensaFeedSBFMain.cs | 2 +- .../CampusAppWP8/Feed/News/NewsFeed.cs | 2 +- CampusAppWP8/CampusAppWP8/Model/XmlModel.cs | 4 +- .../Resources/AppResources.Designer.cs | 81 ----------------- .../CampusAppWP8/Resources/AppResources.resx | 27 ------ .../Resources/Constants.Designer.cs | 63 ------------- .../CampusAppWP8/Resources/Constants.resx | 33 ++----- .../Resources/Constants.resx | 30 ------- .../Resources/Constants1.Designer.cs | 90 ------------------- .../ScheduledAgent.cs | 32 +++---- .../Resources/Constants.resx | 30 +++++++ .../Resources/Constants1.Designer.cs | 90 +++++++++++++++++++ 16 files changed, 150 insertions(+), 342 deletions(-) diff --git a/CampusAppWP8/CampusAppWP8/Feed/Events/EventFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Events/EventFeed.cs index 56ceb088..f132c4f2 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/Events/EventFeed.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/Events/EventFeed.cs @@ -26,7 +26,7 @@ namespace CampusAppWP8.Feed.Events /// /// automatic loading of the data public EventFeed(bool autoLoad = true) - : base(ModelType.FileAndFeed, Constants.FileEvents_Name, Constants.UrlEvents_Addr) + : base(ModelType.FileAndFeed, Constants.FileEvents_Name, CampusAppWPortalLib8.Resources.Constants.UrlEvents_Addr) { this.IsFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad); this.IsFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnSave); diff --git a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBMain.cs b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBMain.cs index f342c9a8..98aeca33 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBMain.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBMain.cs @@ -20,7 +20,7 @@ namespace CampusAppWP8.Feed.Mensa /// Initializes a new instance of the class. /// public MensaFeedCBMain() - : base(Constants.FileMensa_Shedule_CBMain, Constants.UrlMensa_Week_CBMain) + : base(Constants.FileMensa_Shedule_CBMain, CampusAppWPortalLib8.Resources.Constants.UrlMensa_Week_CBMain) { this.Title = AppResources.Campus_CBMain; } diff --git a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBNorth.cs b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBNorth.cs index 76626dc8..6334e3be 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBNorth.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBNorth.cs @@ -20,7 +20,7 @@ namespace CampusAppWP8.Feed.Mensa /// Initializes a new instance of the class. /// public MensaFeedCBNorth() - : base(Constants.FileMensa_Shedule_CBNorth, Constants.UrlMensa_Week_CBNorth) + : base(Constants.FileMensa_Shedule_CBNorth, CampusAppWPortalLib8.Resources.Constants.UrlMensa_Week_CBNorth) { this.Title = AppResources.Campus_CBNorth; } diff --git a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBSouth.cs b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBSouth.cs index f173c3bc..ab2f80d3 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBSouth.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBSouth.cs @@ -20,7 +20,7 @@ namespace CampusAppWP8.Feed.Mensa /// Initializes a new instance of the class. /// public MensaFeedCBSouth() - : base(Constants.FileMensa_Shedule_CBSouth, Constants.UrlMensa_Week_CBSouth) + : base(Constants.FileMensa_Shedule_CBSouth, CampusAppWPortalLib8.Resources.Constants.UrlMensa_Week_CBSouth) { this.Title = AppResources.Campus_CBSouth; } diff --git a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedSBFMain.cs b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedSBFMain.cs index 557ad5ff..39e34a80 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedSBFMain.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedSBFMain.cs @@ -20,7 +20,7 @@ namespace CampusAppWP8.Feed.Mensa /// Initializes a new instance of the class. /// public MensaFeedSBFMain() - : base(Constants.FileMensa_Shedule_SBFMain, Constants.UrlMensa_Week_SBFMain) + : base(Constants.FileMensa_Shedule_SBFMain, CampusAppWPortalLib8.Resources.Constants.UrlMensa_Week_SBFMain) { this.Title = AppResources.Campus_SFBMain; } diff --git a/CampusAppWP8/CampusAppWP8/Feed/News/NewsFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/News/NewsFeed.cs index da60040f..89a5ae4a 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/News/NewsFeed.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/News/NewsFeed.cs @@ -26,7 +26,7 @@ namespace CampusAppWP8.Feed.News /// /// automatic loading of the data public NewsFeed(bool autoLoad = true) - : base(ModelType.FileAndFeed, Constants.FileNews_Name, Constants.UrlNews_Addr) + : base(ModelType.FileAndFeed, Constants.FileNews_Name, CampusAppWPortalLib8.Resources.Constants.UrlNews_Addr) { this.IsFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad); this.IsFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnSave); diff --git a/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs b/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs index b50aaa85..71983884 100644 --- a/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs @@ -28,7 +28,7 @@ namespace CampusAppWP8.Model public XmlModel(ModelType modelType, string fileName, string url) : base(modelType, fileName, url) { - this.ValidRootName = Constants.XMLRootElementName; + this.ValidRootName = CampusAppWPortalLib8.Resources.Constants.XMLRootElementName; } /// @@ -40,7 +40,7 @@ namespace CampusAppWP8.Model public XmlModel(ModelType modelType, string sourceName) : base(modelType, sourceName) { - this.ValidRootName = Constants.XMLRootElementName; + this.ValidRootName = CampusAppWPortalLib8.Resources.Constants.XMLRootElementName; } #endregion diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs index ddfc70cb..b4a616bb 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs @@ -492,69 +492,6 @@ namespace CampusAppWP8.Resources { } } - /// - /// Sucht eine lokalisierte Zeichenfolge, die Aktion ähnelt. - /// - public static string MensaApp_Action { - get { - return ResourceManager.GetString("MensaApp_Action", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die Bio ähnelt. - /// - public static string MensaApp_Bio { - get { - return ResourceManager.GetString("MensaApp_Bio", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die Essen 1 ähnelt. - /// - public static string MensaApp_Dinner1 { - get { - return ResourceManager.GetString("MensaApp_Dinner1", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die Essen 2 ähnelt. - /// - public static string MensaApp_Dinner2 { - get { - return ResourceManager.GetString("MensaApp_Dinner2", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die Essen 3 ähnelt. - /// - public static string MensaApp_Dinner3 { - get { - return ResourceManager.GetString("MensaApp_Dinner3", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die Essen 4 ähnelt. - /// - public static string MensaApp_Dinner4 { - get { - return ResourceManager.GetString("MensaApp_Dinner4", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die Essen 5 ähnelt. - /// - public static string MensaApp_Dinner5 { - get { - return ResourceManager.GetString("MensaApp_Dinner5", resourceCulture); - } - } - /// /// Sucht eine lokalisierte Zeichenfolge, die 84 ähnelt. /// @@ -564,24 +501,6 @@ namespace CampusAppWP8.Resources { } } - /// - /// Sucht eine lokalisierte Zeichenfolge, die Heute nicht im Angbot ähnelt. - /// - public static string MensaApp_NotToday { - get { - return ResourceManager.GetString("MensaApp_NotToday", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die Suppe ähnelt. - /// - public static string MensaApp_Soup { - get { - return ResourceManager.GetString("MensaApp_Soup", resourceCulture); - } - } - /// /// Sucht eine lokalisierte Zeichenfolge, die Mensaplan ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx index 44a33210..08e76485 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx @@ -206,27 +206,6 @@ Mittwoch - - Aktion - - - Bio - - - Essen 1 - - - Essen 2 - - - Essen 3 - - - Essen 4 - - - Heute nicht im Angbot - zur Übersicht @@ -353,12 +332,6 @@ Semesterauswahl - - Essen 5 - - - Suppe - Ortung diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs index 23152345..8bb7086c 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs @@ -1068,15 +1068,6 @@ namespace CampusAppWP8.Resources { } } - /// - /// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_veranstaltungen.php ähnelt. - /// - public static string UrlEvents_Addr { - get { - return ResourceManager.GetString("UrlEvents_Addr", resourceCulture); - } - } - /// /// Sucht eine lokalisierte Zeichenfolge, die https://www.zv.tu-cottbus.de/CMS-Webservice/Pruefungsordnung/Uebersicht ähnelt. /// @@ -1122,51 +1113,6 @@ namespace CampusAppWP8.Resources { } } - /// - /// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1 ähnelt. - /// - public static string UrlMensa_Week_CBMain { - get { - return ResourceManager.GetString("UrlMensa_Week_CBMain", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1 ähnelt. - /// - public static string UrlMensa_Week_CBNorth { - get { - return ResourceManager.GetString("UrlMensa_Week_CBNorth", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusHL&v=1 ähnelt. - /// - public static string UrlMensa_Week_CBSouth { - get { - return ResourceManager.GetString("UrlMensa_Week_CBSouth", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=Senftenberg&v=1 ähnelt. - /// - public static string UrlMensa_Week_SBFMain { - get { - return ResourceManager.GetString("UrlMensa_Week_SBFMain", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_aktuelles.php ähnelt. - /// - public static string UrlNews_Addr { - get { - return ResourceManager.GetString("UrlNews_Addr", resourceCulture); - } - } - /// /// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/campusapp-data/getdata.php?db=openinghours&app=2&appversion=1 ähnelt. /// @@ -1301,14 +1247,5 @@ namespace CampusAppWP8.Resources { return ResourceManager.GetString("Valid_MaxCourseNumber", resourceCulture); } } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die root ähnelt. - /// - public static string XMLRootElementName { - get { - return ResourceManager.GetString("XMLRootElementName", resourceCulture); - } - } } } diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index 9c2833fb..2e17a5d2 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -138,9 +138,6 @@ https://www.tu-cottbus.de/modul/ - - root - https://webmail.tu-cottbus.de @@ -174,9 +171,6 @@ /Pages/Lecture/LecturePage.xaml - - /Pages/Events/EventIndexPage.xaml - /Pages/Webmail/WebmailPage.xaml @@ -225,9 +219,6 @@ pivotindex - - /Pages/Events/EventPage.xaml - /Pages/Links/LinkPage.xaml @@ -264,12 +255,6 @@ NewsFeed.xml - - http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_veranstaltungen.php - - - http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_aktuelles.php - IsolatedStorage_DepartmentModel @@ -378,18 +363,6 @@ MensaFeed_SFBMain.xml - - http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1 - - - http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1 - - - http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusHL&v=1 - - - http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=Senftenberg&v=1 - 1 @@ -534,4 +507,10 @@ Kurzname + + /Pages/Events/EventIndexPage.xaml + + + /Pages/Events/EventPage.xaml + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.resx index 2710e40d..e71129ca 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.resx @@ -117,43 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - root - - - http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1 - - - http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1 - - - http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusHL&v=1 - - - http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=Senftenberg&v=1 - - - /Pages/Mensa/MensaPage.xaml - MensaTask - - /Pages/Events/EventIndexPage.xaml - - - http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_veranstaltungen.php - EventTask NewsTask - - /Pages/News/NewsIndexPage.xaml - - - http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_aktuelles.php - \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants1.Designer.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants1.Designer.cs index ed0806ae..e475252a 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants1.Designer.cs +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants1.Designer.cs @@ -86,95 +86,5 @@ namespace CampusAppWP8ScheduledTaskAgent.Resources { return ResourceManager.GetString("BackgroundTask_News", resourceCulture); } } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die /Pages/Events/EventIndexPage.xaml ähnelt. - /// - public static string PathEvents_EventsIndexPage { - get { - return ResourceManager.GetString("PathEvents_EventsIndexPage", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die /Pages/Mensa/MensaPage.xaml ähnelt. - /// - public static string PathMensa_MensaPage { - get { - return ResourceManager.GetString("PathMensa_MensaPage", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die /Pages/News/NewsIndexPage.xaml ähnelt. - /// - public static string PathNews_NewsIndexPage { - get { - return ResourceManager.GetString("PathNews_NewsIndexPage", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_veranstaltungen.php ähnelt. - /// - public static string UrlEvents_Addr { - get { - return ResourceManager.GetString("UrlEvents_Addr", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1 ähnelt. - /// - public static string UrlMensa_Week_CBMain { - get { - return ResourceManager.GetString("UrlMensa_Week_CBMain", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1 ähnelt. - /// - public static string UrlMensa_Week_CBNorth { - get { - return ResourceManager.GetString("UrlMensa_Week_CBNorth", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusHL&v=1 ähnelt. - /// - public static string UrlMensa_Week_CBSouth { - get { - return ResourceManager.GetString("UrlMensa_Week_CBSouth", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=Senftenberg&v=1 ähnelt. - /// - public static string UrlMensa_Week_SBFMain { - get { - return ResourceManager.GetString("UrlMensa_Week_SBFMain", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_aktuelles.php ähnelt. - /// - public static string UrlNews_Addr { - get { - return ResourceManager.GetString("UrlNews_Addr", resourceCulture); - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die root ähnelt. - /// - public static string XMLRootElementName { - get { - return ResourceManager.GetString("XMLRootElementName", resourceCulture); - } - } } } diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs index 56c2823a..4a07f21b 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs @@ -62,7 +62,7 @@ namespace CampusAppWP8ScheduledTaskAgent if (this.eventModel == null || !this.CheckRssIsUpToDate(this.eventModel.CreateTime)) { HttpRequest api = new HttpRequest(); - Uri url = new Uri(Constants.UrlEvents_Addr, UriKind.Absolute); + Uri url = new Uri(CampusAppWPortalLib8.Resources.Constants.UrlEvents_Addr, UriKind.Absolute); api.HttpGet(url, this.GetEventIsReady); } else @@ -76,7 +76,7 @@ namespace CampusAppWP8ScheduledTaskAgent if (this.newsModel == null || !this.CheckRssIsUpToDate(this.newsModel.CreateTime)) { HttpRequest api = new HttpRequest(); - Uri url = new Uri(Constants.UrlNews_Addr, UriKind.Absolute); + Uri url = new Uri(CampusAppWPortalLib8.Resources.Constants.UrlNews_Addr, UriKind.Absolute); api.HttpGet(url, this.GetNewsIsReady); } else @@ -89,7 +89,7 @@ namespace CampusAppWP8ScheduledTaskAgent { if (arg2.Result != null) { - this.eventModel = XmlManager.DeserializationToModel(arg2.Result, Constants.XMLRootElementName); + this.eventModel = XmlManager.DeserializationToModel(arg2.Result, CampusAppWPortalLib8.Resources.Constants.XMLRootElementName); this.updateEventTile(); } } @@ -98,7 +98,7 @@ namespace CampusAppWP8ScheduledTaskAgent { if (arg2.Result != null) { - this.newsModel = XmlManager.DeserializationToModel(arg2.Result, Constants.XMLRootElementName); + this.newsModel = XmlManager.DeserializationToModel(arg2.Result, CampusAppWPortalLib8.Resources.Constants.XMLRootElementName); this.updateNewsTile(); } } @@ -106,9 +106,9 @@ namespace CampusAppWP8ScheduledTaskAgent private void updateNewsTile() { - ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(Constants.PathNews_NewsIndexPage)); + ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathNews_NewsIndexPage)); - if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(Constants.PathNews_NewsIndexPage)) + if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathNews_NewsIndexPage)) { IconicTileData data = new IconicTileData(); Random random = new Random(); @@ -129,9 +129,9 @@ namespace CampusAppWP8ScheduledTaskAgent private void updateEventTile() { - ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(Constants.PathEvents_EventsIndexPage)); + ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathEvents_EventsIndexPage)); - if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(Constants.PathEvents_EventsIndexPage)) + if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathEvents_EventsIndexPage)) { IconicTileData data = new IconicTileData(); Random random = new Random(); @@ -158,19 +158,19 @@ namespace CampusAppWP8ScheduledTaskAgent switch (feedNumber) { case '1': - url = new Uri(Constants.UrlMensa_Week_CBMain, UriKind.Absolute); + url = new Uri(CampusAppWPortalLib8.Resources.Constants.UrlMensa_Week_CBMain, UriKind.Absolute); break; case '2': - url = new Uri(Constants.UrlMensa_Week_CBSouth, UriKind.Absolute); + url = new Uri(CampusAppWPortalLib8.Resources.Constants.UrlMensa_Week_CBSouth, UriKind.Absolute); break; case '3': - url = new Uri(Constants.UrlMensa_Week_SBFMain, UriKind.Absolute); + url = new Uri(CampusAppWPortalLib8.Resources.Constants.UrlMensa_Week_SBFMain, UriKind.Absolute); break; case '4': - url = new Uri(Constants.UrlMensa_Week_CBMain, UriKind.Absolute); + url = new Uri(CampusAppWPortalLib8.Resources.Constants.UrlMensa_Week_CBMain, UriKind.Absolute); break; default: - url = new Uri(Constants.UrlMensa_Week_CBMain, UriKind.Absolute); + url = new Uri(CampusAppWPortalLib8.Resources.Constants.UrlMensa_Week_CBMain, UriKind.Absolute); break; } @@ -194,7 +194,7 @@ namespace CampusAppWP8ScheduledTaskAgent { if (arg2.Result != null) { - this.mensaModel = XmlManager.DeserializationToModel(arg2.Result, Constants.XMLRootElementName); + this.mensaModel = XmlManager.DeserializationToModel(arg2.Result, CampusAppWPortalLib8.Resources.Constants.XMLRootElementName); this.updateMensaTile(); } @@ -202,9 +202,9 @@ namespace CampusAppWP8ScheduledTaskAgent private void updateMensaTile() { - ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(Constants.PathMensa_MensaPage)); + ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathMensa_MensaPage)); - if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(Constants.PathMensa_MensaPage)) + if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathMensa_MensaPage)) { IconicTileData data = new IconicTileData(); DateTime now = DateTime.Now; diff --git a/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants.resx b/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants.resx index 29dcb1b3..537a908c 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants.resx @@ -117,4 +117,34 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + /Pages/Events/EventIndexPage.xaml + + + /Pages/Mensa/MensaPage.xaml + + + /Pages/News/NewsIndexPage.xaml + + + http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_veranstaltungen.php + + + http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1 + + + http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1 + + + http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusHL&v=1 + + + http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=Senftenberg&v=1 + + + http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_aktuelles.php + + + root + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants1.Designer.cs b/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants1.Designer.cs index dd099688..f36a7113 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants1.Designer.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants1.Designer.cs @@ -60,5 +60,95 @@ namespace CampusAppWPortalLib8.Resources { resourceCulture = value; } } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die /Pages/Events/EventIndexPage.xaml ähnelt. + /// + public static string PathEvents_EventsIndexPage { + get { + return ResourceManager.GetString("PathEvents_EventsIndexPage", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die /Pages/Mensa/MensaPage.xaml ähnelt. + /// + public static string PathMensa_MensaPage { + get { + return ResourceManager.GetString("PathMensa_MensaPage", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die /Pages/News/NewsIndexPage.xaml ähnelt. + /// + public static string PathNews_NewsIndexPage { + get { + return ResourceManager.GetString("PathNews_NewsIndexPage", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_veranstaltungen.php ähnelt. + /// + public static string UrlEvents_Addr { + get { + return ResourceManager.GetString("UrlEvents_Addr", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1 ähnelt. + /// + public static string UrlMensa_Week_CBMain { + get { + return ResourceManager.GetString("UrlMensa_Week_CBMain", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1 ähnelt. + /// + public static string UrlMensa_Week_CBNorth { + get { + return ResourceManager.GetString("UrlMensa_Week_CBNorth", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusHL&v=1 ähnelt. + /// + public static string UrlMensa_Week_CBSouth { + get { + return ResourceManager.GetString("UrlMensa_Week_CBSouth", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=Senftenberg&v=1 ähnelt. + /// + public static string UrlMensa_Week_SBFMain { + get { + return ResourceManager.GetString("UrlMensa_Week_SBFMain", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_aktuelles.php ähnelt. + /// + public static string UrlNews_Addr { + get { + return ResourceManager.GetString("UrlNews_Addr", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die root ähnelt. + /// + public static string XMLRootElementName { + get { + return ResourceManager.GetString("XMLRootElementName", resourceCulture); + } + } } } From 4a76622165e887aea9aeeae63e70d6d9132ca180 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Wed, 18 Sep 2013 11:52:52 +0200 Subject: [PATCH 7/9] fix news issue --- CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs | 1 + CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs b/CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs index 22a7814a..59682d23 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs @@ -22,6 +22,7 @@ namespace CampusAppWP8.Utility try { ScheduledActionService.Add(periodicTask); + ScheduledActionService.LaunchForTest(taskName, new TimeSpan(10)); } catch (Exception e) { diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs index 4a07f21b..a8d2c0dc 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs @@ -112,7 +112,7 @@ namespace CampusAppWP8ScheduledTaskAgent { IconicTileData data = new IconicTileData(); Random random = new Random(); - int randomNumber = random.Next(0, this.eventModel.Channel[0].Item.Count); + int randomNumber = random.Next(0, this.newsModel.Channel[0].Item.Count); RSSModel item = this.newsModel.Channel[0].Item[randomNumber]; data.WideContent1 = item.Date; data.WideContent2 = StringManager.ToShortString(item.Title, 30) + "..."; From 2f5c10486042c9611b665ba92d8446d0a2f11be7 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Wed, 18 Sep 2013 14:50:32 +0200 Subject: [PATCH 8/9] add docs --- .gitattributes | 1 + CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 4 +- .../CampusAppWP8/File/Places/PlacesFile.cs | 2 +- .../CampusAppWP8/Model/Exams/ExamModel.cs | 2 +- .../CampusAppWP8/Model/GeoDb/PlaceModel.cs | 2 +- .../Model/Lecture/LectureActivity.cs | 10 +- .../Model/Person/PersonFunctionModel.cs | 14 +- .../CampusAppWP8/Model/Person/PersonModel.cs | 6 +- .../Utility/CourseListPickerItemListModel.cs | 3 +- CampusAppWP8/CampusAppWP8/Model/XmlModel.cs | 5 +- .../Pages/Campusmap/CampusMapPage.xaml.cs | 4 +- .../Pages/Setting/UserProfil.xaml.cs | 2 +- CampusAppWP8/CampusAppWP8/Settings.StyleCop | 51 +++-- .../CampusAppWP8/Utility/BackgroundTasks.cs | 58 ++++- CampusAppWP8/CampusAppWP8/Utility/File.cs | 1 + CampusAppWP8/CampusAppWP8/Utility/Logger.cs | 39 ---- .../Utility/Lui/Tiles/TileCreator.cs | 103 +++++++-- .../CampusAppWP8/Utility/Utilities.cs | 1 + .../CampusAppWP8/Utility/Wp8StringManager.cs | 29 +++ .../CampusAppWP8/Utility/XmlManager.cs | 91 -------- .../ScheduledAgent.cs | 214 +++++++++++++----- .../Utility/BackgroundTasks.cs | 21 +- .../Utility/HttpRequest.cs | 6 +- .../CampusAppWPortalLib8.csproj | 2 +- .../Model/Mensa/MealModel.cs | 18 +- .../Model/Mensa/MenuWeekModel.cs | 1 - .../Resources/Constants.resx | 6 + .../Resources/Constants1.Designer.cs | 18 ++ .../Utility/AbstractBackgroundTasks.cs | 18 +- .../Utility/AbstractHttpRequest.cs | 7 +- .../Utility/DefaultStringManager.cs} | 33 ++- .../CampusAppWPortalLib8/Utility/Logger.cs | 4 +- .../Utility/StringManager.cs | 69 ------ 33 files changed, 466 insertions(+), 379 deletions(-) delete mode 100644 CampusAppWP8/CampusAppWP8/Utility/Logger.cs create mode 100644 CampusAppWP8/CampusAppWP8/Utility/Wp8StringManager.cs delete mode 100644 CampusAppWP8/CampusAppWP8/Utility/XmlManager.cs rename CampusAppWP8/{CampusAppWP8/Utility/StringManager.cs => CampusAppWPortalLib8/Utility/DefaultStringManager.cs} (75%) delete mode 100644 CampusAppWP8/CampusAppWPortalLib8/Utility/StringManager.cs diff --git a/.gitattributes b/.gitattributes index ad3aeb41..83a97a87 100644 --- a/.gitattributes +++ b/.gitattributes @@ -25,6 +25,7 @@ *.csproj -text merge=union *.sln -text merge=union *.resx -text merge=union +*.StyleCop -text merge=union #*.vbproj merge=binary #*.vcxproj merge=binary #*.vcproj merge=binary diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index d218c078..5494815e 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -269,7 +269,6 @@ - @@ -281,11 +280,10 @@ QRScanner.xaml - + Code - diff --git a/CampusAppWP8/CampusAppWP8/File/Places/PlacesFile.cs b/CampusAppWP8/CampusAppWP8/File/Places/PlacesFile.cs index df16df60..382547bb 100644 --- a/CampusAppWP8/CampusAppWP8/File/Places/PlacesFile.cs +++ b/CampusAppWP8/CampusAppWP8/File/Places/PlacesFile.cs @@ -11,7 +11,7 @@ namespace CampusAppWP8.File.Places using CampusAppWP8.Model; using CampusAppWP8.Model.GeoDb; using CampusAppWP8.Resources; - using CampusAppWP8.Utility; + using CampusAppWPortalLib8.Utility; /// Places file. /// Stubbfel, 09.09.2013. diff --git a/CampusAppWP8/CampusAppWP8/Model/Exams/ExamModel.cs b/CampusAppWP8/CampusAppWP8/Model/Exams/ExamModel.cs index 58c58ce6..e668fe35 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Exams/ExamModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Exams/ExamModel.cs @@ -62,7 +62,7 @@ namespace CampusAppWP8.Model.Exams { get { - return StringManager.StripHTML(this.CourseText + " (" + this.Type + "/" + this.Version + ")"); + return Wp8StringManager.StripAndDecodeHTML(this.CourseText + " (" + this.Type + "/" + this.Version + ")"); } } diff --git a/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs b/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs index 758b2ef1..799b0757 100644 --- a/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs @@ -16,7 +16,7 @@ namespace CampusAppWP8.Model.GeoDb using System.Text.RegularExpressions; using System.Xml.Serialization; using CampusAppWP8.Resources; - using CampusAppWP8.Utility; + using CampusAppWPortalLib8.Utility; /// /// Model for a place of the SPSService diff --git a/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureActivity.cs b/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureActivity.cs index 8d87520b..db0feb15 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureActivity.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Lecture/LectureActivity.cs @@ -199,7 +199,7 @@ namespace CampusAppWP8.Model.Lecture { if (value != this.topic) { - this.topic = StringManager.StripHTML(value); + this.topic = Wp8StringManager.StripAndDecodeHTML(value); } } } @@ -228,10 +228,10 @@ namespace CampusAppWP8.Model.Lecture string result = string.Empty; foreach (LectureLecturer tmpLecturer in this.Lecturer) { - result += StringManager.AddNewLine(tmpLecturer.ToString()); + result += Wp8StringManager.AddNewLine(tmpLecturer.ToString()); } - this.LecturerString = StringManager.RemoveNewLine(result); + this.LecturerString = Wp8StringManager.RemoveNewLine(result); } /// @@ -242,10 +242,10 @@ namespace CampusAppWP8.Model.Lecture string result = string.Empty; foreach (LectureCourse course in this.Course) { - result += StringManager.AddNewLine(course.Title); + result += Wp8StringManager.AddNewLine(course.Title); } - this.CourseString = StringManager.RemoveNewLine(result); + this.CourseString = Wp8StringManager.RemoveNewLine(result); } #endregion diff --git a/CampusAppWP8/CampusAppWP8/Model/Person/PersonFunctionModel.cs b/CampusAppWP8/CampusAppWP8/Model/Person/PersonFunctionModel.cs index 5b68531c..0a0ddc9f 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Person/PersonFunctionModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Person/PersonFunctionModel.cs @@ -55,7 +55,7 @@ namespace CampusAppWP8.Model.Person { if (value != null && value != string.Empty && value != this.tel1) { - this.tel1 = StringManager.CreateUniTelefonNumber(value); + this.tel1 = Wp8StringManager.CreateUniTelefonNumber(value); } } } @@ -74,7 +74,7 @@ namespace CampusAppWP8.Model.Person { if (value != null && value != string.Empty && value != this.tel2) { - this.tel2 = StringManager.CreateUniTelefonNumber(value); + this.tel2 = Wp8StringManager.CreateUniTelefonNumber(value); } } } @@ -93,7 +93,7 @@ namespace CampusAppWP8.Model.Person { if (value != null && value != string.Empty && value != this.fax) { - this.fax = StringManager.CreateUniTelefonNumber(value); + this.fax = Wp8StringManager.CreateUniTelefonNumber(value); } } } @@ -112,7 +112,7 @@ namespace CampusAppWP8.Model.Person { if (value != this.function) { - this.function = StringManager.StripHTML(value); + this.function = Wp8StringManager.StripAndDecodeHTML(value); } } } @@ -131,7 +131,7 @@ namespace CampusAppWP8.Model.Person { if (value != this.appointment) { - this.appointment = StringManager.StripHTML(value); + this.appointment = Wp8StringManager.StripAndDecodeHTML(value); } } } @@ -150,7 +150,7 @@ namespace CampusAppWP8.Model.Person { if (value != this.building) { - this.building = StringManager.StripHTML(value); + this.building = Wp8StringManager.StripAndDecodeHTML(value); } } } @@ -167,7 +167,7 @@ namespace CampusAppWP8.Model.Person set { - if (value != null && value != this.mail && StringManager.IsValidEmail(value)) + if (value != null && value != this.mail && Wp8StringManager.IsValidEmail(value)) { this.mail = value; } diff --git a/CampusAppWP8/CampusAppWP8/Model/Person/PersonModel.cs b/CampusAppWP8/CampusAppWP8/Model/Person/PersonModel.cs index af48f050..d4acbbcd 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Person/PersonModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Person/PersonModel.cs @@ -70,7 +70,7 @@ namespace CampusAppWP8.Model.Person { if (value != this.akadgrad) { - this.akadgrad = StringManager.StripHTML(value); + this.akadgrad = Wp8StringManager.StripAndDecodeHTML(value); } } } @@ -89,7 +89,7 @@ namespace CampusAppWP8.Model.Person { if (value != this.surName) { - this.surName = StringManager.StripHTML(value); + this.surName = Wp8StringManager.StripAndDecodeHTML(value); } } } @@ -108,7 +108,7 @@ namespace CampusAppWP8.Model.Person { if (value != this.firstName) { - this.firstName = StringManager.StripHTML(value); + this.firstName = Wp8StringManager.StripAndDecodeHTML(value); } } } diff --git a/CampusAppWP8/CampusAppWP8/Model/Utility/CourseListPickerItemListModel.cs b/CampusAppWP8/CampusAppWP8/Model/Utility/CourseListPickerItemListModel.cs index 1015879a..fb606444 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Utility/CourseListPickerItemListModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Utility/CourseListPickerItemListModel.cs @@ -8,7 +8,6 @@ namespace CampusAppWP8.Model.Utility { using System.Collections.Generic; using System.Linq; - using CampusAppWP8.Feed.Exams; using CampusAppWP8.Feed.Utility; using CampusAppWP8.Utility; @@ -147,7 +146,7 @@ namespace CampusAppWP8.Model.Utility { foreach (CourseModel course in courseList) { - this.AddItem(new ListPickerItemModel(course.CourseNumber, StringManager.StripHTML(course.CourseText))); + this.AddItem(new ListPickerItemModel(course.CourseNumber, Wp8StringManager.StripAndDecodeHTML(course.CourseText))); } this.List = this.List.OrderBy(o => o.Text).ToList(); diff --git a/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs b/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs index 71983884..27d6108a 100644 --- a/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/XmlModel.cs @@ -6,10 +6,9 @@ // 05.07.2013 //----------------------------------------------------------------------------- namespace CampusAppWP8.Model -{ +{ using System.Text; - using CampusAppWP8.Resources; - using CampusAppWP8.Utility; + using CampusAppWPortalLib8.Utility; /// /// Xml model io handler class. diff --git a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs index 6062f5e8..2b0dc3e4 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs @@ -273,10 +273,10 @@ namespace CampusAppWP8.Pages.Campusmap { msgText += AppResources.PlaceLabel_Name + ": "; msgText += place.GetInformationsValue(Constants.PisInformationName_Name); - msgText = StringManager.AddNewLine(msgText); + msgText = Wp8StringManager.AddNewLine(msgText); msgText += AppResources.PlaceLabel_ShortDesc + ": "; msgText += place.GetInformationsValue(Constants.PisInformationName_ShortDesc); - msgText = StringManager.AddNewLine(msgText); + msgText = Wp8StringManager.AddNewLine(msgText); } MessageBoxes.ShowMainModelInfoMessageBox(msgText); diff --git a/CampusAppWP8/CampusAppWP8/Pages/Setting/UserProfil.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Setting/UserProfil.xaml.cs index 2a5f9a81..a868f4c1 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Setting/UserProfil.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Setting/UserProfil.xaml.cs @@ -12,7 +12,7 @@ namespace CampusAppWP8.Pages.Setting using System.Windows.Navigation; using CampusAppWP8.Model.Setting; using CampusAppWP8.Model.Utility; - using CampusAppWP8.Utility; + using CampusAppWPortalLib8.Utility; using Microsoft.Phone.Controls; /// diff --git a/CampusAppWP8/CampusAppWP8/Settings.StyleCop b/CampusAppWP8/CampusAppWP8/Settings.StyleCop index cf756198..a049e944 100644 --- a/CampusAppWP8/CampusAppWP8/Settings.StyleCop +++ b/CampusAppWP8/CampusAppWP8/Settings.StyleCop @@ -1,26 +1,27 @@ - - - - akadgrad - api - apis - enum - initialise - initialises - ndef - ndefs - nfc - param - pid - pids - pis - prev - pss - Senftenberg - sps - Stubbfel - uni - wifi - - + + + + akadgrad + api + apis + enum + initialise + initialises + ndef + ndefs + nfc + param + perodic + pid + pids + pis + prev + pss + Senftenberg + sps + Stubbfel + uni + wifi + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs b/CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs index 59682d23..76acf9d1 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs @@ -1,28 +1,43 @@ -using CampusAppWP8ScheduledTaskAgent.Resources; -using CampusAppWPortalLib8.Utility; -using Microsoft.Phone.Scheduler; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 18.09.2013 +//---------------------------------------------------------------------- namespace CampusAppWP8.Utility { + using System; + using CampusAppWP8ScheduledTaskAgent.Resources; + using CampusAppWPortalLib8.Utility; + using Microsoft.Phone.Scheduler; + + /// + /// Class provide some static methods for background tasks + /// public class BackgroundTasks : AbstractBackgroundTasks { - public static void StartPerodicTask(string taskName, string taskDesc) { + /// + /// Method start a certain PerodicTask + /// + /// name of the task + /// description of the task + public static void StartPerodicTask(string taskName, string taskDesc) + { BackgroundTasks.StopPerodicTask(BackgroundTasks.LastAddedTaskName); BackgroundTasks.StopPerodicTask(taskName); PeriodicTask periodicTask = new PeriodicTask(taskName); + // load description from localized strings periodicTask.Description = taskDesc; try { ScheduledActionService.Add(periodicTask); - ScheduledActionService.LaunchForTest(taskName, new TimeSpan(10)); + + // ScheduledActionService.LaunchForTest(taskName, new TimeSpan(10)); } catch (Exception e) { @@ -33,6 +48,10 @@ namespace CampusAppWP8.Utility BackgroundTasks.LastAddedTaskName = taskName; } + /// + /// Method stop a certain PerodicTask + /// + /// name of the task public static void StopPerodicTask(string taskName) { if (taskName == null) @@ -54,33 +73,50 @@ namespace CampusAppWP8.Utility } } + /// + /// Method start MensaBackgroundTask + /// public static void StartMensaTask() { int campusId = (int)Settings.UserProfil.DefaultCampus; BackgroundTasks.StartPerodicTask(Constants.BackgroundTask_Mensa, AppResources.BackGroundTaskDesc_Mensa + " - Feed " + campusId); } + /// + /// Method stop MensaBackgroundTask + /// public static void StopMensaTask() { BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_Mensa); } + /// + /// Method start EventBackgroundTask + /// public static void StartEventTask() { BackgroundTasks.StartPerodicTask(Constants.BackgroundTask_Event, AppResources.BackGroundTaskDesc_Event); } + /// + /// Method stop EventBackgroundTask + /// public static void StopEventTask() { BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_Event); } - + /// + /// Method start NewsBackgroundTask + /// public static void StartNewsTask() { BackgroundTasks.StartPerodicTask(Constants.BackgroundTask_News, AppResources.BackGroundTaskDesc_News); } + /// + /// Method stop NewsBackgroundTask + /// public static void StopNewsTask() { BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_News); diff --git a/CampusAppWP8/CampusAppWP8/Utility/File.cs b/CampusAppWP8/CampusAppWP8/Utility/File.cs index 7905b1d9..d49ee632 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/File.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/File.cs @@ -11,6 +11,7 @@ namespace CampusAppWP8.Utility using System.IO; using System.Threading; using System.Threading.Tasks; + using CampusAppWPortalLib8.Utility; using Windows.Storage; /// diff --git a/CampusAppWP8/CampusAppWP8/Utility/Logger.cs b/CampusAppWP8/CampusAppWP8/Utility/Logger.cs deleted file mode 100644 index 4416a3b4..00000000 --- a/CampusAppWP8/CampusAppWP8/Utility/Logger.cs +++ /dev/null @@ -1,39 +0,0 @@ -//-------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 03.05.2013 -//---------------------------------------------------------------------- -namespace CampusAppWP8.Utility -{ - using System; - - /// - /// This Class creates logs for the app - /// - public class Logger - { - #region Method - - /// - /// Method log a Exception - /// - /// exception which has to log - public static void LogException(Exception exception) - { - Console.WriteLine(exception); - } - - /// - /// Log a message. - /// - /// to be logged message - public static void LogMsg(string msg) - { - Console.WriteLine(msg); - } - - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Tiles/TileCreator.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Tiles/TileCreator.cs index 52406b28..f393a002 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Tiles/TileCreator.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Tiles/TileCreator.cs @@ -1,104 +1,163 @@ -using CampusAppWP8.Resources; -using Microsoft.Phone.Scheduler; -using Microsoft.Phone.Shell; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 18.09.2013 +//---------------------------------------------------------------------- namespace CampusAppWP8.Utility.Lui.Tiles { + using System; + using System.Linq; + using CampusAppWP8.Resources; + using Microsoft.Phone.Shell; + + /// + /// Class creates different live tiles + /// public class TileCreator { - public static void CreateIconicTile(string title, string path, string iconUrl, string smallIcon, string wContent1 = null, string wContent2 = null, string wContent3 = null) + /// + /// Method creates an IconicTile + /// + /// title of the tile + /// path the the page + /// icon url of the main icon + /// icon url of the small icon + /// string for the wide content 1 + /// string for the wide content 2 + /// string for the wide content 3 + public static void CreateIconicTile(string title, string path, string iconUrl, string smallIcon, string wideContent1 = null, string wideContent2 = null, string wideContent3 = null) { + IconicTileData iconTile = new IconicTileData(); + iconTile.Title = title; + iconTile.WideContent1 = wideContent1; + iconTile.WideContent2 = wideContent2; + iconTile.WideContent3 = wideContent3; - IconicTileData oIcontile = new IconicTileData(); - oIcontile.Title = title; - oIcontile.WideContent1 = wContent1; - oIcontile.WideContent2 = wContent2; - oIcontile.WideContent3 = wContent3; - - oIcontile.IconImage = new Uri(iconUrl, UriKind.Relative); - oIcontile.SmallIconImage = new Uri(smallIcon, UriKind.Relative); + iconTile.IconImage = new Uri(iconUrl, UriKind.Relative); + iconTile.SmallIconImage = new Uri(smallIcon, UriKind.Relative); // find the tile object for the application tile that using "Iconic" contains string in it. - ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(path)); + ShellTile tileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(path)); - if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(path)) + if (tileToFind != null && tileToFind.NavigationUri.ToString().Contains(path)) { - TileToFind.Delete(); + tileToFind.Delete(); } - ShellTile.Create(new Uri(path, UriKind.Relative), oIcontile, true); + ShellTile.Create(new Uri(path, UriKind.Relative), iconTile, true); } + /// + /// Method creates the MensaTile + /// public static void CreateMensaTile() { TileCreator.CreateIconicTile(AppResources.MensaApp_Title, Constants.PathMensa_MensaPage, Icons.Mensa, Icons.Mensa); - + // create a new task BackgroundTasks.StartMensaTask(); } + /// + /// Method creates the MailTile + /// public static void CreateWebMailTile() { TileCreator.CreateIconicTile(AppResources.MailApp_Title, Constants.PathMail_WebMailPage, Icons.WebMail, Icons.WebMail); } + /// + /// Method creates the NewsTile + /// public static void CreateNewsTile() { TileCreator.CreateIconicTile(AppResources.NewsApp_Title, Constants.PathNews_NewsIndexPage, Icons.News, Icons.News); + + // create a new Task BackgroundTasks.StartNewsTask(); } + /// + /// Method creates the LectureTile + /// public static void CreateLectureTile() { TileCreator.CreateIconicTile(AppResources.LectureApp_Title, Constants.PathLecture_LecturePage, Icons.Lectures, Icons.Lectures); } + /// + /// Method creates the EventTile + /// public static void CreateEventTile() { TileCreator.CreateIconicTile(AppResources.EventApp_Title, Constants.PathEvents_EventsIndexPage, Icons.News, Icons.News); + + // create a new taskk BackgroundTasks.StartEventTask(); } + /// + /// Method creates the DepartmentTile + /// public static void CreateDepartmentTile() { TileCreator.CreateIconicTile(AppResources.DepartmentApp_Title, Constants.PathDepartment_DepartmentIndexPage, Icons.Departments, Icons.Departments); } + /// + /// Method creates the OpeningHoursTile + /// public static void CreateOpeningHoursTile() { TileCreator.CreateIconicTile(AppResources.OpenHoursApp_Title, Constants.PathOpeninghours_OpeninghoursPage, Icons.Openhours, Icons.Openhours); } + /// + /// Method creates the linkTile + /// public static void CreateLinkTile() { TileCreator.CreateIconicTile(AppResources.LinkApp_Title, Constants.PathLinks_LinkPage, Icons.Link, Icons.Link); } + /// + /// Method creates the StudentCouncilTile + /// public static void CreateStudentCouncilTile() { TileCreator.CreateIconicTile(AppResources.OSAApp_Title, Constants.PathStudentCouncil_StudentCouncilPage, Icons.StudentCouncil, Icons.StudentCouncil); } + /// + /// Method creates the ExamsTile + /// public static void CreateExamsTile() { TileCreator.CreateIconicTile(AppResources.ExaminationApp_Header, Constants.PathExams_ExamsPage, Icons.Exams, Icons.Exams); } + /// + /// Method creates the PersonTile + /// public static void CreatePersonTile() { TileCreator.CreateIconicTile(AppResources.PersonApp_Title, Constants.PathPerson_Person, Icons.Person, Icons.Person); } + /// + /// Method creates the PlaceNewsTile + /// public static void CreatePlaceNewsTile() { TileCreator.CreateIconicTile(AppResources.PlaceNewsApp_Title, Constants.PathPlaceNews_PlaceNewsPage, Icons.News, Icons.News); } + /// + /// Method creates the CampusMapTile + /// public static void CreateCampusMapTile() { TileCreator.CreateIconicTile(AppResources.CampusMapApp_Title, Constants.PathCampusmap_Campusmap, Icons.Campus, Icons.Campus); diff --git a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs index cbc4c010..d62a2786 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs @@ -17,6 +17,7 @@ namespace CampusAppWP8.Utility using System.Windows.Media; using CampusAppWP8.Resources; using Microsoft.Phone.Net.NetworkInformation; + using CampusAppWPortalLib8.Utility; /// /// Collection of utility functions. diff --git a/CampusAppWP8/CampusAppWP8/Utility/Wp8StringManager.cs b/CampusAppWP8/CampusAppWP8/Utility/Wp8StringManager.cs new file mode 100644 index 00000000..f8c57b83 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/Wp8StringManager.cs @@ -0,0 +1,29 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 06.06.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Utility +{ + using System; + using System.Text.RegularExpressions; + using CampusAppWP8.Resources; + + /// + /// Class provides some special StringMethods + /// + public class Wp8StringManager : CampusAppWPortalLib8.Utility.DefaultStringManager + { + /// + /// Method removes Html-Tag of a String + /// + /// String with Html-Tags + /// String without Html-Tags + public static string StripAndDecodeHTML(string inputString) + { + return System.Net.HttpUtility.HtmlDecode(Wp8StringManager.StripHTML(inputString)); + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Utility/XmlManager.cs b/CampusAppWP8/CampusAppWP8/Utility/XmlManager.cs deleted file mode 100644 index 118e8a11..00000000 --- a/CampusAppWP8/CampusAppWP8/Utility/XmlManager.cs +++ /dev/null @@ -1,91 +0,0 @@ -//----------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 18.06.2013 -//---------------------------------------------------------------------- -namespace CampusAppWP8.Utility -{ - using System.IO; - using System.Xml.Linq; - using System.Xml.Serialization; - - /// - /// Class provides some Xml-methods - /// - public class XmlManager - { - #region Method - - /// - /// Method deserialization a string to a Model - /// - /// the model - /// the XmlString - /// name of the RootTag - /// return the deserialization of the model - public static T DeserializationToModel(string xmlString, string validRootName) - { - XmlSerializer serializer = new XmlSerializer(typeof(T)); - XDocument document = XDocument.Parse(xmlString); - if (!document.Root.Name.ToString().Equals(validRootName)) - { - XElement content = document.Root; - document = new XDocument(); - document.Add(new XElement(validRootName, content)); - } - - T model = (T)serializer.Deserialize(document.CreateReader()); - return model; - } - - /// Deserialization a xml file to a model. - /// Stubbfel, 20.08.2013. - /// Generic type parameter. - /// Path to the a XmlFile. - /// model of the XmlFile. - public static T DeserializationFileToModel(string xmlFilePath) - { - XmlSerializer serializer = new XmlSerializer(typeof(T)); - XDocument document = XDocument.Load(xmlFilePath); - T model = (T)serializer.Deserialize(document.CreateReader()); - return model; - } - - /// Method serializes a model to a string. - /// Stubbfel, 12.09.2013. - /// type of the model. - /// model object. - /// serialized string. - public static string SerializationToString(T model) - { - string retValue = string.Empty; - - XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); - ns.Add(string.Empty, string.Empty); - - XmlSerializer serializer = new XmlSerializer(typeof(T)); - TextWriter writer = new StringWriter(); - - serializer.Serialize(writer, model, ns); - - retValue = writer.ToString(); - - if (retValue.StartsWith(""); - retValue = retValue.Substring(endTag + 2); - - if (retValue.StartsWith("\r\n") == true) - { - retValue = retValue.Substring(2); - } - } - - return retValue; - } - - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs index a8d2c0dc..597e72cb 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs @@ -1,27 +1,55 @@ -using CampusAppWP8ScheduledTaskAgent.Resources; -using CampusAppWP8ScheduledTaskAgent.Utility; -using CampusAppWPortalLib8.Model.Mensa; -using CampusAppWPortalLib8.Model.RSS; -using CampusAppWPortalLib8.Utility; -using Microsoft.Phone.Scheduler; -using Microsoft.Phone.Shell; -using System; -using System.Diagnostics; -using System.Globalization; -using System.Linq; -using System.Windows; +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 18.09.2013 +//---------------------------------------------------------------------- namespace CampusAppWP8ScheduledTaskAgent { + using System; + using System.Diagnostics; + using System.Globalization; + using System.Linq; + using System.Windows; + using CampusAppWP8ScheduledTaskAgent.Resources; + using CampusAppWP8ScheduledTaskAgent.Utility; + using CampusAppWPortalLib8.Model.Mensa; + using CampusAppWPortalLib8.Model.RSS; + using CampusAppWPortalLib8.Utility; + using Microsoft.Phone.Scheduler; + using Microsoft.Phone.Shell; + + /// + /// Class for agent of the BackgroundTask + /// public class ScheduledAgent : ScheduledTaskAgent { + #region Member + /// + /// Model for the mensa feed + /// private MenuWeekModel mensaModel; + /// + /// Model for the event feed + /// private RSSViewModel eventModel; + /// + /// Model for the news feed + /// private RSSViewModel newsModel; + #endregion + + #region Constructor + + /// + /// Initializes static members of the class. + /// static ScheduledAgent() { Deployment.Current.Dispatcher.BeginInvoke(delegate @@ -30,14 +58,16 @@ namespace CampusAppWP8ScheduledTaskAgent }); } - private static void UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) - { - if (Debugger.IsAttached) - { - Debugger.Break(); - } - } + #endregion + #region Method + + #region protected + + /// + /// override OnInvoke + /// + /// the background Task protected override void OnInvoke(ScheduledTask task) { switch (task.Name) @@ -53,10 +83,30 @@ namespace CampusAppWP8ScheduledTaskAgent case "NewsTask": this.HandleNewsTask(task); break; - } } + #endregion + + #region private + + /// + /// Method handle UnhandledException + /// + /// sender of Exception + /// Exception Args + private static void UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) + { + if (Debugger.IsAttached) + { + Debugger.Break(); + } + } + + /// + /// Method handle the EventBackgroundTask + /// + /// the eventTask private void HandleEventTask(ScheduledTask task) { if (this.eventModel == null || !this.CheckRssIsUpToDate(this.eventModel.CreateTime)) @@ -67,10 +117,14 @@ namespace CampusAppWP8ScheduledTaskAgent } else { - this.updateEventTile(); + this.UpdateEventTile(); } } + /// + /// Method handle the NewsBackgroundTask + /// + /// the newsTask private void HandleNewsTask(ScheduledTask task) { if (this.newsModel == null || !this.CheckRssIsUpToDate(this.newsModel.CreateTime)) @@ -81,75 +135,97 @@ namespace CampusAppWP8ScheduledTaskAgent } else { - this.updateNewsTile(); + this.UpdateNewsTile(); } } - private void GetEventIsReady(object arg1, System.Net.DownloadStringCompletedEventArgs arg2) + /// + /// ResponseHandler for the EventFeed + /// + /// sender of the Event + /// Event Args + private void GetEventIsReady(object sender, System.Net.DownloadStringCompletedEventArgs arg) { - if (arg2.Result != null) + if (arg.Result != null) { - this.eventModel = XmlManager.DeserializationToModel(arg2.Result, CampusAppWPortalLib8.Resources.Constants.XMLRootElementName); - this.updateEventTile(); + this.eventModel = XmlManager.DeserializationToModel(arg.Result, CampusAppWPortalLib8.Resources.Constants.XMLRootElementName); + this.UpdateEventTile(); } } - private void GetNewsIsReady(object arg1, System.Net.DownloadStringCompletedEventArgs arg2) + /// + /// ResponseHandler for the NewsFeed + /// + /// sender of the Event + /// Event Args + private void GetNewsIsReady(object sender, System.Net.DownloadStringCompletedEventArgs arg) { - if (arg2.Result != null) + if (arg.Result != null) { - this.newsModel = XmlManager.DeserializationToModel(arg2.Result, CampusAppWPortalLib8.Resources.Constants.XMLRootElementName); - this.updateNewsTile(); + this.newsModel = XmlManager.DeserializationToModel(arg.Result, CampusAppWPortalLib8.Resources.Constants.XMLRootElementName); + this.UpdateNewsTile(); } } - - private void updateNewsTile() + /// + /// Method update the NewsTile + /// + private void UpdateNewsTile() { - ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathNews_NewsIndexPage)); + ShellTile tileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathNews_NewsIndexPage)); - if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathNews_NewsIndexPage)) + if (tileToFind != null && tileToFind.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathNews_NewsIndexPage)) { IconicTileData data = new IconicTileData(); Random random = new Random(); int randomNumber = random.Next(0, this.newsModel.Channel[0].Item.Count); RSSModel item = this.newsModel.Channel[0].Item[randomNumber]; data.WideContent1 = item.Date; - data.WideContent2 = StringManager.ToShortString(item.Title, 30) + "..."; - data.WideContent3 = StringManager.ToShortString(item.Text, 30) + "..."; + data.WideContent2 = DefaultStringManager.ToShortString(item.Title, 40, "..."); + data.WideContent3 = DefaultStringManager.ToShortString(item.Text, 40, "..."); data.Count = this.newsModel.Channel[0].Item.Count; - TileToFind.Update(data); + tileToFind.Update(data); } else { BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_News); } + this.NotifyComplete(); } - private void updateEventTile() + /// + /// Method update the EventTile + /// + private void UpdateEventTile() { - ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathEvents_EventsIndexPage)); + ShellTile tileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathEvents_EventsIndexPage)); - if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathEvents_EventsIndexPage)) + if (tileToFind != null && tileToFind.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathEvents_EventsIndexPage)) { IconicTileData data = new IconicTileData(); Random random = new Random(); int randomNumber = random.Next(0, this.eventModel.Channel[0].Item.Count); RSSModel item = this.eventModel.Channel[0].Item[randomNumber]; data.WideContent1 = item.Date; - data.WideContent2 = StringManager.ToShortString(item.Title, 30) + "..."; - data.WideContent3 = StringManager.ToShortString(item.Text, 30) + "..."; + data.WideContent2 = DefaultStringManager.ToShortString(item.Title, 40, "..."); + data.WideContent3 = DefaultStringManager.ToShortString(item.Text, 40, "..."); data.Count = this.eventModel.Channel[0].Item.Count; - TileToFind.Update(data); + tileToFind.Update(data); } else { BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_Event); } + this.NotifyComplete(); } + /// + /// Determine the correct MensaFeed/Url + /// + /// the Description of the MensaTask + /// Url of a mensa, which is set is in the UserProfile private Uri CalcMensaUrl(string mensaTaskDesc) { Uri url; @@ -176,6 +252,11 @@ namespace CampusAppWP8ScheduledTaskAgent return url; } + + /// + /// Method handle the MensaBackgroundTask + /// + /// the newsTask private void HandleMensaTask(ScheduledTask task) { if (this.mensaModel == null || !this.CheckMensaIsUpToDate(this.mensaModel.CreateTime)) @@ -186,25 +267,32 @@ namespace CampusAppWP8ScheduledTaskAgent } else { - this.updateMensaTile(); + this.UpdateMensaTile(); } } - private void GetMensaIsReady(object arg1, System.Net.DownloadStringCompletedEventArgs arg2) + /// + /// ResponseHandler for the MensaFeed + /// + /// sender of the Event + /// Event Args + private void GetMensaIsReady(object sender, System.Net.DownloadStringCompletedEventArgs arg) { - if (arg2.Result != null) + if (arg.Result != null) { - this.mensaModel = XmlManager.DeserializationToModel(arg2.Result, CampusAppWPortalLib8.Resources.Constants.XMLRootElementName); - this.updateMensaTile(); + this.mensaModel = XmlManager.DeserializationToModel(arg.Result, CampusAppWPortalLib8.Resources.Constants.XMLRootElementName); + this.UpdateMensaTile(); } - } - private void updateMensaTile() + /// + /// Method update the NewsTile + /// + private void UpdateMensaTile() { - ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathMensa_MensaPage)); + ShellTile tileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathMensa_MensaPage)); - if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathMensa_MensaPage)) + if (tileToFind != null && tileToFind.NavigationUri.ToString().Contains(CampusAppWPortalLib8.Resources.Constants.PathMensa_MensaPage)) { IconicTileData data = new IconicTileData(); DateTime now = DateTime.Now; @@ -228,20 +316,27 @@ namespace CampusAppWP8ScheduledTaskAgent { Random random = new Random(); int randomNumber = random.Next(0, mealCount); - data.WideContent3 = this.mensaModel.Menus[dayIndex].Meals[randomNumber].MealToShortString(); + MealModel meal = this.mensaModel.Menus[dayIndex].Meals[randomNumber]; + data.WideContent3 = meal.MealName + ": " + DefaultStringManager.ToShortString(meal.MealDesc, 30, "..."); data.Count = this.mensaModel.Menus[dayIndex].Meals.Count; } } - TileToFind.Update(data); + + tileToFind.Update(data); } else { BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_Mensa); } + this.NotifyComplete(); } - + /// + /// Check if the model of the mensa is up-to-date + /// + /// Date of the last modification + /// true, if it is up-to-date, otherwise false private bool CheckMensaIsUpToDate(DateTime lastModified) { int diff = lastModified.CompareTo(MenuWeekModel.CalcFirstWeekDay()); @@ -254,6 +349,11 @@ namespace CampusAppWP8ScheduledTaskAgent return true; } + /// + /// Check if the model of the RSS feed is up-to-date + /// + /// Date of the last modification + /// true, if it is up-to-date, otherwise false private bool CheckRssIsUpToDate(DateTime lastModified) { int diff = lastModified.CompareTo(DateTime.Now.AddDays(1)); @@ -265,5 +365,9 @@ namespace CampusAppWP8ScheduledTaskAgent return true; } + + #endregion + + #endregion } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/BackgroundTasks.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/BackgroundTasks.cs index a585873d..26963480 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/BackgroundTasks.cs +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/BackgroundTasks.cs @@ -1,11 +1,26 @@ -using CampusAppWPortalLib8.Utility; -using Microsoft.Phone.Scheduler; -using System; +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 18.09.2013 +//---------------------------------------------------------------------- namespace CampusAppWP8ScheduledTaskAgent.Utility { + using System; + using CampusAppWPortalLib8.Utility; + using Microsoft.Phone.Scheduler; + + /// + /// Class provide some static methods for background tasks + /// public class BackgroundTasks : AbstractBackgroundTasks { + /// + /// Method stop a certain PerodicTask + /// + /// name of the task public static void StopPerodicTask(string taskName) { PeriodicTask periodicTask = ScheduledActionService.Find(taskName) as PeriodicTask; diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/HttpRequest.cs b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/HttpRequest.cs index 455fad0d..2c558936 100644 --- a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/HttpRequest.cs +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Utility/HttpRequest.cs @@ -4,12 +4,12 @@ // // stubbfel // 10.06.2013 -//----------------------------------------------------------------------using System; +//---------------------------------------------------------------------- namespace CampusAppWP8ScheduledTaskAgent.Utility -{ - using CampusAppWPortalLib8.Utility; +{ using System; using System.Net; + using CampusAppWPortalLib8.Utility; /// /// Class realize the access of restful HttpRequest diff --git a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj index 567280d1..409d1953 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj +++ b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj @@ -55,7 +55,7 @@ - + diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/MealModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/MealModel.cs index 9aeb8eb9..bb76fcf7 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/MealModel.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/MealModel.cs @@ -8,8 +8,8 @@ namespace CampusAppWPortalLib8.Model.Mensa { using System.Xml.Serialization; - using CampusAppWPortalLib8.Utility; using CampusAppWPortalLib8.Resources; + using CampusAppWPortalLib8.Utility; /// /// Model for a meal @@ -135,7 +135,7 @@ namespace CampusAppWPortalLib8.Model.Mensa { if (value != this.mealDesc) { - this.mealDesc = StringManager.StripHTML(value); + this.mealDesc = DefaultStringManager.StripHTML(value); } } } @@ -144,20 +144,6 @@ namespace CampusAppWPortalLib8.Model.Mensa #region Methods - #region public - - public string MealToShortString() - { - string shortDesc = this.mealDesc; - if (shortDesc.Length > 30) - { - shortDesc = shortDesc.Substring(0, 30) + "..."; - - } - return this.MealName + ": " + shortDesc; - } - #endregion - /// /// Method create depends of the mealId the mealName /// diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/MenuWeekModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/MenuWeekModel.cs index b26fd398..0af57379 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/MenuWeekModel.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/MenuWeekModel.cs @@ -7,7 +7,6 @@ //---------------------------------------------------------------------- namespace CampusAppWPortalLib8.Model.Mensa { - using CampusAppWPortalLib8.Utility; using System; using System.Collections.ObjectModel; using System.Xml.Serialization; diff --git a/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants.resx b/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants.resx index 537a908c..5680b6f2 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + +49 + /Pages/Events/EventIndexPage.xaml @@ -126,6 +129,9 @@ /Pages/News/NewsIndexPage.xaml + + 035569 + http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_veranstaltungen.php diff --git a/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants1.Designer.cs b/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants1.Designer.cs index f36a7113..5420fda2 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants1.Designer.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Resources/Constants1.Designer.cs @@ -61,6 +61,15 @@ namespace CampusAppWPortalLib8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die +49 ähnelt. + /// + public static string DeTelPrefix { + get { + return ResourceManager.GetString("DeTelPrefix", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die /Pages/Events/EventIndexPage.xaml ähnelt. /// @@ -88,6 +97,15 @@ namespace CampusAppWPortalLib8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die 035569 ähnelt. + /// + public static string UniCBTelPrefix { + get { + return ResourceManager.GetString("UniCBTelPrefix", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_veranstaltungen.php ähnelt. /// diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractBackgroundTasks.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractBackgroundTasks.cs index 6456db33..434104b4 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractBackgroundTasks.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractBackgroundTasks.cs @@ -1,7 +1,21 @@ -namespace CampusAppWPortalLib8.Utility +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 18.09.2013 +//---------------------------------------------------------------------- + +namespace CampusAppWPortalLib8.Utility { + /// + /// abstract class for BackGroundTask + /// public abstract class AbstractBackgroundTasks { - protected static string LastAddedTaskName {get; set;} + /// + /// Gets or sets the name of the last running task + /// + protected static string LastAddedTaskName { get; set; } } } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractHttpRequest.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractHttpRequest.cs index f931f530..e52f9b50 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractHttpRequest.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractHttpRequest.cs @@ -1,5 +1,5 @@ //----------------------------------------------------------------------- -// +// // Company copyright tag. // // stubbfel @@ -13,7 +13,7 @@ namespace CampusAppWPortalLib8.Utility using CampusAppWPortalLib8.Model.Utility; /// - /// Class realize the access of restful HttpRequest + /// abstract Class provides some methods and member for HttpRequest /// public abstract class AbstractHttpRequest { @@ -28,6 +28,9 @@ namespace CampusAppWPortalLib8.Utility #region property + /// + /// Gets or sets BaseAddress of the webClient + /// protected string BaseAddress { get diff --git a/CampusAppWP8/CampusAppWP8/Utility/StringManager.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/DefaultStringManager.cs similarity index 75% rename from CampusAppWP8/CampusAppWP8/Utility/StringManager.cs rename to CampusAppWP8/CampusAppWPortalLib8/Utility/DefaultStringManager.cs index 8a87aeae..faf0b1b3 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/StringManager.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Utility/DefaultStringManager.cs @@ -1,20 +1,20 @@ //----------------------------------------------------------------------- -// +// // Company copyright tag. // // stubbfel // 06.06.2013 //---------------------------------------------------------------------- -namespace CampusAppWP8.Utility -{ +namespace CampusAppWPortalLib8.Utility +{ using System; using System.Text.RegularExpressions; - using CampusAppWP8.Resources; + using CampusAppWPortalLib8.Resources; /// /// Class provides some special StringMethods /// - public static class StringManager + public class DefaultStringManager { #region Members @@ -37,8 +37,7 @@ namespace CampusAppWP8.Utility /// String without Html-Tags public static string StripHTML(string inputString) { - string result = Regex.Replace(inputString, HtmlTagPattern, string.Empty); - return System.Net.HttpUtility.HtmlDecode(result); + return Regex.Replace(inputString, DefaultStringManager.HtmlTagPattern, string.Empty); } /// @@ -71,7 +70,7 @@ namespace CampusAppWP8.Utility { return Regex.IsMatch( strIn, - StringManager.EMailValidRegex, + DefaultStringManager.EMailValidRegex, RegexOptions.IgnoreCase); } catch (Exception) @@ -101,6 +100,24 @@ namespace CampusAppWP8.Utility result = Constants.DeTelPrefix + result; return result; } + + /// + /// Method create from a long string a short string + /// + /// the long input String + /// max length of the short string + /// (optional) suffix which added to the short string, when long string has to be cut + /// the shorted string + public static string ToShortString(string longStr, int maxLenght, string suffix = "") + { + string shortStr = longStr; + if (shortStr.Length > maxLenght) + { + shortStr = shortStr.Substring(0, maxLenght) + suffix; + } + + return shortStr; + } #endregion } } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/Logger.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/Logger.cs index b5fe92cb..f12400bc 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Utility/Logger.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Utility/Logger.cs @@ -20,7 +20,7 @@ namespace CampusAppWPortalLib8.Utility /// exception which has to log public static void LogException(Exception exception) { - // Console.WriteLine(exception); + // Console.WriteLine(exception); } /// @@ -29,7 +29,7 @@ namespace CampusAppWPortalLib8.Utility /// to be logged message public static void LogMsg(string msg) { - // Console.WriteLine(msg); + // Console.WriteLine(msg); } } } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/StringManager.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/StringManager.cs deleted file mode 100644 index 29b2f707..00000000 --- a/CampusAppWP8/CampusAppWPortalLib8/Utility/StringManager.cs +++ /dev/null @@ -1,69 +0,0 @@ -//----------------------------------------------------------------------- -// -// Company copyright tag. -// -// stubbfel -// 06.06.2013 -//---------------------------------------------------------------------- -namespace CampusAppWPortalLib8.Utility -{ - using System.Text.RegularExpressions; - - /// - /// Class provides some special StringMethods - /// - public static class StringManager - { - #region Members - - /// - /// Patter for Html-Tags - /// - private static readonly string HtmlTagPattern = "<.*?>"; - - #endregion - - #region Methods - - /// - /// Method removes Html-Tag of a String - /// - /// String with Html-Tags - /// String without Html-Tags - public static string StripHTML(string inputString) - { - return Regex.Replace(inputString, HtmlTagPattern, string.Empty); - } - - /// - /// Method add an Newline to a string - /// - /// input string - /// input string + newline - public static string AddNewLine(string str) - { - return str.ToString() + "\n"; - } - - /// - /// Method remove(TrimEND!) an Newline to a string - /// - /// input string - /// input string - newline maxLenght) - { - shortStr = shortStr.Substring(0, maxLenght); - } - return shortStr; - } - #endregion - } -} From 870b7c1f4cdcaae146d002482101088de7cfd376 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Wed, 18 Sep 2013 14:50:59 +0200 Subject: [PATCH 9/9] add stylecops --- .../CampusAppWP8ScheduledTaskAgent/Settings.StyleCop | 7 +++++++ CampusAppWP8/CampusAppWPortalLib8/Settings.StyleCop | 11 +++++++++++ 2 files changed, 18 insertions(+) create mode 100644 CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Settings.StyleCop create mode 100644 CampusAppWP8/CampusAppWPortalLib8/Settings.StyleCop diff --git a/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Settings.StyleCop b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Settings.StyleCop new file mode 100644 index 00000000..6e72570c --- /dev/null +++ b/CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Settings.StyleCop @@ -0,0 +1,7 @@ + + + + perodic + + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWPortalLib8/Settings.StyleCop b/CampusAppWP8/CampusAppWPortalLib8/Settings.StyleCop new file mode 100644 index 00000000..7aff7afb --- /dev/null +++ b/CampusAppWP8/CampusAppWPortalLib8/Settings.StyleCop @@ -0,0 +1,11 @@ + + + + param + str + stubbfel + telefon + uni + + + \ No newline at end of file