add placeNews

This commit is contained in:
stubbfel
2013-09-09 18:39:55 +02:00
parent 0e2fa07a5b
commit fcb5b6a62f
18 changed files with 1037 additions and 6 deletions

View File

@@ -0,0 +1,56 @@
//-----------------------------------------------------------------------
// <copyright file="PisApi.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>09.09.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Api.GeoApi
{
using System.Collections.Generic;
using CampusAppWP8.Model;
using CampusAppWP8.Model.GeoDb;
using CampusAppWP8.Model.Utility;
using CampusAppWP8.Resources;
/// <summary>Pis api.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
public class PisApi : XmlModel<SpsModel>
{
/// <summary>Initializes a new instance of the PisApi class.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
public PisApi()
: base(ModelType.Feed, Constants.UrlPisService)
{
}
/// <summary>Sets up the information request.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="pidList"> List of pids.</param>
/// <param name="infoNames">(Optional) list of names of the informations.</param>
public void SetupInformationRequest(List<string> pidList, List<string> infoNames = null)
{
string pidListStr = string.Empty;
foreach (string pid in pidList)
{
pidListStr += "/" + pid;
}
List<UrlParamModel> parameterList = new List<UrlParamModel>();
parameterList.Add(new CleanUrlParamModel(Constants.PisApi_PidListKey, pidListStr.Trim('/')));
if (infoNames != null)
{
string infoNamesStr = string.Empty;
foreach (string name in infoNames)
{
infoNamesStr += "/" + name;
}
parameterList.Add(new CleanUrlParamModel(Constants.PisApi_InformationNameKey, infoNamesStr.Trim('/')));
}
this.SetUriParams(parameterList);
}
}
}

View File

@@ -0,0 +1,56 @@
//-----------------------------------------------------------------------
// <copyright file="PssApi.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>09.09.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Api.GeoApi
{
using System.Collections.Generic;
using CampusAppWP8.Model;
using CampusAppWP8.Model.GeoDb;
using CampusAppWP8.Model.Utility;
using CampusAppWP8.Resources;
/// <summary>Pss api.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
public class PssApi : XmlModel<SpsModel>
{
/// <summary>Initializes a new instance of the PssApi class.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
public PssApi()
: base(ModelType.Feed, Constants.UrlPssService)
{
}
/// <summary>Sets up the service request.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="pidList"> List of pids.</param>
/// <param name="serviceNames">(Optional) list of names of the services.</param>
public void SetupServiceRequest(List<string> pidList, List<string> serviceNames = null)
{
string pidListStr = string.Empty;
foreach (string pid in pidList)
{
pidListStr += "/" + pid;
}
List<UrlParamModel> parameterList = new List<UrlParamModel>();
parameterList.Add(new CleanUrlParamModel(Constants.PssApi_PidListKey, pidListStr.Trim('/')));
if (serviceNames != null)
{
string serviceNamesStr = string.Empty;
foreach (string name in serviceNames)
{
serviceNamesStr += "/" + name;
}
parameterList.Add(new CleanUrlParamModel(Constants.PssApi_ServiceNameKey, serviceNamesStr.Trim('/')));
}
this.SetUriParams(parameterList);
}
}
}

View File

@@ -7,13 +7,12 @@
//----------------------------------------------------------------------
namespace CampusAppWP8.Api.GeoApi
{
using System;
using System.Collections.Generic;
using CampusAppWP8.Model;
using CampusAppWP8.Model.GeoDb;
using CampusAppWP8.Model.Utility;
using CampusAppWP8.Resources;
using CampusAppWP8.Utility;
using CampusAppWP8.Utility;
/// <summary>
/// Class for SPSAPI
@@ -46,5 +45,16 @@ namespace CampusAppWP8.Api.GeoApi
this.SetUriParams(parameterList);
}
/// <summary>Sets up the current place request.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="domian">(Optional) request domain.</param>
public void SetupCurrentPlaceRequest(string domian = null)
{
Utilities.DetermineAndStoreCurrentPosition();
string lat = App.LoadFromAppState<string>(Constants.GeoWatch_CurrentPosition_Lat);
string log = App.LoadFromAppState<string>(Constants.GeoWatch_CurrentPosition_Long);
this.SetupPlaceRequest(lat, log, domian);
}
}
}

