Merge branch 'feature/#196' into develop

This commit is contained in:
stubbfel
2013-09-19 13:10:16 +02:00
12 changed files with 472 additions and 29 deletions

View File

@@ -169,6 +169,12 @@ namespace CampusAppWP8.Model.GeoDb
public List<PlaceModel> FilterByPid(List<string> pidList)
{
List<PlaceModel> fitlerList = new List<PlaceModel>();
if (pidList == null || pidList.Count < 1)
{
return fitlerList;
}
foreach (PlaceModel place in this.Places)
{
if (pidList.Contains(place.PlaceId))

View File

@@ -69,8 +69,12 @@
</Grid>
</Grid>
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="False" Mode="Minimized" >
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" Mode="Minimized" >
<lui:UpdateButtonAppBar Click="UpdateButtonAppBar_Click"/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="Scan QR-Code" Click="SearchPlaceByQR_Click" />
<shell:ApplicationBarMenuItem Text="Scan NFC-Tag" Click="SearchPlaceByNFC_Click"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
</phone:PhoneApplicationPage>

View File

@@ -11,15 +11,19 @@ namespace CampusAppWP8.Pages.Campusmap
using System.Collections.Generic;
using System.Device.Location;
using System.Globalization;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading;
using System.Windows;
using System.Windows.Navigation;
using System.Windows.Navigation;
using CampusAppWP8.Model.Campusmap;
using CampusAppWP8.Model.GeoDb;
using CampusAppWP8.Resources;
using CampusAppWP8.Utility;
using CampusAppWP8.Utility.Lui.MessageBoxes;
using CampusAppWP8.Utility.NDEF;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Windows.Networking.Proximity;
/// <summary>Class for the campusMap page.</summary>
/// <remarks>Stubbfel, 19.08.2013.</remarks>
@@ -27,6 +31,9 @@ namespace CampusAppWP8.Pages.Campusmap
{
#region Member
/// <summary>The device.</summary>
private readonly ProximityDevice device = ProximityDevice.GetDefault();
/// <summary>Variable for the map model.</summary>
private MapModel map;
@@ -35,6 +42,11 @@ namespace CampusAppWP8.Pages.Campusmap
/// </summary>
private List<string> informationsNames;
/// <summary>
/// Flag which indicates if an qrCode scan is running
/// </summary>
private bool qrcodeScan = false;
#endregion
#region Constructor
@@ -47,6 +59,19 @@ namespace CampusAppWP8.Pages.Campusmap
this.map = new CBMainMapModel();
this.MapCanvas.DataContext = this.map;
this.map.ShowMapInfos += new CBMainMapModel.MapInfos(this.ShowMapInfo);
ApplicationBarMenuItem menuItem1 = ApplicationBar.MenuItems[0] as ApplicationBarMenuItem;
ApplicationBarMenuItem menuItem2 = ApplicationBar.MenuItems[1] as ApplicationBarMenuItem;
if (menuItem1 != null)
{
menuItem1.Text = AppResources.CampusMapApp_ScanQR;
}
if (menuItem2 != null)
{
menuItem2.Text = AppResources.CampusMapApp_ScanNfc;
}
}
#endregion
@@ -61,7 +86,12 @@ namespace CampusAppWP8.Pages.Campusmap
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (this.map.Spatial != null && e.NavigationMode == NavigationMode.New)
if (this.map.Spatial == null)
{
return;
}
if (e.NavigationMode == NavigationMode.New)
{
MapCanvas.Children.Clear();
@@ -80,12 +110,63 @@ namespace CampusAppWP8.Pages.Campusmap
this.ShowCurrentPositionDispatcher(scroll);
}
else if (this.qrcodeScan && e.NavigationMode == NavigationMode.Back)
{
this.qrcodeScan = false;
string qrcodeResult = App.LoadFromIsolatedStorage<string>(Constants.CampusMapApp_QRCodeSearchResultStorageKey);
App.SaveToIsolatedStorage<string>(Constants.CampusMapApp_QRCodeSearchResultStorageKey, null);
string searchPid = Wp8StringManager.FilterPlaceIdinQRResultString(qrcodeResult);
if (searchPid != null)
{
this.AddPinsByPids(new List<string>() { searchPid }, MapPinModel.PinType.SearchPlace);
}
}
}
#endregion
#region private
/// <summary>
/// Method adds pin to the map by given list of placeId
/// </summary>
/// <param name="pidList">list of placeId</param>
/// <param name="pinType">type of pin</param>
/// <param name="clearCanvas">(optional) if its true, clear canvas before adding</param>
private void AddPinsByPids(List<string> pidList, MapPinModel.PinType pinType, bool clearCanvas = true)
{
// clear canvas
if (clearCanvas)
{
MapCanvas.Children.Clear();
}
// null and empty list assert
if (pidList == null || pidList.Count < 1)
{
return;
}
List<PlaceModel> placeList = new List<PlaceModel>();
PlaceModel tmpPlace;
foreach (string pid in pidList)
{
tmpPlace = this.map.Spatial.GetPlaceById(pid);
if (tmpPlace != null)
{
placeList.Add(tmpPlace);
}
}
// add pins to map
if (placeList.Count > 0)
{
this.AddPins(placeList, pinType);
}
}
/// <summary>Button click method.</summary>
/// <remarks>Stubbfel, 19.08.2013.</remarks>
/// <param name="sender">caller object.</param>
@@ -95,6 +176,83 @@ namespace CampusAppWP8.Pages.Campusmap
// this.AddPin(double.Parse(XPoint.Text), double.Parse(YPoint.Text));
}
/// <summary>
/// Method start a NFCScan
/// </summary>
/// <param name="sender">sender of event</param>
/// <param name="e">the event args</param>
private void SearchPlaceByNFC_Click(object sender, EventArgs e)
{
MessageBoxes.ShowMainModelInfoMessageBox(AppResources.ScarNfc_Search);
this.ProgressBar.Visibility = Visibility.Visible;
this.device.SubscribeForMessage(Constants.NCFMessageType_NDEF, this.NDEFHandler);
}
/// <summary>
/// Method start a QRCodeScan
/// </summary>
/// <param name="sender">sender of event</param>
/// <param name="e">the event args</param>
private void SearchPlaceByQR_Click(object sender, EventArgs e)
{
this.qrcodeScan = true;
string urlString = Constants.PathQR_QRPage;
urlString += "?" + Constants.ParamQRResultKey + "=" + Constants.CampusMapApp_QRCodeSearchResultStorageKey;
Uri url = new Uri(urlString as string, UriKind.Relative);
this.NavigationService.Navigate(url);
}
/// <summary>
/// Method handle the result of a NFCScan
/// </summary>
/// <param name="sender">the sender device</param>
/// <param name="message">the message of the device</param>
private void NDEFHandler(ProximityDevice sender, ProximityMessage message)
{
// create ndefMessage
this.device.StopSubscribingForMessage(message.SubscriptionId);
var ndefMessage = message.Data;
byte[] data = ndefMessage.ToArray();
NDEFMessage ndef = new NDEFMessage(data);
// search for placeId
string nfcContent = ndef.GetContent();
string searchPid = Wp8StringManager.FilterPlaceIdinNFCResultString(nfcContent.Trim());
if (searchPid != null)
{
// add pins to map
if (this.Dispatcher != null)
{
this.Dispatcher.BeginInvoke(new Action(() => this.AddPinsByPids(new List<string>() { searchPid }, MapPinModel.PinType.SearchPlace)));
}
else
{
this.AddPinsByPids(new List<string>() { searchPid }, MapPinModel.PinType.SearchPlace);
}
}
else
{
// Errorcase
if (this.Dispatcher != null)
{
this.Dispatcher.BeginInvoke(new Action(() => MessageBoxes.ShowMainModelErrorMessageBox(AppResources.ScarNfc_Fail)));
}
else
{
MessageBoxes.ShowMainModelErrorMessageBox(AppResources.ScarNfc_Fail);
}
}
if (this.Dispatcher != null)
{
this.Dispatcher.BeginInvoke(new Action(() => this.ProgressBar.Visibility = Visibility.Collapsed));
}
else
{
this.ProgressBar.Visibility = Visibility.Collapsed;
}
}
/// <summary>Button click method.</summary>
/// <remarks>Stubbfel, 19.08.2013.</remarks>
/// <param name="sender">caller object.</param>

