add shcedulagent
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -548,7 +548,12 @@
|
||||
<ItemGroup>
|
||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CampusAppWP8ScheduledTaskAgent\CampusAppWP8ScheduledTaskAgent.csproj">
|
||||
<Project>{2A51FA6C-791B-4935-B869-FDBA9ED774D7}</Project>
|
||||
<Name>CampusAppWP8ScheduledTaskAgent</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using CampusAppWP8.Resources;
|
||||
using Microsoft.Phone.Scheduler;
|
||||
using Microsoft.Phone.Shell;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -36,6 +37,48 @@ 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.
|
||||
}
|
||||
}
|
||||
|
||||
public static void CreateWebMailTile()
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.20506</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{2A51FA6C-791B-4935-B869-FDBA9ED774D7}</ProjectGuid>
|
||||
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CampusAppWP8ScheduledTaskAgent</RootNamespace>
|
||||
<AssemblyName>CampusAppWP8ScheduledTaskAgent</AssemblyName>
|
||||
<TargetFrameworkIdentifier>WindowsPhone</TargetFrameworkIdentifier>
|
||||
<TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
|
||||
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
|
||||
<SilverlightApplication>false</SilverlightApplication>
|
||||
<ValidateXaml>true</ValidateXaml>
|
||||
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
|
||||
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
|
||||
<BackgroundAgentType>AgentLibrary</BackgroundAgentType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\x86\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\x86\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|ARM' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\ARM\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|ARM' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\ARM\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Model\Mensa\MealModel.cs" />
|
||||
<Compile Include="Model\Mensa\MenuModel.cs" />
|
||||
<Compile Include="Model\Mensa\MenuWeekModel.cs" />
|
||||
<Compile Include="Model\Utility\CleanUrlParamModel.cs" />
|
||||
<Compile Include="Model\Utility\URLParamModel.cs" />
|
||||
<Compile Include="Resources\AppResources.Designer.cs">
|
||||
<DependentUpon>AppResources.resx</DependentUpon>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<Compile Include="Resources\Constants.Designer.cs">
|
||||
<DependentUpon>Constants.resx</DependentUpon>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<Compile Include="ScheduledAgent.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Utility\HttpRequest.cs" />
|
||||
<Compile Include="Utility\Logger.cs" />
|
||||
<Compile Include="Utility\StringManager.cs" />
|
||||
<Compile Include="Utility\XmlManager.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\AppResources.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>AppResources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Resources\Constants.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Constants.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets" />
|
||||
<ProjectExtensions />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,185 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="MealModel.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>06.08.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
namespace CampusAppWP8ScheduledTaskAgent.Model.Mensa
|
||||
{
|
||||
using System.Xml.Serialization;
|
||||
using CampusAppWP8ScheduledTaskAgent.Resources;
|
||||
using CampusAppWP8ScheduledTaskAgent.Utility;
|
||||
|
||||
/// <summary>
|
||||
/// Model for a meal
|
||||
/// </summary>
|
||||
public class MealModel
|
||||
{
|
||||
#region Members
|
||||
|
||||
/// <summary>
|
||||
/// Constant for the vegetarian icon
|
||||
/// </summary>
|
||||
private const string MealIconNameVegetarian = "CARROTTE";
|
||||
|
||||
/// <summary>
|
||||
/// Constant for the free icon
|
||||
/// </summary>
|
||||
private const string MealIconNameFree = "FREI";
|
||||
|
||||
/// <summary>
|
||||
/// Constant for the pig icon
|
||||
/// </summary>
|
||||
private const string MealIconNamePig = "SCHWEIN";
|
||||
|
||||
/// <summary>
|
||||
/// Constant for the cow icon
|
||||
/// </summary>
|
||||
private const string MealIconNameCow = "RIND";
|
||||
|
||||
/// <summary>
|
||||
/// Constant for the fowl icon
|
||||
/// </summary>
|
||||
private const string MealIconNameFowl = "GEFL";
|
||||
|
||||
/// <summary>
|
||||
/// Constant for the cow-pig icon
|
||||
/// </summary>
|
||||
private const string MealIconNameCowPig = "RINDSCHWEIN";
|
||||
|
||||
/// <summary>
|
||||
/// Constant for the fish icon
|
||||
/// </summary>
|
||||
private const string MealIconNameFish = "FISCH";
|
||||
|
||||
/// <summary>
|
||||
/// Constant for the wild icon
|
||||
/// </summary>
|
||||
private const string MealIconNameWild = "WILD";
|
||||
|
||||
/// <summary>
|
||||
/// Constant for the lamb icon
|
||||
/// </summary>
|
||||
private const string MealIconNameLamb = "LAMM";
|
||||
|
||||
/// <summary>
|
||||
/// Variable for the id of the meal
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// ValueRange : 0 - 7
|
||||
/// </remarks>
|
||||
private int mealId;
|
||||
|
||||
/// <summary>
|
||||
/// Name of the meal
|
||||
/// </summary>
|
||||
private string mealName;
|
||||
|
||||
/// <summary>
|
||||
/// Description of the meal
|
||||
/// </summary>
|
||||
private string mealDesc;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Proberty
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the mealId
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// ValueRange : 0 - 7
|
||||
/// </remarks>
|
||||
[XmlAttribute("id")]
|
||||
public int MealId
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.mealId;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value > -1 && value < 8)
|
||||
{
|
||||
this.mealId = value;
|
||||
this.CreateMealName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mealName
|
||||
/// </summary>
|
||||
public string MealName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.mealName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the mealDescription
|
||||
/// </summary>
|
||||
[XmlAttribute("desc")]
|
||||
public string MealDesc
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.mealDesc;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != this.mealDesc)
|
||||
{
|
||||
this.mealDesc = StringManager.StripHTML(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Method create depends of the mealId the mealName
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="MenuModel.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>04.05.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
namespace CampusAppWP8ScheduledTaskAgent.Model.Mensa
|
||||
{
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
/// <summary>
|
||||
/// Model for menu
|
||||
/// </summary>
|
||||
public class MenuModel
|
||||
{
|
||||
#region Member
|
||||
|
||||
/// <summary>
|
||||
/// Name of the day
|
||||
/// </summary>
|
||||
private string dayName;
|
||||
|
||||
/// <summary>
|
||||
/// DateTime of the day
|
||||
/// </summary>
|
||||
private string date;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MenuModel" /> class.
|
||||
/// </summary>
|
||||
public MenuModel()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the menus for the week
|
||||
/// </summary>
|
||||
[XmlElement("Meal")]
|
||||
public ObservableCollection<MealModel> Meals { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the WeekDay
|
||||
/// </summary>
|
||||
[XmlAttribute("day")]
|
||||
public string Day
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.dayName;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != this.dayName)
|
||||
{
|
||||
this.dayName = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets of Date
|
||||
/// </summary>
|
||||
[XmlAttribute("date")]
|
||||
public string Date
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.date.ToString();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != this.date)
|
||||
{
|
||||
this.date = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="MenuWeekModel.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>03.05.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
namespace CampusAppWP8ScheduledTaskAgent.Model.Mensa
|
||||
{
|
||||
using CampusAppWP8ScheduledTaskAgent.Utility;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
/// <summary>
|
||||
/// Model for menus in one week
|
||||
/// </summary>
|
||||
[XmlRoot("root")]
|
||||
public class MenuWeekModel
|
||||
{
|
||||
#region Members
|
||||
/// <summary>
|
||||
/// Time when the model was created
|
||||
/// </summary>
|
||||
private readonly DateTime createTime;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MenuWeekModel" /> class.
|
||||
/// </summary>
|
||||
public MenuWeekModel()
|
||||
{
|
||||
this.createTime = DateTime.Now;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Proberty
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the menus for the week
|
||||
/// </summary>
|
||||
[XmlArray("Mealplan")]
|
||||
[XmlArrayItem("Menu")]
|
||||
public ObservableCollection<MenuModel> Menus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the creation time of the model
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="CleanUrlParamModel.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>06.08.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
namespace CampusAppWP8ScheduledTaskAgent.Model.Utility
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is a Model for the URLParameter like GET-Parameter
|
||||
/// </summary>
|
||||
public class CleanUrlParamModel : UrlParamModel
|
||||
{
|
||||
#region Constructor
|
||||
|
||||
/// <summary>Initializes a new instance of the CleanUrlParamModel class.</summary>
|
||||
/// <remarks>Stubbfel, 12.09.2013.</remarks>
|
||||
/// <param name="key">the key for the parameter.</param>
|
||||
public CleanUrlParamModel(string key)
|
||||
: base(key)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the CleanUrlParamModel class.</summary>
|
||||
/// <remarks>Stubbfel, 12.09.2013.</remarks>
|
||||
/// <param name="key"> the key for the parameter.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
public CleanUrlParamModel(string key, string value)
|
||||
: base(key, value)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Proberty
|
||||
|
||||
/// <summary>
|
||||
/// Gets the token, which indicate that the parameterList started
|
||||
/// </summary>
|
||||
public override string ParamToken
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Method return a formatted string like Key=Value
|
||||
/// </summary>
|
||||
/// <returns> return formatted string</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
if (!this.IsParamValid())
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return "/" + this.key + "/" + this.Value;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="URLParamModel.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>17.06.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
namespace CampusAppWP8ScheduledTaskAgent.Model.Utility
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is a Model for the URLParameter like GET-Parameter
|
||||
/// </summary>
|
||||
public class UrlParamModel
|
||||
{
|
||||
#region Members
|
||||
|
||||
/// <summary>
|
||||
/// Variable of the key
|
||||
/// </summary>
|
||||
protected readonly string key;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UrlParamModel" /> class.
|
||||
/// </summary>
|
||||
/// <param name="key">the key for the parameter</param>
|
||||
public UrlParamModel(string key)
|
||||
{
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UrlParamModel" /> class.
|
||||
/// </summary>
|
||||
/// <param name="key">the key for the parameter</param>>
|
||||
/// <param name="value">value of the parameter</param>
|
||||
public UrlParamModel(string key, string value)
|
||||
{
|
||||
this.key = key;
|
||||
this.Value = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Proberty
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the Parameter
|
||||
/// </summary>
|
||||
public string Value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the key of the parameter
|
||||
/// </summary>
|
||||
public string Key
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.key;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the token, which indicate that the parameterList started
|
||||
/// </summary>
|
||||
public virtual string ParamToken
|
||||
{
|
||||
get
|
||||
{
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Method check if the parameter is valid
|
||||
/// </summary>
|
||||
/// <returns>true if is it valid, otherwise false</returns>
|
||||
public virtual bool IsParamValid()
|
||||
{
|
||||
if (this.key == null || string.Empty.Equals(this.key) || string.Empty.Equals(this.Value))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method return a formatted string like Key=Value
|
||||
/// </summary>
|
||||
/// <returns> return formatted string</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
if (!this.IsParamValid())
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return "&" + this.key + "=" + this.Value;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -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")]
|
||||
162
CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.Designer.cs
generated
Normal file
162
CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/AppResources.Designer.cs
generated
Normal file
@@ -0,0 +1,162 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace CampusAppWP8ScheduledTaskAgent.Resources {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
||||
/// </summary>
|
||||
// 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() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
|
||||
/// </summary>
|
||||
[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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
|
||||
/// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Aktion ähnelt.
|
||||
/// </summary>
|
||||
public static string MensaApp_Action {
|
||||
get {
|
||||
return ResourceManager.GetString("MensaApp_Action", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Bio ähnelt.
|
||||
/// </summary>
|
||||
public static string MensaApp_Bio {
|
||||
get {
|
||||
return ResourceManager.GetString("MensaApp_Bio", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Essen 1 ähnelt.
|
||||
/// </summary>
|
||||
public static string MensaApp_Dinner1 {
|
||||
get {
|
||||
return ResourceManager.GetString("MensaApp_Dinner1", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Essen 2 ähnelt.
|
||||
/// </summary>
|
||||
public static string MensaApp_Dinner2 {
|
||||
get {
|
||||
return ResourceManager.GetString("MensaApp_Dinner2", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Essen 3 ähnelt.
|
||||
/// </summary>
|
||||
public static string MensaApp_Dinner3 {
|
||||
get {
|
||||
return ResourceManager.GetString("MensaApp_Dinner3", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Essen 4 ähnelt.
|
||||
/// </summary>
|
||||
public static string MensaApp_Dinner4 {
|
||||
get {
|
||||
return ResourceManager.GetString("MensaApp_Dinner4", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Essen 5 ähnelt.
|
||||
/// </summary>
|
||||
public static string MensaApp_Dinner5 {
|
||||
get {
|
||||
return ResourceManager.GetString("MensaApp_Dinner5", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die 84 ähnelt.
|
||||
/// </summary>
|
||||
public static string MensaApp_DinnerLabelW {
|
||||
get {
|
||||
return ResourceManager.GetString("MensaApp_DinnerLabelW", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Heute nicht im Angbot ähnelt.
|
||||
/// </summary>
|
||||
public static string MensaApp_NotToday {
|
||||
get {
|
||||
return ResourceManager.GetString("MensaApp_NotToday", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Suppe ähnelt.
|
||||
/// </summary>
|
||||
public static string MensaApp_Soup {
|
||||
get {
|
||||
return ResourceManager.GetString("MensaApp_Soup", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Mensaplan ähnelt.
|
||||
/// </summary>
|
||||
public static string MensaApp_Title {
|
||||
get {
|
||||
return ResourceManager.GetString("MensaApp_Title", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="MensaApp_Title" xml:space="preserve">
|
||||
<value>Mensaplan</value>
|
||||
</data>
|
||||
<data name="MensaApp_Action" xml:space="preserve">
|
||||
<value>Aktion</value>
|
||||
</data>
|
||||
<data name="MensaApp_Bio" xml:space="preserve">
|
||||
<value>Bio</value>
|
||||
</data>
|
||||
<data name="MensaApp_Dinner1" xml:space="preserve">
|
||||
<value>Essen 1</value>
|
||||
</data>
|
||||
<data name="MensaApp_Dinner2" xml:space="preserve">
|
||||
<value>Essen 2</value>
|
||||
</data>
|
||||
<data name="MensaApp_Dinner3" xml:space="preserve">
|
||||
<value>Essen 3</value>
|
||||
</data>
|
||||
<data name="MensaApp_Dinner4" xml:space="preserve">
|
||||
<value>Essen 4</value>
|
||||
</data>
|
||||
<data name="MensaApp_NotToday" xml:space="preserve">
|
||||
<value>Heute nicht im Angbot</value>
|
||||
</data>
|
||||
<data name="MensaApp_DinnerLabelW" xml:space="preserve">
|
||||
<value>84</value>
|
||||
</data>
|
||||
<data name="MensaApp_Dinner5" xml:space="preserve">
|
||||
<value>Essen 5</value>
|
||||
</data>
|
||||
<data name="MensaApp_Soup" xml:space="preserve">
|
||||
<value>Suppe</value>
|
||||
</data>
|
||||
</root>
|
||||
117
CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.Designer.cs
generated
Normal file
117
CampusAppWP8/CampusAppWP8ScheduledTaskAgent/Resources/Constants.Designer.cs
generated
Normal file
@@ -0,0 +1,117 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace CampusAppWP8ScheduledTaskAgent.Resources {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
||||
/// </summary>
|
||||
// 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() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
|
||||
/// </summary>
|
||||
[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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
|
||||
/// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die /Pages/Mensa/MensaPage.xaml ähnelt.
|
||||
/// </summary>
|
||||
public static string PathMensa_MensaPage {
|
||||
get {
|
||||
return ResourceManager.GetString("PathMensa_MensaPage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1 ähnelt.
|
||||
/// </summary>
|
||||
public static string UrlMensa_Week_CBMain {
|
||||
get {
|
||||
return ResourceManager.GetString("UrlMensa_Week_CBMain", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1 ähnelt.
|
||||
/// </summary>
|
||||
public static string UrlMensa_Week_CBNorth {
|
||||
get {
|
||||
return ResourceManager.GetString("UrlMensa_Week_CBNorth", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusHL&v=1 ähnelt.
|
||||
/// </summary>
|
||||
public static string UrlMensa_Week_CBSouth {
|
||||
get {
|
||||
return ResourceManager.GetString("UrlMensa_Week_CBSouth", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=Senftenberg&v=1 ähnelt.
|
||||
/// </summary>
|
||||
public static string UrlMensa_Week_SBFMain {
|
||||
get {
|
||||
return ResourceManager.GetString("UrlMensa_Week_SBFMain", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die root ähnelt.
|
||||
/// </summary>
|
||||
public static string XMLRootElementName {
|
||||
get {
|
||||
return ResourceManager.GetString("XMLRootElementName", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="XMLRootElementName" xml:space="preserve">
|
||||
<value>root</value>
|
||||
</data>
|
||||
<data name="UrlMensa_Week_CBMain" xml:space="preserve">
|
||||
<value>http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1</value>
|
||||
</data>
|
||||
<data name="UrlMensa_Week_CBNorth" xml:space="preserve">
|
||||
<value>http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusBTU&v=1</value>
|
||||
</data>
|
||||
<data name="UrlMensa_Week_CBSouth" xml:space="preserve">
|
||||
<value>http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=CottbusHL&v=1</value>
|
||||
</data>
|
||||
<data name="UrlMensa_Week_SBFMain" xml:space="preserve">
|
||||
<value>http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/index.php?mensa=Senftenberg&v=1</value>
|
||||
</data>
|
||||
<data name="PathMensa_MensaPage" xml:space="preserve">
|
||||
<value>/Pages/Mensa/MensaPage.xaml</value>
|
||||
</data>
|
||||
</root>
|
||||
109
CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs
Normal file
109
CampusAppWP8/CampusAppWP8ScheduledTaskAgent/ScheduledAgent.cs
Normal file
@@ -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<string> MealList;
|
||||
|
||||
private static string LastMensaUpdate;
|
||||
|
||||
/// <remarks>
|
||||
/// ScheduledAgent-Konstruktor, initialisiert den UnhandledException-Handler
|
||||
/// </remarks>
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Agent zum Ausführen einer geplanten Aufgabe
|
||||
/// </summary>
|
||||
/// <param name="task">
|
||||
/// Die aufgerufene Aufgabe
|
||||
/// </param>
|
||||
/// <remarks>
|
||||
/// Diese Methode wird aufgerufen, wenn eine regelmäßige oder ressourcenintensive Aufgabe aufgerufen wird
|
||||
/// </remarks>
|
||||
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<MenuWeekModel>(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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="HttpRequest.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>10.06.2013</sience>
|
||||
//----------------------------------------------------------------------using System;
|
||||
namespace CampusAppWP8ScheduledTaskAgent.Utility
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using CampusAppWP8ScheduledTaskAgent.Model.Utility;
|
||||
|
||||
/// <summary>
|
||||
/// Class realize the access of restful HttpRequest
|
||||
/// </summary>
|
||||
public class HttpRequest
|
||||
{
|
||||
#region Member
|
||||
|
||||
/// <summary>
|
||||
/// BaseAddress of the webClient
|
||||
/// </summary>
|
||||
private string baseAddress;
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HttpRequest" /> class.
|
||||
/// </summary>
|
||||
public HttpRequest()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HttpRequest" /> class.
|
||||
/// </summary>
|
||||
/// <param name="apiBaseAddress">the url of the HttpRequest base address</param>
|
||||
public HttpRequest(Uri apiBaseAddress)
|
||||
{
|
||||
this.baseAddress = apiBaseAddress.AbsoluteUri;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
#region public
|
||||
|
||||
/// <summary>
|
||||
/// Method realize the http-get-method resource
|
||||
/// </summary>
|
||||
/// <param name="url">Url of the resource</param>
|
||||
/// <param name="action">callback method</param>
|
||||
public void HttpGet(Uri url, Action<object, DownloadStringCompletedEventArgs> action)
|
||||
{
|
||||
WebClient client = new WebClient();
|
||||
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(action);
|
||||
client.DownloadStringAsync(url);
|
||||
}
|
||||
|
||||
/// <summary>Method realize the http-get-method resource.</summary>
|
||||
/// <remarks>Stubbfel, 03.09.2013.</remarks>
|
||||
/// <param name="url"> Url of the resource.</param>
|
||||
/// <param name="action">The action.</param>
|
||||
public void HttpGet(Uri url, Action<object, OpenReadCompletedEventArgs> action)
|
||||
{
|
||||
WebClient client = new WebClient();
|
||||
client.OpenReadCompleted += new OpenReadCompletedEventHandler(action);
|
||||
client.OpenReadAsync(url);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method create the Url for the http-get-method
|
||||
/// </summary>
|
||||
/// <param name="parameters"> list of parameters</param>
|
||||
/// <returns>absolute API-Url include GetParameter</returns>
|
||||
public Uri CreateGetUrl(List<UrlParamModel> parameters)
|
||||
{
|
||||
string paramterStr = string.Empty;
|
||||
string seperator = string.Empty;
|
||||
foreach (UrlParamModel parameter in parameters)
|
||||
{
|
||||
if (string.Empty.Equals(seperator))
|
||||
{
|
||||
seperator = parameter.ParamToken;
|
||||
}
|
||||
|
||||
paramterStr += parameter.ToString();
|
||||
}
|
||||
|
||||
string getUrlStr = this.baseAddress + seperator + paramterStr;
|
||||
return new Uri(getUrlStr, UriKind.Absolute);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method realize the http-delete-method
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// is not supported by WebClient
|
||||
/// </remarks>
|
||||
/// <param name="url">Url of the resource</param>
|
||||
/// <param name="action">callback method</param>
|
||||
public void HttpDelete(Uri url, Action<object, DownloadStringCompletedEventArgs> action)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method realize the http-head-method
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// is not supported by WebClient
|
||||
/// </remarks>
|
||||
/// <param name="url">Url of the resource</param>
|
||||
/// <param name="action">callback method</param>
|
||||
public void HttpHead(Uri url, Action<object, DownloadStringCompletedEventArgs> action)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method realize the http-options-method
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// is not supported by WebClient
|
||||
/// </remarks>
|
||||
/// <param name="url">Url of the resource</param>
|
||||
/// <param name="action">callback method</param>
|
||||
public void HttpOptions(Uri url, Action<object, DownloadStringCompletedEventArgs> action)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method realize the http-connect-method
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// is not supported by WebClient
|
||||
/// </remarks>
|
||||
/// <param name="url">Url of the resource</param>
|
||||
/// <param name="action">callback method</param>
|
||||
public void HttpConnect(Uri url, Action<object, DownloadStringCompletedEventArgs> action)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method realize the http-trace-method
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// is not supported by WebClient
|
||||
/// </remarks>
|
||||
/// <param name="url">Url of the resource</param>
|
||||
/// <param name="action">callback method</param>
|
||||
public void HttpTrace(Uri url, Action<object, DownloadStringCompletedEventArgs> action)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method realize the http-post-method
|
||||
/// </summary>
|
||||
/// <param name="url">Url of the resource</param>
|
||||
/// <param name="action">callback method</param>
|
||||
/// <param name="postData">Data which are sending via post to the HttpRequest</param>
|
||||
public void HttpPost(Uri url, Action<object, UploadStringCompletedEventArgs> action, string postData)
|
||||
{
|
||||
this.UploadData(url, action, "POST", postData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method realize the http-put-method
|
||||
/// </summary>
|
||||
/// <param name="url">Url of the resource</param>
|
||||
/// <param name="action">callback method</param>
|
||||
/// <param name="putData">Data which are sending via put to the HttpRequest</param>
|
||||
public void HttpPut(Uri url, Action<object, UploadStringCompletedEventArgs> action, string putData)
|
||||
{
|
||||
this.UploadData(url, action, "PUT", putData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method realize the http-patch-method
|
||||
/// </summary>
|
||||
/// <param name="url">Url of the resource</param>
|
||||
/// <param name="action">callback method</param>
|
||||
/// <param name="patchData">Data which are sending via patch to the HttpRequest</param>
|
||||
public void HttpPatch(Uri url, Action<object, UploadStringCompletedEventArgs> action, string patchData)
|
||||
{
|
||||
this.UploadData(url, action, "PATCH", patchData);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region private
|
||||
|
||||
/// <summary>
|
||||
/// Method uploaded Data to the HttpRequest
|
||||
/// </summary>
|
||||
/// <param name="url">Url of the resource</param>
|
||||
/// <param name="action">callback method</param>
|
||||
/// <param name="method">name of APIMethod, how the data will be uploaded</param>
|
||||
/// <param name="data">Data which are sending to the HttpRequest</param>
|
||||
private void UploadData(Uri url, Action<object, UploadStringCompletedEventArgs> action, string method, string data)
|
||||
{
|
||||
WebClient client = new WebClient();
|
||||
client.UploadStringCompleted += new UploadStringCompletedEventHandler(action);
|
||||
client.UploadStringAsync(url, method, data);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
//--------------------------------------------------------------------
|
||||
// <copyright file="Logger.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>03.05.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
namespace CampusAppWP8ScheduledTaskAgent.Utility
|
||||
{
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// This Class creates logs for the app
|
||||
/// </summary>
|
||||
public class Logger
|
||||
{
|
||||
/// <summary>
|
||||
/// Method log a Exception
|
||||
/// </summary>
|
||||
/// <param name="exception">exception which has to log</param>
|
||||
public static void LogException(Exception exception)
|
||||
{
|
||||
// Console.WriteLine(exception);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Log a message.
|
||||
/// </summary>
|
||||
/// <param name="msg">to be logged message</param>
|
||||
public static void LogMsg(string msg)
|
||||
{
|
||||
// Console.WriteLine(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="StringManager.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>06.06.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
namespace CampusAppWP8ScheduledTaskAgent.Utility
|
||||
{
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
/// <summary>
|
||||
/// Class provides some special StringMethods
|
||||
/// </summary>
|
||||
public static class StringManager
|
||||
{
|
||||
#region Members
|
||||
|
||||
/// <summary>
|
||||
/// Patter for Html-Tags
|
||||
/// </summary>
|
||||
private static readonly string HtmlTagPattern = "<.*?>";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Method removes Html-Tag of a String
|
||||
/// </summary>
|
||||
/// <param name="inputString">String with Html-Tags</param>
|
||||
/// <returns>String without Html-Tags</returns>
|
||||
public static string StripHTML(string inputString)
|
||||
{
|
||||
return Regex.Replace(inputString, HtmlTagPattern, string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method add an Newline to a string
|
||||
/// </summary>
|
||||
/// <param name="str">input string</param>
|
||||
/// <returns>input string + newline</returns>
|
||||
public static string AddNewLine(string str)
|
||||
{
|
||||
return str.ToString() + "\n";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method remove(TrimEND!) an Newline to a string
|
||||
/// </summary>
|
||||
/// <param name="str">input string</param>
|
||||
/// <returns>input string - newline</returns
|
||||
public static string RemoveNewLine(string str)
|
||||
{
|
||||
return str.TrimEnd('\n');
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="XmlManager.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>18.06.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
namespace CampusAppWP8ScheduledTaskAgent.Utility
|
||||
{
|
||||
using System.IO;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
/// <summary>
|
||||
/// Class provides some Xml-methods
|
||||
/// </summary>
|
||||
public class XmlManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Method deserialization a string to a Model
|
||||
/// </summary>
|
||||
/// <typeparam name="T">the model</typeparam>
|
||||
/// <param name="xmlString">the XmlString</param>
|
||||
/// <param name="validRootName">name of the RootTag</param>
|
||||
/// <returns>return the deserialization of the model</returns>
|
||||
public static T DeserializationToModel<T>(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;
|
||||
}
|
||||
|
||||
/// <summary>Deserialization a xml file to a model.</summary>
|
||||
/// <remarks>Stubbfel, 20.08.2013.</remarks>
|
||||
/// <typeparam name="T">Generic type parameter.</typeparam>
|
||||
/// <param name="xmlFilePath">Path to the a XmlFile.</param>
|
||||
/// <returns>model of the XmlFile.</returns>
|
||||
public static T DeserializationFileToModel<T>(string xmlFilePath)
|
||||
{
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(T));
|
||||
XDocument document = XDocument.Load(xmlFilePath);
|
||||
T model = (T)serializer.Deserialize(document.CreateReader());
|
||||
return model;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method serializes a model to a string.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">type of the model</typeparam>
|
||||
/// <param name="model">model object</param>
|
||||
/// <returns>serialized string</returns>
|
||||
public static string SerializationToString<T>(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("<?xml") == true)
|
||||
{
|
||||
int endTag = retValue.IndexOf("?>");
|
||||
retValue = retValue.Substring(endTag + 2);
|
||||
|
||||
if (retValue.StartsWith("\r\n") == true)
|
||||
{
|
||||
retValue = retValue.Substring(2);
|
||||
}
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,10 @@
|
||||
<Compile Include="Model\GeoDb\PlaceModel.cs" />
|
||||
<Compile Include="Model\GeoDb\PlaceService.cs" />
|
||||
<Compile Include="Model\GeoDb\SpsModel.cs" />
|
||||
<Compile Include="Model\Utility\CleanUrlParamModel.cs" />
|
||||
<Compile Include="Model\Utility\URLParamModel.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Utility\HttpRequest.cs" />
|
||||
<Compile Include="Utility\Logger.cs" />
|
||||
<Compile Include="Utility\NDEF\NDEFMessage.cs" />
|
||||
<Compile Include="Utility\NDEF\NDEFRecord.cs" />
|
||||
|
||||
Reference in New Issue
Block a user