View File

@@ -94,6 +94,8 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="Api\GeoApi\CampusSpsApi.cs" />
<Compile Include="Api\GeoApi\PisApi.cs" />
<Compile Include="Api\GeoApi\PssApi.cs" />
<Compile Include="Api\GeoApi\SpsApi.cs" />
<Compile Include="Api\Person\PersonSearchApi.cs" />
<Compile Include="App.xaml.cs">
@@ -107,6 +109,7 @@
<Compile Include="Feed\Mensa\MensaFeedCBNorth.cs" />
<Compile Include="Feed\Mensa\MensaFeedCBMain.cs" />
<Compile Include="File\Exams\ExamFile.cs" />
<Compile Include="File\Places\PlacesFile.cs" />
<Compile Include="Model\BinaryModel.cs" />
<Compile Include="Model\Campusmap\CBMainMapModel.cs" />
<Compile Include="Model\Campusmap\CurrentPositionPinModel.cs" />
@@ -134,6 +137,12 @@
<Compile Include="Pages\Person\PersonPage.xaml.cs">
<DependentUpon>PersonPage.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\PlaceNews\PlaceNews.xaml.cs">
<DependentUpon>PlaceNews.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\PlaceNews\ShowPad.xaml.cs">
<DependentUpon>ShowPad.xaml</DependentUpon>
</Compile>
<Compile Include="Utility\Lui\Button\AddPersonButton.cs" />
<Compile Include="Utility\NDEF\NDEFMessage.cs" />
<Compile Include="Utility\NDEF\NDEFRecord.cs" />
@@ -363,6 +372,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\PlaceNews\PlaceNews.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\PlaceNews\ShowPad.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\Setting\AppSettingPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@@ -0,0 +1,43 @@
//-----------------------------------------------------------------------
// <copyright file="PlacesFile.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>09.09.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.File.Places
{
using CampusAppWP8.Model;
using CampusAppWP8.Model.GeoDb;
using CampusAppWP8.Resources;
/// <summary>Places file.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
public class PlacesFile : XmlModel<SpsModel>
{
/// <summary>Initializes a new instance of the PlacesFile class.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
public PlacesFile()
: base(ModelType.File, Constants.FilePlace_AllPlaces)
{
this.IsFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate);
this.IsFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate);
}
/// <summary>Check is file up to date.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="model"> The model.</param>
/// <param name="fileInfo">Information describing the file.</param>
/// <returns>true if it succeeds, false if it fails.</returns>
private bool CheckIsFileUpToDate(SpsModel model, System.IO.FileInfo fileInfo)
{
if (fileInfo == null || !fileInfo.Exists || fileInfo.Length < 1)
{
return false;
}
return true;
}
}
}

View File

@@ -7,20 +7,35 @@
//----------------------------------------------------------------------
namespace CampusAppWP8.Model.GeoDb
{
using System;
using System.Xml.Serialization;
/// <summary>Information about the place.</summary>
/// <remarks>Stubbfel, 19.08.2013.</remarks>
public class PlaceInformation
public class PlaceInformation : IEquatable<PlaceInformation>
{
/// <summary>Gets or sets the name of the information.</summary>
/// <value>The name of the information.</value>
[XmlElement("placeInformationName")]
[XmlAttribute("placeInformationName")]
public string InformationName { get; set; }
/// <summary>Gets or sets the information value.</summary>
/// <value>The information value.</value>
[XmlText]
public string InformationValue { get; set; }
/// <summary>Tests if this PlaceInformation is considered equal to another.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="other">The place information to compare to this object.</param>
/// <returns>true if the objects are considered equal, false if they are not.</returns>
public bool Equals(PlaceInformation other)
{
if (other.InformationName.Equals(this.InformationName))
{
return true;
}
return false;
}
}
}