View File

@@ -48,6 +48,8 @@ namespace CampusAppWP8.Pages.Dev
/// <summary>true if this object is in autofocus. </summary>
private bool isInAutofocus = false;
private string ResultAppStoreKey;
#endregion
#region Constructor
@@ -73,6 +75,10 @@ namespace CampusAppWP8.Pages.Dev
{
if (PhotoCamera.IsCameraTypeSupported(CameraType.Primary) == true)
{
if (NavigationContext.QueryString.ContainsKey(Constants.ParamQRResultKey))
{
this.ResultAppStoreKey = NavigationContext.QueryString[Constants.ParamQRResultKey];
}
this.cam = new PhotoCamera(CameraType.Primary);
this.cam.Initialized += new EventHandler<CameraOperationCompletedEventArgs>(this.Cam_Initialized);
this.cam.AutoFocusCompleted += new EventHandler<CameraOperationCompletedEventArgs>(this.Cam_AutoFocusCompl);
@@ -85,7 +91,7 @@ namespace CampusAppWP8.Pages.Dev
{
this.Dispatcher.BeginInvoke(delegate
{
this.scannText.Text = AppResources.PrimCamNotSupported;
MessageBox.Show(AppResources.PrimCamNotSupported);
});
}
}
@@ -211,7 +217,15 @@ namespace CampusAppWP8.Pages.Dev
{
Dispatcher.BeginInvoke(delegate
{
this.scannText.Text = result.Text;
if (this.ResultAppStoreKey != null)
{
App.SaveToIsolatedStorage(this.ResultAppStoreKey, result.Text);
NavigationService.GoBack();
}
else
{
MessageBox.Show(result.Text);
}
});
}
}

