Version 3.0.357

This commit is contained in:
Anja 2023-01-18 14:22:51 +01:00
parent 5980410182
commit 5c0b2e70c9
84 changed files with 1012 additions and 449 deletions

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
@ -26,7 +26,8 @@ namespace TINK.Model.Bikes
/// <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.
@ -54,7 +55,9 @@ namespace TINK.Model.Bikes
}
// Update bike.
GetById(bikeInfo.Id).State.Load(bikeInfo.State);
var updateTarget = GetById(bikeInfo.Id);
updateTarget.State.Load(bikeInfo.State);
updateTarget.DataSource = bikeInfo.DataSource;
if (bikesToBeRemoved.Contains<string>(bikeInfo.Id))
{
@ -109,11 +112,7 @@ namespace TINK.Model.Bikes
/// <param name="id"></param>
/// <returns></returns>
public BikeInfoMutable GetById(string id)
{
{
return this.FirstOrDefault(bike => bike.Id == id);
}
}
=> this.FirstOrDefault(bike => bike.Id == id);
/// <summary>
/// Deteermines whether a bike by given key exists.
@ -121,9 +120,7 @@ namespace TINK.Model.Bikes
/// <param name="p_strKey">Key to check.</param>
/// <returns>True if bike exists.</returns>
public bool ContainsKey(string id)
{
return GetById(id) != null;
}
=> GetById(id) != null;
/// <summary>
/// Removes a bike by its id.
@ -150,9 +147,9 @@ namespace TINK.Model.Bikes
BikeInfo bikeInfo,
string stationName)
{
if (bikeInfo is Bikes.BikeInfoNS.BluetoothLock.BikeInfo btBikeInfo)
if (bikeInfo is BikeInfoNS.BluetoothLock.BikeInfo btBikeInfo)
{
return new Bikes.BikeInfoNS.BluetoothLock.BikeInfoMutable(btBikeInfo, stationName);
return new BikeInfoNS.BluetoothLock.BikeInfoMutable(btBikeInfo, stationName);
}
else if (bikeInfo is BikeInfoNS.CopriLock.BikeInfo copriBikeInfo)
{

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
@ -17,18 +17,23 @@ namespace TINK.Model.Bikes.BikeInfoNS.BC
/// <summary>
/// Holds the bike object.
/// </summary>
public BikeNS.Bike Bike { get; }
public Bike Bike { get; }
/// <summary>
/// Holds the drive object.
/// </summary>
public Drive Drive { get; }
/// <summary> Gets the information where the data origins from. </summary>
public DataSource DataSource { get; }
/// <summary> Constructs a bike object.</summary>
/// <param name="dataSource">Specified the source of the data.</param>
protected BikeInfo(
IStateInfo stateInfo,
BikeNS.Bike bike,
Bike bike,
Drive drive,
DataSource dataSource,
bool? isDemo = DEFAULTVALUEISDEMO,
IEnumerable<string> group = null,
string stationId = null,
@ -37,6 +42,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.BC
{
Bike = bike ?? throw new ArgumentNullException(nameof(bike));
Drive = drive ?? throw new ArgumentNullException(nameof(drive));
DataSource = dataSource;
_StateInfo = stateInfo;
IsDemo = isDemo ?? DEFAULTVALUEISDEMO;
@ -50,6 +56,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.BC
bikeInfo != null ? bikeInfo?.State : throw new ArgumentNullException(nameof(bikeInfo)),
bikeInfo.Bike,
bikeInfo.Drive,
bikeInfo.DataSource,
bikeInfo.IsDemo,
bikeInfo.Group,
bikeInfo.StationId,
@ -60,12 +67,14 @@ namespace TINK.Model.Bikes.BikeInfoNS.BC
/// <summary>
/// Constructs a bike info object for a available bike.
/// </summary>
/// <param name="dataSource">Specified the source of the data.</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>
public BikeInfo(
BikeNS.Bike bike,
Bike bike,
Drive drive,
DataSource dataSource,
string stationId,
Uri operatorUri = null,
RentalDescription tariffDescription = null,
@ -74,6 +83,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.BC
new StateInfo(),
bike,
drive,
dataSource,
isDemo,
group,
stationId,
@ -85,6 +95,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.BC
/// <summary>
/// Constructs a bike info object for a booked bike.
/// </summary>
/// <param name="dataSource">Specified the source of the data.</param>
/// <param name="dateTimeProvider">Provider for current date time to calculate remainig time on demand for state of type reserved.</param>
/// <param name="currentStationId">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>
@ -93,8 +104,9 @@ namespace TINK.Model.Bikes.BikeInfoNS.BC
/// <param name="mailAddress">Mail address of user which booked bike.</param>
/// <param name="code">Booking code.</param>
public BikeInfo(
BikeNS.Bike bike,
Bike bike,
Drive drive,
DataSource dataSource,
bool? isDemo,
IEnumerable<string> group,
string currentStationId,
@ -109,6 +121,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.BC
code),
bike,
drive,
dataSource,
isDemo,
group,
currentStationId,
@ -131,7 +144,6 @@ namespace TINK.Model.Bikes.BikeInfoNS.BC
/// <summary> Holds description about the tarif. </summary>
public RentalDescription TariffDescription { get; }
/// Holds the rent state of the bike.
/// </summary>
public IStateInfo State

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.Serialization;
@ -12,7 +12,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.BC
public class BikeInfoMutable : IBikeInfoMutable, INotifyPropertyChanged
{
/// <summary> Holds the bike. </summary>
private readonly BikeNS.Bike _Bike;
private readonly Bike _Bike;
/// <summary> Holds the drive of the bike. </summary>
private readonly Drive _Drive;
@ -30,8 +30,9 @@ namespace TINK.Model.Bikes.BikeInfoNS.BC
/// <param name="tariffDescription">Hold tariff description of bike.</param>
/// <param name="stateInfo">Bike state info.</param>
protected BikeInfoMutable(
BikeNS.Bike bike,
Bike bike,
Drive drive,
DataSource dataSource,
bool isDemo = BikeInfo.DEFAULTVALUEISDEMO,
IEnumerable<string> group = null,
string stationId = null,
@ -45,6 +46,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.BC
Group = group;
_Bike = bike;
_Drive = drive;
DataSource = dataSource;
_StateInfo = new StateInfoMutable(dateTimeProvider, stateInfo);
_StateInfo.PropertyChanged += (sender, eventargs) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(eventargs.PropertyName));
StationId = stationId;
@ -59,6 +61,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.BC
? bike.Bike
: throw new ArgumentNullException(nameof(bike)),
bike.Drive,
bike.DataSource,
bike.IsDemo,
bike.Group,
bike.StationId,
@ -121,6 +124,22 @@ namespace TINK.Model.Bikes.BikeInfoNS.BC
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
private DataSource _DataSource = DataSource.Copri;
/// <summary> Gets or sets the information where the data origins from. </summary>
public DataSource DataSource
{
get => _DataSource;
set
{
if (_DataSource == value)
return;
_DataSource = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(DataSource)));
}
}
/// <summary>
/// Converts the instance to text.
/// </summary>

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
using TINK.Model.State;
@ -20,6 +20,9 @@ namespace TINK.Model.Bikes.BikeInfoNS.BC
/// </summary>
Drive Drive { get; }
/// <summary> Gets or sets the information where the data origins from. </summary>
DataSource DataSource { get; }
/// <summary> True if bike is a demo bike. </summary>
bool IsDemo { get; }
@ -44,4 +47,19 @@ namespace TINK.Model.Bikes.BikeInfoNS.BC
/// </summary>
IStateInfo State { get; }
}
/// <summary>
/// Origin of the data.
/// </summary>
public enum DataSource
{
/// <summary>
/// Data source corpi.
/// </summary>
Copri,
/// <summary>
/// Data source cache.
/// </summary>
Cache
}
}

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
@ -56,6 +56,9 @@ namespace TINK.Model.Bikes.BikeInfoNS.BC
/// </summary>
Drive Drive { get; }
/// <summary> Gets or sets the information where the data origins from. </summary>
DataSource DataSource { get; set; }
event PropertyChangedEventHandler PropertyChanged;
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using TINK.Model.Bikes.BikeInfoNS.BC;
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
using TINK.Model.State;
@ -11,6 +12,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
/// <summary>
/// Constructs a bike info object for a available bike.
/// </summary>
/// <param name="dataSource">Specified the source of the data.</param>
/// <param name="lockId">Id of the lock.</param>
/// <param name="lockGuid">GUID specifying the lock.</param>
/// <param name="currentStationId">Id of station where bike is located.</param>
@ -19,6 +21,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
public BikeInfo(
Bike bike,
Drive drive,
DataSource dataSource,
int lockId,
Guid lockGuid,
string currentStationId,
@ -36,6 +39,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
dataSource,
isDemo,
group,
currentStationId,
@ -48,6 +52,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
/// <summary>
/// Constructs a bike info object for a requested bike.
/// </summary>
/// <param name="dataSource">Specified the source of the data.</param>
/// <param name="dateTimeProvider">Provider for current date time to calculate remainig time on demand for state of type reserved.</param>
/// <param name="lockId">Id of the lock.</param>
/// <param name="lockGuid">GUID specifying the lock.</param>
@ -60,6 +65,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
public BikeInfo(
Bike bike,
Drive drive,
DataSource dataSource,
int lockId,
Guid lockGuid,
byte[] userKey,
@ -87,6 +93,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
dataSource,
isDemo,
group,
currentStationId,
@ -99,7 +106,8 @@ namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
/// <summary>
/// Constructs a bike info object for a booked bike.
/// </summary>
/// <param name="id">Unique id of bike.</param>
/// <param name="bike">Unique id of bike.</param>
/// <param name="dataSource">Specified the source of the data.</param>
/// <param name="lockId">Id of the lock.</param>
/// <param name="lockGuid">GUID specifying the lock.</param>
/// <param name="bookedAt">Date time when bike was booked</param>
@ -111,6 +119,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
public BikeInfo(
Bike bike,
Drive drive,
DataSource dataSource,
int lockId,
Guid lockGuid,
byte[] userKey,
@ -136,6 +145,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
bike.Description)
: throw new ArgumentNullException(),
drive,
dataSource,
isDemo,
group,
currentStationId,

View file

@ -1,8 +1,8 @@
using System;
using System;
namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
{
public class BikeInfoMutable : Model.Bikes.BikeInfoNS.BC.BikeInfoMutable, IBikeInfoMutable
public class BikeInfoMutable : BC.BikeInfoMutable, IBikeInfoMutable
{
/// <summary> Constructs a bike object from source. </summary>
public BikeInfoMutable(BikeInfo bike, string stationName) : base(
@ -10,6 +10,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.BluetoothLock
? bike.Bike
: throw new ArgumentNullException(nameof(bike)),
bike.Drive,
bike.DataSource,
bike.IsDemo,
bike.Group,
bike.StationId,

View file

@ -1,5 +1,6 @@
using System;
using System;
using System.Collections.Generic;
using TINK.Model.Bikes.BikeInfoNS.BC;
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
using TINK.Model.MiniSurvey;
@ -13,14 +14,16 @@ namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
/// Constructs a bike info object for a available bike or bike for which feed back is pending.
/// </summary>
/// <param name="bike">Bike object.</param>
/// <param name="dataSource">Specified the source of the data.</param>
/// <param name="currentStationId">Id of station where bike is located.</param>
/// <param name="lockInfo">Lock info.</param>
/// <param name="isFeedbackPending">If true user has not yet given feedback after returning bike.</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>
public BikeInfo(
BikeNS.Bike bike,
Bike bike,
Drive drive,
DataSource dataSource,
string currentStationId,
LockInfo lockInfo,
bool isFeedbackPending = false,
@ -40,6 +43,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
dataSource,
isDemo,
group,
currentStationId,
@ -55,6 +59,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
/// Constructs a bike info object for a requested bike.
/// </summary>
/// <param name="bike">Bike object.</param>
/// <param name="dataSource">Specified the source of the data.</param>
/// <param name="requestedAt">Date time when bike was requested</param>
/// <param name="mailAddress">Mail address of user which requested bike.</param>
/// <param name="currentStationId">Name of station where bike is located, null if bike is on the road.</param>
@ -63,8 +68,9 @@ namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
/// <param name="tariffDescription">Hold tariff description of bike.</param>
/// <param name="dateTimeProvider">Provider for current date time to calculate remainig time on demand for state of type reserved.</param>
public BikeInfo(
BikeNS.Bike bike,
Bike bike,
Drive drive,
DataSource dataSource,
DateTime requestedAt,
string mailAddress,
string currentStationId,
@ -80,7 +86,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
mailAddress,
""),
bike != null
? new BikeNS.Bike(
? new Bike(
bike.Id,
LockModel.Sigo /* Ensure consistend lock model value */,
bike.WheelType,
@ -88,6 +94,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
dataSource,
isDemo,
group,
currentStationId,
@ -103,6 +110,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
/// Constructs a bike info object for a booked bike.
/// </summary>
/// <param name="bike">Bike object.</param>
/// <param name="dataSource">Specified the source of the data.</param>
/// <param name="bookedAt">Date time when bike was booked</param>
/// <param name="mailAddress">Mail address of user which booked bike.</param>
/// <param name="currentStationId">Name of station where bike is located, null if bike is on the road.</param>
@ -110,8 +118,9 @@ namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
/// <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>
public BikeInfo(
BikeNS.Bike bike,
Bike bike,
Drive drive,
DataSource dataSource,
DateTime bookedAt,
string mailAddress,
string currentStationId,
@ -125,7 +134,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
mailAddress,
""),
bike != null
? new BikeNS.Bike(
? new Bike(
bike.Id,
LockModel.Sigo /* Ensure consistend lock model value */,
bike.WheelType,
@ -133,6 +142,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
bike.Description)
: throw new ArgumentNullException(nameof(bike)),
drive,
dataSource,
isDemo,
group,
currentStationId,
@ -143,7 +153,6 @@ namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
MiniSurvey = new MiniSurveyModel();
Co2Saving = string.Empty;
}
public BikeInfo(BC.BikeInfo bikeInfo, LockInfo lockInfo) : base(
bikeInfo ?? throw new ArgumentException($"Can not copy-construct {typeof(BikeInfo).Name}-object. Source bike info must not be null."))
{

View file

@ -1,4 +1,4 @@
using System;
using System;
namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
{
@ -10,6 +10,7 @@ namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
? bike.Bike
: throw new ArgumentNullException(nameof(bike)),
bike.Drive,
bike.DataSource,
bike.IsDemo,
bike.Group,
bike.StationId,