View File

@@ -9,6 +9,7 @@
namespace CampusAppWP8.Model.GeoDb
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Device.Location;
using System.Globalization;
@@ -20,7 +21,7 @@ namespace CampusAppWP8.Model.GeoDb
/// <summary>
/// Model for a place of the SPSService
/// </summary>
public class PlaceModel
public class PlaceModel : IEquatable<PlaceModel>
{
/// <summary>
/// Gets or sets the placeId
@@ -92,5 +93,112 @@ namespace CampusAppWP8.Model.GeoDb
string nfcStr = "{\"pid\":\"" + this.PlaceId + "\",\"parent\":\"" + this.ParentId + "\"}";
return nfcStr;
}
/// <summary>Tests if this PlaceModel is considered equal to another.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="other">The place model to compare to this object.</param>
/// <returns>true if the objects are considered equal, false if they are not.</returns>
public bool Equals(PlaceModel other)
{
if (other.PlaceId.Equals(this.PlaceId))
{
return true;
}
return false;
}
/// <summary>Adds a place informations.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="placeInformations">The place informations.</param>
public void AddPlaceInformations(List<PlaceInformation> placeInformations)
{
foreach (PlaceInformation info in placeInformations)
{
if (this.Informations.Contains(info))
{
int index = this.Informations.IndexOf(info);
this.Informations[index].InformationValue = info.InformationValue;
}
else
{
this.Informations.Add(info);
}
}
}
/// <summary>Adds a place services.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="placeServices">The place services.</param>
public void AddPlaceServices(List<PlaceService> placeServices)
{
foreach (PlaceService service in placeServices)
{
if (this.Services.Contains(service))
{
int index = this.Services.IndexOf(service);
this.Services[index].Request = service.Request;
this.Services[index].SAP = service.SAP;
}
else
{
this.Services.Add(service);
}
}
}
/// <summary>Query if 'names' contains information names.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="names">The names.</param>
/// <returns>true if it succeeds, false if it fails.</returns>
public bool ContainsInformationNames(List<string> names)
{
foreach (string name in names)
{
bool tmpResult = false;
foreach (PlaceInformation info in this.Informations)
{
if (name.Equals(info.InformationName))
{
tmpResult = true;
break;
}
}
if (!tmpResult)
{
return tmpResult;
}
}
return true;
}
/// <summary>Query if 'services' contains service names.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="services">The services.</param>
/// <returns>true if it succeeds, false if it fails.</returns>
public bool ContainsServiceNames(List<string> services)
{
foreach (string name in services)
{
bool tmpResult = false;
foreach (PlaceService service in this.Services)
{
if (name.Equals(service.ServiceName))
{
tmpResult = true;
break;
}
}
if (!tmpResult)
{
return tmpResult;
}
}
return true;
}
}
}

View File

@@ -8,11 +8,12 @@
namespace CampusAppWP8.Model.GeoDb
{
using System;
using System.Xml.Serialization;
/// <summary>Place service.</summary>
/// <remarks>Stubbfel, 19.08.2013.</remarks>
public class PlaceService
public class PlaceService : IEquatable<PlaceService>
{
/// <summary>Gets or sets the name of the service.</summary>
/// <value>The name of the service.</value>
@@ -28,5 +29,29 @@ namespace CampusAppWP8.Model.GeoDb
/// <value>The request.</value>
[XmlElement("request")]
public string Request { get; set; }
/// <summary>Gets the URL string.</summary>
/// <value>The URL string.</value>
public string URLString
{
get
{
return this.SAP + this.Request;
}
}
/// <summary>Tests if this PlaceService is considered equal to another.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="other">The place service to compare to this object.</param>
/// <returns>true if the objects are considered equal, false if they are not.</returns>
public bool Equals(PlaceService other)
{
if (other.ServiceName.Equals(this.ServiceName))
{
return true;
}
return false;
}
}
}