View File

@@ -22,6 +22,10 @@ namespace CampusAppWP8.Pages.PlaceNews
using CampusAppWP8.Utility;
using CampusAppWP8.Utility.Lui.MessageBoxes;
using Microsoft.Phone.Controls;
using Windows.Networking.Proximity;
using CampusAppWP8.Utility.NDEF;
using System.Runtime.InteropServices.WindowsRuntime;
using Microsoft.Phone.Shell;
/// <summary>Place news.</summary>
/// <remarks>Stubbfel, 09.09.2013.</remarks>
@@ -49,6 +53,11 @@ namespace CampusAppWP8.Pages.PlaceNews
/// <summary>List of search pids.</summary>
private List<string> searchPidList;
private bool qrScan = false;
/// <summary>The device.</summary>
private readonly ProximityDevice device = ProximityDevice.GetDefault();
#endregion
#region Constructor
@@ -74,11 +83,32 @@ namespace CampusAppWP8.Pages.PlaceNews
{
base.OnNavigatedTo(e);
if (NavigationMode.Back == e.NavigationMode && this.places == null)
if (NavigationMode.Back == e.NavigationMode)
{
this.places = new PlacesFile();
this.places.Model = App.LoadFromIsolatedStorage<SpsModel>(Constants.IsolatedStorage_AllPlaces);
this.SetupResultBox();
if (this.places == null)
{
this.places = new PlacesFile();
this.places.Model = App.LoadFromIsolatedStorage<SpsModel>(Constants.IsolatedStorage_AllPlaces);
}
if (qrScan)
{
qrScan = false;
string qrResult = App.LoadFromIsolatedStorage<string>("PlaceNewsQCCode");
App.SaveToIsolatedStorage<string>("PlaceNewsQCCode", null);
string searchPid = Wp8StringManager.FilterPlaceIdinQRResultString(qrResult);
if (searchPid != null)
{
this.searchPidList = new List<string>() { searchPid };
this.SendGetPisPssForPlacenews(this.searchPidList);
}
}
else
{
this.SetupResultBox();
}
}
else
{
@@ -120,22 +150,24 @@ namespace CampusAppWP8.Pages.PlaceNews
this.places.OnFailedLoad += new PlacesFile.OnFailed(this.PlacesFileIsFail);
this.places.LoadData();
}
// init sps Api
if (this.spsApi == null || this.forceRequest)
if (this.spsApi == null)
{
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);
if (this.forceRequest)
{
this.spsApi.LoadData();
}
}
if (this.forceRequest)
{
this.spsApi.LoadData();
}
// init pis API
if (this.pisApi == null || this.forceRequest)
if (this.pisApi == null)
{
this.pisApi = new PisApi();
this.pisApi.OnLoaded += new PisApi.OnIO(this.PisApiIsReady);
@@ -143,7 +175,7 @@ namespace CampusAppWP8.Pages.PlaceNews
}
// init pss Api
if (this.pssApi == null || this.forceRequest)
if (this.pssApi == null)
{
this.pssApi = new PssApi();
this.pssApi.OnLoaded += new PssApi.OnIO(this.PssApiIsReady);
@@ -174,8 +206,8 @@ namespace CampusAppWP8.Pages.PlaceNews
this.spsApi.OnLoaded += new SpsApi.OnIO(this.SpsApiIsReady);
this.spsApi.OnFailedLoad += new SpsApi.OnFailed(this.ApiIsFail);
this.spsApi.SetupCurrentPlaceRequest(Constants.SpsDomain_Buildings);
}
}
this.spsApi.LoadData();
this.waitForApi++;
}
@@ -232,29 +264,62 @@ namespace CampusAppWP8.Pages.PlaceNews
private void SpsApiIsReady()
{
this.waitForApi--;
this.places.Model.AddPlaces(this.spsApi.Model.Places.ToList());
this.searchPidList = this.spsApi.Model.CreatePidList();
if (spsApi.Model.Places.Count > 0)
{
this.places.Model.AddPlaces(this.spsApi.Model.Places.ToList());
this.searchPidList = this.spsApi.Model.CreatePidList();
this.SendGetPisPssForPlacenews(this.searchPidList);
}
this.CheckedSetupResultBox();
}
/// <summary>
/// send get request to pis andd pss for PlaceNews service
/// </summary>
/// <param name="pidList">list of place id</param>
private void SendGetPisPssForPlacenews(List<string> pidList) {
List<string> infoNames = new List<string>() { Constants.PisInformationName_Name };
List<string> serviceNames = new List<string>() { Constants.PssServiceName_PlaceNews };
// load from pis api
if (this.forceRequest || !this.places.Model.ContainsInformationNames(this.searchPidList, infoNames))
this.SendGetPlaceInformation(this.searchPidList, infoNames, this.forceRequest);
// load from pis api
this.SendGetPlaceService(this.searchPidList, serviceNames);
this.CheckedSetupResultBox();
}
/// <summary>
/// Method send get for PlaceInformation of certain places
/// </summary>
/// <param name="pidList">list of place id</param>
/// <param name="infoNames">list of informations name</param>
/// <param name="force">if its true then force api load</param>
private void SendGetPlaceInformation(List<string> pidList, List<string> infoNames, bool force = false)
{
if (force || !this.places.Model.ContainsInformationNames(pidList, infoNames))
{
this.pisApi.SetupInformationRequest(this.searchPidList, infoNames);
this.pisApi.LoadData();
this.waitForApi++;
}
// load from pis api
if (this.forceRequest || !this.places.Model.ContainsServiceNames(this.searchPidList, serviceNames))
}
/// <summary>
/// Method send get for PlaceSetvice of certain places
/// </summary>
/// <param name="pidList">list of place id</param>
/// <param name="serviceNames">list of service name</param>
/// <param name="force">if its true then force api load</param>
private void SendGetPlaceService(List<string> pidList, List<string> serviceNames, bool force = false)
{
if (this.forceRequest || !this.places.Model.ContainsServiceNames(pidList, serviceNames))
{
this.pssApi.SetupServiceRequest(this.searchPidList, serviceNames);
this.pssApi.LoadData();
this.waitForApi++;
}
this.CheckedSetupResultBox();
}
/// <summary>Sets up the result box.</summary>
@@ -294,6 +359,11 @@ namespace CampusAppWP8.Pages.PlaceNews
/// <param name="e"> Event information.</param>
private void ApplicationBarMenuItem_Click(object sender, EventArgs e)
{
this.qrScan = true;
string urlString = Constants.PathQR_QRPage;
urlString += "?" + Constants.ParamQRResultKey + "=" + "PlaceNewsQCCode";
Uri url = new Uri(urlString as string, UriKind.Relative);
this.NavigationService.Navigate(url);
}
/// <summary>Event handler. Called by ApplicationBarMenuItem_Click for 1 events.</summary>
@@ -302,6 +372,8 @@ namespace CampusAppWP8.Pages.PlaceNews
/// <param name="e"> Event information.</param>
private void ApplicationBarMenuItem_Click_1(object sender, EventArgs e)
{
this.ProgressBar.Visibility = Visibility.Visible;
this.device.SubscribeForMessage("NDEF", this.NDEFHandler);
}
/// <summary>Checked setup result box.</summary>
@@ -346,6 +418,27 @@ namespace CampusAppWP8.Pages.PlaceNews
txt.Text = place.GetInformationsValue(Constants.PisInformationName_Name);
}
/// <summary>Handler, called when the ndef.</summary>
/// <remarks>Stubbfel, 22.08.2013.</remarks>
/// <param name="sender"> The sender.</param>
/// <param name="message">The message.</param>
private void NDEFHandler(ProximityDevice sender, ProximityMessage message)
{
this.device.StopSubscribingForMessage(message.SubscriptionId);
var ndefMessage = message.Data;
byte[] data = ndefMessage.ToArray();
NDEFMessage ndef = new NDEFMessage(data);
string nfcContent = ndef.GetContent();
string pid = Wp8StringManager.FilterPlaceIdinNFCResultString(nfcContent.Trim());
if (pid != null)
{
this.searchPidList = new List<string>() { pid };
this.SendGetPisPssForPlacenews(this.searchPidList);
}
// this.Dispatcher.BeginInvoke(new Action(() => MessageBox.Show(ndef.GetContent())));
}
#endregion
}
}

