add event and news task
This commit is contained in:
@@ -145,6 +145,7 @@
|
||||
<Compile Include="Pages\PlaceNews\ShowPad.xaml.cs">
|
||||
<DependentUpon>ShowPad.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Utility\BackgroundTasks.cs" />
|
||||
<Compile Include="Utility\Lui\Button\AddPersonButton.cs" />
|
||||
<Compile Include="Utility\Lui\Tiles\TileCreator.cs" />
|
||||
<Compile Include="Utility\NDEF\NDEFMessage.cs" />
|
||||
|
||||
@@ -51,6 +51,12 @@
|
||||
<Image Source="{Binding Path=ThemelizedIcon.News, Source={StaticResource ThemelizedIcons}}" Style="{StaticResource StartPageButtonImg}"/>
|
||||
<TextBlock Text="{Binding Path=LocalizedResources.NewsApp_Title, Source={StaticResource LocalizedStrings}}" Style="{StaticResource StartPageButtonText}"/>
|
||||
</StackPanel>
|
||||
<toolkit:ContextMenuService.ContextMenu>
|
||||
<toolkit:ContextMenu>
|
||||
<toolkit:MenuItem Tag="NewsAppButton" Header="{Binding Path=LocalizedResources.ContextMenu_PinToStart, Source={StaticResource LocalizedStrings}}" Click="PintoStart_Click">
|
||||
</toolkit:MenuItem>
|
||||
</toolkit:ContextMenu>
|
||||
</toolkit:ContextMenuService.ContextMenu>
|
||||
</lui:NavigateButton>
|
||||
|
||||
<lui:NavigateButton Name="LectureAppButton" Style="{StaticResource StartPageButton}" Url="{Binding Path=Constants.PathLecture_LecturePage, Source={StaticResource Const}}" Grid.Column="2">
|
||||
@@ -58,6 +64,12 @@
|
||||
<Image Source="{Binding Path=ThemelizedIcon.Lectures, Source={StaticResource ThemelizedIcons}}" Style="{StaticResource StartPageButtonImg}"/>
|
||||
<TextBlock Text="{Binding Path=LocalizedResources.LectureApp_Title, Source={StaticResource LocalizedStrings}}" Style="{StaticResource StartPageButtonText}"/>
|
||||
</StackPanel>
|
||||
<toolkit:ContextMenuService.ContextMenu>
|
||||
<toolkit:ContextMenu>
|
||||
<toolkit:MenuItem Tag="LectureAppButton" Header="{Binding Path=LocalizedResources.ContextMenu_PinToStart, Source={StaticResource LocalizedStrings}}" Click="PintoStart_Click">
|
||||
</toolkit:MenuItem>
|
||||
</toolkit:ContextMenu>
|
||||
</toolkit:ContextMenuService.ContextMenu>
|
||||
</lui:NavigateButton>
|
||||
</Grid>
|
||||
|
||||
@@ -83,6 +95,12 @@
|
||||
<Image Source="{Binding Path=ThemelizedIcon.News, Source={StaticResource ThemelizedIcons}}" Style="{StaticResource StartPageButtonImg}"/>
|
||||
<TextBlock Text="{Binding Path=LocalizedResources.EventApp_Title, Source={StaticResource LocalizedStrings}}" Style="{StaticResource StartPageButtonText}"/>
|
||||
</StackPanel>
|
||||
<toolkit:ContextMenuService.ContextMenu>
|
||||
<toolkit:ContextMenu>
|
||||
<toolkit:MenuItem Tag="EventAppButton" Header="{Binding Path=LocalizedResources.ContextMenu_PinToStart, Source={StaticResource LocalizedStrings}}" Click="PintoStart_Click">
|
||||
</toolkit:MenuItem>
|
||||
</toolkit:ContextMenu>
|
||||
</toolkit:ContextMenuService.ContextMenu>
|
||||
</lui:NavigateButton>
|
||||
|
||||
<lui:NavigateButton Name="CampusMapAppButton" Grid.Column="2" Style="{StaticResource StartPageButton}" Url="{Binding Path=Constants.PathCampusmap_Campusmap, Source={StaticResource Const}}">
|
||||
@@ -90,6 +108,12 @@
|
||||
<Image Source="{Binding Path=ThemelizedIcon.Campus, Source={StaticResource ThemelizedIcons}}" Style="{StaticResource StartPageButtonImg}"/>
|
||||
<TextBlock Text="{Binding Path=LocalizedResources.CampusMapApp_Title, Source={StaticResource LocalizedStrings}}" Style="{StaticResource StartPageButtonText}"/>
|
||||
</StackPanel>
|
||||
<toolkit:ContextMenuService.ContextMenu>
|
||||
<toolkit:ContextMenu>
|
||||
<toolkit:MenuItem Tag="CampusMapAppButton" Header="{Binding Path=LocalizedResources.ContextMenu_PinToStart, Source={StaticResource LocalizedStrings}}" Click="PintoStart_Click">
|
||||
</toolkit:MenuItem>
|
||||
</toolkit:ContextMenu>
|
||||
</toolkit:ContextMenuService.ContextMenu>
|
||||
</lui:NavigateButton>
|
||||
</Grid>
|
||||
|
||||
@@ -107,22 +131,25 @@
|
||||
<Image Source="{Binding Path=ThemelizedIcon.Departments, Source={StaticResource ThemelizedIcons}}" Style="{StaticResource StartPageButtonImg}"/>
|
||||
<TextBlock Text="{Binding Path=LocalizedResources.DepartmentApp_Title, Source={StaticResource LocalizedStrings}}" Style="{StaticResource StartPageButtonText}"/>
|
||||
</StackPanel>
|
||||
<toolkit:ContextMenuService.ContextMenu>
|
||||
<toolkit:ContextMenu>
|
||||
<toolkit:MenuItem Tag="DepartmentAppButton" Header="{Binding Path=LocalizedResources.ContextMenu_PinToStart, Source={StaticResource LocalizedStrings}}" Click="PintoStart_Click">
|
||||
</toolkit:MenuItem>
|
||||
</toolkit:ContextMenu>
|
||||
</toolkit:ContextMenuService.ContextMenu>
|
||||
</lui:NavigateButton>
|
||||
|
||||
<lui:NavigateButton Name="MensaAppButton" Grid.Column="1" Style="{StaticResource StartPageButton}" Url="{Binding Path=Constants.PathMensa_MensaPage, Source={StaticResource Const}}">
|
||||
<lui:NavigateButton Name="MensaAppButton" Grid.Column="1" Style="{StaticResource StartPageButton}" Url="{Binding Path=Constants.PathMensa_MensaPage, Source={StaticResource Const}}">
|
||||
<StackPanel Style="{StaticResource StartPageStackPanelStyle}">
|
||||
<Image Source="{Binding Path=ThemelizedIcon.Mensa, Source={StaticResource ThemelizedIcons}}" Style="{StaticResource StartPageButtonImg}"/>
|
||||
<TextBlock Text="{Binding Path=LocalizedResources.MensaApp_Title, Source={StaticResource LocalizedStrings}}" Style="{StaticResource StartPageButtonText}"/>
|
||||
|
||||
<toolkit:ContextMenuService.ContextMenu>
|
||||
<toolkit:ContextMenu>
|
||||
<toolkit:MenuItem Header="Pin to Start" Click="PintoStart_Click">
|
||||
|
||||
</toolkit:MenuItem>
|
||||
</toolkit:ContextMenu>
|
||||
</toolkit:ContextMenuService.ContextMenu>
|
||||
|
||||
</StackPanel>
|
||||
<toolkit:ContextMenuService.ContextMenu>
|
||||
<toolkit:ContextMenu>
|
||||
<toolkit:MenuItem Tag="MensaAppButton" Header="{Binding Path=LocalizedResources.ContextMenu_PinToStart, Source={StaticResource LocalizedStrings}}" Click="PintoStart_Click">
|
||||
</toolkit:MenuItem>
|
||||
</toolkit:ContextMenu>
|
||||
</toolkit:ContextMenuService.ContextMenu>
|
||||
</lui:NavigateButton>
|
||||
|
||||
<lui:NavigateButton Name="MailAppButton" Grid.Column="2" Style="{StaticResource StartPageButton}" Url="{Binding Path=Constants.PathMail_WebMailPage, Source={StaticResource Const}}">
|
||||
@@ -132,9 +159,7 @@
|
||||
</StackPanel>
|
||||
<toolkit:ContextMenuService.ContextMenu>
|
||||
<toolkit:ContextMenu>
|
||||
<toolkit:MenuItem Header="Pin to Start" Click="PintoStart_Click2">
|
||||
|
||||
</toolkit:MenuItem>
|
||||
<toolkit:MenuItem Tag="MailAppButton" Header="{Binding Path=LocalizedResources.ContextMenu_PinToStart, Source={StaticResource LocalizedStrings}}" Click="PintoStart_Click" />
|
||||
</toolkit:ContextMenu>
|
||||
</toolkit:ContextMenuService.ContextMenu>
|
||||
</lui:NavigateButton>
|
||||
@@ -155,6 +180,12 @@
|
||||
<Image Source="{Binding Path=ThemelizedIcon.Openhours, Source={StaticResource ThemelizedIcons}}" Style="{StaticResource StartPageButtonImg}"/>
|
||||
<TextBlock Name="OpenHoursAppButtonText" Text="{Binding Path=LocalizedResources.OpenHoursApp_Title2, Source={StaticResource LocalizedStrings}}" Style="{StaticResource StartPageButtonText}"/>
|
||||
</StackPanel>
|
||||
<toolkit:ContextMenuService.ContextMenu>
|
||||
<toolkit:ContextMenu>
|
||||
<toolkit:MenuItem Tag="OpenHoursAppButton" Header="{Binding Path=LocalizedResources.ContextMenu_PinToStart, Source={StaticResource LocalizedStrings}}" Click="PintoStart_Click">
|
||||
</toolkit:MenuItem>
|
||||
</toolkit:ContextMenu>
|
||||
</toolkit:ContextMenuService.ContextMenu>
|
||||
</lui:NavigateButton>
|
||||
|
||||
<lui:NavigateButton Name="LinkAppButton" Url="{Binding Path=Constants.PathLinks_LinkPage, Source={StaticResource Const}}" Grid.Column="1" Style="{StaticResource StartPageButton}">
|
||||
@@ -162,6 +193,12 @@
|
||||
<Image Source="{Binding Path=ThemelizedIcon.Link, Source={StaticResource ThemelizedIcons}}" Style="{StaticResource StartPageButtonImg}"/>
|
||||
<TextBlock Text="{Binding Path=LocalizedResources.LinkApp_Title, Source={StaticResource LocalizedStrings}}" Style="{StaticResource StartPageButtonText}"/>
|
||||
</StackPanel>
|
||||
<toolkit:ContextMenuService.ContextMenu>
|
||||
<toolkit:ContextMenu>
|
||||
<toolkit:MenuItem Tag="LinkAppButton" Header="{Binding Path=LocalizedResources.ContextMenu_PinToStart, Source={StaticResource LocalizedStrings}}" Click="PintoStart_Click">
|
||||
</toolkit:MenuItem>
|
||||
</toolkit:ContextMenu>
|
||||
</toolkit:ContextMenuService.ContextMenu>
|
||||
</lui:NavigateButton>
|
||||
|
||||
<lui:NavigateButton Name="OSAAppButton" Url="{Binding Path=Constants.PathStudentCouncil_StudentCouncilPage, Source={StaticResource Const}}" Grid.Column="2" Style="{StaticResource StartPageButton}">
|
||||
@@ -172,6 +209,12 @@
|
||||
<Image Source="{Binding Path=ThemelizedIcon.StudentCouncil, Source={StaticResource ThemelizedIcons}}" Style="{StaticResource StartPageButtonImg}"/>
|
||||
<TextBlock Text="{Binding Path=LocalizedResources.OSAApp_Title, Source={StaticResource LocalizedStrings}}" Style="{StaticResource StartPageButtonText}"/>
|
||||
</StackPanel>
|
||||
<toolkit:ContextMenuService.ContextMenu>
|
||||
<toolkit:ContextMenu>
|
||||
<toolkit:MenuItem Tag="OSAAppButton" Header="{Binding Path=LocalizedResources.ContextMenu_PinToStart, Source={StaticResource LocalizedStrings}}" Click="PintoStart_Click">
|
||||
</toolkit:MenuItem>
|
||||
</toolkit:ContextMenu>
|
||||
</toolkit:ContextMenuService.ContextMenu>
|
||||
</lui:NavigateButton>
|
||||
</Grid>
|
||||
|
||||
@@ -190,6 +233,12 @@
|
||||
<Image Source="{Binding Path=ThemelizedIcon.Exams, Source={StaticResource ThemelizedIcons}}" Style="{StaticResource StartPageButtonImg}"/>
|
||||
<TextBlock Name="examinationAppButtonText" Text="{Binding Path=LocalizedResources.ExaminationApp_Title, Source={StaticResource LocalizedStrings}}" Style="{StaticResource StartPageButtonText}"/>
|
||||
</StackPanel>
|
||||
<toolkit:ContextMenuService.ContextMenu>
|
||||
<toolkit:ContextMenu>
|
||||
<toolkit:MenuItem Tag="examinationAppButton" Header="{Binding Path=LocalizedResources.ContextMenu_PinToStart, Source={StaticResource LocalizedStrings}}" Click="PintoStart_Click">
|
||||
</toolkit:MenuItem>
|
||||
</toolkit:ContextMenu>
|
||||
</toolkit:ContextMenuService.ContextMenu>
|
||||
</lui:NavigateButton>
|
||||
|
||||
<lui:NavigateButton Name="personAppButton" Url="{Binding Path=Constants.PathPerson_Person, Source={StaticResource Const}}" Grid.Column="1" Style="{StaticResource StartPageButton}">
|
||||
@@ -197,12 +246,25 @@
|
||||
<Image Source="{Binding Path=ThemelizedIcon.Person, Source={StaticResource ThemelizedIcons}}" Style="{StaticResource StartPageButtonImg}"/>
|
||||
<TextBlock Name="personAppButtonText" Text="{Binding Path=LocalizedResources.PersonApp_Title, Source={StaticResource LocalizedStrings}}" Style="{StaticResource StartPageButtonText}"/>
|
||||
</StackPanel>
|
||||
<toolkit:ContextMenuService.ContextMenu>
|
||||
<toolkit:ContextMenu>
|
||||
<toolkit:MenuItem Tag="personAppButton" Header="{Binding Path=LocalizedResources.ContextMenu_PinToStart, Source={StaticResource LocalizedStrings}}" Click="PintoStart_Click">
|
||||
</toolkit:MenuItem>
|
||||
</toolkit:ContextMenu>
|
||||
</toolkit:ContextMenuService.ContextMenu>
|
||||
</lui:NavigateButton>
|
||||
|
||||
<lui:NavigateButton Name="placeNewsAppButton" Url="{Binding Path=Constants.PathPlaceNews_PlaceNewsPage, Source={StaticResource Const}}" Grid.Column="2" Style="{StaticResource StartPageButton}">
|
||||
<StackPanel Style="{StaticResource StartPageStackPanelStyle}">
|
||||
<Image Source="{Binding Path=ThemelizedIcon.News, Source={StaticResource ThemelizedIcons}}" Style="{StaticResource StartPageButtonImg}"/>
|
||||
<TextBlock Name="placeNewsButtonText" Text="{Binding Path=LocalizedResources.PlaceNewsApp_Title, Source={StaticResource LocalizedStrings}}" Style="{StaticResource StartPageButtonText}"/>
|
||||
</StackPanel>
|
||||
<toolkit:ContextMenuService.ContextMenu>
|
||||
<toolkit:ContextMenu>
|
||||
<toolkit:MenuItem Tag="placeNewsAppButton" Header="{Binding Path=LocalizedResources.ContextMenu_PinToStart, Source={StaticResource LocalizedStrings}}" Click="PintoStart_Click">
|
||||
</toolkit:MenuItem>
|
||||
</toolkit:ContextMenu>
|
||||
</toolkit:ContextMenuService.ContextMenu>
|
||||
</lui:NavigateButton>
|
||||
</Grid>
|
||||
|
||||
|
||||
@@ -282,7 +282,61 @@ namespace CampusAppWP8.Pages
|
||||
|
||||
private void PintoStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
TileCreator.CreateMensaTile();
|
||||
FrameworkElement elment = sender as FrameworkElement;
|
||||
if (elment == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string tagButtonName = elment.Tag as string;
|
||||
if (tagButtonName == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (tagButtonName)
|
||||
{
|
||||
case "MensaAppButton":
|
||||
TileCreator.CreateMensaTile();
|
||||
break;
|
||||
case "MailAppButton":
|
||||
TileCreator.CreateWebMailTile();
|
||||
break;
|
||||
case "NewsAppButton":
|
||||
TileCreator.CreateNewsTile();
|
||||
break;
|
||||
case "LectureAppButton":
|
||||
TileCreator.CreateLectureTile();
|
||||
break;
|
||||
case "EventAppButton":
|
||||
TileCreator.CreateEventTile();
|
||||
break;
|
||||
case "CampusMapAppButton":
|
||||
TileCreator.CreateCampusMapTile();
|
||||
break;
|
||||
case "DepartmentAppButton":
|
||||
TileCreator.CreateDepartmentTile();
|
||||
break;
|
||||
case "OpenHoursAppButton":
|
||||
TileCreator.CreateOpeningHoursTile();
|
||||
break;
|
||||
case "LinkAppButton":
|
||||
TileCreator.CreateLinkTile();
|
||||
break;
|
||||
case "OSAAppButton":
|
||||
TileCreator.CreateStudentCouncilTile();
|
||||
break;
|
||||
case "examinationAppButton":
|
||||
TileCreator.CreateExamsTile();
|
||||
break;
|
||||
case "personAppButton":
|
||||
TileCreator.CreatePersonTile();
|
||||
break;
|
||||
case "placeNewsAppButton":
|
||||
TileCreator.CreatePlaceNewsTile();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void PintoStart_Click2(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -150,6 +150,15 @@ namespace CampusAppWP8.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Auf Startseite ähnelt.
|
||||
/// </summary>
|
||||
public static string ContextMenu_PinToStart {
|
||||
get {
|
||||
return ResourceManager.GetString("ContextMenu_PinToStart", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Bachelor ähnelt.
|
||||
/// </summary>
|
||||
|
||||
@@ -464,4 +464,7 @@
|
||||
<data name="PlaceLabel_ShortDesc" xml:space="preserve">
|
||||
<value>Beschreibung</value>
|
||||
</data>
|
||||
<data name="ContextMenu_PinToStart" xml:space="preserve">
|
||||
<value>Auf Startseite</value>
|
||||
</data>
|
||||
</root>
|
||||
78
CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs
Normal file
78
CampusAppWP8/CampusAppWP8/Utility/BackgroundTasks.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using CampusAppWP8ScheduledTaskAgent.Resources;
|
||||
using Microsoft.Phone.Scheduler;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CampusAppWP8.Utility
|
||||
{
|
||||
public class BackgroundTasks
|
||||
{
|
||||
public static void StartPerodicTask(string taskName, string taskDesc) {
|
||||
BackgroundTasks.StopPerodicTask(taskName);
|
||||
|
||||
PeriodicTask periodicTask = new PeriodicTask(taskName);
|
||||
// load description from localized strings
|
||||
periodicTask.Description = taskDesc;
|
||||
|
||||
try
|
||||
{
|
||||
ScheduledActionService.Add(periodicTask);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void StopPerodicTask(string taskName)
|
||||
{
|
||||
PeriodicTask periodicTask = ScheduledActionService.Find(taskName) as PeriodicTask;
|
||||
if (periodicTask != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
ScheduledActionService.Remove(taskName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void StartMensaTask()
|
||||
{
|
||||
int campusId = (int)Settings.UserProfil.DefaultCampus;
|
||||
BackgroundTasks.StartPerodicTask(Constants.BackgroundTask_Mensa, AppResources.BackGroundTaskDesc_Mensa + " - Feed " + campusId);
|
||||
}
|
||||
|
||||
public static void StopMensaTask()
|
||||
{
|
||||
BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_Mensa);
|
||||
}
|
||||
|
||||
public static void StartEventTask()
|
||||
{
|
||||
BackgroundTasks.StartPerodicTask(Constants.BackgroundTask_Event, AppResources.BackGroundTaskDesc_Event);
|
||||
}
|
||||
|
||||
public static void StopEventTask()
|
||||
{
|
||||
BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_Event);
|
||||
}
|
||||
|
||||
|
||||
public static void StartNewsTask()
|
||||
{
|
||||
BackgroundTasks.StartPerodicTask(Constants.BackgroundTask_News, AppResources.BackGroundTaskDesc_News);
|
||||
}
|
||||
|
||||
public static void StopNewsTask()
|
||||
{
|
||||
BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_News);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,53 +37,70 @@ namespace CampusAppWP8.Utility.Lui.Tiles
|
||||
public static void CreateMensaTile()
|
||||
{
|
||||
TileCreator.CreateIconicTile(AppResources.MensaApp_Title, Constants.PathMensa_MensaPage, Icons.Mensa, Icons.Mensa);
|
||||
PeriodicTask periodicTask = ScheduledActionService.Find("MensaTask") as PeriodicTask;
|
||||
if (periodicTask != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
ScheduledActionService.Remove("MensaTask");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// create a new task
|
||||
periodicTask = new PeriodicTask("MensaTask");
|
||||
// load description from localized strings
|
||||
periodicTask.Description = "Load MensaFeed :" + Settings.UserProfil.DefaultCampus.ToString();
|
||||
|
||||
try
|
||||
{
|
||||
// add thas to scheduled action service
|
||||
ScheduledActionService.Add(periodicTask);
|
||||
|
||||
ScheduledActionService.LaunchForTest("MensaTask", TimeSpan.FromSeconds(10));
|
||||
System.Diagnostics.Debug.WriteLine("Periodic task is started: " + "MensaTask");
|
||||
|
||||
|
||||
}
|
||||
catch (InvalidOperationException exception)
|
||||
{
|
||||
if (exception.Message.Contains("BNS Error: The action is disabled"))
|
||||
{
|
||||
// load error text from localized strings
|
||||
//MessageBox.Show("Background agents for this application have been disabled by the user.");
|
||||
}
|
||||
if (exception.Message.Contains("BNS Error: The maximum number of ScheduledActions of this type have already been added."))
|
||||
{
|
||||
// No user action required. The system prompts the user when the hard limit of periodic tasks has been reached.
|
||||
}
|
||||
}
|
||||
catch (SchedulerServiceException)
|
||||
{
|
||||
// No user action required.
|
||||
}
|
||||
BackgroundTasks.StartMensaTask();
|
||||
}
|
||||
|
||||
public static void CreateWebMailTile()
|
||||
{
|
||||
TileCreator.CreateIconicTile(AppResources.MensaApp_Title, Constants.PathMensa_MensaPage, Icons.Mensa, Icons.Mensa);
|
||||
TileCreator.CreateIconicTile(AppResources.MailApp_Title, Constants.PathMail_WebMailPage, Icons.WebMail, Icons.WebMail);
|
||||
}
|
||||
|
||||
public static void CreateNewsTile()
|
||||
{
|
||||
TileCreator.CreateIconicTile(AppResources.NewsApp_Title, Constants.PathNews_NewsIndexPage, Icons.News, Icons.News);
|
||||
}
|
||||
|
||||
public static void CreateLectureTile()
|
||||
{
|
||||
TileCreator.CreateIconicTile(AppResources.LectureApp_Title, Constants.PathLecture_LecturePage, Icons.Lectures, Icons.Lectures);
|
||||
}
|
||||
|
||||
public static void CreateEventTile()
|
||||
{
|
||||
TileCreator.CreateIconicTile(AppResources.EventApp_Title, Constants.PathEvents_EventsIndexPage, Icons.News, Icons.News);
|
||||
BackgroundTasks.StartEventTask();
|
||||
}
|
||||
|
||||
public static void CreateDepartmentTile()
|
||||
{
|
||||
TileCreator.CreateIconicTile(AppResources.DepartmentApp_Title, Constants.PathDepartment_DepartmentIndexPage, Icons.Departments, Icons.Departments);
|
||||
}
|
||||
|
||||
public static void CreateOpeningHoursTile()
|
||||
{
|
||||
TileCreator.CreateIconicTile(AppResources.OpenHoursApp_Title, Constants.PathOpeninghours_OpeninghoursPage, Icons.Openhours, Icons.Openhours);
|
||||
}
|
||||
|
||||
public static void CreateLinkTile()
|
||||
{
|
||||
TileCreator.CreateIconicTile(AppResources.LinkApp_Title, Constants.PathLinks_LinkPage, Icons.Link, Icons.Link);
|
||||
}
|
||||
|
||||
public static void CreateStudentCouncilTile()
|
||||
{
|
||||
TileCreator.CreateIconicTile(AppResources.OSAApp_Title, Constants.PathStudentCouncil_StudentCouncilPage, Icons.StudentCouncil, Icons.StudentCouncil);
|
||||
}
|
||||
|
||||
public static void CreateExamsTile()
|
||||
{
|
||||
TileCreator.CreateIconicTile(AppResources.ExaminationApp_Header, Constants.PathExams_ExamsPage, Icons.Exams, Icons.Exams);
|
||||
}
|
||||
|
||||
public static void CreatePersonTile()
|
||||
{
|
||||
TileCreator.CreateIconicTile(AppResources.PersonApp_Title, Constants.PathPerson_Person, Icons.Person, Icons.Person);
|
||||
}
|
||||
|
||||
public static void CreatePlaceNewsTile()
|
||||
{
|
||||
TileCreator.CreateIconicTile(AppResources.PlaceNewsApp_Title, Constants.PathPlaceNews_PlaceNewsPage, Icons.News, Icons.News);
|
||||
}
|
||||
|
||||
public static void CreateCampusMapTile()
|
||||
{
|
||||
TileCreator.CreateIconicTile(AppResources.CampusMapApp_Title, Constants.PathCampusmap_Campusmap, Icons.Campus, Icons.Campus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,9 @@
|
||||
<Compile Include="Model\Mensa\MealModel.cs" />
|
||||
<Compile Include="Model\Mensa\MenuModel.cs" />
|
||||
<Compile Include="Model\Mensa\MenuWeekModel.cs" />
|
||||
<Compile Include="Model\RSS\RSSChannelModel.cs" />
|
||||
<Compile Include="Model\RSS\RSSModel.cs" />
|
||||
<Compile Include="Model\RSS\RSSViewModel.cs" />
|
||||
<Compile Include="Model\Utility\CleanUrlParamModel.cs" />
|
||||
<Compile Include="Model\Utility\URLParamModel.cs" />
|
||||
<Compile Include="Resources\AppResources.Designer.cs">
|
||||
@@ -94,13 +97,14 @@
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<Compile Include="Resources\Constants.Designer.cs">
|
||||
<DependentUpon>Constants.resx</DependentUpon>
|
||||
<Compile Include="Resources\Constants1.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Constants.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ScheduledAgent.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Utility\BackgroundTasks.cs" />
|
||||
<Compile Include="Utility\HttpRequest.cs" />
|
||||
<Compile Include="Utility\Logger.cs" />
|
||||
<Compile Include="Utility\StringManager.cs" />
|
||||
@@ -113,9 +117,9 @@
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Resources\Constants.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Constants.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
<LastGenOutput>Constants1.Designer.cs</LastGenOutput>
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -144,6 +144,20 @@ namespace CampusAppWP8ScheduledTaskAgent.Model.Mensa
|
||||
|
||||
#region Methods
|
||||
|
||||
#region public
|
||||
|
||||
public string MealToShortString()
|
||||
{
|
||||
string shortDesc = this.mealDesc;
|
||||
if (shortDesc.Length > 30)
|
||||
{
|
||||
shortDesc = shortDesc.Substring(0, 30) + "...";
|
||||
|
||||
}
|
||||
return this.MealName + ": " + shortDesc;
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Method create depends of the mealId the mealName
|
||||
/// </summary>
|
||||
|
||||
@@ -62,41 +62,21 @@ namespace CampusAppWP8ScheduledTaskAgent.Model.Mensa
|
||||
|
||||
#region Methods
|
||||
|
||||
public string MealToString(string date)
|
||||
{
|
||||
string mealString = string.Empty;
|
||||
|
||||
foreach (MenuModel menu in this.Menus)
|
||||
/// <summary>
|
||||
/// Method calculate this day of the week, which its gets new menus
|
||||
/// </summary>
|
||||
/// <returns>Date of NewMenuWeekDay</returns>
|
||||
public static DateTime CalcFirstWeekDay()
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
while (now.DayOfWeek != DayOfWeek.Monday)
|
||||
{
|
||||
if (menu.Date.Equals(date))
|
||||
{
|
||||
foreach (MealModel meal in menu.Meals)
|
||||
{
|
||||
int lenght = meal.MealDesc.Length;
|
||||
if (lenght > 30) {
|
||||
lenght = 30;
|
||||
}
|
||||
mealString += meal.MealName + ": " + meal.MealDesc.Substring(0, lenght) +"...";
|
||||
mealString = StringManager.AddNewLine(mealString);
|
||||
}
|
||||
return mealString;
|
||||
}
|
||||
now = now.Subtract(new TimeSpan(1, 0, 0, 0));
|
||||
}
|
||||
|
||||
return mealString;
|
||||
}
|
||||
|
||||
public int GetMealCount(string date)
|
||||
{
|
||||
foreach (MenuModel menu in this.Menus)
|
||||
{
|
||||
if (menu.Date.Equals(date))
|
||||
{
|
||||
return menu.Meals.Count;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
DateTime monday = new DateTime(now.Year, now.Month, now.Day);
|
||||
return monday;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// <copyright file="RSSChannelModel.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>fiedlchr</author>
|
||||
// <sience>24.06.2013</sience>
|
||||
//-----------------------------------------------------------------------------
|
||||
namespace CampusAppWP8ScheduledTaskAgent.Model.RSS
|
||||
{
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
/// <summary>
|
||||
/// Channel Model, which contains the RSS feed item list.
|
||||
/// </summary>
|
||||
public class RSSChannelModel
|
||||
{
|
||||
/// <summary>
|
||||
/// RSS feed information item list.
|
||||
/// </summary>
|
||||
private ObservableCollection<RSSModel> item;
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RSSChannelModel" /> class.
|
||||
/// </summary>
|
||||
public RSSChannelModel()
|
||||
{
|
||||
this.item = new ObservableCollection<RSSModel>();
|
||||
this.item.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnListChanged);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the RSS feed item list.
|
||||
/// </summary>
|
||||
[XmlElement("item")]
|
||||
public ObservableCollection<RSSModel> Item
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.item;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != this.item)
|
||||
{
|
||||
this.item = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method
|
||||
|
||||
/// <summary>
|
||||
/// Is called when the item list has changed.
|
||||
/// Here used for the add event.
|
||||
/// Set the index of the last list element.
|
||||
/// </summary>
|
||||
/// <param name="sender">item list</param>
|
||||
/// <param name="e">event args</param>
|
||||
private void OnListChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
if (e.Action == NotifyCollectionChangedAction.Add)
|
||||
{
|
||||
ObservableCollection<RSSModel> list = sender as ObservableCollection<RSSModel>;
|
||||
|
||||
list[list.Count - 1].Index = list.Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// <copyright file="RSSModel.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>fiedlchr</author>
|
||||
// <sience>24.06.2013</sience>
|
||||
//-----------------------------------------------------------------------------
|
||||
namespace CampusAppWP8ScheduledTaskAgent.Model.RSS
|
||||
{
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the RSS feed information.
|
||||
/// </summary>
|
||||
public class RSSModel
|
||||
{
|
||||
#region Member
|
||||
|
||||
/// <summary>
|
||||
/// Index of this object.
|
||||
/// </summary>
|
||||
private int index = -1;
|
||||
|
||||
/// <summary>
|
||||
/// Title of the fees
|
||||
/// </summary>
|
||||
private string title;
|
||||
|
||||
/// <summary>
|
||||
/// Description text of the feed.
|
||||
/// </summary>
|
||||
private string text;
|
||||
|
||||
/// <summary>
|
||||
/// Timestamp (publication date) of the event or news.
|
||||
/// </summary>
|
||||
private DateTime timestamp;
|
||||
|
||||
/// <summary>
|
||||
/// Url of the feed.
|
||||
/// </summary>
|
||||
private string link;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the title of the feed.
|
||||
/// </summary>
|
||||
[XmlElement("title")]
|
||||
public string Title
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.title;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (this.title != value)
|
||||
{
|
||||
this.title = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the text of the feed.
|
||||
/// </summary>
|
||||
[XmlElement("description")]
|
||||
public string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.text;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (this.text != this.HTMLUnicodeToString(value))
|
||||
{
|
||||
this.text = this.HTMLUnicodeToString(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the timestamp of the feed as string.
|
||||
/// </summary>
|
||||
[XmlElement("pubDate")]
|
||||
public string Timestamp
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.timestamp.ToString("R");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (this.timestamp != DateTime.Parse(value))
|
||||
{
|
||||
this.timestamp = DateTime.Parse(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the timestamp of the feed as DateTime object.
|
||||
/// </summary>
|
||||
public DateTime DTTimestamp
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.timestamp;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.timestamp = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the date of the timestamp as string.
|
||||
/// example: Mon, 25.06.2013.
|
||||
/// </summary>
|
||||
public string Date
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format("{0:ddd, dd.MM.yyyy}", this.timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the time of the timestamp as string.
|
||||
/// example: 12:56.
|
||||
/// </summary>
|
||||
public string Time
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format("{0:h:mm} Uhr", this.timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the link/url of the feed.
|
||||
/// </summary>
|
||||
[XmlElement("link")]
|
||||
public string Link
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.link;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (this.link != value)
|
||||
{
|
||||
this.link = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ListIndex.
|
||||
/// </summary>
|
||||
public int Index
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.index;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.index = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method
|
||||
|
||||
#region public
|
||||
|
||||
/// <summary>
|
||||
/// Comparing function for DateTime timestamps.
|
||||
/// (currently unused)
|
||||
/// </summary>
|
||||
/// <param name="item1">first item</param>
|
||||
/// <param name="item2">second item</param>
|
||||
/// <returns>-1 if item2 is older then item1, otherwise 0</returns>
|
||||
public static int CompareTimeStamp(RSSModel item1, RSSModel item2)
|
||||
{
|
||||
if (item1.DTTimestamp > item2.DTTimestamp)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region private
|
||||
|
||||
/// <summary>
|
||||
/// Remove or transform html-unicode specific tags into ASCII.
|
||||
/// </summary>
|
||||
/// <param name="htmluni">html string</param>
|
||||
/// <returns>ASCII string</returns>
|
||||
private string HTMLUnicodeToString(string htmluni)
|
||||
{
|
||||
StringBuilder retValue = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < htmluni.Length; i++)
|
||||
{
|
||||
switch (htmluni[i])
|
||||
{
|
||||
// beginning tag of the unicode
|
||||
case '&':
|
||||
int startOff = i + 2;
|
||||
//// sear closing tag of the unicode
|
||||
int endOff = htmluni.IndexOf(';', startOff);
|
||||
//// get and parse value inbetween
|
||||
string sub = htmluni.Substring(startOff, endOff - startOff);
|
||||
int charVal = int.Parse(sub);
|
||||
|
||||
switch (charVal)
|
||||
{
|
||||
// if the unicode value is 128 (€)
|
||||
case 128:
|
||||
retValue.Append('€');
|
||||
break;
|
||||
|
||||
default:
|
||||
retValue.Append((char)charVal);
|
||||
break;
|
||||
}
|
||||
|
||||
// set the current index to the end of the unicode tag
|
||||
i = endOff;
|
||||
break;
|
||||
|
||||
case '<':
|
||||
// ignoring <..> html tags
|
||||
i = htmluni.IndexOf('>', i);
|
||||
break;
|
||||
|
||||
case '\t':
|
||||
// removing tabs
|
||||
break;
|
||||
|
||||
default:
|
||||
// adding other characters to the return string
|
||||
retValue.Append(htmluni[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return retValue.ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// <copyright file="RSSViewModel.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>fiedlchr</author>
|
||||
// <sience>24.06.2013</sience>
|
||||
//-----------------------------------------------------------------------------
|
||||
namespace CampusAppWP8ScheduledTaskAgent.Model.RSS
|
||||
{
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
/// <summary>
|
||||
/// ViewModel of the RSS feed, containing the feed/channel object.
|
||||
/// </summary>
|
||||
[XmlRoot("root")]
|
||||
public class RSSViewModel
|
||||
{
|
||||
#region Member
|
||||
|
||||
/// <summary>
|
||||
/// Object to store the time when the instance was created.
|
||||
/// </summary>
|
||||
private DateTime createTime;
|
||||
|
||||
/// <summary>
|
||||
/// Channel list for the RSS feeds.
|
||||
/// </summary>
|
||||
private ObservableCollection<RSSChannelModel> channel;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RSSViewModel" /> class.
|
||||
/// </summary>
|
||||
public RSSViewModel()
|
||||
{
|
||||
this.channel = new ObservableCollection<RSSChannelModel>();
|
||||
this.createTime = DateTime.Now;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the channel list.
|
||||
/// </summary>
|
||||
[XmlArray("rss")]
|
||||
[XmlArrayItem("channel")]
|
||||
public ObservableCollection<RSSChannelModel> Channel
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != this.channel)
|
||||
{
|
||||
this.channel = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the creation time.
|
||||
/// </summary>
|
||||
public DateTime CreateTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.createTime;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,33 @@ namespace CampusAppWP8ScheduledTaskAgent.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Hintergrunddienst für die BTU-Event-Feed ähnelt.
|
||||
/// </summary>
|
||||
public static string BackGroundTaskDesc_Event {
|
||||
get {
|
||||
return ResourceManager.GetString("BackGroundTaskDesc_Event", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Hintergrunddienst für die BTU-Mensa ähnelt.
|
||||
/// </summary>
|
||||
public static string BackGroundTaskDesc_Mensa {
|
||||
get {
|
||||
return ResourceManager.GetString("BackGroundTaskDesc_Mensa", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Hintergrunddienst für die BTU-News-Feed ähnelt.
|
||||
/// </summary>
|
||||
public static string BackGroundTaskDesc_News {
|
||||
get {
|
||||
return ResourceManager.GetString("BackGroundTaskDesc_News", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Aktion ähnelt.
|
||||
/// </summary>
|
||||
@@ -78,6 +105,15 @@ namespace CampusAppWP8ScheduledTaskAgent.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Die Mensa ist heute geschlossen ähnelt.
|
||||
/// </summary>
|
||||
public static string MensaApp_CloseMensa {
|
||||
get {
|
||||
return ResourceManager.GetString("MensaApp_CloseMensa", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Essen 1 ähnelt.
|
||||
/// </summary>
|
||||
|
||||
@@ -150,4 +150,16 @@
|
||||
<data name="MensaApp_Soup" xml:space="preserve">
|
||||
<value>Suppe</value>
|
||||
</data>
|
||||
<data name="BackGroundTaskDesc_Mensa" xml:space="preserve">
|
||||
<value>Hintergrunddienst für die BTU-Mensa</value>
|
||||
</data>
|
||||
<data name="MensaApp_CloseMensa" xml:space="preserve">
|
||||
<value>Die Mensa ist heute geschlossen</value>
|
||||
</data>
|
||||
<data name="BackGroundTaskDesc_Event" xml:space="preserve">
|
||||
<value>Hintergrunddienst für die BTU-Event-Feed</value>
|
||||
</data>
|
||||
<data name="BackGroundTaskDesc_News" xml:space="preserve">
|
||||
<value>Hintergrunddienst für die BTU-News-Feed</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -135,4 +135,25 @@
|
||||
<data name="PathMensa_MensaPage" xml:space="preserve">
|
||||
<value>/Pages/Mensa/MensaPage.xaml</value>
|
||||
</data>
|
||||
<data name="BackgroundTask_Mensa" xml:space="preserve">
|
||||
<value>MensaTask</value>
|
||||
</data>
|
||||
<data name="PathEvents_EventsIndexPage" xml:space="preserve">
|
||||
<value>/Pages/Events/EventIndexPage.xaml</value>
|
||||
</data>
|
||||
<data name="UrlEvents_Addr" xml:space="preserve">
|
||||
<value>http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_veranstaltungen.php</value>
|
||||
</data>
|
||||
<data name="BackgroundTask_Event" xml:space="preserve">
|
||||
<value>EventTask</value>
|
||||
</data>
|
||||
<data name="BackgroundTask_News" xml:space="preserve">
|
||||
<value>NewsTask</value>
|
||||
</data>
|
||||
<data name="PathNews_NewsIndexPage" xml:space="preserve">
|
||||
<value>/Pages/News/NewsIndexPage.xaml</value>
|
||||
</data>
|
||||
<data name="UrlNews_Addr" xml:space="preserve">
|
||||
<value>http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_aktuelles.php</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -60,6 +60,42 @@ namespace CampusAppWP8ScheduledTaskAgent.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die EventTask ähnelt.
|
||||
/// </summary>
|
||||
public static string BackgroundTask_Event {
|
||||
get {
|
||||
return ResourceManager.GetString("BackgroundTask_Event", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die MensaTask ähnelt.
|
||||
/// </summary>
|
||||
public static string BackgroundTask_Mensa {
|
||||
get {
|
||||
return ResourceManager.GetString("BackgroundTask_Mensa", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die NewsTask ähnelt.
|
||||
/// </summary>
|
||||
public static string BackgroundTask_News {
|
||||
get {
|
||||
return ResourceManager.GetString("BackgroundTask_News", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die /Pages/Events/EventIndexPage.xaml ähnelt.
|
||||
/// </summary>
|
||||
public static string PathEvents_EventsIndexPage {
|
||||
get {
|
||||
return ResourceManager.GetString("PathEvents_EventsIndexPage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die /Pages/Mensa/MensaPage.xaml ähnelt.
|
||||
/// </summary>
|
||||
@@ -69,6 +105,24 @@ namespace CampusAppWP8ScheduledTaskAgent.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die /Pages/News/NewsIndexPage.xaml ähnelt.
|
||||
/// </summary>
|
||||
public static string PathNews_NewsIndexPage {
|
||||
get {
|
||||
return ResourceManager.GetString("PathNews_NewsIndexPage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_veranstaltungen.php ähnelt.
|
||||
/// </summary>
|
||||
public static string UrlEvents_Addr {
|
||||
get {
|
||||
return ResourceManager.GetString("UrlEvents_Addr", 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>
|
||||
@@ -105,6 +159,15 @@ namespace CampusAppWP8ScheduledTaskAgent.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_aktuelles.php ähnelt.
|
||||
/// </summary>
|
||||
public static string UrlNews_Addr {
|
||||
get {
|
||||
return ResourceManager.GetString("UrlNews_Addr", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die root ähnelt.
|
||||
/// </summary>
|
||||
@@ -1,109 +1,268 @@
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using Microsoft.Phone.Scheduler;
|
||||
using CampusAppWP8ScheduledTaskAgent.Utility;
|
||||
using System;
|
||||
using CampusAppWP8ScheduledTaskAgent.Model.Mensa;
|
||||
using CampusAppWP8ScheduledTaskAgent.Model.RSS;
|
||||
using CampusAppWP8ScheduledTaskAgent.Resources;
|
||||
using CampusAppWP8ScheduledTaskAgent.Model.Mensa;
|
||||
using CampusAppWP8ScheduledTaskAgent.Utility;
|
||||
using Microsoft.Phone.Scheduler;
|
||||
using Microsoft.Phone.Shell;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace CampusAppWP8ScheduledTaskAgent
|
||||
{
|
||||
public class ScheduledAgent : ScheduledTaskAgent
|
||||
{
|
||||
private static List<string> MealList;
|
||||
|
||||
private static string LastMensaUpdate;
|
||||
private MenuWeekModel mensaModel;
|
||||
|
||||
private RSSViewModel eventModel;
|
||||
|
||||
private RSSViewModel newsModel;
|
||||
|
||||
/// <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"))
|
||||
switch (task.Name)
|
||||
{
|
||||
//TODO: Code zum Ausführen der Aufgabe im Hintergrund hinzufügen
|
||||
if (ScheduledAgent.LastMensaUpdate == null || !ScheduledAgent.LastMensaUpdate.Equals(DateTime.Now.ToShortDateString()))
|
||||
{
|
||||
HttpRequest api = new HttpRequest();
|
||||
Uri url = new Uri(Constants.UrlMensa_Week_CBMain, UriKind.Absolute);
|
||||
api.HttpGet(url, this.GetIsReady);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(Constants.PathMensa_MensaPage));
|
||||
case "MensaTask":
|
||||
this.HandleMensaTask(task);
|
||||
break;
|
||||
|
||||
if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(Constants.PathMensa_MensaPage))
|
||||
{
|
||||
IconicTileData data = new IconicTileData();
|
||||
DateTime now = DateTime.Now;
|
||||
Random random = new Random();
|
||||
int randomNumber = random.Next(0, ScheduledAgent.MealList.Count - 1);
|
||||
data.WideContent3 = ScheduledAgent.MealList[randomNumber];
|
||||
TileToFind.Update(data);
|
||||
}
|
||||
}
|
||||
case "EventTask":
|
||||
this.HandleEventTask(task);
|
||||
break;
|
||||
|
||||
case "NewsTask":
|
||||
this.HandleNewsTask(task);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void GetIsReady(object arg1, System.Net.DownloadStringCompletedEventArgs arg2)
|
||||
private void HandleEventTask(ScheduledTask task)
|
||||
{
|
||||
if (this.eventModel == null || !this.CheckRssIsUpToDate(this.eventModel.CreateTime))
|
||||
{
|
||||
HttpRequest api = new HttpRequest();
|
||||
Uri url = new Uri(Constants.UrlEvents_Addr, UriKind.Absolute);
|
||||
api.HttpGet(url, this.GetEventIsReady);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.updateEventTile();
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleNewsTask(ScheduledTask task)
|
||||
{
|
||||
if (this.newsModel == null || !this.CheckRssIsUpToDate(this.newsModel.CreateTime))
|
||||
{
|
||||
HttpRequest api = new HttpRequest();
|
||||
Uri url = new Uri(Constants.UrlNews_Addr, UriKind.Absolute);
|
||||
api.HttpGet(url, this.GetNewsIsReady);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.updateNewsTile();
|
||||
}
|
||||
}
|
||||
|
||||
private void GetEventIsReady(object arg1, System.Net.DownloadStringCompletedEventArgs arg2)
|
||||
{
|
||||
if (arg2.Result != null)
|
||||
{
|
||||
MenuWeekModel week = XmlManager.DeserializationToModel<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);
|
||||
}
|
||||
this.eventModel = XmlManager.DeserializationToModel<RSSViewModel>(arg2.Result, Constants.XMLRootElementName);
|
||||
this.updateEventTile();
|
||||
}
|
||||
NotifyComplete();
|
||||
}
|
||||
|
||||
private void GetNewsIsReady(object arg1, System.Net.DownloadStringCompletedEventArgs arg2)
|
||||
{
|
||||
if (arg2.Result != null)
|
||||
{
|
||||
this.newsModel = XmlManager.DeserializationToModel<RSSViewModel>(arg2.Result, Constants.XMLRootElementName);
|
||||
this.updateNewsTile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void updateNewsTile()
|
||||
{
|
||||
ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(Constants.PathNews_NewsIndexPage));
|
||||
|
||||
if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(Constants.PathNews_NewsIndexPage))
|
||||
{
|
||||
IconicTileData data = new IconicTileData();
|
||||
Random random = new Random();
|
||||
int randomNumber = random.Next(0, this.eventModel.Channel[0].Item.Count);
|
||||
RSSModel item = this.newsModel.Channel[0].Item[randomNumber];
|
||||
data.WideContent1 = item.Date;
|
||||
data.WideContent2 = StringManager.ToShortString(item.Title, 30) + "...";
|
||||
data.WideContent3 = StringManager.ToShortString(item.Text, 30) + "...";
|
||||
data.Count = this.newsModel.Channel[0].Item.Count;
|
||||
TileToFind.Update(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_News);
|
||||
}
|
||||
this.NotifyComplete();
|
||||
}
|
||||
|
||||
private void updateEventTile()
|
||||
{
|
||||
ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(Constants.PathEvents_EventsIndexPage));
|
||||
|
||||
if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(Constants.PathEvents_EventsIndexPage))
|
||||
{
|
||||
IconicTileData data = new IconicTileData();
|
||||
Random random = new Random();
|
||||
int randomNumber = random.Next(0, this.eventModel.Channel[0].Item.Count);
|
||||
RSSModel item = this.eventModel.Channel[0].Item[randomNumber];
|
||||
data.WideContent1 = item.Date;
|
||||
data.WideContent2 = StringManager.ToShortString(item.Title, 30) + "...";
|
||||
data.WideContent3 = StringManager.ToShortString(item.Text, 30) + "...";
|
||||
data.Count = this.eventModel.Channel[0].Item.Count;
|
||||
TileToFind.Update(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_Event);
|
||||
}
|
||||
this.NotifyComplete();
|
||||
}
|
||||
|
||||
private Uri CalcMensaUrl(string mensaTaskDesc)
|
||||
{
|
||||
Uri url;
|
||||
char feedNumber = mensaTaskDesc[mensaTaskDesc.Length - 1];
|
||||
|
||||
switch (feedNumber)
|
||||
{
|
||||
case '1':
|
||||
url = new Uri(Constants.UrlMensa_Week_CBMain, UriKind.Absolute);
|
||||
break;
|
||||
case '2':
|
||||
url = new Uri(Constants.UrlMensa_Week_CBSouth, UriKind.Absolute);
|
||||
break;
|
||||
case '3':
|
||||
url = new Uri(Constants.UrlMensa_Week_SBFMain, UriKind.Absolute);
|
||||
break;
|
||||
case '4':
|
||||
url = new Uri(Constants.UrlMensa_Week_CBMain, UriKind.Absolute);
|
||||
break;
|
||||
default:
|
||||
url = new Uri(Constants.UrlMensa_Week_CBMain, UriKind.Absolute);
|
||||
break;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
private void HandleMensaTask(ScheduledTask task)
|
||||
{
|
||||
if (this.mensaModel == null || !this.CheckMensaIsUpToDate(this.mensaModel.CreateTime))
|
||||
{
|
||||
HttpRequest api = new HttpRequest();
|
||||
Uri url = this.CalcMensaUrl(task.Description);
|
||||
api.HttpGet(url, this.GetMensaIsReady);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.updateMensaTile();
|
||||
}
|
||||
}
|
||||
|
||||
private void GetMensaIsReady(object arg1, System.Net.DownloadStringCompletedEventArgs arg2)
|
||||
{
|
||||
if (arg2.Result != null)
|
||||
{
|
||||
this.mensaModel = XmlManager.DeserializationToModel<MenuWeekModel>(arg2.Result, Constants.XMLRootElementName);
|
||||
this.updateMensaTile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateMensaTile()
|
||||
{
|
||||
ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(Constants.PathMensa_MensaPage));
|
||||
|
||||
if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains(Constants.PathMensa_MensaPage))
|
||||
{
|
||||
IconicTileData data = new IconicTileData();
|
||||
DateTime now = DateTime.Now;
|
||||
int dayIndex = (int)DateTime.Now.DayOfWeek;
|
||||
data.WideContent1 = CultureInfo.CurrentCulture.DateTimeFormat.DayNames[dayIndex];
|
||||
data.WideContent2 = now.Date.ToShortDateString();
|
||||
if (dayIndex == 0 || dayIndex > this.mensaModel.Menus.Count)
|
||||
{
|
||||
data.WideContent3 = AppResources.MensaApp_CloseMensa;
|
||||
}
|
||||
else
|
||||
{
|
||||
// correct index (week sart with monday not sunday
|
||||
dayIndex--;
|
||||
int mealCount = this.mensaModel.Menus[dayIndex].Meals.Count;
|
||||
if (mealCount < 1)
|
||||
{
|
||||
data.WideContent3 = AppResources.MensaApp_CloseMensa;
|
||||
}
|
||||
else
|
||||
{
|
||||
Random random = new Random();
|
||||
int randomNumber = random.Next(0, mealCount);
|
||||
data.WideContent3 = this.mensaModel.Menus[dayIndex].Meals[randomNumber].MealToShortString();
|
||||
data.Count = this.mensaModel.Menus[dayIndex].Meals.Count;
|
||||
}
|
||||
}
|
||||
TileToFind.Update(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
BackgroundTasks.StopPerodicTask(Constants.BackgroundTask_Mensa);
|
||||
}
|
||||
this.NotifyComplete();
|
||||
}
|
||||
|
||||
|
||||
private bool CheckMensaIsUpToDate(DateTime lastModified)
|
||||
{
|
||||
int diff = lastModified.CompareTo(MenuWeekModel.CalcFirstWeekDay());
|
||||
|
||||
if (diff < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool CheckRssIsUpToDate(DateTime lastModified)
|
||||
{
|
||||
int diff = lastModified.CompareTo(DateTime.Now.AddDays(1));
|
||||
|
||||
if (diff < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using CampusAppWP8ScheduledTaskAgent.Resources;
|
||||
using Microsoft.Phone.Scheduler;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CampusAppWP8ScheduledTaskAgent.Utility
|
||||
{
|
||||
public class BackgroundTasks
|
||||
{
|
||||
public static void StartPerodicTask(string taskName, string taskDesc) {
|
||||
BackgroundTasks.StopPerodicTask(taskName);
|
||||
|
||||
PeriodicTask periodicTask = new PeriodicTask(taskName);
|
||||
// load description from localized strings
|
||||
periodicTask.Description = taskDesc;
|
||||
|
||||
try
|
||||
{
|
||||
ScheduledActionService.Add(periodicTask);
|
||||
|
||||
//ScheduledActionService.LaunchForTest(taskName, TimeSpan.FromSeconds(10));
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void StopPerodicTask(string taskName)
|
||||
{
|
||||
PeriodicTask periodicTask = ScheduledActionService.Find(taskName) as PeriodicTask;
|
||||
if (periodicTask != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
ScheduledActionService.Remove(taskName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,16 @@ namespace CampusAppWP8ScheduledTaskAgent.Utility
|
||||
{
|
||||
return str.TrimEnd('\n');
|
||||
}
|
||||
|
||||
public static string ToShortString(string longStr, int maxLenght)
|
||||
{
|
||||
string shortStr = longStr;
|
||||
if (shortStr.Length > maxLenght)
|
||||
{
|
||||
shortStr = shortStr.Substring(0, maxLenght);
|
||||
}
|
||||
return shortStr;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,10 +39,7 @@
|
||||
<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