Merge branch 'hotfix/#191' into develmaster
This commit is contained in:
@@ -47,56 +47,28 @@ namespace CampusAppWP8.Model.GeoDb
|
||||
|
||||
#region Method
|
||||
|
||||
#region public
|
||||
|
||||
/// <summary>Gets places by information.</summary>
|
||||
/// <remarks>Stubbfel, 19.08.2013.</remarks>
|
||||
/// <param name="query"> The query.</param>
|
||||
/// <param name="ignoreCases"> (Optional) the ignore cases.</param>
|
||||
/// <param name="informationName">(Optional) name of the information.</param>
|
||||
/// <param name="informationNames">(Optional) name of the information.</param>
|
||||
/// <returns>The places by information.</returns>
|
||||
public List<PlaceModel> GetPlacesByInformation(string query, bool ignoreCases = true, string informationName = null)
|
||||
public List<PlaceModel> GetPlacesByInformation(string query, bool ignoreCases = true, List<string> informationNames = null)
|
||||
{
|
||||
string querryLow = string.Empty;
|
||||
IEnumerable<PlaceModel> resultplaces = null;
|
||||
string querryStr = string.Empty;
|
||||
List<PlaceModel> resultplaces = new List<PlaceModel>();
|
||||
|
||||
// select correct statement
|
||||
if (ignoreCases && informationName == null)
|
||||
foreach (PlaceModel place in this.Places)
|
||||
{
|
||||
querryLow = query.ToLower();
|
||||
resultplaces = from place in this.Places
|
||||
from info in place.Informations
|
||||
where info.InformationValue.ToLower().Contains(querryLow)
|
||||
select place;
|
||||
}
|
||||
else if (ignoreCases && informationName != null)
|
||||
{
|
||||
querryLow = query.ToLower();
|
||||
resultplaces = from place in this.Places
|
||||
from info in place.Informations
|
||||
where info.InformationValue.ToLower().Contains(querryLow) && info.InformationName.Equals(informationName)
|
||||
select place;
|
||||
}
|
||||
else if (!ignoreCases && informationName == null)
|
||||
{
|
||||
resultplaces = from place in this.Places
|
||||
from info in place.Informations
|
||||
where info.InformationValue.Contains(querryLow)
|
||||
select place;
|
||||
}
|
||||
else if (!ignoreCases && informationName != null)
|
||||
{
|
||||
resultplaces = from place in this.Places
|
||||
from info in place.Informations
|
||||
where info.InformationValue.Contains(querryLow) && info.InformationName.Equals(informationName)
|
||||
select place;
|
||||
if (this.IsPlaceQueryMatched(place, query, ignoreCases, informationNames))
|
||||
{
|
||||
resultplaces.Add(place);
|
||||
}
|
||||
}
|
||||
|
||||
// null assert
|
||||
if (resultplaces == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return resultplaces.ToList<PlaceModel>();
|
||||
return resultplaces;
|
||||
}
|
||||
|
||||
/// <summary>Adds the places.</summary>
|
||||
@@ -209,5 +181,52 @@ namespace CampusAppWP8.Model.GeoDb
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region private
|
||||
|
||||
/// <summary>
|
||||
/// Method check if a certain place matched by query string
|
||||
/// </summary>
|
||||
/// <param name="place">the Place</param>
|
||||
/// <param name="query">the Query</param>
|
||||
/// <param name="ignoreCases"> (Optional) the ignore cases.</param>
|
||||
/// <param name="informationNames">(Optional) name of the information.</param>
|
||||
/// <returns>true if it match otherwise false</returns>
|
||||
private bool IsPlaceQueryMatched(PlaceModel place, string query, bool ignoreCases = true, List<string> informationNames = null)
|
||||
{
|
||||
string queryString = query;
|
||||
if (ignoreCases)
|
||||
{
|
||||
queryString = query.ToLower();
|
||||
}
|
||||
|
||||
bool allInfos = true;
|
||||
if (informationNames != null && informationNames.Count > 0)
|
||||
{
|
||||
allInfos = false;
|
||||
}
|
||||
|
||||
foreach (PlaceInformation info in place.Informations)
|
||||
{
|
||||
if (allInfos || informationNames.Contains(info.InformationName))
|
||||
{
|
||||
string infoVal = info.InformationValue;
|
||||
if (ignoreCases)
|
||||
{
|
||||
infoVal = infoVal.ToLower();
|
||||
}
|
||||
|
||||
if (infoVal.Contains(queryString))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,11 @@ namespace CampusAppWP8.Pages.Campusmap
|
||||
/// <summary>Variable for the map model.</summary>
|
||||
private MapModel map;
|
||||
|
||||
/// <summary>
|
||||
/// List of information names
|
||||
/// </summary>
|
||||
private List<string> informationsNames;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
@@ -111,7 +116,15 @@ namespace CampusAppWP8.Pages.Campusmap
|
||||
/// <returns>The found places.</returns>
|
||||
private List<PlaceModel> SearchPlaces(string query)
|
||||
{
|
||||
return this.map.Spatial.GetPlacesByInformation(query);
|
||||
if (this.informationsNames == null)
|
||||
{
|
||||
this.informationsNames = new List<string>();
|
||||
this.informationsNames.Add(Constants.PisInformationName_Name);
|
||||
this.informationsNames.Add(Constants.PisInformationName_Typ);
|
||||
this.informationsNames.Add(Constants.PisInformationName_ShortName);
|
||||
}
|
||||
|
||||
return this.map.Spatial.GetPlacesByInformation(query, true, this.informationsNames);
|
||||
}
|
||||
|
||||
/// <summary>Adds the pins.</summary>
|
||||
|
||||
@@ -915,6 +915,24 @@ namespace CampusAppWP8.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Kurzbeschreibung ähnelt.
|
||||
/// </summary>
|
||||
public static string PisInformationName_ShortDesc {
|
||||
get {
|
||||
return ResourceManager.GetString("PisInformationName_ShortDesc", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Kurzname ähnelt.
|
||||
/// </summary>
|
||||
public static string PisInformationName_ShortName {
|
||||
get {
|
||||
return ResourceManager.GetString("PisInformationName_ShortName", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die typ ähnelt.
|
||||
/// </summary>
|
||||
|
||||
@@ -528,4 +528,10 @@
|
||||
<data name="UrlPssService" xml:space="preserve">
|
||||
<value>http://141.43.76.140/service/pss</value>
|
||||
</data>
|
||||
<data name="PisInformationName_ShortDesc" xml:space="preserve">
|
||||
<value>Kurzbeschreibung</value>
|
||||
</data>
|
||||
<data name="PisInformationName_ShortName" xml:space="preserve">
|
||||
<value>Kurzname</value>
|
||||
</data>
|
||||
</root>
|
||||
Reference in New Issue
Block a user