View File

@@ -141,6 +141,24 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Info via NFC ähnelt.
/// </summary>
public static string CampusMapApp_ScanNfc {
get {
return ResourceManager.GetString("CampusMapApp_ScanNfc", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Info via QR-Code ähnelt.
/// </summary>
public static string CampusMapApp_ScanQR {
get {
return ResourceManager.GetString("CampusMapApp_ScanQR", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Campusplan ähnelt.
/// </summary>
@@ -807,6 +825,24 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Kein gültigen NFC-Tag gefunden ähnelt.
/// </summary>
public static string ScarNfc_Fail {
get {
return ResourceManager.GetString("ScarNfc_Fail", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Bitte halten Sie das Handy vor dem NFC-Tag ähnelt.
/// </summary>
public static string ScarNfc_Search {
get {
return ResourceManager.GetString("ScarNfc_Search", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Appeinstellungen ähnelt.
/// </summary>

View File

@@ -440,4 +440,16 @@
<data name="ContextMenu_PinToStart" xml:space="preserve">
<value>Auf Startseite</value>
</data>
<data name="CampusMapApp_ScanNfc" xml:space="preserve">
<value>Info via NFC</value>
</data>
<data name="CampusMapApp_ScanQR" xml:space="preserve">
<value>Info via QR-Code</value>
</data>
<data name="ScarNfc_Fail" xml:space="preserve">
<value>Kein gültigen NFC-Tag gefunden</value>
</data>
<data name="ScarNfc_Search" xml:space="preserve">
<value>Bitte halten Sie das Handy vor dem NFC-Tag</value>
</data>
</root>

View File

@@ -177,6 +177,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die CampusMapAppQRCodeSearchResultStorageKey ähnelt.
/// </summary>
public static string CampusMapApp_QRCodeSearchResultStorageKey {
get {
return ResourceManager.GetString("CampusMapApp_QRCodeSearchResultStorageKey", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die +49 ähnelt.
/// </summary>
@@ -555,6 +564,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die NDEF ähnelt.
/// </summary>
public static string NCFMessageType_NDEF {
get {
return ResourceManager.GetString("NCFMessageType_NDEF", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Studiengang ähnelt.
/// </summary>
@@ -654,6 +672,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die QRResultKey ähnelt.
/// </summary>
public static string ParamQRResultKey {
get {
return ResourceManager.GetString("ParamQRResultKey", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Url ähnelt.
/// </summary>
@@ -852,6 +879,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die /Pages/Dev/QRScanner.xaml ähnelt.
/// </summary>
public static string PathQR_QRPage {
get {
return ResourceManager.GetString("PathQR_QRPage", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die /Pages/Setting/AppSettingPage.xaml ähnelt.
/// </summary>

View File

@@ -513,4 +513,16 @@
<data name="PathEvent_EventPage" xml:space="preserve">
<value>/Pages/Events/EventPage.xaml</value>
</data>
<data name="ParamQRResultKey" xml:space="preserve">
<value>QRResultKey</value>
</data>
<data name="PathQR_QRPage" xml:space="preserve">
<value>/Pages/Dev/QRScanner.xaml</value>
</data>
<data name="CampusMapApp_QRCodeSearchResultStorageKey" xml:space="preserve">
<value>CampusMapAppQRCodeSearchResultStorageKey</value>
</data>
<data name="NCFMessageType_NDEF" xml:space="preserve">
<value>NDEF</value>
</data>
</root>

View File

@@ -17,6 +17,7 @@
<Value>pis</Value>
<Value>prev</Value>
<Value>pss</Value>
<Value>qr</Value>
<Value>Senftenberg</Value>
<Value>sps</Value>
<Value>Stubbfel</Value>

View File

@@ -1,7 +1,9 @@
<StyleCopSettings Version="105">
<GlobalSettings>
<CollectionProperty Name="RecognizedWords">
<Value>nfc</Value>
<Value>param</Value>
<Value>qr</Value>
<Value>str</Value>
<Value>stubbfel</Value>
<Value>telefon</Value>

View File

@@ -6,7 +6,7 @@
// <sience>06.06.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWPortalLib8.Utility
{
{
using System;
using System.Text.RegularExpressions;
using CampusAppWPortalLib8.Resources;
@@ -118,6 +118,75 @@ namespace CampusAppWPortalLib8.Utility
return shortStr;
}
/// <summary>
/// Method gets the placeId of the result string for an qrCode string
/// </summary>
/// <param name="qrcodeResult">input qrCode string</param>
/// <returns>the id if it was found it in the string otherwise null</returns>
public static string FilterPlaceIdinQRResultString(string qrcodeResult)
{
string[] lines = qrcodeResult.Split('\n');
string tmpLineTrim;
foreach (string line in lines)
{
tmpLineTrim = line.Trim();
if (DefaultStringManager.IsDigitsOnly(tmpLineTrim))
{
return tmpLineTrim;
}
}
return null;
}
/// <summary>
/// Method check if the string contains only digit
/// </summary>
/// <param name="str">input string</param>
/// <returns>true if the string contains only digit, otherwise false</returns>
public static bool IsDigitsOnly(string str)
{
foreach (char c in str)
{
if (c < '0' || c > '9')
{
return false;
}
}
return true;
}
/// <summary>
/// Method gets the placeId of the result string for an nfc string
/// </summary>
/// <param name="nfcResult">input nfc string</param>
/// <returns>the id if it was found it in the string otherwise null</returns>
public static string FilterPlaceIdinNFCResultString(string nfcResult)
{
string nfcResultTrim = nfcResult.Trim('{');
nfcResultTrim = nfcResultTrim.Trim('}');
string[] items = nfcResultTrim.Split(',');
string[] tmpStringPair;
foreach (string item in items)
{
tmpStringPair = item.Trim().Split(':');
if (tmpStringPair.Length == 2)
{
string pairKey = tmpStringPair[0].Trim('\"').Trim();
if (pairKey.Equals("pid"))
{
return tmpStringPair[1].Trim('\"').Trim();
}
}
}
return null;
}
#endregion
}
}