View File

@@ -83,5 +83,94 @@ namespace CampusAppWP8.Model.GeoDb
return resultplaces.ToList<PlaceModel>();
}
/// <summary>Adds the places.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="places">A list of places.</param>
public void AddPlaces(List<PlaceModel> places)
{
foreach (PlaceModel place in places)
{
if (this.Places.Contains(place))
{
int index = this.Places.IndexOf(place);
this.Places[index].AddPlaceInformations(place.Informations.ToList());
this.Places[index].AddPlaceServices(place.Services.ToList());
}
else
{
this.Places.Add(place);
}
}
}
/// <summary>Creates PID list.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <returns>The new PID list.</returns>
public List<string> CreatePidList()
{
List<string> pidList = new List<string>();
foreach (PlaceModel place in this.Places)
{
pidList.Add(place.PlaceId);
}
return pidList;
}
/// <summary>Gets place by identifier.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="id">The identifier.</param>
/// <returns>The place by identifier.</returns>
public PlaceModel GetPlaceById(string id)
{
foreach (PlaceModel place in this.Places)
{
if (place.PlaceId.Equals(id))
{
return place;
}
}
return null;
}
/// <summary>Query if 'pidList' contains information names.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="pidList">List of pids.</param>
/// <param name="names"> The names.</param>
/// <returns>true if it succeeds, false if it fails.</returns>
public bool ContainsInformationNames(List<string> pidList, List<string> names)
{
foreach (string pid in pidList)
{
PlaceModel place = this.GetPlaceById(pid);
if (!place.ContainsInformationNames(names))
{
return false;
}
}
return true;
}
/// <summary>Query if 'pidList' contains service names.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="pidList">List of pids.</param>
/// <param name="names"> The names.</param>
/// <returns>true if it succeeds, false if it fails.</returns>
public bool ContainsServiceNames(List<string> pidList, List<string> names)
{
foreach (string pid in pidList)
{
PlaceModel place = this.GetPlaceById(pid);
if (!place.ContainsServiceNames(names))
{
return false;
}
}
return true;
}
}
}

View File

@@ -0,0 +1,60 @@
<phone:PhoneApplicationPage
x:Class="CampusAppWP8.Pages.PlaceNews.PlaceNews"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:lui="clr-namespace:CampusAppWP8.Utility.Lui.Button"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot ist das Stammraster, in dem alle anderen Seiteninhalte platziert werden-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ProgressBar Name="ProgressBar" Grid.Row="1" Visibility="Collapsed" IsIndeterminate="True"/>
<!--TitlePanel enthält den Namen der Anwendung und den Seitentitel-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="{Binding Path=LocalizedResources.PlaceNewsApp_Title, Source={StaticResource LocalizedStrings}}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle2Style}"/>
</StackPanel>
<!--ContentPanel - zusätzliche Inhalte hier platzieren-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ListBox x:Name="ResultBox">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<lui:NavigateButton Url="{Binding Path=Constants.PathPlaceNews_ShowPadPage, Source={StaticResource Const}}" QuerryStringValue="{Binding PlaceId}" QuerryStringName="{Binding Path=Constants.ParamPlaceID, Source={StaticResource Const}}" Style="{StaticResource ListButtonStyle}">
<TextBlock Text="{Binding Informations[0].InformationValue}"/>
</lui:NavigateButton>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Grid>
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" Mode="Minimized" >
<lui:UpdateButtonAppBar Click="UpdateButtonAppBar_Click"/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="Scan QR-Code" Click="ApplicationBarMenuItem_Click"/>
<shell:ApplicationBarMenuItem Text="Scan NFC-Tag" Click="ApplicationBarMenuItem_Click_1"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
</phone:PhoneApplicationPage>

View File

