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 @@ + + +