From fcb5b6a62f9e398bda7f6b8ce29a00baa58e4e98 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Mon, 9 Sep 2013 18:39:55 +0200 Subject: [PATCH] add placeNews --- .../CampusAppWP8/Api/GeoApi/PisApi.cs | 56 ++++ .../CampusAppWP8/Api/GeoApi/PssApi.cs | 56 ++++ .../CampusAppWP8/Api/GeoApi/SpsApi.cs | 14 +- CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 17 ++ .../CampusAppWP8/File/Places/PlacesFile.cs | 43 +++ .../Model/GeoDb/PlaceInformation.cs | 19 +- .../CampusAppWP8/Model/GeoDb/PlaceModel.cs | 110 ++++++- .../CampusAppWP8/Model/GeoDb/PlaceService.cs | 27 +- .../CampusAppWP8/Model/GeoDb/SpsModel.cs | 89 ++++++ .../Pages/PlaceNews/PlaceNews.xaml | 60 ++++ .../Pages/PlaceNews/PlaceNews.xaml.cs | 271 ++++++++++++++++++ .../CampusAppWP8/Pages/PlaceNews/ShowPad.xaml | 35 +++ .../Pages/PlaceNews/ShowPad.xaml.cs | 48 ++++ .../CampusAppWP8/Pages/StartPage.xaml | 6 + .../Resources/AppResources.Designer.cs | 9 + .../CampusAppWP8/Resources/AppResources.resx | 3 + .../Resources/Constants.Designer.cs | 135 +++++++++ .../CampusAppWP8/Resources/Constants.resx | 45 +++ 18 files changed, 1037 insertions(+), 6 deletions(-) create mode 100644 CampusAppWP8/CampusAppWP8/Api/GeoApi/PisApi.cs create mode 100644 CampusAppWP8/CampusAppWP8/Api/GeoApi/PssApi.cs create mode 100644 CampusAppWP8/CampusAppWP8/File/Places/PlacesFile.cs create mode 100644 CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml create mode 100644 CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs create mode 100644 CampusAppWP8/CampusAppWP8/Pages/PlaceNews/ShowPad.xaml create mode 100644 CampusAppWP8/CampusAppWP8/Pages/PlaceNews/ShowPad.xaml.cs diff --git a/CampusAppWP8/CampusAppWP8/Api/GeoApi/PisApi.cs b/CampusAppWP8/CampusAppWP8/Api/GeoApi/PisApi.cs new file mode 100644 index 00000000..c527c94e --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Api/GeoApi/PisApi.cs @@ -0,0 +1,56 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 09.09.2013 +//---------------------------------------------------------------------- + +namespace CampusAppWP8.Api.GeoApi +{ + using System.Collections.Generic; + using CampusAppWP8.Model; + using CampusAppWP8.Model.GeoDb; + using CampusAppWP8.Model.Utility; + using CampusAppWP8.Resources; + + /// Pis api. + /// Stubbfel, 09.09.2013. + public class PisApi : XmlModel + { + /// Initializes a new instance of the PisApi class. + /// Stubbfel, 09.09.2013. + public PisApi() + : base(ModelType.Feed, Constants.UrlPisService) + { + } + + /// Sets up the information request. + /// Stubbfel, 09.09.2013. + /// List of pids. + /// (Optional) list of names of the informations. + public void SetupInformationRequest(List pidList, List infoNames = null) + { + string pidListStr = string.Empty; + foreach (string pid in pidList) + { + pidListStr += "/" + pid; + } + + List parameterList = new List(); + 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); + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Api/GeoApi/PssApi.cs b/CampusAppWP8/CampusAppWP8/Api/GeoApi/PssApi.cs new file mode 100644 index 00000000..c90e157b --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Api/GeoApi/PssApi.cs @@ -0,0 +1,56 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 09.09.2013 +//---------------------------------------------------------------------- + +namespace CampusAppWP8.Api.GeoApi +{ + using System.Collections.Generic; + using CampusAppWP8.Model; + using CampusAppWP8.Model.GeoDb; + using CampusAppWP8.Model.Utility; + using CampusAppWP8.Resources; + + /// Pss api. + /// Stubbfel, 09.09.2013. + public class PssApi : XmlModel + { + /// Initializes a new instance of the PssApi class. + /// Stubbfel, 09.09.2013. + public PssApi() + : base(ModelType.Feed, Constants.UrlPssService) + { + } + + /// Sets up the service request. + /// Stubbfel, 09.09.2013. + /// List of pids. + /// (Optional) list of names of the services. + public void SetupServiceRequest(List pidList, List serviceNames = null) + { + string pidListStr = string.Empty; + foreach (string pid in pidList) + { + pidListStr += "/" + pid; + } + + List parameterList = new List(); + 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); + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Api/GeoApi/SpsApi.cs b/CampusAppWP8/CampusAppWP8/Api/GeoApi/SpsApi.cs index 3bef6f90..217f192b 100644 --- a/CampusAppWP8/CampusAppWP8/Api/GeoApi/SpsApi.cs +++ b/CampusAppWP8/CampusAppWP8/Api/GeoApi/SpsApi.cs @@ -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; /// /// Class for SPSAPI @@ -46,5 +45,16 @@ namespace CampusAppWP8.Api.GeoApi this.SetUriParams(parameterList); } + + /// Sets up the current place request. + /// Stubbfel, 09.09.2013. + /// (Optional) request domain. + public void SetupCurrentPlaceRequest(string domian = null) + { + Utilities.DetermineAndStoreCurrentPosition(); + string lat = App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Lat); + string log = App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Long); + this.SetupPlaceRequest(lat, log, domian); + } } } diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index a6d11552..69ec4569 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -94,6 +94,8 @@ + + @@ -107,6 +109,7 @@ + @@ -134,6 +137,12 @@ PersonPage.xaml + + PlaceNews.xaml + + + ShowPad.xaml + @@ -363,6 +372,14 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/CampusAppWP8/CampusAppWP8/File/Places/PlacesFile.cs b/CampusAppWP8/CampusAppWP8/File/Places/PlacesFile.cs new file mode 100644 index 00000000..ea62725b --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/File/Places/PlacesFile.cs @@ -0,0 +1,43 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 09.09.2013 +//---------------------------------------------------------------------- + +namespace CampusAppWP8.File.Places +{ + using CampusAppWP8.Model; + using CampusAppWP8.Model.GeoDb; +using CampusAppWP8.Resources; + + /// Places file. + /// Stubbfel, 09.09.2013. + public class PlacesFile : XmlModel + { + /// Initializes a new instance of the PlacesFile class. + /// Stubbfel, 09.09.2013. + public PlacesFile() + : base(ModelType.File, Constants.FilePlace_AllPlaces) + { + this.IsFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate); + this.IsFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate); + } + + /// Check is file up to date. + /// Stubbfel, 09.09.2013. + /// The model. + /// Information describing the file. + /// true if it succeeds, false if it fails. + private bool CheckIsFileUpToDate(SpsModel model, System.IO.FileInfo fileInfo) + { + if (fileInfo == null || !fileInfo.Exists || fileInfo.Length < 1) + { + return false; + } + + return true; + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceInformation.cs b/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceInformation.cs index ee09ea34..55c50d24 100644 --- a/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceInformation.cs +++ b/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceInformation.cs @@ -7,20 +7,35 @@ //---------------------------------------------------------------------- namespace CampusAppWP8.Model.GeoDb { + using System; using System.Xml.Serialization; /// Information about the place. /// Stubbfel, 19.08.2013. - public class PlaceInformation + public class PlaceInformation : IEquatable { /// Gets or sets the name of the information. /// The name of the information. - [XmlElement("placeInformationName")] + [XmlAttribute("placeInformationName")] public string InformationName { get; set; } /// Gets or sets the information value. /// The information value. [XmlText] public string InformationValue { get; set; } + + /// Tests if this PlaceInformation is considered equal to another. + /// Stubbfel, 09.09.2013. + /// The place information to compare to this object. + /// true if the objects are considered equal, false if they are not. + public bool Equals(PlaceInformation other) + { + if (other.InformationName.Equals(this.InformationName)) + { + return true; + } + + return false; + } } } diff --git a/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs b/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs index 0a2ed4c2..463bcd89 100644 --- a/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceModel.cs @@ -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 /// /// Model for a place of the SPSService /// - public class PlaceModel + public class PlaceModel : IEquatable { /// /// Gets or sets the placeId @@ -92,5 +93,112 @@ namespace CampusAppWP8.Model.GeoDb string nfcStr = "{\"pid\":\"" + this.PlaceId + "\",\"parent\":\"" + this.ParentId + "\"}"; return nfcStr; } + + /// Tests if this PlaceModel is considered equal to another. + /// Stubbfel, 09.09.2013. + /// The place model to compare to this object. + /// true if the objects are considered equal, false if they are not. + public bool Equals(PlaceModel other) + { + if (other.PlaceId.Equals(this.PlaceId)) + { + return true; + } + + return false; + } + + /// Adds a place informations. + /// Stubbfel, 09.09.2013. + /// The place informations. + public void AddPlaceInformations(List 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); + } + } + } + + /// Adds a place services. + /// Stubbfel, 09.09.2013. + /// The place services. + public void AddPlaceServices(List 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); + } + } + } + + /// Query if 'names' contains information names. + /// Stubbfel, 09.09.2013. + /// The names. + /// true if it succeeds, false if it fails. + public bool ContainsInformationNames(List 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; + } + + /// Query if 'services' contains service names. + /// Stubbfel, 09.09.2013. + /// The services. + /// true if it succeeds, false if it fails. + public bool ContainsServiceNames(List 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; + } } } diff --git a/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceService.cs b/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceService.cs index f0a22000..303c760c 100644 --- a/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceService.cs +++ b/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceService.cs @@ -8,11 +8,12 @@ namespace CampusAppWP8.Model.GeoDb { + using System; using System.Xml.Serialization; /// Place service. /// Stubbfel, 19.08.2013. - public class PlaceService + public class PlaceService : IEquatable { /// Gets or sets the name of the service. /// The name of the service. @@ -28,5 +29,29 @@ namespace CampusAppWP8.Model.GeoDb /// The request. [XmlElement("request")] public string Request { get; set; } + + /// Gets the URL string. + /// The URL string. + public string URLString + { + get + { + return this.SAP + this.Request; + } + } + + /// Tests if this PlaceService is considered equal to another. + /// Stubbfel, 09.09.2013. + /// The place service to compare to this object. + /// true if the objects are considered equal, false if they are not. + public bool Equals(PlaceService other) + { + if (other.ServiceName.Equals(this.ServiceName)) + { + return true; + } + + return false; + } } } diff --git a/CampusAppWP8/CampusAppWP8/Model/GeoDb/SpsModel.cs b/CampusAppWP8/CampusAppWP8/Model/GeoDb/SpsModel.cs index e9485e84..213dd8e4 100644 --- a/CampusAppWP8/CampusAppWP8/Model/GeoDb/SpsModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/GeoDb/SpsModel.cs @@ -83,5 +83,94 @@ namespace CampusAppWP8.Model.GeoDb return resultplaces.ToList(); } + + /// Adds the places. + /// Stubbfel, 09.09.2013. + /// A list of places. + public void AddPlaces(List 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); + } + } + } + + /// Creates PID list. + /// Stubbfel, 09.09.2013. + /// The new PID list. + public List CreatePidList() + { + List pidList = new List(); + foreach (PlaceModel place in this.Places) + { + pidList.Add(place.PlaceId); + } + + return pidList; + } + + /// Gets place by identifier. + /// Stubbfel, 09.09.2013. + /// The identifier. + /// The place by identifier. + public PlaceModel GetPlaceById(string id) + { + foreach (PlaceModel place in this.Places) + { + if (place.PlaceId.Equals(id)) + { + return place; + } + } + + return null; + } + + /// Query if 'pidList' contains information names. + /// Stubbfel, 09.09.2013. + /// List of pids. + /// The names. + /// true if it succeeds, false if it fails. + public bool ContainsInformationNames(List pidList, List names) + { + foreach (string pid in pidList) + { + PlaceModel place = this.GetPlaceById(pid); + if (!place.ContainsInformationNames(names)) + { + return false; + } + } + + return true; + } + + /// Query if 'pidList' contains service names. + /// Stubbfel, 09.09.2013. + /// List of pids. + /// The names. + /// true if it succeeds, false if it fails. + public bool ContainsServiceNames(List pidList, List names) + { + foreach (string pid in pidList) + { + PlaceModel place = this.GetPlaceById(pid); + if (!place.ContainsServiceNames(names)) + { + return false; + } + } + + return true; + } } } diff --git a/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml b/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml new file mode 100644 index 00000000..52cbd5de --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs new file mode 100644 index 00000000..1f4457ac --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/PlaceNews.xaml.cs @@ -0,0 +1,271 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 09.09.2013 +//---------------------------------------------------------------------- + +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; + + /// Place news. + /// Stubbfel, 09.09.2013. + public partial class PlaceNews : PhoneApplicationPage + { + /// The sps API. + private SpsApi spsApi; + + /// The pis API. + private PisApi pisApi; + + /// The pss API. + private PssApi pssApi; + + /// The places. + private PlacesFile places; + + /// varaible indicates how many apis are running. + private int waitForApi; + + /// true to force reqest. + private bool forceReqest; + + /// Initializes a new instance of the PlaceNews class. + /// Stubbfel, 09.09.2013. + public PlaceNews() + { + this.InitializeComponent(); + this.waitForApi = 0; + } + + /// Wird aufgerufen, wenn eine Seite die aktive Seite in einem Frame wird. + /// Stubbfel, 09.09.2013. + /// Ein Objekt, das die Ereignisdaten enthält. + protected override void OnNavigatedTo(NavigationEventArgs e) + { + if (NavigationMode.Back == e.NavigationMode && this.places == null) + { + this.places = new PlacesFile(); + this.places.Model = App.LoadFromIsolatedStorage(Constants.IsolatedStorage_AllPlaces); + this.SetupResultBox(); + } + else + { + this.InitializeApi(); + } + } + + /// + /// Wird aufgerufen, wenn eine Seite nicht mehr die aktive Seite in einem Frame ist. + /// + /// Stubbfel, 09.09.2013. + /// Ein Objekt, das die Ereignisdaten enthält. + protected override void OnNavigatedFrom(NavigationEventArgs e) + { + if (NavigationMode.Back == e.NavigationMode) + { + App.SaveToIsolatedStorage(Constants.IsolatedStorage_AllPlaces, null); + } + } + + /// Initializes the API. + /// Stubbfel, 09.09.2013. + 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); + } + } + + /// Places file is fail. + /// Stubbfel, 09.09.2013. + private void PlacesFileIsFail() + { + this.places.Model = new SpsModel(); + if (this.spsApi != null) + { + this.spsApi.LoadData(); + this.waitForApi++; + } + } + + /// Places file is ready. + /// Stubbfel, 09.09.2013. + private void PlacesFileIsReady() + { + if (this.spsApi != null) + { + this.spsApi.LoadData(); + this.waitForApi++; + } + } + + /// Pss API is ready. + /// Stubbfel, 09.09.2013. + private void PssApiIsReady() + { + this.waitForApi--; + this.places.Model.AddPlaces(this.pssApi.Model.Places.ToList()); + + if (this.waitForApi < 1) + { + this.SetupResultBox(); + } + } + + /// Pis API is ready. + /// Stubbfel, 09.09.2013. + private void PisApiIsReady() + { + this.waitForApi--; + this.places.Model.AddPlaces(this.pisApi.Model.Places.ToList()); + + if (this.waitForApi < 1) + { + this.SetupResultBox(); + } + } + + /// API is fail. + /// Stubbfel, 09.09.2013. + private void ApiIsFail() + { + if (this.Dispatcher != null) + { + this.Dispatcher.BeginInvoke(new Action(() => MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadWeb))); + } + } + + /// Sps API is ready. + /// Stubbfel, 09.09.2013. + private void SpsApiIsReady() + { + this.waitForApi--; + this.places.Model.AddPlaces(this.spsApi.Model.Places.ToList()); + + List pidlist = this.spsApi.Model.CreatePidList(); + List infoNames = new List() { Constants.PisInformationName_Name }; + List serviceNames = new List() { 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(); + } + } + + /// Sets up the result box. + /// Stubbfel, 09.09.2013. + private void SetupResultBox() + { + this.ResultBox.ItemsSource = this.places.Model.Places; + this.ProgressBar.Visibility = Visibility.Collapsed; + this.places.SaveData(); + App.SaveToIsolatedStorage(Constants.IsolatedStorage_AllPlaces, this.places.Model); + this.forceReqest = false; + } + + /// Event handler. Called by UpdateButtonAppBar for click events. + /// Stubbfel, 09.09.2013. + /// Source of the event. + /// Event information. + private void UpdateButtonAppBar_Click(object sender, EventArgs e) + { + this.ProgressBar.Visibility = Visibility.Visible; + Thread thread = new Thread(delegate() { this.InitApiCurrentPositionForce(); }); + thread.Start(); + } + + /// Initialises the API current position force. + /// Stubbfel, 09.09.2013. + private void InitApiCurrentPositionForce() + { + Utilities.DetermineAndStoreCurrentPositionForce(); + this.forceReqest = true; + this.Dispatcher.BeginInvoke(new Action(() => this.InitializeApi())); + } + + /// Event handler. Called by ApplicationBarMenuItem for click events. + /// Stubbfel, 09.09.2013. + /// Source of the event. + /// Event information. + private void ApplicationBarMenuItem_Click(object sender, EventArgs e) + { + } + + /// Event handler. Called by ApplicationBarMenuItem_Click for 1 events. + /// Stubbfel, 09.09.2013. + /// Source of the event. + /// Event information. + private void ApplicationBarMenuItem_Click_1(object sender, EventArgs e) + { + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/ShowPad.xaml b/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/ShowPad.xaml new file mode 100644 index 00000000..364bb4a0 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/ShowPad.xaml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/ShowPad.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/ShowPad.xaml.cs new file mode 100644 index 00000000..960241b3 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/PlaceNews/ShowPad.xaml.cs @@ -0,0 +1,48 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 09.09.2013 +//---------------------------------------------------------------------- + +namespace CampusAppWP8.Pages.PlaceNews +{ + using System; + using System.Windows.Navigation; + using CampusAppWP8.Model.GeoDb; + using CampusAppWP8.Resources; + using Microsoft.Phone.Controls; + + /// Show pad. + /// Stubbfel, 09.09.2013. + public partial class ShowPad : PhoneApplicationPage + { + /// Initializes a new instance of the ShowPad class. + /// Stubbfel, 09.09.2013. + public ShowPad() + { + InitializeComponent(); + } + + /// Wird aufgerufen, wenn eine Seite die aktive Seite in einem Frame wird. + /// Stubbfel, 09.09.2013. + /// Ein Objekt, das die Ereignisdaten enthält. + protected override void OnNavigatedTo(NavigationEventArgs e) + { + if (NavigationContext.QueryString.ContainsKey(Constants.ParamPlaceID)) + { + SpsModel model = App.LoadFromIsolatedStorage(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); + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml index 4ec8dd6e..2502caf2 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml @@ -181,6 +181,12 @@ + + + + + + diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs index 9bbb8d49..eb9cd698 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs @@ -753,6 +753,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Placenews ähnelt. + /// + public static string PlaceNewsApp_Title { + get { + return ResourceManager.GetString("PlaceNewsApp_Title", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Die primäre Kamera steht nicht zur Verfügung. ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx index 8c61fce3..24bed03d 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx @@ -443,4 +443,7 @@ Nachname + + Placenews + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs index e50aa78f..1904f740 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs @@ -339,6 +339,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die allPlaces.xml ähnelt. + /// + public static string FilePlace_AllPlaces { + get { + return ResourceManager.GetString("FilePlace_AllPlaces", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die user.xml ähnelt. /// @@ -384,6 +393,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die AllPlaces ähnelt. + /// + public static string IsolatedStorage_AllPlaces { + get { + return ResourceManager.GetString("IsolatedStorage_AllPlaces", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die IsolatedStorage_DepartmentFavoriteModel ähnelt. /// @@ -627,6 +645,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die placeId ähnelt. + /// + public static string ParamPlaceID { + get { + return ResourceManager.GetString("ParamPlaceID", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Url ähnelt. /// @@ -807,6 +834,24 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die /Pages/PlaceNews/PlaceNews.xaml ähnelt. + /// + public static string PathPlaceNews_PlaceNewsPage { + get { + return ResourceManager.GetString("PathPlaceNews_PlaceNewsPage", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die /Pages/PlaceNews/ShowPad.xaml ähnelt. + /// + public static string PathPlaceNews_ShowPadPage { + get { + return ResourceManager.GetString("PathPlaceNews_ShowPadPage", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die /Pages/Setting/AppSettingPage.xaml ähnelt. /// @@ -843,6 +888,69 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die iname ähnelt. + /// + public static string PisApi_InformationNameKey { + get { + return ResourceManager.GetString("PisApi_InformationNameKey", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die pid ähnelt. + /// + public static string PisApi_PidListKey { + get { + return ResourceManager.GetString("PisApi_PidListKey", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die name ähnelt. + /// + public static string PisInformationName_Name { + get { + return ResourceManager.GetString("PisInformationName_Name", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die typ ähnelt. + /// + public static string PisInformationName_Typ { + get { + return ResourceManager.GetString("PisInformationName_Typ", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die pid ähnelt. + /// + public static string PssApi_PidListKey { + get { + return ResourceManager.GetString("PssApi_PidListKey", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die sname ähnelt. + /// + public static string PssApi_ServiceNameKey { + get { + return ResourceManager.GetString("PssApi_ServiceNameKey", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die PlaceNews ähnelt. + /// + public static string PssServiceName_PlaceNews { + get { + return ResourceManager.GetString("PssServiceName_PlaceNews", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die [+-]{0,1}[0-9]+[.,]{0,1}[0-9]+[\s][+-]{0,1}[0-9]+[.,]{0,1}[0-9]+ ähnelt. /// @@ -906,6 +1014,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die 1 ähnelt. + /// + public static string SpsDomain_Buildings { + get { + return ResourceManager.GetString("SpsDomain_Buildings", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die ToggleContent ähnelt. /// @@ -1050,6 +1167,24 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die http://141.43.76.140/service/pis ähnelt. + /// + public static string UrlPisService { + get { + return ResourceManager.GetString("UrlPisService", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die http://141.43.76.140/service/pss ähnelt. + /// + public static string UrlPssService { + get { + return ResourceManager.GetString("UrlPssService", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die http://141.43.76.140/service/sps ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index 5710e363..fc6b58b5 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -483,4 +483,49 @@ Uebersicht + + allPlaces.xml + + + AllPlaces + + + placeId + + + /Pages/PlaceNews/PlaceNews.xaml + + + /Pages/PlaceNews/ShowPad.xaml + + + iname + + + pid + + + name + + + typ + + + pid + + + sname + + + PlaceNews + + + 1 + + + http://141.43.76.140/service/pis + + + http://141.43.76.140/service/pss + \ No newline at end of file