@@ -0,0 +1,271 @@
//-----------------------------------------------------------------------
// <copyright file="PlaceNews.xaml.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>09.09.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Pages.PlaceNews
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Windows;
using System.Windows.Navigation;
using CampusAppWP8.Api.GeoApi;
using CampusAppWP8.File.Places;
using CampusAppWP8.Model.GeoDb;
using CampusAppWP8.Resources;
using CampusAppWP8.Utility;
using CampusAppWP8.Utility.Lui.MessageBoxes;
using Microsoft.Phone.Controls;
/// <summary>Place news.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
public partial class PlaceNews : PhoneApplicationPage
{
/// <summary>The sps API.</summary>
private SpsApi spsApi;
/// <summary>The pis API.</summary>
private PisApi pisApi;
/// <summary>The pss API.</summary>
private PssApi pssApi;
/// <summary>The places.</summary>
private PlacesFile places;
/// <summary>varaible indicates how many apis are running.</summary>
private int waitForApi;
/// <summary>true to force reqest.</summary>
private bool forceReqest;
/// <summary>Initializes a new instance of the PlaceNews class.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
public PlaceNews()
{
this.InitializeComponent();
this.waitForApi = 0;
}
/// <summary>Wird aufgerufen, wenn eine Seite die aktive Seite in einem Frame wird.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="e">Ein Objekt, das die Ereignisdaten enthält.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (NavigationMode.Back == e.NavigationMode && this.places == null)
{
this.places = new PlacesFile();
this.places.Model = App.LoadFromIsolatedStorage<SpsModel>(Constants.IsolatedStorage_AllPlaces);
this.SetupResultBox();
}
else
{
this.InitializeApi();
}
}
/// <summary>
/// Wird aufgerufen, wenn eine Seite nicht mehr die aktive Seite in einem Frame ist.
/// </summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="e">Ein Objekt, das die Ereignisdaten enthält.</param>
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
if (NavigationMode.Back == e.NavigationMode)
{
App.SaveToIsolatedStorage<SpsModel>(Constants.IsolatedStorage_AllPlaces, null);
}
}
/// <summary>Initializes the API.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
private void InitializeApi()
{
// init place file
if (this.places == null)
{
this.places = new PlacesFile();
this.places.OnLoaded += new PlacesFile.OnIO(this.PlacesFileIsReady);
this.places.OnFailedLoad += new PlacesFile.OnFailed(this.PlacesFileIsFail);
this.places.LoadData();
}
// init sps API
if (this.spsApi == null || this.forceReqest)
{
this.spsApi = new SpsApi();
this.spsApi.OnLoaded += new SpsApi.OnIO(this.SpsApiIsReady);
this.spsApi.OnFailedLoad += new SpsApi.OnFailed(this.ApiIsFail);
this.spsApi.SetupCurrentPlaceRequest(Constants.SpsDomain_Buildings);
this.ProgressBar.Visibility = System.Windows.Visibility.Visible;
if (this.places.Model != null)
{
this.spsApi.LoadData();
this.waitForApi++;
}
}
// init pis API
if (this.pisApi == null || this.forceReqest)
{
this.pisApi = new PisApi();
this.pisApi.OnLoaded += new PisApi.OnIO(this.PisApiIsReady);
this.pisApi.OnFailedLoad += new PisApi.OnFailed(this.ApiIsFail);
}
// init pss Api
if (this.pssApi == null || this.forceReqest)
{
this.pssApi = new PssApi();
this.pssApi.OnLoaded += new PssApi.OnIO(this.PssApiIsReady);
this.pssApi.OnFailedLoad += new PssApi.OnFailed(this.ApiIsFail);
}
}
/// <summary>Places file is fail.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
private void PlacesFileIsFail()
{
this.places.Model = new SpsModel();
if (this.spsApi != null)
{
this.spsApi.LoadData();
this.waitForApi++;
}
}
/// <summary>Places file is ready.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
private void PlacesFileIsReady()
{
if (this.spsApi != null)
{
this.spsApi.LoadData();
this.waitForApi++;
}
}
/// <summary>Pss API is ready.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
private void PssApiIsReady()
{
this.waitForApi--;
this.places.Model.AddPlaces(this.pssApi.Model.Places.ToList());
if (this.waitForApi < 1)
{
this.SetupResultBox();
}
}
/// <summary>Pis API is ready.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
private void PisApiIsReady()
{
this.waitForApi--;
this.places.Model.AddPlaces(this.pisApi.Model.Places.ToList());
if (this.waitForApi < 1)
{
this.SetupResultBox();
}
}
/// <summary>API is fail.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
private void ApiIsFail()
{
if (this.Dispatcher != null)
{
this.Dispatcher.BeginInvoke(new Action(() => MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadWeb)));
}
}
/// <summary>Sps API is ready.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
private void SpsApiIsReady()
{
this.waitForApi--;
this.places.Model.AddPlaces(this.spsApi.Model.Places.ToList());
List<string> pidlist = this.spsApi.Model.CreatePidList();
List<string> infoNames = new List<string>() { Constants.PisInformationName_Name };
List<string> serviceNames = new List<string>() { Constants.PssServiceName_PlaceNews };
this.ProgressBar.Visibility = System.Windows.Visibility.Visible;
// load from pis api
if (this.forceReqest || !this.places.Model.ContainsInformationNames(pidlist, infoNames))
{
this.pisApi.SetupInformationRequest(pidlist, infoNames);
this.pisApi.LoadData();
this.waitForApi++;
}
// load from pis api
if (this.forceReqest || !this.places.Model.ContainsServiceNames(pidlist, serviceNames))
{
this.pssApi.SetupServiceRequest(pidlist, serviceNames);
this.pssApi.LoadData();
this.waitForApi++;
}
if (this.waitForApi < 1)
{
this.SetupResultBox();
}
}
/// <summary>Sets up the result box.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
private void SetupResultBox()
{
this.ResultBox.ItemsSource = this.places.Model.Places;
this.ProgressBar.Visibility = Visibility.Collapsed;
this.places.SaveData();
App.SaveToIsolatedStorage<SpsModel>(Constants.IsolatedStorage_AllPlaces, this.places.Model);
this.forceReqest = false;
}
/// <summary>Event handler. Called by UpdateButtonAppBar for click events.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="sender">Source of the event.</param>
/// <param name="e"> Event information.</param>
private void UpdateButtonAppBar_Click(object sender, EventArgs e)
{
this.ProgressBar.Visibility = Visibility.Visible;
Thread thread = new Thread(delegate() { this.InitApiCurrentPositionForce(); });
thread.Start();
}
/// <summary>Initialises the API current position force.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
private void InitApiCurrentPositionForce()
{
Utilities.DetermineAndStoreCurrentPositionForce();
this.forceReqest = true;
this.Dispatcher.BeginInvoke(new Action(() => this.InitializeApi()));
}
/// <summary>Event handler. Called by ApplicationBarMenuItem for click events.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="sender">Source of the event.</param>
/// <param name="e"> Event information.</param>
private void ApplicationBarMenuItem_Click(object sender, EventArgs e)
{
}
/// <summary>Event handler. Called by ApplicationBarMenuItem_Click for 1 events.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="sender">Source of the event.</param>
/// <param name="e"> Event information.</param>
private void ApplicationBarMenuItem_Click_1(object sender, EventArgs e)
{
}
}
}

