mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-21 21:46:27 +02:00
Version 3.0.270
This commit is contained in:
parent
67999ef4ae
commit
e0c75d5b37
81 changed files with 812 additions and 474 deletions
|
@ -27,7 +27,7 @@ namespace TINK.Model.Bike.BC
|
|||
WheelType? wheelType = null,
|
||||
TypeOfBike? typeOfBike = null,
|
||||
string description = null,
|
||||
string currentStationId = null,
|
||||
string stationId = null,
|
||||
Uri operatorUri = null,
|
||||
TariffDescription tariffDescription = null)
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ namespace TINK.Model.Bike.BC
|
|||
|
||||
IsDemo = isDemo ?? DEFAULTVALUEISDEMO;
|
||||
Group = group ?? new List<string>();
|
||||
CurrentStation = currentStationId;
|
||||
StationId = stationId;
|
||||
OperatorUri = operatorUri;
|
||||
TariffDescription = tariffDescription;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ namespace TINK.Model.Bike.BC
|
|||
bikeInfo.WheelType,
|
||||
bikeInfo.TypeOfBike,
|
||||
bikeInfo.Description,
|
||||
bikeInfo.CurrentStation,
|
||||
bikeInfo.StationId,
|
||||
bikeInfo.OperatorUri,
|
||||
bikeInfo.TariffDescription) { }
|
||||
|
||||
|
@ -58,13 +58,13 @@ namespace TINK.Model.Bike.BC
|
|||
/// Constructs a bike info object for a available bike.
|
||||
/// </summary>
|
||||
/// <param name="id">Unique id of bike.</param>
|
||||
/// <param name="currentStationId">Id of station where bike is located.</param>
|
||||
/// <param name="stationId">Id of station where bike is located.</param>
|
||||
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
|
||||
/// <param name="tariffDescription">Hold tariff description of bike.</param>
|
||||
/// <param name="wheelType"></param>
|
||||
public BikeInfo(
|
||||
string id,
|
||||
string currentStationId,
|
||||
string stationId,
|
||||
Uri operatorUri = null,
|
||||
TariffDescription tariffDescription = null,
|
||||
bool? isDemo = DEFAULTVALUEISDEMO,
|
||||
|
@ -79,7 +79,7 @@ namespace TINK.Model.Bike.BC
|
|||
wheelType,
|
||||
typeOfBike,
|
||||
description,
|
||||
currentStationId,
|
||||
stationId,
|
||||
operatorUri,
|
||||
tariffDescription)
|
||||
{
|
||||
|
@ -179,7 +179,7 @@ namespace TINK.Model.Bike.BC
|
|||
/// <summary>
|
||||
/// Station a which bike is located, null otherwise.
|
||||
/// </summary>
|
||||
public string CurrentStation { get; }
|
||||
public string StationId { get; }
|
||||
|
||||
/// <summary> Holds description about the tarif. </summary>
|
||||
public TariffDescription TariffDescription { get; }
|
||||
|
@ -210,7 +210,7 @@ namespace TINK.Model.Bike.BC
|
|||
/// </summary>
|
||||
public new string ToString()
|
||||
{
|
||||
return $"Id={Bike.Id}{(Bike.WheelType != null ? $", wheel(s)={Bike.WheelType}" : string.Empty)}{(Bike.TypeOfBike != null ? $"type={Bike.TypeOfBike}" : "")}, state={State}, location={(!string.IsNullOrEmpty(CurrentStation)? $"Station {CurrentStation}" : "On the road")}, is demo={IsDemo}.";
|
||||
return $"Id={Bike.Id}{(Bike.WheelType != null ? $", wheel(s)={Bike.WheelType}" : string.Empty)}{(Bike.TypeOfBike != null ? $"type={Bike.TypeOfBike}" : "")}, state={State}, location={(!string.IsNullOrEmpty(StationId)? $"Station {StationId}" : "On the road")}, is demo={IsDemo}.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace TINK.Model.Bike.BC
|
|||
/// <param name="isDemo">True if device is demo device, false otherwise.</param>
|
||||
/// <param name="dateTimeProvider">Provider for current date time to calculate remainig time on demand for state of type reserved.</param>
|
||||
/// <param name="wheelType"></param>
|
||||
/// <param name="currentStationId">Name of station where bike is located, null if bike is on the road.</param>
|
||||
/// <param name="stationId">Name of station where bike is located, null if bike is on the road.</param>
|
||||
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
|
||||
/// <param name="tariffDescription">Hold tariff description of bike.</param>
|
||||
/// <param name="stateInfo">Bike state info.</param>
|
||||
|
@ -35,7 +35,8 @@ namespace TINK.Model.Bike.BC
|
|||
WheelType? wheelType = null,
|
||||
TypeOfBike? typeOfBike = null,
|
||||
string description = null,
|
||||
string currentStationId = null,
|
||||
string stationId = null,
|
||||
string stationName = null,
|
||||
Uri operatorUri = null,
|
||||
TariffDescription tariffDescription = null,
|
||||
Func<DateTime> dateTimeProvider = null,
|
||||
|
@ -46,32 +47,36 @@ namespace TINK.Model.Bike.BC
|
|||
m_oBike = new Bike(id, wheelType, typeOfBike, description);
|
||||
m_oStateInfo = new StateInfoMutable(dateTimeProvider, stateInfo);
|
||||
m_oStateInfo.PropertyChanged += (sender, eventargs) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(eventargs.PropertyName));
|
||||
CurrentStation = currentStationId;
|
||||
StationId = stationId;
|
||||
StationName = stationName;
|
||||
OperatorUri = operatorUri;
|
||||
TariffDescription = tariffDescription;
|
||||
}
|
||||
|
||||
/// <summary> Constructs a bike object from source. </summary>
|
||||
public BikeInfoMutable(IBikeInfo p_oBike) : this(
|
||||
p_oBike.Id,
|
||||
p_oBike.IsDemo,
|
||||
p_oBike.Group,
|
||||
p_oBike.WheelType,
|
||||
p_oBike.TypeOfBike,
|
||||
p_oBike.Description,
|
||||
p_oBike.CurrentStation,
|
||||
p_oBike.OperatorUri,
|
||||
p_oBike.TariffDescription,
|
||||
public BikeInfoMutable(IBikeInfo bike, string stationName) : this(
|
||||
bike.Id,
|
||||
bike.IsDemo,
|
||||
bike.Group,
|
||||
bike.WheelType,
|
||||
bike.TypeOfBike,
|
||||
bike.Description,
|
||||
bike.StationId,
|
||||
stationName,
|
||||
bike.OperatorUri,
|
||||
bike.TariffDescription,
|
||||
null,
|
||||
p_oBike.State)
|
||||
bike.State)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Station a which bike is located, null otherwise.
|
||||
/// </summary>
|
||||
/// <summary> Id of station a which bike is located, null otherwise.</summary>
|
||||
[DataMember]
|
||||
public string CurrentStation { get; }
|
||||
public string StationId { get; }
|
||||
|
||||
/// <summary> Name of station a which bike is located, null otherwise. </summary>
|
||||
[DataMember]
|
||||
public string StationName { get; }
|
||||
|
||||
/// <summary> Holds description about the tarif. </summary>
|
||||
[DataMember]
|
||||
|
@ -118,7 +123,7 @@ namespace TINK.Model.Bike.BC
|
|||
/// <returns></returns>
|
||||
public new string ToString()
|
||||
{
|
||||
return $"Id={Id}{(WheelType != null ? $", wheel(s)={WheelType}" : string.Empty)}{(TypeOfBike != null ? $", type={TypeOfBike}" : "")}, demo={IsDemo}, state={State.ToString()}, location={(!string.IsNullOrEmpty(CurrentStation) ? $"Station {CurrentStation}" : "On the road")}.";
|
||||
return $"Id={Id}{(WheelType != null ? $", wheel(s)={WheelType}" : string.Empty)}{(TypeOfBike != null ? $", type={TypeOfBike}" : "")}, demo={IsDemo}, state={State.ToString()}, location={(!string.IsNullOrEmpty(StationId) ? $"Station {StationId}" : "On the road")}.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace TINK.Model.Bike.BC
|
|||
/// <summary>
|
||||
/// Station a which bike is located, null otherwise.
|
||||
/// </summary>
|
||||
string CurrentStation { get; }
|
||||
string StationId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Uri of the operator or null, in case of single operator setup.
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace TINK.Model.Bikes.Bike.BC
|
|||
/// <summary>
|
||||
/// Station a which bike is located, null otherwise.
|
||||
/// </summary>
|
||||
string CurrentStation { get; }
|
||||
string StationId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Holds the rent state of the bike.
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using TINK.Model.Bikes.Bike;
|
||||
using TINK.Model.Bikes.Bike.BluetoothLock;
|
||||
|
||||
namespace TINK.Model.Bike.BluetoothLock
|
||||
|
@ -7,14 +6,15 @@ namespace TINK.Model.Bike.BluetoothLock
|
|||
public class BikeInfoMutable : BC.BikeInfoMutable, IBikeInfoMutable
|
||||
{
|
||||
/// <summary> Constructs a bike object from source. </summary>
|
||||
public BikeInfoMutable(BikeInfo bike) : base(
|
||||
public BikeInfoMutable(BikeInfo bike, string stationName) : base(
|
||||
bike.Id,
|
||||
bike.IsDemo,
|
||||
bike.Group,
|
||||
bike.WheelType,
|
||||
bike.TypeOfBike,
|
||||
bike.Description,
|
||||
bike.CurrentStation,
|
||||
bike.StationId,
|
||||
stationName,
|
||||
bike.OperatorUri,
|
||||
bike.TariffDescription,
|
||||
() => DateTime.Now,
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace TINK.Model
|
|||
string selectedStation)
|
||||
{
|
||||
return new BikeCollection(bikesAtAnyStation?
|
||||
.Where(bike => !string.IsNullOrEmpty(selectedStation) && bike.CurrentStation == selectedStation)
|
||||
.Where(bike => !string.IsNullOrEmpty(selectedStation) && bike.StationId == selectedStation)
|
||||
.ToDictionary(x => x.Id) ?? new Dictionary<string, BikeInfo>());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
using System;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
||||
using TINK.Model.Station;
|
||||
using BikeInfo = TINK.Model.Bike.BC.BikeInfo;
|
||||
using BikeInfoMutable = TINK.Model.Bike.BC.BikeInfoMutable;
|
||||
|
||||
|
@ -22,10 +23,11 @@ namespace TINK.Model.Bike
|
|||
/// - removes bikes which are no more contained in bikes response
|
||||
/// - updates state of all bikes from state contained in bikes response
|
||||
/// </summary>
|
||||
/// <param name="bikesAll"> Object holding bikes info from copri to update from.</param>
|
||||
/// <param name="bikesAll"> Object holding bikes info from copri to update from. Holds station id but not station name.</param>
|
||||
/// <param name="stations"> All stations to get station names from.</param>
|
||||
/// <param name="p_oDateTimeProvider">Provices date time information.</param>
|
||||
public void Update(
|
||||
IEnumerable<BikeInfo> bikesAll)
|
||||
public void Update(IEnumerable<BikeInfo> bikesAll,
|
||||
IEnumerable<IStation> stations)
|
||||
{
|
||||
// Get list of current bikes by state(s) to update.
|
||||
// Needed to remove bikes which switched state and have to be removed from collection.
|
||||
|
@ -33,16 +35,21 @@ namespace TINK.Model.Bike
|
|||
|
||||
foreach (var bikeInfo in bikesAll ?? new List<BikeInfo>())
|
||||
{
|
||||
/// Check if bike has to be added to list of existing station.
|
||||
// Get name of station form station id.
|
||||
var stationName = stations?.FirstOrDefault(x => x.Id == bikeInfo.StationId)?.StationName ?? string.Empty;
|
||||
if (string.IsNullOrEmpty(stationName))
|
||||
Log.ForContext<BikeCollectionMutable>().Debug($"No name for station with id {bikeInfo.StationId} found.");
|
||||
|
||||
// Check if bike has to be added to list of existing station.
|
||||
if (ContainsKey(bikeInfo.Id) == false)
|
||||
{
|
||||
// Bike does not yet exist in list of bikes.
|
||||
Add(BikeInfoMutableFactory.Create(bikeInfo));
|
||||
Add(BikeInfoMutableFactory.Create(bikeInfo, stationName));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Update bike.
|
||||
GetById(bikeInfo.Id).State.Load(bikeInfo.State);
|
||||
GetById(bikeInfo.Id).State.Load(bikeInfo.State);
|
||||
|
||||
if (bikesToBeRemoved.Contains<string>(bikeInfo.Id))
|
||||
{
|
||||
|
@ -52,29 +59,29 @@ namespace TINK.Model.Bike
|
|||
}
|
||||
|
||||
// Remove obsolete bikes.
|
||||
foreach (var l_oId in bikesToBeRemoved)
|
||||
foreach (var stationId in bikesToBeRemoved)
|
||||
{
|
||||
RemoveById(l_oId);
|
||||
RemoveById(stationId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new bike to collecion of bike.
|
||||
/// </summary>
|
||||
/// <param name="p_oNewBike">New bike to add.</param>
|
||||
/// <param name="newBike">New bike to add.</param>
|
||||
/// <exception cref="Exception">Thrown if bike is not unique.</exception>
|
||||
public new void Add(BikeInfoMutable p_oNewBike)
|
||||
public new void Add(BikeInfoMutable newBike)
|
||||
{
|
||||
// Ensure that bike id of new bike is is unique
|
||||
foreach (BikeInfoMutable l_oBike in Items)
|
||||
foreach (BikeInfoMutable bike in Items)
|
||||
{
|
||||
if (l_oBike.Id == p_oNewBike.Id)
|
||||
if (bike.Id == newBike.Id)
|
||||
{
|
||||
throw new Exception(string.Format("Can not add bike with {0} to collection ob bike. Id is not unnique.", p_oNewBike));
|
||||
throw new Exception(string.Format("Can not add bike with {0} to collection ob bike. Id is not unnique.", newBike));
|
||||
}
|
||||
}
|
||||
|
||||
base.Add(p_oNewBike);
|
||||
base.Add(newBike);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -134,11 +141,11 @@ namespace TINK.Model.Bike
|
|||
/// </summary>
|
||||
private static class BikeInfoMutableFactory
|
||||
{
|
||||
public static BikeInfoMutable Create(BikeInfo bikeInfo)
|
||||
public static BikeInfoMutable Create(BikeInfo bikeInfo, string stationName)
|
||||
{
|
||||
return (bikeInfo is BluetoothLock.BikeInfo bluetoothLockBikeInfo)
|
||||
? new BluetoothLock.BikeInfoMutable(bluetoothLockBikeInfo)
|
||||
: new BikeInfoMutable(bikeInfo);
|
||||
? new BluetoothLock.BikeInfoMutable(bluetoothLockBikeInfo, stationName)
|
||||
: new BikeInfoMutable(bikeInfo, stationName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace TINK.Model.Connector
|
|||
{
|
||||
response = (await CopriServer.DoAuthorizationAsync(mail, password, deviceId)).GetIsResponseOk(mail);
|
||||
}
|
||||
catch (System.Exception)
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
|
|
@ -23,9 +23,9 @@ namespace TINK.Model.Connector
|
|||
/// <summary>Constructs a copri query object.</summary>
|
||||
/// <param name="p_oCopriServer">Server which implements communication.</param>
|
||||
public CommandLoggedIn(ICopriServerBase p_oCopriServer,
|
||||
string p_strSessionCookie,
|
||||
string p_strMail,
|
||||
Func<DateTime> p_oDateTimeProvider) : base(p_oCopriServer, p_strSessionCookie, p_strMail, p_oDateTimeProvider)
|
||||
string sessionCookie,
|
||||
string mail,
|
||||
Func<DateTime> dateTimeProvider) : base(p_oCopriServer, sessionCookie, mail, dateTimeProvider)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -36,14 +36,14 @@ namespace TINK.Model.Connector
|
|||
/// If communication fails an TINK.Repository.Exception is thrown.
|
||||
/// </summary>
|
||||
/// <param name="p_oAccount">Account to use for login.</param>
|
||||
public Task<IAccount> DoLogin(string p_strMail, string p_strPassword, string p_strDeviceId)
|
||||
public Task<IAccount> DoLogin(string mail, string password, string deviceId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(p_strMail))
|
||||
if (string.IsNullOrEmpty(mail))
|
||||
{
|
||||
throw new ArgumentNullException("Can not loging user. Mail address must not be null or empty.");
|
||||
}
|
||||
|
||||
throw new Exception($"Fehler beim Anmelden von unter {p_strMail}. Benutzer {Mail} ist bereits angemeldet.");
|
||||
throw new Exception($"Fehler beim Anmelden von unter {mail}. Benutzer {Mail} ist bereits angemeldet.");
|
||||
}
|
||||
|
||||
/// <summary> Logs user out. </summary>
|
||||
|
|
|
@ -25,12 +25,12 @@ namespace TINK.Model.Connector
|
|||
ICachedCopriServer server = null )
|
||||
{
|
||||
Command = GetCommand(
|
||||
server ?? new CopriProviderHttps(activeUri, TinkApp.MerchantId, appContextInfo, sessionCookie),
|
||||
server ?? new CopriProviderHttps(activeUri, appContextInfo.MerchantId, appContextInfo, sessionCookie),
|
||||
sessionCookie,
|
||||
mail);
|
||||
|
||||
Query = GetQuery(
|
||||
server ?? new CopriProviderHttps(activeUri, TinkApp.MerchantId, appContextInfo, sessionCookie, expiresAfter),
|
||||
server ?? new CopriProviderHttps(activeUri, appContextInfo.MerchantId, appContextInfo, sessionCookie, expiresAfter),
|
||||
sessionCookie,
|
||||
mail);
|
||||
}
|
||||
|
|
|
@ -14,18 +14,19 @@ namespace TINK.Model.Connector
|
|||
/// <param name="p_strMail">Mail of user.</param>
|
||||
/// <param name="server"> Provides addess to copri.</param>
|
||||
public ConnectorCache(
|
||||
AppContextInfo appContextInfo,
|
||||
string sessionCookie,
|
||||
string mail,
|
||||
ICopriServer server = null)
|
||||
{
|
||||
|
||||
Command = Connector.GetCommand(
|
||||
server ?? new CopriProviderMonkeyStore(TinkApp.MerchantId, sessionCookie),
|
||||
server ?? new CopriProviderMonkeyStore(appContextInfo.MerchantId, sessionCookie),
|
||||
sessionCookie,
|
||||
mail);
|
||||
|
||||
Query = GetQuery(
|
||||
server ?? new CopriProviderMonkeyStore(TinkApp.MerchantId, sessionCookie),
|
||||
server ?? new CopriProviderMonkeyStore(appContextInfo.MerchantId, sessionCookie),
|
||||
sessionCookie,
|
||||
mail);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace TINK.Model.Connector
|
|||
{
|
||||
return isConnected
|
||||
? new Connector(activeUri, appContextInfo, sessionCookie, mail, expiresAfter: expiresAfter) as IConnector
|
||||
: new ConnectorCache(sessionCookie, mail);
|
||||
: new ConnectorCache(appContextInfo, sessionCookie, mail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,24 +16,24 @@ namespace TINK.Model.Connector
|
|||
protected readonly Func<DateTime> DateTimeProvider;
|
||||
|
||||
/// <summary>Constructs a copri query object.</summary>
|
||||
/// <param name="p_oCopriServer">Server which implements communication.</param>
|
||||
public BaseLoggedIn(ICopriServerBase p_oCopriServer,
|
||||
string p_strSessionCookie,
|
||||
string p_strMail,
|
||||
Func<DateTime> p_oDateTimeProvider) : base(p_oCopriServer)
|
||||
/// <param name="copriServer">Server which implements communication.</param>
|
||||
public BaseLoggedIn(ICopriServerBase copriServer,
|
||||
string sessionCookie,
|
||||
string mail,
|
||||
Func<DateTime> p_oDateTimeProvider) : base(copriServer)
|
||||
{
|
||||
if (string.IsNullOrEmpty(p_strSessionCookie))
|
||||
if (string.IsNullOrEmpty(sessionCookie))
|
||||
throw new ArgumentException("Can not instantiate query object- object. Session cookie must never be null or emtpy.");
|
||||
|
||||
if (string.IsNullOrEmpty(p_strMail))
|
||||
if (string.IsNullOrEmpty(mail))
|
||||
throw new ArgumentException("Can not instantiate query object- object. Mail address must never be null or emtpy.");
|
||||
|
||||
DateTimeProvider = p_oDateTimeProvider
|
||||
?? throw new ArgumentException("Can not instantiate connector- object. No date time provider object available.");
|
||||
|
||||
SessionCookie = p_strSessionCookie;
|
||||
SessionCookie = sessionCookie;
|
||||
|
||||
Mail = p_strMail;
|
||||
Mail = mail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,30 +26,30 @@ namespace TINK.Model.Connector
|
|||
/// <summary>
|
||||
/// Gets the position from StationInfo object.
|
||||
/// </summary>
|
||||
/// <param name="p_oStationInfo">Object to get information from.</param>
|
||||
/// <param name="stationInfo">Object to get information from.</param>
|
||||
/// <returns>Position information.</returns>
|
||||
public static Station.Position GetPosition(this StationsAvailableResponse.StationInfo p_oStationInfo)
|
||||
public static Station.Position GetPosition(this StationsAvailableResponse.StationInfo stationInfo)
|
||||
{
|
||||
return GetPosition(p_oStationInfo.gps);
|
||||
return GetPosition(stationInfo.gps);
|
||||
}
|
||||
|
||||
/// <summary> Gets the position from StationInfo object. </summary>
|
||||
/// <param name="p_oAuthorizationResponse">Object to get information from.</param>
|
||||
/// <param name="authorizationResponse">Object to get information from.</param>
|
||||
/// <returns>Position information.</returns>
|
||||
public static IEnumerable<string> GetGroup(this AuthorizationResponse p_oAuthorizationResponse)
|
||||
public static IEnumerable<string> GetGroup(this AuthorizationResponse authorizationResponse)
|
||||
{
|
||||
try
|
||||
{
|
||||
return p_oAuthorizationResponse.user_group.GetGroup();
|
||||
return authorizationResponse.user_group.GetGroup();
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
throw new Exception($"Can not get group of user from text \"{p_oAuthorizationResponse.user_group}\".", l_oException);
|
||||
throw new Exception($"Can not get group of user from text \"{authorizationResponse.user_group}\".", l_oException);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets the position from StationInfo object. </summary>
|
||||
/// <param name="p_oAuthorizationResponse">Object to get information from.</param>
|
||||
/// <param name="group">Object to get information from.</param>
|
||||
/// <returns>Position information.</returns>
|
||||
public static IEnumerable<string> GetGroup(this string[] group)
|
||||
{
|
||||
|
@ -63,43 +63,50 @@ namespace TINK.Model.Connector
|
|||
return new HashSet<string>(group).ToList();
|
||||
}
|
||||
|
||||
/// <summary> Gets the position from StationInfo object. </summary>
|
||||
/// <param name="p_oAuthorizationResponse">Object to get information from.</param>
|
||||
/// <summary> Gets if user acknowldged ags or not. </summary>
|
||||
/// <param name="authorizationResponse">Object to get information from.</param>
|
||||
/// <returns>Position information.</returns>
|
||||
public static string GetGroup(this IEnumerable<string> p_oGroup)
|
||||
public static bool GetIsAgbAcknowledged(this AuthorizationResponse authorizationResponse)
|
||||
=> int.TryParse(authorizationResponse?.agb_checked, out int result)
|
||||
&& result != 0;
|
||||
|
||||
/// <summary> Gets the position from StationInfo object. </summary>
|
||||
/// <param name="group">Object to get information from.</param>
|
||||
/// <returns>Position information.</returns>
|
||||
public static string GetGroup(this IEnumerable<string> group)
|
||||
{
|
||||
return string.Join(",", p_oGroup);
|
||||
return string.Join(",", group);
|
||||
}
|
||||
|
||||
/// <summary> Gets the position from StationInfo object. </summary>
|
||||
/// <param name="p_oStationInfo">Object to get information from.</param>
|
||||
/// <param name="stationInfo">Object to get information from.</param>
|
||||
/// <returns>Position information.</returns>
|
||||
public static IEnumerable<string> GetGroup(this StationsAvailableResponse.StationInfo p_oStationInfo)
|
||||
public static IEnumerable<string> GetGroup(this StationsAvailableResponse.StationInfo stationInfo)
|
||||
{
|
||||
try
|
||||
{
|
||||
return p_oStationInfo.station_group.GetGroup();
|
||||
return stationInfo.station_group.GetGroup();
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
throw new Exception($"Can not get group of stations from text \"{p_oStationInfo.station_group}\".", l_oException);
|
||||
throw new Exception($"Can not get group of stations from text \"{stationInfo.station_group}\".", l_oException);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the position from StationInfo object.
|
||||
/// </summary>
|
||||
/// <param name="p_oBikeInfo">Object to get information from.</param>
|
||||
/// <param name="bikeInfo">Object to get information from.</param>
|
||||
/// <returns>Position information.</returns>
|
||||
public static InUseStateEnum GetState(this BikeInfoBase p_oBikeInfo)
|
||||
public static InUseStateEnum GetState(this BikeInfoBase bikeInfo)
|
||||
{
|
||||
var l_oState = p_oBikeInfo.state;
|
||||
var l_oState = bikeInfo.state;
|
||||
|
||||
if (string.IsNullOrEmpty(l_oState))
|
||||
{
|
||||
throw new InvalidResponseException<BikeInfoBase>(
|
||||
string.Format("Unknown reservation state detected. Member {0}.{1}.", typeof(BikeInfoBase), nameof(BikeInfoBase.state)),
|
||||
p_oBikeInfo);
|
||||
bikeInfo);
|
||||
}
|
||||
|
||||
if (l_oState == "available")
|
||||
|
@ -123,58 +130,58 @@ namespace TINK.Model.Connector
|
|||
/// <summary>
|
||||
/// Gets the from date information from JSON.
|
||||
/// </summary>
|
||||
/// <param name="p_oBikeInfo">JSON to get information from..</param>
|
||||
/// <param name="bikeInfo">JSON to get information from..</param>
|
||||
/// <returns>From information.</returns>
|
||||
public static DateTime GetFrom(this BikeInfoReservedOrBooked p_oBikeInfo)
|
||||
public static DateTime GetFrom(this BikeInfoReservedOrBooked bikeInfo)
|
||||
{
|
||||
return DateTime.Parse(p_oBikeInfo.start_time);
|
||||
return DateTime.Parse(bikeInfo.start_time);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the bike is a trike or not.
|
||||
/// </summary>
|
||||
/// <param name="p_oBikeInfo">JSON to get information from..</param>
|
||||
/// <param name="bikeInfo">JSON to get information from..</param>
|
||||
/// <returns>From information.</returns>
|
||||
public static bool? GetIsDemo(this BikeInfoBase p_oBikeInfo)
|
||||
public static bool? GetIsDemo(this BikeInfoBase bikeInfo)
|
||||
{
|
||||
return p_oBikeInfo?.description != null
|
||||
? p_oBikeInfo.description.ToUpper().Contains(DEMOBIKEMARKER)
|
||||
return bikeInfo?.description != null
|
||||
? bikeInfo.description.ToUpper().Contains(DEMOBIKEMARKER)
|
||||
: (bool?) null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the bike is a trike or not.
|
||||
/// </summary>
|
||||
/// <param name="p_oBikeInfo">JSON to get information from..</param>
|
||||
/// <param name="bikeInfo">JSON to get information from.</param>
|
||||
/// <returns>From information.</returns>
|
||||
public static IEnumerable<string> GetGroup(this BikeInfoBase p_oBikeInfo)
|
||||
public static IEnumerable<string> GetGroup(this BikeInfoBase bikeInfo)
|
||||
{
|
||||
try
|
||||
{
|
||||
return p_oBikeInfo?.bike_group?.GetGroup()?.ToList() ?? new List<string>();
|
||||
return bikeInfo?.bike_group?.GetGroup()?.ToList() ?? new List<string>();
|
||||
}
|
||||
catch (System.Exception l_oException)
|
||||
{
|
||||
throw new System.Exception($"Can not get group of user from text \"{p_oBikeInfo.bike_group}\".", l_oException);
|
||||
throw new System.Exception($"Can not get group of user from text \"{bikeInfo.bike_group}\".", l_oException);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets whether the bike has a bord computer or not. </summary>
|
||||
/// <param name="p_oBikeInfo">JSON to get information from.</param>
|
||||
/// <param name="bikeInfo">JSON to get information from.</param>
|
||||
/// <returns>From information.</returns>
|
||||
public static bool GetIsManualLockBike(this BikeInfoBase p_oBikeInfo)
|
||||
public static bool GetIsManualLockBike(this BikeInfoBase bikeInfo)
|
||||
{
|
||||
return !string.IsNullOrEmpty(p_oBikeInfo.system)
|
||||
&& p_oBikeInfo.system.ToUpper().StartsWith("LOCK");
|
||||
return !string.IsNullOrEmpty(bikeInfo.system)
|
||||
&& bikeInfo.system.ToUpper().StartsWith("LOCK");
|
||||
}
|
||||
|
||||
/// <summary> Gets whether the bike has a bord computer or not. </summary>
|
||||
/// <param name="p_oBikeInfo">JSON to get information from..</param>
|
||||
/// <param name="bikeInfo">JSON to get information from..</param>
|
||||
/// <returns>From information.</returns>
|
||||
public static bool GetIsBluetoothLockBike(this BikeInfoBase p_oBikeInfo)
|
||||
public static bool GetIsBluetoothLockBike(this BikeInfoBase bikeInfo)
|
||||
{
|
||||
return !string.IsNullOrEmpty(p_oBikeInfo.system)
|
||||
&& p_oBikeInfo.system.ToUpper().StartsWith("ILOCKIT");
|
||||
return !string.IsNullOrEmpty(bikeInfo.system)
|
||||
&& bikeInfo.system.ToUpper().StartsWith("ILOCKIT");
|
||||
}
|
||||
|
||||
/// <summary> Gets whether the bike has a bord computer or not. </summary>
|
||||
|
@ -342,13 +349,22 @@ namespace TINK.Model.Connector
|
|||
: null;
|
||||
}
|
||||
|
||||
/// <summary> Tries to get the copriversion from response.</summary>
|
||||
/// <param name="response">Response to get version info from.</param>
|
||||
/// <returns>COPRI version</returns>
|
||||
public static bool TryGetCopriVersion(this CopriVersion response, out Version copriVersion)
|
||||
{
|
||||
copriVersion = new Version(0, 0);
|
||||
return response != null
|
||||
&& !string.IsNullOrEmpty(response.copri_version)
|
||||
&& Version.TryParse(response.copri_version, out copriVersion);
|
||||
}
|
||||
|
||||
/// <summary> Gets the copriversion from.</summary>
|
||||
/// <param name="response">Response to get version info from.</param>
|
||||
/// <returns>COPRI version</returns>
|
||||
public static Version GetCopriVersion(this CopriVersion response)
|
||||
=> response!= null
|
||||
&& !string.IsNullOrEmpty(response.copri_version)
|
||||
&& Version.TryParse(response.copri_version, out Version copriVersion)
|
||||
=> response.TryGetCopriVersion(out Version copriVersion)
|
||||
? copriVersion
|
||||
: throw new InvalidResponseException($"Can not get version info from copri response {response?.copri_version}.");
|
||||
}
|
||||
|
|
|
@ -85,7 +85,9 @@ namespace TINK.Model.Connector
|
|||
/// <param name="response">Response to get data from.</param>
|
||||
/// <returns>General data object initialized form COPRI response.</returns>
|
||||
public static GeneralData GetGeneralData(this ResponseBase response)
|
||||
=> new GeneralData(response.merchant_message, response.GetCopriVersion());
|
||||
=> new GeneralData(response.merchant_message, response.TryGetCopriVersion(out Version copriVersion)
|
||||
? new Version(0,0)
|
||||
: copriVersion);
|
||||
|
||||
/// <summary> Gets account object from login response.</summary>
|
||||
/// <param name="merchantId">Needed to extract cookie from autorization response.</param>
|
||||
|
@ -106,6 +108,7 @@ namespace TINK.Model.Connector
|
|||
return new Account(
|
||||
mail,
|
||||
password,
|
||||
loginResponse.GetIsAgbAcknowledged(),
|
||||
loginResponse.authcookie?.Replace(merchantId, ""),
|
||||
loginResponse.GetGroup(),
|
||||
loginResponse.debuglevel == 1
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace TINK.Model
|
|||
public delegate bool SetCredentialsDelegate(string p_strMailAddress, string p_strPassword);
|
||||
|
||||
/// <summary>Returns the id of the app (sharee.bike) to be identified by copri.</summary>
|
||||
public static string MerchantId => "oiF2kahH";
|
||||
public static string MerchantId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Holds status about whants new page.
|
||||
|
@ -160,6 +160,7 @@ namespace TINK.Model
|
|||
Settings.Settings settings,
|
||||
IStore accountStore,
|
||||
Func<bool, Uri, string /* session cookie*/, string /* mail address*/, TimeSpan, IConnector> connectorFactory,
|
||||
string merchantId,
|
||||
IServicesContainer<IGeolocation> geolocationServicesContainer,
|
||||
ILocksService locksService,
|
||||
ISmartDevice device,
|
||||
|
@ -179,6 +180,9 @@ namespace TINK.Model
|
|||
ConnectorFactory = connectorFactory
|
||||
?? throw new ArgumentException("Can not instantiate TinkApp- object. No connector factory object available.");
|
||||
|
||||
MerchantId = merchantId
|
||||
?? throw new ArgumentException($"Can not instantiate {nameof(TinkApp)}. No merchant id available.");
|
||||
|
||||
Cipher = cipher ?? new Cipher();
|
||||
|
||||
var locksServices = locksService != null
|
||||
|
|
|
@ -49,6 +49,8 @@ namespace TINK.Model.User.Account
|
|||
/// </summary>
|
||||
public class Account : IAccount
|
||||
{
|
||||
public const bool DEFAULTISAGBACKNOWLEDGED = false;
|
||||
|
||||
/// <summary> Constructs an account object.</summary>
|
||||
/// <param name="mail">Mail address of the account holder.</param>
|
||||
/// <param name="password">Password.</param>
|
||||
|
@ -58,12 +60,14 @@ namespace TINK.Model.User.Account
|
|||
public Account(
|
||||
string mail,
|
||||
string password,
|
||||
bool isAgbAcknowledged,
|
||||
string sessionCookie,
|
||||
IEnumerable<string> bikeGroup,
|
||||
Permissions debugLevel = Permissions.None)
|
||||
{
|
||||
Mail = mail;
|
||||
Pwd = password;
|
||||
IsAgbAcknowledged = isAgbAcknowledged;
|
||||
SessionCookie = sessionCookie;
|
||||
DebugLevel = debugLevel;
|
||||
Group = bikeGroup != null
|
||||
|
@ -71,7 +75,7 @@ namespace TINK.Model.User.Account
|
|||
: throw new ArgumentException("Can not instantiate account object. Reference to group list must not be empty.");
|
||||
}
|
||||
|
||||
public Account(IAccount p_oSource) : this(p_oSource?.Mail, p_oSource?.Pwd, p_oSource?.SessionCookie, p_oSource?.Group, p_oSource?.DebugLevel ?? Permissions.None)
|
||||
public Account(IAccount source) : this(source?.Mail, source?.Pwd, source?.IsAgbAcknowledged ?? DEFAULTISAGBACKNOWLEDGED, source?.SessionCookie, source?.Group, source?.DebugLevel ?? Permissions.None)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -81,6 +85,9 @@ namespace TINK.Model.User.Account
|
|||
/// <summary>Password of to authenticate.</summary>
|
||||
public string Pwd { get; }
|
||||
|
||||
/// <summary>True if user acknowleged agbs.</summary>
|
||||
public bool IsAgbAcknowledged { get; }
|
||||
|
||||
/// <summary>Session cookie used to sign in to copri.</summary>
|
||||
public string SessionCookie { get; }
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace TINK.Model.User.Account
|
|||
public string Mail
|
||||
{
|
||||
get { return m_oAccount.Mail; }
|
||||
set { m_oAccount = new Account(value, m_oAccount.Pwd, m_oAccount.SessionCookie, m_oAccount.Group, m_oAccount.DebugLevel); }
|
||||
set { m_oAccount = new Account(value, m_oAccount.Pwd, m_oAccount.IsAgbAcknowledged, m_oAccount.SessionCookie, m_oAccount.Group, m_oAccount.DebugLevel); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -38,16 +38,19 @@ namespace TINK.Model.User.Account
|
|||
public string Pwd
|
||||
{
|
||||
get { return m_oAccount.Pwd; }
|
||||
set { m_oAccount = new Account(m_oAccount.Mail, value, m_oAccount.SessionCookie, m_oAccount.Group, m_oAccount.DebugLevel); }
|
||||
set { m_oAccount = new Account(m_oAccount.Mail, value, m_oAccount.IsAgbAcknowledged, m_oAccount.SessionCookie, m_oAccount.Group, m_oAccount.DebugLevel); }
|
||||
}
|
||||
|
||||
/// <summary>True if user acknowleged agbs.</summary>
|
||||
public bool IsAgbAcknowledged => m_oAccount.IsAgbAcknowledged;
|
||||
|
||||
/// <summary>
|
||||
/// Session cookie used to sign in to copri.
|
||||
/// </summary>
|
||||
public string SessionCookie
|
||||
{
|
||||
get { return m_oAccount.SessionCookie; }
|
||||
set { m_oAccount = new Account(m_oAccount.Mail, m_oAccount.Pwd, value, m_oAccount.Group, m_oAccount.DebugLevel); }
|
||||
set { m_oAccount = new Account(m_oAccount.Mail, m_oAccount.Pwd, m_oAccount.IsAgbAcknowledged, value, m_oAccount.Group, m_oAccount.DebugLevel); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -64,7 +67,7 @@ namespace TINK.Model.User.Account
|
|||
public Permissions DebugLevel
|
||||
{
|
||||
get { return m_oAccount.DebugLevel; }
|
||||
set { m_oAccount = new Account(m_oAccount.Mail, m_oAccount.Pwd, m_oAccount.SessionCookie, m_oAccount.Group, value); }
|
||||
set { m_oAccount = new Account(m_oAccount.Mail, m_oAccount.Pwd, m_oAccount.IsAgbAcknowledged, m_oAccount.SessionCookie, m_oAccount.Group, value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ namespace TINK.Model.User.Account
|
|||
|
||||
public string Pwd => null;
|
||||
|
||||
public bool IsAgbAcknowledged => false;
|
||||
|
||||
public string SessionCookie => null;
|
||||
|
||||
public Permissions DebugLevel => Permissions.None;
|
||||
|
|
|
@ -13,6 +13,9 @@ namespace TINK.Model.User.Account
|
|||
/// <summary>Password of the account.</summary>
|
||||
string Pwd { get; }
|
||||
|
||||
/// <summary>True if user acknowleged agbs.</summary>
|
||||
bool IsAgbAcknowledged { get; }
|
||||
|
||||
/// <summary>Session cookie used to sign in to copri.</summary>
|
||||
string SessionCookie { get; }
|
||||
|
||||
|
|
|
@ -17,6 +17,9 @@ namespace TINK.Model.User.Account
|
|||
/// <summary> Holds id of the mail address key. </summary>
|
||||
private const string KEY_MAILADDRESS = "MailAddress";
|
||||
|
||||
/// <summary> Holds key for flag is agb acknowledged. </summary>
|
||||
private const string KEY_ISAGBACKNOWLEDGED = "IsAgbAcknowledged";
|
||||
|
||||
public IAccount Delete(IAccount account)
|
||||
{
|
||||
SecureStorage.RemoveAll();
|
||||
|
@ -27,15 +30,16 @@ namespace TINK.Model.User.Account
|
|||
{
|
||||
|
||||
var mail = string.Empty;
|
||||
var isAgbAcknowledged = Account.DEFAULTISAGBACKNOWLEDGED;
|
||||
var sessionCookie = string.Empty;
|
||||
var debugLevel = Permissions.None;
|
||||
|
||||
try
|
||||
{
|
||||
mail = await SecureStorage.GetAsync(KEY_MAILADDRESS);
|
||||
bool.TryParse(await SecureStorage.GetAsync(KEY_ISAGBACKNOWLEDGED), out isAgbAcknowledged);
|
||||
sessionCookie = await SecureStorage.GetAsync(KEY_SESSIONCOOKIE);
|
||||
Enum.TryParse(await SecureStorage.GetAsync(KEY_DEBUGLEVEL), out debugLevel);
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
@ -45,6 +49,7 @@ namespace TINK.Model.User.Account
|
|||
return new Account(
|
||||
mail,
|
||||
string.Empty,
|
||||
isAgbAcknowledged,
|
||||
sessionCookie,
|
||||
new List<string>(),
|
||||
debugLevel);
|
||||
|
@ -55,6 +60,7 @@ namespace TINK.Model.User.Account
|
|||
try
|
||||
{
|
||||
await SecureStorage.SetAsync(KEY_MAILADDRESS, mailAndPwd.Mail);
|
||||
await SecureStorage.SetAsync(KEY_ISAGBACKNOWLEDGED, mailAndPwd.IsAgbAcknowledged.ToString());
|
||||
await SecureStorage.SetAsync(KEY_SESSIONCOOKIE, mailAndPwd.SessionCookie);
|
||||
await SecureStorage.SetAsync(KEY_DEBUGLEVEL, mailAndPwd.DebugLevel.ToString());
|
||||
}
|
||||
|
|
|
@ -476,7 +476,7 @@ namespace TINK.Model
|
|||
AppResources.ChangeLog3_0_266
|
||||
},
|
||||
{
|
||||
new Version(3, 0, 267),
|
||||
new Version(3, 0, 270),
|
||||
AppResources.ChangeLog3_0_231 // Minor improvements.
|
||||
}
|
||||
};
|
||||
|
|
|
@ -767,29 +767,29 @@ namespace TINK.Repository
|
|||
var l_strHost = uRL;
|
||||
|
||||
// Returns a http request.
|
||||
var l_oRequest = WebRequest.CreateHttp(l_strHost);
|
||||
var request = WebRequest.CreateHttp(l_strHost);
|
||||
|
||||
l_oRequest.Method = "POST";
|
||||
l_oRequest.ContentType = "application/x-www-form-urlencoded";
|
||||
l_oRequest.UserAgent = userAgent;
|
||||
request.Method = "POST";
|
||||
request.ContentType = "application/x-www-form-urlencoded";
|
||||
request.UserAgent = userAgent;
|
||||
|
||||
// Workaround for issue https://bugzilla.xamarin.com/show_bug.cgi?id=57705
|
||||
// If not KeepAlive is set to true Stream.Write leads arbitrarily to an object disposed exception.
|
||||
l_oRequest.KeepAlive = true;
|
||||
request.KeepAlive = true;
|
||||
|
||||
byte[] l_oPostData = Encoding.UTF8.GetBytes(p_strCommand);
|
||||
|
||||
l_oRequest.ContentLength = l_oPostData.Length;
|
||||
request.ContentLength = l_oPostData.Length;
|
||||
|
||||
// Get the request stream.
|
||||
using (Stream l_oDataStream = await l_oRequest.GetRequestStreamAsync())
|
||||
using (Stream l_oDataStream = await request.GetRequestStreamAsync())
|
||||
{
|
||||
// Write the data to the request stream.
|
||||
await l_oDataStream.WriteAsync(l_oPostData, 0, l_oPostData.Length);
|
||||
}
|
||||
|
||||
// Get the response.
|
||||
var l_oResponse = await l_oRequest.GetResponseAsync() as HttpWebResponse;
|
||||
var l_oResponse = await request.GetResponseAsync() as HttpWebResponse;
|
||||
|
||||
if (l_oResponse == null)
|
||||
{
|
||||
|
|
|
@ -1380,7 +1380,7 @@ namespace TINK.Repository
|
|||
get
|
||||
{
|
||||
var l_iCount = 1;
|
||||
while (GetBikesAvailable(CopriDevelHostUri, TinkApp.MerchantId, p_eSampleSet: ActiveSampleSet, p_lStageIndex: l_iCount) != null)
|
||||
while (GetBikesAvailable(CopriDevelHostUri, MerchantId, p_eSampleSet: ActiveSampleSet, p_lStageIndex: l_iCount) != null)
|
||||
{
|
||||
l_iCount++;
|
||||
}
|
||||
|
|
|
@ -11,5 +11,9 @@ namespace TINK.Repository.Response
|
|||
/// <summary> Holds the group of the bike (TINK, Konrad, ...).</summary>
|
||||
[DataMember]
|
||||
public string[] user_group { get; private set; }
|
||||
|
||||
/// <summary> Holds value of 0 if agb were not acknowledged.</summary>
|
||||
[DataMember]
|
||||
public string agb_checked { get; private set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,13 +195,13 @@ namespace TINK.ViewModel.Bikes.Bike
|
|||
case InUseStateEnum.Reserved:
|
||||
return GetReservedInfo(
|
||||
bike.State.RemainingTime,
|
||||
bike.CurrentStation,
|
||||
bike.StationId,
|
||||
null); // Hide reservation code because no one but active user should see code
|
||||
|
||||
case InUseStateEnum.Booked:
|
||||
return GetBookedInfo(
|
||||
bike.State.From,
|
||||
bike.CurrentStation,
|
||||
bike.StationId,
|
||||
null); // Hide reservation code because no one but active user should see code
|
||||
|
||||
default:
|
||||
|
@ -215,7 +215,7 @@ namespace TINK.ViewModel.Bikes.Bike
|
|||
return bike.State.MailAddress == ActiveUser.Mail
|
||||
? GetReservedInfo(
|
||||
bike.State.RemainingTime,
|
||||
bike.CurrentStation,
|
||||
bike.StationId,
|
||||
bike.State.Code)
|
||||
: "Fahrrad bereits reserviert durch anderen Nutzer.";
|
||||
|
||||
|
@ -223,7 +223,7 @@ namespace TINK.ViewModel.Bikes.Bike
|
|||
return bike.State.MailAddress == ActiveUser.Mail
|
||||
? GetBookedInfo(
|
||||
bike.State.From,
|
||||
bike.CurrentStation,
|
||||
bike.StationId,
|
||||
bike.State.Code)
|
||||
: "Fahrrad bereits gebucht durch anderen Nutzer.";
|
||||
|
||||
|
|
|
@ -27,14 +27,11 @@ namespace TINK.ViewModel.Bikes.Bike
|
|||
// No tariff description details available.
|
||||
return string.Empty;
|
||||
|
||||
// Up to version MessageBikesManagementTariffDescriptionTariffHeaderNameId
|
||||
#if USCSHARP9
|
||||
return Tariff?.Number != null
|
||||
? string.Format(AppResources.MessageBikesManagementTariffDescriptionTariffHeaderNameId, Tariff?.Name ?? "-", Tariff?.Number != null ? Tariff.Number : "-");
|
||||
: string.Format(AppResources.MessageBikesManagementTariffDescriptionTariffHeader, Tariff?.Name ?? "-");
|
||||
return string.Format(AppResources.MessageBikesManagementTariffDescriptionTariffHeader, Tariff?.Name ?? "-");
|
||||
#else
|
||||
return Tariff?.Number != null
|
||||
? string.Format(AppResources.MessageBikesManagementTariffDescriptionTariffHeaderNameId, Tariff?.Name ?? "-", Tariff?.Number != null ? Tariff.Number.ToString() : "-")
|
||||
: string.Format(AppResources.MessageBikesManagementTariffDescriptionTariffHeader, Tariff?.Name ?? "-");
|
||||
return string.Format(AppResources.MessageBikesManagementTariffDescriptionTariffHeader, Tariff?.Name ?? "-");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ namespace TINK.ViewModel.BikesAtStation
|
|||
if (!dialogResult)
|
||||
{
|
||||
// User decided not to give access to locations permissions.
|
||||
BikeCollection.Update(bikesAtStation);
|
||||
BikeCollection.Update(bikesAtStation, new List<IStation> { m_oStation});
|
||||
|
||||
await OnAppearing(() => UpdateTask());
|
||||
|
||||
|
@ -287,7 +287,7 @@ namespace TINK.ViewModel.BikesAtStation
|
|||
AppResources.MessageBikesManagementLocationActivation,
|
||||
AppResources.MessageAnswerOk);
|
||||
|
||||
BikeCollection.Update(bikesAtStation);
|
||||
BikeCollection.Update(bikesAtStation, new List<IStation> { m_oStation });
|
||||
|
||||
await OnAppearing(() => UpdateTask());
|
||||
|
||||
|
@ -303,7 +303,7 @@ namespace TINK.ViewModel.BikesAtStation
|
|||
AppResources.MessageBikesManagementBluetoothActivation,
|
||||
AppResources.MessageAnswerOk);
|
||||
|
||||
BikeCollection.Update(bikesAtStation);
|
||||
BikeCollection.Update(bikesAtStation, new List<IStation> { m_oStation });
|
||||
|
||||
await OnAppearing(() => UpdateTask());
|
||||
|
||||
|
@ -330,7 +330,7 @@ namespace TINK.ViewModel.BikesAtStation
|
|||
|
||||
var locksInfo = lockIdList.UpdateById(locksInfoTdo);
|
||||
|
||||
BikeCollection.Update(bikesAtStation.UpdateLockInfo(locksInfo));
|
||||
BikeCollection.Update(bikesAtStation.UpdateLockInfo(locksInfo), new List<IStation> { m_oStation });
|
||||
|
||||
// Backup GUI synchronization context.
|
||||
await OnAppearing(() => UpdateTask());
|
||||
|
@ -363,7 +363,7 @@ namespace TINK.ViewModel.BikesAtStation
|
|||
PostAction(
|
||||
unused =>
|
||||
{
|
||||
BikeCollection.Update(bikes);
|
||||
BikeCollection.Update(bikes, new List<IStation> { m_oStation });
|
||||
Exception = result.Exception;
|
||||
ActionText = string.Empty;
|
||||
},
|
||||
|
|
|
@ -508,7 +508,7 @@ namespace TINK.ViewModel.Contact
|
|||
foreach (var stationId in stationsId)
|
||||
{
|
||||
// Get color of given station.
|
||||
var bikesAtStation = bikesAll.Where(x => x.CurrentStation == stationId).ToList();
|
||||
var bikesAtStation = bikesAll.Where(x => x.StationId == stationId).ToList();
|
||||
if (bikesAtStation.FirstOrDefault(x => x.State.Value != Model.State.InUseStateEnum.Disposable) != null)
|
||||
{
|
||||
// There is at least one requested or booked bike
|
||||
|
|
|
@ -4,16 +4,23 @@ namespace TINK.ViewModel.CopriWebView
|
|||
{
|
||||
public class RegisterPageViewModel
|
||||
{
|
||||
/// <summary> Holds the merchant id.</summary>
|
||||
private string MerchantId { get; }
|
||||
|
||||
/// <summary> Holds the name of the host.</summary>
|
||||
private string HostName { get; }
|
||||
|
||||
public RegisterPageViewModel(
|
||||
string merchantId,
|
||||
string hostName)
|
||||
{
|
||||
HostName = hostName;
|
||||
} /// <summary>Get Uri of web view for creating account.</summary>
|
||||
MerchantId = merchantId;
|
||||
}
|
||||
|
||||
/// <summary>Get Uri of web view for creating account.</summary>
|
||||
public string Uri =>
|
||||
$"https://{HostName}/{HostName.GetAppFolderName()}/Account/1.%20Kundendaten";
|
||||
$"https://{HostName}/{HostName.GetAppFolderName()}/Account/1.%20Kundendaten?sessionid={MerchantId}";
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ using TINK.Services.Permissions;
|
|||
using Plugin.BLE.Abstractions.Contracts;
|
||||
using TINK.MultilingualResources;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Model.Station;
|
||||
|
||||
namespace TINK.ViewModel.FindBike
|
||||
{
|
||||
|
@ -55,6 +56,9 @@ namespace TINK.ViewModel.FindBike
|
|||
/// <summary> Hide id input fields as soon as bike is found.</summary>
|
||||
public bool IsSelectBikeVisible => BikeCollection != null && BikeCollection.Count == 0;
|
||||
|
||||
/// <summary> Holds the stations to get station names form station ids. </summary>
|
||||
private IEnumerable<IStation> Stations { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs bike collection view model in case information about occupied bikes is available.
|
||||
/// </summary>
|
||||
|
@ -66,6 +70,7 @@ namespace TINK.ViewModel.FindBike
|
|||
/// <param name="isConnectedDelegate">Returns if mobile is connected to web or not.</param>
|
||||
/// <param name="connectorFactory">Connects system to copri.</param>
|
||||
/// <param name="lockService">Service to control lock retrieve info.</param>
|
||||
/// <param name="stations">Stations to get station name from station id.</param>
|
||||
/// <param name="polling"> Holds whether to poll or not and the periode leght is polling is on. </param>
|
||||
/// <param name="postAction">Executes actions on GUI thread.</param>
|
||||
/// <param name="smartDevice">Provides info about the smart device (phone, tablet, ...).</param>
|
||||
|
@ -79,6 +84,7 @@ namespace TINK.ViewModel.FindBike
|
|||
Func<bool, IConnector> connectorFactory,
|
||||
IGeolocation geolocation,
|
||||
ILocksService lockService,
|
||||
IEnumerable<IStation> stations,
|
||||
PollingParameters polling,
|
||||
Action<SendOrPostCallback, object> postAction,
|
||||
ISmartDevice smartDevice,
|
||||
|
@ -88,6 +94,8 @@ namespace TINK.ViewModel.FindBike
|
|||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsSelectBikeVisible)));
|
||||
};
|
||||
|
||||
Stations = stations ?? throw new ArgumentException(nameof(stations));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -159,7 +167,7 @@ namespace TINK.ViewModel.FindBike
|
|||
if (!dialogResult)
|
||||
{
|
||||
// User decided not to give access to locations permissions.
|
||||
BikeCollection.Update(bikeCollection);
|
||||
BikeCollection.Update(bikeCollection, Stations);
|
||||
|
||||
//await OnAppearing(() => UpdateTask());
|
||||
|
||||
|
@ -181,7 +189,7 @@ namespace TINK.ViewModel.FindBike
|
|||
AppResources.MessageBikesManagementLocationActivation,
|
||||
AppResources.MessageAnswerOk);
|
||||
|
||||
BikeCollection.Update(bikeCollection);
|
||||
BikeCollection.Update(bikeCollection, Stations);
|
||||
|
||||
await OnAppearing(() => UpdateTask());
|
||||
|
||||
|
@ -198,7 +206,7 @@ namespace TINK.ViewModel.FindBike
|
|||
AppResources.MessageBikesManagementBluetoothActivation,
|
||||
AppResources.MessageAnswerOk);
|
||||
|
||||
BikeCollection.Update(bikeCollection);
|
||||
BikeCollection.Update(bikeCollection, Stations);
|
||||
|
||||
await OnAppearing(() => UpdateTask());
|
||||
|
||||
|
@ -225,7 +233,7 @@ namespace TINK.ViewModel.FindBike
|
|||
|
||||
var locksInfo = lockIdList.UpdateById(locksInfoTdo);
|
||||
|
||||
BikeCollection.Update(bikeCollection.UpdateLockInfo(locksInfo));
|
||||
BikeCollection.Update(bikeCollection.UpdateLockInfo(locksInfo), Stations);
|
||||
|
||||
await OnAppearing(() => UpdateTask());
|
||||
|
||||
|
@ -265,7 +273,7 @@ namespace TINK.ViewModel.FindBike
|
|||
PostAction(
|
||||
unused =>
|
||||
{
|
||||
BikeCollection.Update(bikes); // Updating collection leads to update of GUI.
|
||||
BikeCollection.Update(bikes, Stations); // Updating collection leads to update of GUI.
|
||||
Exception = result.Exception;
|
||||
ActionText = string.Empty;
|
||||
},
|
||||
|
|
|
@ -214,6 +214,7 @@ namespace TINK.ViewModel
|
|||
public async Task Login()
|
||||
#endif
|
||||
{
|
||||
IAccount account = new EmptyAccount();
|
||||
try
|
||||
{
|
||||
Log.ForContext<LoginPageViewModel>().Information("User taped login button.");
|
||||
|
@ -223,9 +224,9 @@ namespace TINK.ViewModel
|
|||
TinkApp.ActiveUser.CheckIsPasswordValid(MailAddress, Password);
|
||||
|
||||
// Do login.
|
||||
var l_oAccount = await TinkApp.GetConnector(CrossConnectivity.Current.IsConnected).Command.DoLogin(MailAddress, Password, TinkApp.ActiveUser.DeviceId);
|
||||
account = await TinkApp.GetConnector(CrossConnectivity.Current.IsConnected).Command.DoLogin(MailAddress, Password, TinkApp.ActiveUser.DeviceId);
|
||||
|
||||
await TinkApp.ActiveUser.Login(l_oAccount);
|
||||
await TinkApp.ActiveUser.Login(account);
|
||||
|
||||
// Update map page filter because user might be of both groups TINK an Konrad.
|
||||
TinkApp.GroupFilterMapPage =
|
||||
|
@ -318,7 +319,8 @@ namespace TINK.ViewModel
|
|||
{
|
||||
// No need to show "Anleitung TINK Räder" because user can not use tink.
|
||||
#if USEFLYOUT
|
||||
m_oViewService.ShowPage(ViewTypes.MapPage);
|
||||
|
||||
m_oViewService.ShowPage(account.IsAgbAcknowledged ? ViewTypes.MapPage : ViewTypes.ManageAccountPage);
|
||||
#else
|
||||
await m_oViewService.ShowPage("//MapPage");
|
||||
#endif
|
||||
|
|
|
@ -34,6 +34,10 @@ namespace TINK.ViewModel.Map
|
|||
{
|
||||
public class MapPageViewModel : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary> True if message was already shown to user. </summary>
|
||||
private static bool WasMerchantMessageAlreadyShown { get; set; } = false;
|
||||
|
||||
|
||||
/// <summary> Holds the count of custom icons availalbe.</summary>
|
||||
private const int CUSTOM_ICONS_COUNT = 30;
|
||||
|
||||
|
@ -322,6 +326,16 @@ namespace TINK.ViewModel.Map
|
|||
|
||||
TinkApp.Stations = resultStationsAndBikes.Response.StationsAll;
|
||||
|
||||
if (!string.IsNullOrEmpty(resultStationsAndBikes?.GeneralData?.MerchantMessage)
|
||||
&& !WasMerchantMessageAlreadyShown)
|
||||
{
|
||||
await ViewService.DisplayAlert(
|
||||
"Information",
|
||||
resultStationsAndBikes.GeneralData.MerchantMessage,
|
||||
"OK");
|
||||
WasMerchantMessageAlreadyShown = true;
|
||||
}
|
||||
|
||||
await SetStationsOnMap(resultStationsAndBikes.Response.StationsAll);
|
||||
await HandleAuthCookieNotDefinedException(resultStationsAndBikes.Exception);
|
||||
|
||||
|
@ -677,7 +691,7 @@ namespace TINK.ViewModel.Map
|
|||
foreach (var stationId in stationsId)
|
||||
{
|
||||
// Get color of given station.
|
||||
var bikesAtStation = bikesAll.Where(x => x.CurrentStation == stationId).ToList();
|
||||
var bikesAtStation = bikesAll.Where(x => x.StationId == stationId).ToList();
|
||||
if (bikesAtStation.FirstOrDefault(x => x.State.Value != Model.State.InUseStateEnum.Disposable) != null)
|
||||
{
|
||||
// There is at least one requested or booked bike
|
||||
|
|
|
@ -22,11 +22,15 @@ using TINK.Services.Permissions;
|
|||
using Plugin.BLE.Abstractions.Contracts;
|
||||
using TINK.MultilingualResources;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Model.Station;
|
||||
|
||||
namespace TINK.ViewModel.MyBikes
|
||||
{
|
||||
public class MyBikesPageViewModel : BikesViewModel, INotifyCollectionChanged, INotifyPropertyChanged
|
||||
{
|
||||
/// <summary> Holds the stations to get station names form station ids. </summary>
|
||||
private IEnumerable<IStation> Stations { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs bike collection view model in case information about occupied bikes is available.
|
||||
/// </summary>
|
||||
|
@ -38,6 +42,7 @@ namespace TINK.ViewModel.MyBikes
|
|||
/// <param name="isConnectedDelegate">Returns if mobile is connected to web or not.</param>
|
||||
/// <param name="connectorFactory">Connects system to copri.</param>
|
||||
/// <param name="lockService">Service to control lock retrieve info.</param>
|
||||
/// <param name="stations">Stations to get station name from station id.</param>
|
||||
/// <param name="p_oPolling"> Holds whether to poll or not and the periode leght is polling is on. </param>
|
||||
/// <param name="postAction">Executes actions on GUI thread.</param>
|
||||
/// <param name="smartDevice">Provides info about the smart device (phone, tablet, ...).</param>
|
||||
|
@ -51,6 +56,7 @@ namespace TINK.ViewModel.MyBikes
|
|||
Func<bool, IConnector> connectorFactory,
|
||||
IGeolocation geolocation,
|
||||
ILocksService lockService,
|
||||
IEnumerable<IStation> stations,
|
||||
PollingParameters p_oPolling,
|
||||
Action<SendOrPostCallback, object> postAction,
|
||||
ISmartDevice smartDevice,
|
||||
|
@ -61,6 +67,8 @@ namespace TINK.ViewModel.MyBikes
|
|||
OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsNoBikesOccupiedVisible)));
|
||||
OnPropertyChanged(new PropertyChangedEventArgs(nameof(NoBikesOccupiedText)));
|
||||
};
|
||||
|
||||
Stations = stations ?? throw new ArgumentException(nameof(stations));
|
||||
}
|
||||
|
||||
/// <summary> Returns if info about the fact that user did not request or book any bikes is visible or not.<summary>
|
||||
|
@ -134,7 +142,7 @@ namespace TINK.ViewModel.MyBikes
|
|||
if (!dialogResult)
|
||||
{
|
||||
// User decided not to give access to locations permissions.
|
||||
BikeCollection.Update(bikesOccupied.Response);
|
||||
BikeCollection.Update(bikesOccupied.Response, Stations);
|
||||
|
||||
await OnAppearing(() => UpdateTask());
|
||||
|
||||
|
@ -156,7 +164,7 @@ namespace TINK.ViewModel.MyBikes
|
|||
AppResources.MessageBikesManagementLocationActivation,
|
||||
AppResources.MessageAnswerOk);
|
||||
|
||||
BikeCollection.Update(bikesOccupied.Response);
|
||||
BikeCollection.Update(bikesOccupied.Response, Stations);
|
||||
|
||||
await OnAppearing(() => UpdateTask());
|
||||
|
||||
|
@ -173,7 +181,7 @@ namespace TINK.ViewModel.MyBikes
|
|||
AppResources.MessageBikesManagementBluetoothActivation,
|
||||
AppResources.MessageAnswerOk);
|
||||
|
||||
BikeCollection.Update(bikesOccupied.Response);
|
||||
BikeCollection.Update(bikesOccupied.Response, Stations);
|
||||
|
||||
await OnAppearing(() => UpdateTask());
|
||||
|
||||
|
@ -200,7 +208,7 @@ namespace TINK.ViewModel.MyBikes
|
|||
|
||||
var locksInfo = lockIdList.UpdateById(locksInfoTdo);
|
||||
|
||||
BikeCollection.Update(bikesOccupied.Response.UpdateLockInfo(locksInfo));
|
||||
BikeCollection.Update(bikesOccupied.Response.UpdateLockInfo(locksInfo), Stations);
|
||||
|
||||
await OnAppearing(() => UpdateTask());
|
||||
|
||||
|
@ -251,7 +259,7 @@ namespace TINK.ViewModel.MyBikes
|
|||
PostAction(
|
||||
unused =>
|
||||
{
|
||||
BikeCollection.Update(bikes); // Updating collection leads to update of GUI.
|
||||
BikeCollection.Update(bikes, Stations); // Updating collection leads to update of GUI.
|
||||
Exception = result.Exception;
|
||||
ActionText = string.Empty;
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue