update Appdll and plib

This commit is contained in:
stubbfel
2013-09-12 12:41:23 +02:00
parent 5fb0d589c1
commit df4fd8ee3d
8 changed files with 554 additions and 8 deletions

View File

@@ -7,20 +7,35 @@
//----------------------------------------------------------------------
namespace CampusAppDLL.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

@@ -8,13 +8,16 @@
namespace CampusAppDLL.Model.GeoDb
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
/// <summary>
/// Model for a place of the SPSService
/// </summary>
public class PlaceModel
public class PlaceModel : IEquatable<PlaceModel>
{
/// <summary>
/// Gets or sets the placeId
@@ -34,6 +37,7 @@ namespace CampusAppDLL.Model.GeoDb
[XmlAttribute("refpoint")]
public string RefPoint { get; set; }
/// <summary>Gets or sets the information.</summary>
/// <value>The information.</value>
[XmlElement("placeInformation")]
@@ -43,5 +47,121 @@ namespace CampusAppDLL.Model.GeoDb
/// <value>The services.</value>
[XmlElement("placeService")]
public ObservableCollection<PlaceService> Services { get; set; }
/// <summary>Converts this object to a nfc string.</summary>
/// <remarks>Stubbfel, 21.08.2013.</remarks>
/// <returns>This object as a string.</returns>
public string ToNfcString()
{
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 CampusAppDLL.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 CampusAppDLL.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

@@ -23,6 +23,7 @@ namespace CampusAppDLL.Model.GeoDb
/// <remarks>Stubbfel, 20.08.2013.</remarks>
public SpsModel()
{
this.HasChanged = false;
this.Places = new ObservableCollection<PlaceModel>();
}
@@ -32,6 +33,10 @@ namespace CampusAppDLL.Model.GeoDb
[XmlElement("place")]
public ObservableCollection<PlaceModel> Places { get; set; }
/// <summary>Gets a value indicating whether this object has changed.</summary>
/// <value>true if this object has changed, false if not.</value>
public bool HasChanged { get; set; }
/// <summary>Gets places by information.</summary>
/// <remarks>Stubbfel, 19.08.2013.</remarks>
/// <param name="query"> The query.</param>
@@ -83,5 +88,113 @@ namespace CampusAppDLL.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);
}
}
this.HasChanged = true;
}
/// <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;
}
/// <summary>Filter by PID.</summary>
/// <remarks>Stubbfel, 11.09.2013.</remarks>
/// <param name="pidList">List of pids.</param>
/// <returns>flitered list of places</returns>
public List<PlaceModel> FilterByPid(List<string> pidList)
{
List<PlaceModel> fitlerList = new List<PlaceModel>();
foreach (PlaceModel place in this.Places)
{
if (pidList.Contains(place.PlaceId))
{
fitlerList.Add(place);
}
}
return fitlerList;
}
}
}

View File

@@ -7,20 +7,35 @@
//----------------------------------------------------------------------
namespace CampusAppWPortalLib8.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

@@ -8,13 +8,16 @@
namespace CampusAppWPortalLib8.Model.GeoDb
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
/// <summary>
/// Model for a place of the SPSService
/// </summary>
public class PlaceModel
public class PlaceModel : IEquatable<PlaceModel>
{
/// <summary>
/// Gets or sets the placeId
@@ -34,6 +37,7 @@ namespace CampusAppWPortalLib8.Model.GeoDb
[XmlAttribute("refpoint")]
public string RefPoint { get; set; }
/// <summary>Gets or sets the information.</summary>
/// <value>The information.</value>
[XmlElement("placeInformation")]
@@ -43,5 +47,121 @@ namespace CampusAppWPortalLib8.Model.GeoDb
/// <value>The services.</value>
[XmlElement("placeService")]
public ObservableCollection<PlaceService> Services { get; set; }
/// <summary>Converts this object to a nfc string.</summary>
/// <remarks>Stubbfel, 21.08.2013.</remarks>
/// <returns>This object as a string.</returns>
public string ToNfcString()
{
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 CampusAppWPortalLib8.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 CampusAppWPortalLib8.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

@@ -23,6 +23,7 @@ namespace CampusAppWPortalLib8.Model.GeoDb
/// <remarks>Stubbfel, 20.08.2013.</remarks>
public SpsModel()
{
this.HasChanged = false;
this.Places = new ObservableCollection<PlaceModel>();
}
@@ -32,6 +33,10 @@ namespace CampusAppWPortalLib8.Model.GeoDb
[XmlElement("place")]
public ObservableCollection<PlaceModel> Places { get; set; }
/// <summary>Gets a value indicating whether this object has changed.</summary>
/// <value>true if this object has changed, false if not.</value>
public bool HasChanged { get; set; }
/// <summary>Gets places by information.</summary>
/// <remarks>Stubbfel, 19.08.2013.</remarks>
/// <param name="query"> The query.</param>
@@ -83,5 +88,113 @@ namespace CampusAppWPortalLib8.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);
}
}
this.HasChanged = true;
}
/// <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;
}
/// <summary>Filter by PID.</summary>
/// <remarks>Stubbfel, 11.09.2013.</remarks>
/// <param name="pidList">List of pids.</param>
/// <returns>flitered list of places</returns>
public List<PlaceModel> FilterByPid(List<string> pidList)
{
List<PlaceModel> fitlerList = new List<PlaceModel>();
foreach (PlaceModel place in this.Places)
{
if (pidList.Contains(place.PlaceId))
{
fitlerList.Add(place);
}
}
return fitlerList;
}
}
}