View File

@@ -0,0 +1,35 @@
<phone:PhoneApplicationPage
x:Class="CampusAppWP8.Pages.PlaceNews.ShowPad"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot ist das Stammraster, in dem alle anderen Seiteninhalte platziert werden-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel enthält den Namen der Anwendung und den Seitentitel-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Name="Room" Text="{Binding Path=LocalizedResources.PlaceNewsApp_Title, Source={StaticResource LocalizedStrings}}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle2Style}"/>
</StackPanel>
<!--ContentPanel - zusätzliche Inhalte hier platzieren-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<phone:WebBrowser x:Name="WebmailBrowser" IsScriptEnabled="True"/>
</Grid>
</Grid>
</phone:PhoneApplicationPage>

View File

@@ -0,0 +1,48 @@
//-----------------------------------------------------------------------
// <copyright file="ShowPad.xaml.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>09.09.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Pages.PlaceNews
{
using System;
using System.Windows.Navigation;
using CampusAppWP8.Model.GeoDb;
using CampusAppWP8.Resources;
using Microsoft.Phone.Controls;
/// <summary>Show pad.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
public partial class ShowPad : PhoneApplicationPage
{
/// <summary>Initializes a new instance of the ShowPad class.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
public ShowPad()
{
InitializeComponent();
}
/// <summary>Wird aufgerufen, wenn eine Seite die aktive Seite in einem Frame wird.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
/// <param name="e">Ein Objekt, das die Ereignisdaten enthält.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (NavigationContext.QueryString.ContainsKey(Constants.ParamPlaceID))
{
SpsModel model = App.LoadFromIsolatedStorage<SpsModel>(Constants.IsolatedStorage_AllPlaces);
string placeId = NavigationContext.QueryString[Constants.ParamPlaceID];
PlaceModel place = model.GetPlaceById(placeId);
if (place != null && place.Services != null && place.Services.Count > 0 && place.Informations != null && place.Informations.Count > 0)
{
this.Room.Text += " - " + place.Informations[0].InformationValue;
this.WebmailBrowser.Navigate(new Uri(place.Services[0].URLString, UriKind.Absolute));
}
}
base.OnNavigatedTo(e);
}
}
}

View File

@@ -181,6 +181,12 @@
<TextBlock Name="personAppButtonText" Text="{Binding Path=LocalizedResources.PersonApp_Title, Source={StaticResource LocalizedStrings}}" Style="{StaticResource StartPageButtonText}"/>
</StackPanel>
</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>
</lui:NavigateButton>
</Grid>
</StackPanel>

View File

@@ -753,6 +753,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Placenews ähnelt.
/// </summary>
public static string PlaceNewsApp_Title {
get {
return ResourceManager.GetString("PlaceNewsApp_Title", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Die primäre Kamera steht nicht zur Verfügung. ähnelt.
/// </summary>

View File

@@ -443,4 +443,7 @@
<data name="PersonApp_SearchTextLabel" xml:space="preserve">
<value>Nachname</value>
</data>
<data name="PlaceNewsApp_Title" xml:space="preserve">
<value>Placenews</value>
</data>
</root>

View File

@@ -339,6 +339,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die allPlaces.xml ähnelt.
/// </summary>
public static string FilePlace_AllPlaces {
get {
return ResourceManager.GetString("FilePlace_AllPlaces", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die user.xml ähnelt.
/// </summary>
@@ -384,6 +393,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die AllPlaces ähnelt.
/// </summary>
public static string IsolatedStorage_AllPlaces {
get {
return ResourceManager.GetString("IsolatedStorage_AllPlaces", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die IsolatedStorage_DepartmentFavoriteModel ähnelt.
/// </summary>
@@ -627,6 +645,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die placeId ähnelt.
/// </summary>
public static string ParamPlaceID {
get {
return ResourceManager.GetString("ParamPlaceID", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Url ähnelt.
/// </summary>
@@ -807,6 +834,24 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die /Pages/PlaceNews/PlaceNews.xaml ähnelt.
/// </summary>
public static string PathPlaceNews_PlaceNewsPage {
get {
return ResourceManager.GetString("PathPlaceNews_PlaceNewsPage", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die /Pages/PlaceNews/ShowPad.xaml ähnelt.
/// </summary>
public static string PathPlaceNews_ShowPadPage {
get {
return ResourceManager.GetString("PathPlaceNews_ShowPadPage", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die /Pages/Setting/AppSettingPage.xaml ähnelt.
/// </summary>
@@ -843,6 +888,69 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die iname ähnelt.
/// </summary>
public static string PisApi_InformationNameKey {
get {
return ResourceManager.GetString("PisApi_InformationNameKey", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die pid ähnelt.
/// </summary>
public static string PisApi_PidListKey {
get {
return ResourceManager.GetString("PisApi_PidListKey", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die name ähnelt.
/// </summary>
public static string PisInformationName_Name {
get {
return ResourceManager.GetString("PisInformationName_Name", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die typ ähnelt.
/// </summary>
public static string PisInformationName_Typ {
get {
return ResourceManager.GetString("PisInformationName_Typ", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die pid ähnelt.
/// </summary>
public static string PssApi_PidListKey {
get {
return ResourceManager.GetString("PssApi_PidListKey", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die sname ähnelt.
/// </summary>
public static string PssApi_ServiceNameKey {
get {
return ResourceManager.GetString("PssApi_ServiceNameKey", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die PlaceNews ähnelt.
/// </summary>
public static string PssServiceName_PlaceNews {
get {
return ResourceManager.GetString("PssServiceName_PlaceNews", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die [+-]{0,1}[0-9]+[.,]{0,1}[0-9]+[\s][+-]{0,1}[0-9]+[.,]{0,1}[0-9]+ ähnelt.
/// </summary>
@@ -906,6 +1014,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die 1 ähnelt.
/// </summary>
public static string SpsDomain_Buildings {
get {
return ResourceManager.GetString("SpsDomain_Buildings", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die ToggleContent ähnelt.
/// </summary>
@@ -1050,6 +1167,24 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die http://141.43.76.140/service/pis ähnelt.
/// </summary>
public static string UrlPisService {
get {
return ResourceManager.GetString("UrlPisService", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die http://141.43.76.140/service/pss ähnelt.
/// </summary>
public static string UrlPssService {
get {
return ResourceManager.GetString("UrlPssService", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die http://141.43.76.140/service/sps ähnelt.
/// </summary>

View File

@@ -483,4 +483,49 @@
<data name="ParamPersonList" xml:space="preserve">
<value>Uebersicht</value>
</data>
<data name="FilePlace_AllPlaces" xml:space="preserve">
<value>allPlaces.xml</value>
</data>
<data name="IsolatedStorage_AllPlaces" xml:space="preserve">
<value>AllPlaces</value>
</data>
<data name="ParamPlaceID" xml:space="preserve">
<value>placeId</value>
</data>
<data name="PathPlaceNews_PlaceNewsPage" xml:space="preserve">
<value>/Pages/PlaceNews/PlaceNews.xaml</value>
</data>
<data name="PathPlaceNews_ShowPadPage" xml:space="preserve">
<value>/Pages/PlaceNews/ShowPad.xaml</value>
</data>
<data name="PisApi_InformationNameKey" xml:space="preserve">
<value>iname</value>
</data>
<data name="PisApi_PidListKey" xml:space="preserve">
<value>pid</value>
</data>
<data name="PisInformationName_Name" xml:space="preserve">
<value>name</value>
</data>
<data name="PisInformationName_Typ" xml:space="preserve">
<value>typ</value>
</data>
<data name="PssApi_PidListKey" xml:space="preserve">
<value>pid</value>
</data>
<data name="PssApi_ServiceNameKey" xml:space="preserve">
<value>sname</value>
</data>
<data name="PssServiceName_PlaceNews" xml:space="preserve">
<value>PlaceNews</value>
</data>
<data name="SpsDomain_Buildings" xml:space="preserve">
<value>1</value>
</data>
<data name="UrlPisService" xml:space="preserve">
<value>http://141.43.76.140/service/pis</value>
</data>
<data name="UrlPssService" xml:space="preserve">
<value>http://141.43.76.140/service/pss</value>
</data>
</root>