mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-21 21:46:27 +02:00
Mini survey added.
Minor fiexes.
This commit is contained in:
parent
ddfea49ea6
commit
e321764119
73 changed files with 1628 additions and 185 deletions
|
@ -6,6 +6,8 @@ using TINK.Repository.Request;
|
|||
using TINK.Repository.Response;
|
||||
using TINK.Model.User.Account;
|
||||
using TINK.Model.Device;
|
||||
using System.Collections.Generic;
|
||||
using TINK.Model.MiniSurvey;
|
||||
|
||||
namespace TINK.Model.Connector
|
||||
{
|
||||
|
@ -120,14 +122,13 @@ namespace TINK.Model.Connector
|
|||
Log.ForContext<Command>().Error("Unexpected booking request detected. No user logged in.");
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task DoReturn(
|
||||
public async Task<MiniSurveyModel> DoReturn(
|
||||
Bikes.Bike.BluetoothLock.IBikeInfoMutable bike,
|
||||
LocationDto location,
|
||||
ISmartDevice smartDevice)
|
||||
{
|
||||
Log.ForContext<Command>().Error("Unexpected returning request detected. No user logged in.");
|
||||
await Task.CompletedTask;
|
||||
return await Task.FromResult(new MiniSurveyModel());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -143,5 +144,13 @@ namespace TINK.Model.Connector
|
|||
Log.ForContext<Command>().Error("Unexpected submit feedback request detected. No user logged in.");
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public async Task DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
{
|
||||
Log.ForContext<Command>().Error("Unexpected submit mini survey request detected. No user logged in.");
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,6 +7,8 @@ using TINK.Repository.Request;
|
|||
using TINK.Repository.Response;
|
||||
using TINK.Model.User.Account;
|
||||
using TINK.Model.Device;
|
||||
using System.Collections.Generic;
|
||||
using TINK.Model.MiniSurvey;
|
||||
|
||||
namespace TINK.Model.Connector
|
||||
{
|
||||
|
@ -246,7 +248,7 @@ namespace TINK.Model.Connector
|
|||
/// <param name="bike">Bike to return.</param>
|
||||
/// <param name="locaton">Position of the bike.</param>
|
||||
/// <param name="smartDevice">Provides info about hard and software.</param>
|
||||
public async Task DoReturn(
|
||||
public async Task<MiniSurveyModel> DoReturn(
|
||||
Bikes.Bike.BluetoothLock.IBikeInfoMutable bike,
|
||||
LocationDto location,
|
||||
ISmartDevice smartDevice)
|
||||
|
@ -256,10 +258,10 @@ namespace TINK.Model.Connector
|
|||
throw new ArgumentNullException("Can not return bike. No bike object available.");
|
||||
}
|
||||
|
||||
ReservationCancelReturnResponse l_oResponse;
|
||||
ReservationCancelReturnResponse response;
|
||||
try
|
||||
{
|
||||
l_oResponse = (await CopriServer.DoReturn(bike.Id, location, smartDevice, bike.OperatorUri)).GetIsReturnBikeResponseOk(bike.Id);
|
||||
response = (await CopriServer.DoReturn(bike.Id, location, smartDevice, bike.OperatorUri)).GetIsReturnBikeResponseOk(bike.Id);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
@ -268,6 +270,7 @@ namespace TINK.Model.Connector
|
|||
}
|
||||
|
||||
bike.Load(Bikes.Bike.BC.NotifyPropertyChangedLevel.None);
|
||||
return response?.Create() ?? new MiniSurveyModel();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -281,5 +284,10 @@ namespace TINK.Model.Connector
|
|||
public async Task DoSubmitFeedback(IUserFeedback userFeedback, Uri opertorUri)
|
||||
=> await CopriServer.DoSubmitFeedback(userFeedback.BikeId, userFeedback.Message, userFeedback.IsBikeBroken, opertorUri);
|
||||
#endif
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public async Task DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> await CopriServer.DoSubmitMiniSurvey(answers);
|
||||
}
|
||||
}
|
|
@ -3,6 +3,8 @@ using System.Threading.Tasks;
|
|||
using TINK.Repository.Request;
|
||||
using TINK.Model.User.Account;
|
||||
using TINK.Model.Device;
|
||||
using System.Collections.Generic;
|
||||
using TINK.Model.MiniSurvey;
|
||||
|
||||
namespace TINK.Model.Connector
|
||||
{
|
||||
|
@ -48,7 +50,7 @@ namespace TINK.Model.Connector
|
|||
/// <param name="bike">Bike to return.</param>
|
||||
/// <param name="location">Geolocation of lock when returning bike.</param>
|
||||
/// <param name="smartDevice">Provides info about hard and software.</param>
|
||||
Task DoReturn(Bikes.Bike.BluetoothLock.IBikeInfoMutable bike, LocationDto geolocation = null, ISmartDevice smartDevice = null);
|
||||
Task<MiniSurveyModel> DoReturn(Bikes.Bike.BluetoothLock.IBikeInfoMutable bike, LocationDto geolocation = null, ISmartDevice smartDevice = null);
|
||||
|
||||
/// <summary> True if connector has access to copri server, false if cached values are used. </summary>
|
||||
bool IsConnected { get; }
|
||||
|
@ -57,6 +59,11 @@ namespace TINK.Model.Connector
|
|||
string SessionCookie { get; }
|
||||
|
||||
Task DoSubmitFeedback(IUserFeedback userFeedback, Uri opertorUri);
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
Task DoSubmitMiniSurvey(IDictionary<string, string> answers);
|
||||
|
||||
#if USCSHARP9
|
||||
/// <summary>
|
||||
/// Feedback given by user when returning bike.
|
||||
|
|
|
@ -13,6 +13,8 @@ using IBikeInfoMutable = TINK.Model.Bikes.Bike.BC.IBikeInfoMutable;
|
|||
using System.Globalization;
|
||||
using TINK.Model.Station.Operator;
|
||||
using Xamarin.Forms;
|
||||
using System.Linq;
|
||||
using TINK.Model.MiniSurvey;
|
||||
|
||||
namespace TINK.Model.Connector
|
||||
{
|
||||
|
@ -507,5 +509,39 @@ namespace TINK.Model.Connector
|
|||
MaxFeeEuroPerDay = double.TryParse(tariffDesciption?.max_eur_per_day, NumberStyles.Any, CultureInfo.InvariantCulture, out double maxEuroPerDay) ? maxEuroPerDay : double.NaN,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary> Creates a survey object from response.</summary>
|
||||
/// <param name="response">Response to create survey object from.</param>
|
||||
public static MiniSurveyModel Create(this ReservationCancelReturnResponse response)
|
||||
{
|
||||
if (response?.user_miniquery == null)
|
||||
{
|
||||
return new MiniSurveyModel();
|
||||
}
|
||||
|
||||
var miniquery = response.user_miniquery;
|
||||
var survey = new MiniSurveyModel
|
||||
{
|
||||
Title = miniquery.title,
|
||||
Subtitle = miniquery.subtitle,
|
||||
Footer = miniquery.footer
|
||||
};
|
||||
|
||||
foreach (var question in miniquery?.questions?.OrderBy(x => x.Key) ?? new Dictionary<string, MiniSurveyResponse.Question>().OrderBy(x => x.Key))
|
||||
{
|
||||
if (string.IsNullOrEmpty(question.Key.Trim())
|
||||
|| question.Value.query == null)
|
||||
{
|
||||
// Skip invalid entries.
|
||||
continue;
|
||||
}
|
||||
|
||||
survey.Questions.Add(
|
||||
question.Key,
|
||||
new MiniSurveyModel.QuestionModel());
|
||||
}
|
||||
|
||||
return survey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
40
TINKLib/Model/MiniSurvey/MiniSurveyModel.cs
Normal file
40
TINKLib/Model/MiniSurvey/MiniSurveyModel.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace TINK.Model.MiniSurvey
|
||||
|
||||
{
|
||||
public class MiniSurveyModel
|
||||
{
|
||||
public enum Type
|
||||
{
|
||||
SingleAnswer,
|
||||
CustomText
|
||||
}
|
||||
public class QuestionModel
|
||||
{
|
||||
public QuestionModel()
|
||||
{
|
||||
PossibleAnswers = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
public string Text { get; set; }
|
||||
|
||||
public Type Type { get; set; }
|
||||
|
||||
public Dictionary<string, string> PossibleAnswers { get; private set; }
|
||||
}
|
||||
|
||||
public MiniSurveyModel()
|
||||
{
|
||||
Questions = new Dictionary<string, QuestionModel>();
|
||||
}
|
||||
|
||||
public string Title { get; set; }
|
||||
|
||||
public string Subtitle { get; set; }
|
||||
|
||||
public string Footer { get; set; }
|
||||
|
||||
public Dictionary<string, QuestionModel> Questions { get; }
|
||||
}
|
||||
}
|
|
@ -421,6 +421,10 @@ namespace TINK.Model
|
|||
{
|
||||
new Version(3, 0, 242),
|
||||
AppResources.ChangeLog3_0_242
|
||||
},
|
||||
{
|
||||
new Version(3, 0, 243),
|
||||
AppResources.ChangeLog3_0_243
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -769,6 +769,16 @@ namespace TINK.MultilingualResources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Mini survey implemented.
|
||||
///Minor fixes..
|
||||
/// </summary>
|
||||
public static string ChangeLog3_0_243 {
|
||||
get {
|
||||
return ResourceManager.GetString("ChangeLog3_0_243", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Lock of rented bike can not be found..
|
||||
/// </summary>
|
||||
|
@ -1074,6 +1084,24 @@ namespace TINK.MultilingualResources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Operator: {0}..
|
||||
/// </summary>
|
||||
public static string MarkingBikeSharingOperator {
|
||||
get {
|
||||
return ResourceManager.GetString("MarkingBikeSharingOperator", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Contact Operator..
|
||||
/// </summary>
|
||||
public static string MarkingBikeSharingOperatorNoOperatorInfoAvailable {
|
||||
get {
|
||||
return ResourceManager.GetString("MarkingBikeSharingOperatorNoOperatorInfoAvailable", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Please open a bike station page to to contact the bike sharing operator..
|
||||
/// </summary>
|
||||
|
@ -1589,7 +1617,7 @@ namespace TINK.MultilingualResources {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Urgent question related to {0}?.
|
||||
/// Looks up a localized string similar to Urgent questions?.
|
||||
/// </summary>
|
||||
public static string MessagePhoneMail {
|
||||
get {
|
||||
|
@ -1660,6 +1688,24 @@ namespace TINK.MultilingualResources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Select an answer please..
|
||||
/// </summary>
|
||||
public static string MiniSurveyAskForAnswer {
|
||||
get {
|
||||
return ResourceManager.GetString("MiniSurveyAskForAnswer", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Enter answer here please..
|
||||
/// </summary>
|
||||
public static string MiniSurveyEnterAnswer {
|
||||
get {
|
||||
return ResourceManager.GetString("MiniSurveyEnterAnswer", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to No.
|
||||
/// </summary>
|
||||
|
|
|
@ -157,9 +157,6 @@ Eine Radrückgabe ist nur möglich, wenn das Rad in Reichweite ist und Standorti
|
|||
<data name="MessageContactMail" xml:space="preserve">
|
||||
<value>Fragen? Hinweise? Kritik?</value>
|
||||
</data>
|
||||
<data name="MessagePhoneMail" xml:space="preserve">
|
||||
<value>Eilige Frage rund um {0}?</value>
|
||||
</data>
|
||||
<data name="MessageRateMail" xml:space="preserve">
|
||||
<value>Gefällt die {0}-App?</value>
|
||||
</data>
|
||||
|
@ -637,4 +634,22 @@ Layout Anzeige Radnamen und nummern verbessert.</value>
|
|||
<data name="ChangeLog3_0_242" xml:space="preserve">
|
||||
<value>Seite zur Auswahl einer Station hinzugefügt zum Abrufen von Kontaktinformationen.</value>
|
||||
</data>
|
||||
<data name="MessagePhoneMail" xml:space="preserve">
|
||||
<value>Eilige Fragen?</value>
|
||||
</data>
|
||||
<data name="MarkingBikeSharingOperator" xml:space="preserve">
|
||||
<value>Betreiber: {0}.</value>
|
||||
</data>
|
||||
<data name="MarkingBikeSharingOperatorNoOperatorInfoAvailable" xml:space="preserve">
|
||||
<value>Betreiber Kontaktieren.</value>
|
||||
</data>
|
||||
<data name="MiniSurveyAskForAnswer" xml:space="preserve">
|
||||
<value>Bitte eine Antwort auswählen.</value>
|
||||
</data>
|
||||
<data name="MiniSurveyEnterAnswer" xml:space="preserve">
|
||||
<value>Bitte Antwort hier eingeben.</value>
|
||||
</data>
|
||||
<data name="ChangeLog3_0_241" xml:space="preserve">
|
||||
<value>Auf der Kontaktseite werden Kontaktinformationen betreiberspezifisch angezeigt.</value>
|
||||
</data>
|
||||
</root>
|
|
@ -248,7 +248,7 @@ Use of app is restricted to maximu 8 devices per account.
|
|||
Please login to app once again. In case this fails please check on website if the account is still valid.</value>
|
||||
</data>
|
||||
<data name="MessagePhoneMail" xml:space="preserve">
|
||||
<value>Urgent question related to {0}?</value>
|
||||
<value>Urgent questions?</value>
|
||||
</data>
|
||||
<data name="MessageRateMail" xml:space="preserve">
|
||||
<value>Are you enjoying the {0}-App?</value>
|
||||
|
@ -733,4 +733,20 @@ Layout of bike names and id display improved.</value>
|
|||
<data name="ChangeLog3_0_242" xml:space="preserve">
|
||||
<value>Select station page added to ease getting operator specific contact information.</value>
|
||||
</data>
|
||||
<data name="MarkingBikeSharingOperator" xml:space="preserve">
|
||||
<value>Operator: {0}.</value>
|
||||
</data>
|
||||
<data name="MarkingBikeSharingOperatorNoOperatorInfoAvailable" xml:space="preserve">
|
||||
<value>Contact Operator.</value>
|
||||
</data>
|
||||
<data name="MiniSurveyAskForAnswer" xml:space="preserve">
|
||||
<value>Select an answer please.</value>
|
||||
</data>
|
||||
<data name="MiniSurveyEnterAnswer" xml:space="preserve">
|
||||
<value>Enter answer here please.</value>
|
||||
</data>
|
||||
<data name="ChangeLog3_0_243" xml:space="preserve">
|
||||
<value>Mini survey implemented.
|
||||
Minor fixes.</value>
|
||||
</data>
|
||||
</root>
|
|
@ -202,10 +202,6 @@ Eine Radrückgabe ist nur möglich, wenn das Rad in Reichweite ist und Standorti
|
|||
<source>Questions? Remarks? Criticism?</source>
|
||||
<target state="translated">Fragen? Hinweise? Kritik?</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="MessagePhoneMail" translate="yes" xml:space="preserve">
|
||||
<source>Urgent question related to {0}?</source>
|
||||
<target state="translated">Eilige Frage rund um {0}?</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="MessageRateMail" translate="yes" xml:space="preserve">
|
||||
<source>Are you enjoying the {0}-App?</source>
|
||||
<target state="translated">Gefällt die {0}-App?</target>
|
||||
|
@ -853,6 +849,32 @@ Layout Anzeige Radnamen und nummern verbessert.</target>
|
|||
<source>Select station page added to ease getting operator specific contact information.</source>
|
||||
<target state="translated">Seite zur Auswahl einer Station hinzugefügt zum Abrufen von Kontaktinformationen.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="MessagePhoneMail" translate="yes" xml:space="preserve">
|
||||
<source>Urgent questions?</source>
|
||||
<target state="translated">Eilige Fragen?</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="MarkingBikeSharingOperator" translate="yes" xml:space="preserve">
|
||||
<source>Operator: {0}.</source>
|
||||
<target state="translated">Betreiber: {0}.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="MarkingBikeSharingOperatorNoOperatorInfoAvailable" translate="yes" xml:space="preserve">
|
||||
<source>Contact Operator.</source>
|
||||
<target state="translated">Betreiber Kontaktieren.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="MiniSurveyAskForAnswer" translate="yes" xml:space="preserve">
|
||||
<source>Select an answer please.</source>
|
||||
<target state="translated">Bitte eine Antwort auswählen.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="MiniSurveyEnterAnswer" translate="yes" xml:space="preserve">
|
||||
<source>Enter answer here please.</source>
|
||||
<target state="translated">Bitte Antwort hier eingeben.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="ChangeLog3_0_243" translate="yes" xml:space="preserve">
|
||||
<source>Mini survey implemented.
|
||||
Minor fixes.</source>
|
||||
<target state="translated">Miniumfrage implementiert.
|
||||
Kleinere Verbesserungen.</target>
|
||||
</trans-unit>
|
||||
</group>
|
||||
</body>
|
||||
</file>
|
||||
|
|
|
@ -10,6 +10,7 @@ using TINK.Repository.Request;
|
|||
using TINK.Repository.Response;
|
||||
using TINK.Model.Logging;
|
||||
using TINK.Model.Device;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TINK.Repository
|
||||
{
|
||||
|
@ -231,6 +232,14 @@ namespace TINK.Repository
|
|||
requestBuilder.DoSubmitFeedback(bikeId, message, isBikeBroken),
|
||||
UserAgent);
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> DoSubmitMiniSurvey(
|
||||
m_oCopriHost.AbsoluteUri,
|
||||
requestBuilder.DoSubmitMiniSurvey(answers),
|
||||
UserAgent);
|
||||
|
||||
/// <summary> Logs user in. </summary>
|
||||
/// <param name="copriHost">Host to connect to. </param>
|
||||
/// <param name="command">Command to log user in.</param>
|
||||
|
@ -612,10 +621,10 @@ namespace TINK.Repository
|
|||
string userAgent = null)
|
||||
{
|
||||
#if !WINDOWS_UWP
|
||||
string l_oBikesAvaialbeResponse;
|
||||
string cancelOrReturnResponse;
|
||||
try
|
||||
{
|
||||
l_oBikesAvaialbeResponse = await PostAsync(copriHost, command, userAgent);
|
||||
cancelOrReturnResponse = await PostAsync(copriHost, command, userAgent);
|
||||
}
|
||||
catch (System.Exception l_oException)
|
||||
{
|
||||
|
@ -633,7 +642,7 @@ namespace TINK.Repository
|
|||
}
|
||||
|
||||
// Extract bikes from response.
|
||||
return JsonConvertRethrow.DeserializeObject<ResponseContainer<ReservationCancelReturnResponse>>(l_oBikesAvaialbeResponse)?.shareejson;
|
||||
return JsonConvertRethrow.DeserializeObject<ResponseContainer<ReservationCancelReturnResponse>>(cancelOrReturnResponse)?.shareejson;
|
||||
#else
|
||||
return null;
|
||||
#endif
|
||||
|
@ -672,6 +681,40 @@ namespace TINK.Repository
|
|||
#endif
|
||||
}
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
public async Task<ResponseBase> DoSubmitMiniSurvey(
|
||||
string copriHost,
|
||||
string command,
|
||||
string userAgent = null)
|
||||
{
|
||||
#if !WINDOWS_UWP
|
||||
string miniSurveyResponse;
|
||||
try
|
||||
{
|
||||
miniSurveyResponse = await PostAsync(copriHost, command, userAgent);
|
||||
}
|
||||
catch (System.Exception l_oException)
|
||||
{
|
||||
if (l_oException.GetIsConnectFailureException())
|
||||
{
|
||||
throw new WebConnectFailureException("Senden der Miniumfrage aufgrund eines Netzwerkfehlers fehlgeschlagen.", l_oException);
|
||||
}
|
||||
|
||||
if (l_oException.GetIsForbiddenException())
|
||||
{
|
||||
throw new WebForbiddenException("Senden der der Miniumfrage aufgrund eines Netzwerkfehlers fehlgeschlagen.", l_oException);
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
// Extract bikes from response.
|
||||
return JsonConvertRethrow.DeserializeObject<ResponseContainer<ResponseBase>>(miniSurveyResponse)?.shareejson;
|
||||
#else
|
||||
return null;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary> http get- request.</summary>
|
||||
/// <param name="Url">Ulr to get info from.</param>
|
||||
/// <returns>response from server</returns>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model;
|
||||
using TINK.Model.Device;
|
||||
|
@ -1633,7 +1634,13 @@ namespace TINK.Repository
|
|||
return null;
|
||||
}
|
||||
|
||||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string message, bool isBikeBroken, Uri operatorUri) => null;
|
||||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string message, bool isBikeBroken, Uri operatorUri)
|
||||
=> null;
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> null ;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of bikes reserved/ booked by acctive user from Copri.
|
||||
|
|
|
@ -5,6 +5,7 @@ using TINK.Repository.Request;
|
|||
using TINK.Repository.Response;
|
||||
using TINK.Model.Services.CopriApi;
|
||||
using TINK.Model.Device;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TINK.Repository
|
||||
{
|
||||
|
@ -183,6 +184,11 @@ namespace TINK.Repository
|
|||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string message, bool isBikeBroken, Uri operatorUri) =>
|
||||
throw new System.Exception("Übermittlung von Feedback im Offlinemodus nicht möglich!");
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> throw new System.Exception("Übermittlung von der Miniumfrage im Offlinemodus nicht möglich!");
|
||||
|
||||
public Task<AuthorizationResponse> DoAuthorizationAsync(string p_strMailAddress, string p_strPassword, string p_strDeviceId)
|
||||
{
|
||||
throw new System.Exception("Anmelden im Offlinemodus nicht möglich!");
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository.Request;
|
||||
|
@ -97,6 +98,10 @@ namespace TINK.Repository
|
|||
bool isBikeBroken,
|
||||
Uri operatorUri);
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers);
|
||||
|
||||
/// <summary> True if connector has access to copri server, false if cached values are used. </summary>
|
||||
bool IsConnected { get; }
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TINK.Model.Device;
|
||||
|
||||
namespace TINK.Repository.Request
|
||||
|
@ -85,6 +86,12 @@ namespace TINK.Repository.Request
|
|||
/// <param name="message">General purpose message or error description.</param>
|
||||
/// <param name="isBikeBroken">True if bike is broken.</param>
|
||||
string DoSubmitFeedback(string bikeId, string message = null, bool isBikeBroken = false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets request for submiting mini survey to copri server.
|
||||
/// </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
string DoSubmitMiniSurvey(IDictionary<string, string> answers);
|
||||
}
|
||||
|
||||
/// <summary> Copri locking states</summary>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository.Exception;
|
||||
|
@ -111,5 +112,12 @@ namespace TINK.Repository.Request
|
|||
string bikeId,
|
||||
string message = null,
|
||||
bool isBikeBroken = false) => throw new NotSupportedException();
|
||||
|
||||
/// <summary>
|
||||
/// Gets request for submiting mini survey to copri server.
|
||||
/// </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public string DoSubmitMiniSurvey(IDictionary<string, string> answers) =>
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository.Exception;
|
||||
|
@ -76,21 +78,21 @@ namespace TINK.Repository.Request
|
|||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <param name="bikeId">Id of the bike to reserve.</param>
|
||||
/// <returns>Requst to reserve bike.</returns>
|
||||
public string DoReserve(string bikeId)
|
||||
public string DoReserve(string bikeId)
|
||||
=> $"request=booking_request&bike={bikeId}&authcookie={SessionCookie}{MerchantId}";
|
||||
|
||||
/// <summary> Gets request to cancel reservation. </summary>
|
||||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <param name="bikeId">Id of the bike to cancel reservation for.</param>
|
||||
/// <returns>Requst on cancel booking request.</returns>
|
||||
public string DoCancelReservation(string p_iBikeId)
|
||||
public string DoCancelReservation(string p_iBikeId)
|
||||
=> $"request=booking_cancel&bike={p_iBikeId}&authcookie={SessionCookie}{MerchantId}";
|
||||
|
||||
/// <summary> Request to get keys. </summary>
|
||||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <param name="bikeId">Id of the bike to get keys for.</param>
|
||||
/// <returns>Request to get keys.</returns>
|
||||
public string CalculateAuthParameters(string bikeId)
|
||||
public string CalculateAuthParameters(string bikeId)
|
||||
=> $"request=booking_update&bike={bikeId}&authcookie={SessionCookie}{MerchantId}&genkey=1";
|
||||
|
||||
/// <summary> Gets the request for updating lock state for a booked bike. </summary>
|
||||
|
@ -99,7 +101,7 @@ namespace TINK.Repository.Request
|
|||
/// <param name="state">New locking state.</param>
|
||||
/// <returns>Request to update locking state.</returns>
|
||||
public string UpateLockingState(string bikeId, LocationDto geolocation, lock_state state, double batteryPercentage)
|
||||
{
|
||||
{
|
||||
return $"request=booking_update&bike={bikeId}{GetLocationParameters(geolocation)}&lock_state={state}{GetBatteryPercentageParameters(batteryPercentage)}&authcookie={SessionCookie}{MerchantId}";
|
||||
}
|
||||
|
||||
|
@ -109,7 +111,7 @@ namespace TINK.Repository.Request
|
|||
/// <param name="guid">Used to publish GUID from app to copri. Used for initial setup of bike in copri.</param>
|
||||
/// <param name="batteryPercentage">Holds the filling level percentage of the battery.</param>
|
||||
/// <returns>Request to booking bike.</returns>
|
||||
public string DoBook(string bikeId, Guid guid, double batteryPercentage)
|
||||
public string DoBook(string bikeId, Guid guid, double batteryPercentage)
|
||||
=> $"request=booking_update&bike={bikeId}&authcookie={SessionCookie}{MerchantId}&Ilockit_GUID={guid}&state=occupied&lock_state=unlocked{GetBatteryPercentageParameters(batteryPercentage)}";
|
||||
|
||||
/// <summary> Gets request for returning the bike. </summary>
|
||||
|
@ -118,7 +120,7 @@ namespace TINK.Repository.Request
|
|||
/// <param name="geolocation">Geolocation of lock when returning bike.</param>
|
||||
/// <returns>Requst on returning request.</returns>
|
||||
public string DoReturn(string bikeId, LocationDto geolocation, ISmartDevice smartDevice)
|
||||
{
|
||||
{
|
||||
return $"request=booking_update" +
|
||||
$"&bike={bikeId}" +
|
||||
$"&authcookie={SessionCookie}{MerchantId}" +
|
||||
|
@ -133,10 +135,10 @@ namespace TINK.Repository.Request
|
|||
/// <param name="message">General purpose message or error description.</param>
|
||||
/// <param name="isBikeBroken">True if bike is broken.</param>
|
||||
/// <returns>Submit feedback request.</returns>
|
||||
public string DoSubmitFeedback(
|
||||
public string DoSubmitFeedback(
|
||||
string bikeId,
|
||||
string message = null,
|
||||
bool isBikeBroken = false)
|
||||
string message = null,
|
||||
bool isBikeBroken = false)
|
||||
{
|
||||
if (string.IsNullOrEmpty(message) && !isBikeBroken)
|
||||
{
|
||||
|
@ -161,7 +163,7 @@ namespace TINK.Repository.Request
|
|||
return $"request=user_feedback&bike={bikeId}&bike_broken=1&message={WebUtility.UrlEncode(message)}&authcookie={SessionCookie}{MerchantId}";
|
||||
}
|
||||
|
||||
private string GetBatteryPercentageParameters(double batteryPercentage) => !double.IsNaN(batteryPercentage)
|
||||
private string GetBatteryPercentageParameters(double batteryPercentage) => !double.IsNaN(batteryPercentage)
|
||||
? $"&voltage={batteryPercentage.ToString(CultureInfo.InvariantCulture)}"
|
||||
: string.Empty;
|
||||
|
||||
|
@ -169,7 +171,7 @@ namespace TINK.Repository.Request
|
|||
/// <param name="geolocation">Geolocation or null.</param>
|
||||
private string GetLocationParameters(LocationDto geolocation)
|
||||
{
|
||||
if (geolocation == null)
|
||||
if (geolocation == null)
|
||||
return string.Empty;
|
||||
|
||||
if (geolocation.Accuracy == null)
|
||||
|
@ -188,5 +190,21 @@ namespace TINK.Repository.Request
|
|||
$"{(!string.IsNullOrEmpty(smartDevice.VersionText) ? $"&user_device_version={smartDevice.VersionText}" : string.Empty)}" +
|
||||
$"{(!string.IsNullOrEmpty(smartDevice.Identifier) ? $"&user_device_id={smartDevice.Identifier}" : string.Empty)}"
|
||||
: string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets request for submiting mini survey to copri server.
|
||||
/// </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public string DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
{
|
||||
// Remove entires which invalid keys or values.
|
||||
var validAnsers = answers?.Where(x => !string.IsNullOrEmpty(x.Key?.Trim()) && !string.IsNullOrEmpty(x.Value?.Trim()));
|
||||
// Create quersy
|
||||
return validAnsers != null && validAnsers.Count() > 0
|
||||
? $"request=user_minianswer&{string.Join("&", validAnsers.Select(x => $"{x.Key}={WebUtility.UrlEncode(x.Value)}"))}&authcookie={SessionCookie}{MerchantId}"
|
||||
: $"request=user_minianswer&authcookie={SessionCookie}{MerchantId}";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
34
TINKLib/Repository/Response/MiniSurvey.cs
Normal file
34
TINKLib/Repository/Response/MiniSurvey.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace TINK.Repository.Response
|
||||
{
|
||||
[DataContract]
|
||||
public class MiniSurveyResponse
|
||||
{
|
||||
[DataContract]
|
||||
public class Question
|
||||
{
|
||||
[DataMember]
|
||||
public string quest_text { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public string type { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public Dictionary<string, string> query { get; private set; }
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
public string title { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public string subtitle { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public string footer { get; private set; }
|
||||
|
||||
[DataMember]
|
||||
public Dictionary<string, Question> questions { get; private set; }
|
||||
}
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace TINK.Repository.Response
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -6,5 +8,8 @@ namespace TINK.Repository.Response
|
|||
/// </summary>
|
||||
public class ReservationCancelReturnResponse : BikesReservedOccupiedResponse
|
||||
{
|
||||
/// <summary> Mini survey.</summary>
|
||||
[DataMember]
|
||||
public MiniSurveyResponse user_miniquery { get; private set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository;
|
||||
|
@ -250,5 +251,11 @@ namespace TINK.Model.Services.CopriApi
|
|||
/// <param name="isBikeBroken">True if bike is broken.</param>
|
||||
public async Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string message, bool isBikeBroken, Uri opertorUri) =>
|
||||
await HttpsServer.DoSubmitFeedback(bikeId, message, isBikeBroken, opertorUri);
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public async Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> await HttpsServer.DoSubmitMiniSurvey(answers);
|
||||
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository;
|
||||
|
@ -61,7 +62,14 @@ namespace TINK.Model.Services.CopriApi
|
|||
return await monkeyStore.DoReturn(bikeId, geolocation, smartDevice, operatorUri);
|
||||
}
|
||||
|
||||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string messge, bool bIsBikeBroke, Uri operatorUri) => throw new NotImplementedException();
|
||||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string messge, bool bIsBikeBroke, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> throw new NotSupportedException();
|
||||
|
||||
|
||||
public async Task<AuthorizationResponse> DoAuthorizationAsync(string p_strMailAddress, string p_strPassword, string p_strDeviceId)
|
||||
{
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace TINK.ViewModel.Account
|
|||
private int? m_iMyBikesCount;
|
||||
|
||||
/// <summary>
|
||||
/// Reference on view servcie to show modal notifications and to perform navigation.
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
private readonly IViewService m_oViewService;
|
||||
|
||||
|
@ -56,11 +56,11 @@ namespace TINK.ViewModel.Account
|
|||
/// <param name="p_oPolling"> Holds whether to poll or not and the periode leght is polling is on. </param>
|
||||
/// <param name="p_oDefaultPollingPeriode">Default polling periode lenght.</param>
|
||||
/// <param name="p_oMinimumLogEventLevel">Controls logging level.</param>
|
||||
/// <param name="p_oViewService">Interface to view</param>
|
||||
/// <param name="viewService">Interface to view</param>
|
||||
public AccountPageViewModel(
|
||||
ITinkApp tinkApp,
|
||||
Action<string> openUrlInExternalBrowser,
|
||||
IViewService p_oViewService)
|
||||
IViewService viewService)
|
||||
{
|
||||
TinkApp = tinkApp
|
||||
?? throw new ArgumentException("Can not instantiate settings page view model- object. No tink app object available.");
|
||||
|
@ -68,7 +68,7 @@ namespace TINK.ViewModel.Account
|
|||
OpenUrlInExternalBrowser = openUrlInExternalBrowser
|
||||
?? throw new ArgumentException("Can not instantiate settings page view model- object. No user external browse service available.");
|
||||
|
||||
m_oViewService = p_oViewService
|
||||
m_oViewService = viewService
|
||||
?? throw new ArgumentException("Can not instantiate settings page view model- object. No user view service available.");
|
||||
|
||||
m_oViewUpdateManager = new IdlePollingUpdateTaskManager();
|
||||
|
|
|
@ -31,11 +31,11 @@ namespace TINK.ViewModel.Bikes.Bike.BC.RequestHandler
|
|||
protected ISmartDevice SmartDevice;
|
||||
|
||||
/// <summary>
|
||||
/// Reference on view servcie to show modal notifications and to perform navigation.
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
protected IViewService ViewService { get; }
|
||||
|
||||
/// <summary> Provides an connector object.</summary>
|
||||
/// <summary> Provides a connector object.</summary>
|
||||
protected Func<bool, IConnector> ConnectorFactory { get; }
|
||||
|
||||
/// <summary> Delegate to retrieve connected state. </summary>
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace TINK.ViewModel.Bikes.Bike.BC.RequestHandler
|
|||
public string ButtonText => AppResources.ActionReturn; // "Miete beenden"
|
||||
|
||||
/// <summary>
|
||||
/// Reference on view servcie to show modal notifications and to perform navigation.
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
protected IViewService ViewService { get; }
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace TINK.ViewModel.Bikes.Bike.BC.RequestHandler
|
|||
public string ActionText { get => BikesViewModel.ActionText; private set => BikesViewModel.ActionText = value; }
|
||||
|
||||
/// <summary>
|
||||
/// Reference on view servcie to show modal notifications and to perform navigation.
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
protected IViewService ViewService { get; }
|
||||
|
||||
|
|
|
@ -30,11 +30,11 @@ namespace TINK.ViewModel.Bikes.Bike
|
|||
protected ISmartDevice SmartDevice;
|
||||
|
||||
/// <summary>
|
||||
/// Reference on view servcie to show modal notifications and to perform navigation.
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
protected IViewService ViewService { get; }
|
||||
|
||||
/// <summary> Provides an connector object.</summary>
|
||||
/// <summary> Provides a connect orobject.</summary>
|
||||
protected Func<bool, IConnector> ConnectorFactory { get; }
|
||||
|
||||
/// <summary> Delegate to retrieve connected state. </summary>
|
||||
|
|
|
@ -15,6 +15,7 @@ using TINK.Model.User;
|
|||
using Xamarin.Essentials;
|
||||
using TINK.Repository.Request;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Model.MiniSurvey;
|
||||
|
||||
namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
||||
{
|
||||
|
@ -126,10 +127,10 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
|||
IsConnected = IsConnectedDelegate();
|
||||
|
||||
var feedBackUri = SelectedBike?.OperatorUri;
|
||||
|
||||
MiniSurveyModel miniSurvey;
|
||||
try
|
||||
{
|
||||
await ConnectorFactory(IsConnected).Command.DoReturn(
|
||||
miniSurvey = await ConnectorFactory(IsConnected).Command.DoReturn(
|
||||
SelectedBike,
|
||||
currentLocationDto);
|
||||
|
||||
|
@ -229,11 +230,11 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
|||
if (exception is ResponseException copriException)
|
||||
{
|
||||
// Copri server is not reachable.
|
||||
Log.ForContext<BookedOpen>().Information("User selected booked bike {bike} but returing failed. COPRI returned an error.", SelectedBike);
|
||||
Log.ForContext<BookedOpen>().Information("Submitting feedback for bike {bike} failed. COPRI returned an error.", SelectedBike);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.ForContext<BookedOpen>().Error("User selected availalbe bike {bike} but reserving failed. {@l_oException}", SelectedBike.Id, exception);
|
||||
Log.ForContext<BookedOpen>().Error("Submitting feedback for bike {bike} failed. {@l_oException}", SelectedBike.Id, exception);
|
||||
}
|
||||
|
||||
await ViewService.DisplayAlert(
|
||||
|
@ -250,6 +251,10 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
|||
return RequestHandlerFactory.Create(SelectedBike, IsConnectedDelegate, ConnectorFactory, Geolocation, LockService, ViewUpdateManager, SmartDevice, ViewService, BikesViewModel, ActiveUser);
|
||||
}
|
||||
#endif
|
||||
if (miniSurvey != null && miniSurvey.Questions.Count > 0)
|
||||
{
|
||||
await ViewService.PushModalAsync(ViewTypes.MiniSurvey);
|
||||
}
|
||||
|
||||
// Restart polling again.
|
||||
BikesViewModel.ActionText = AppResources.ActivityTextStartingUpdater;
|
||||
|
|
|
@ -15,6 +15,7 @@ using TINK.Model.Bikes.Bike.BluetoothLock;
|
|||
using TINK.Model.User;
|
||||
using TINK.Repository.Request;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Model.MiniSurvey;
|
||||
|
||||
namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
||||
{
|
||||
|
@ -195,10 +196,10 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
|||
IsConnected = IsConnectedDelegate();
|
||||
|
||||
var feedBackUri = SelectedBike?.OperatorUri;
|
||||
|
||||
MiniSurveyModel miniSurvey;
|
||||
try
|
||||
{
|
||||
await ConnectorFactory(IsConnected).Command.DoReturn(
|
||||
miniSurvey = await ConnectorFactory(IsConnected).Command.DoReturn(
|
||||
SelectedBike,
|
||||
currentLocation != null
|
||||
? new LocationDto.Builder
|
||||
|
@ -304,11 +305,11 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
|||
if (exception is ResponseException copriException)
|
||||
{
|
||||
// Copri server is not reachable.
|
||||
Log.ForContext<BookedOpen>().Information("User selected booked bike {bike} but returing failed. COPRI returned an error.", SelectedBike);
|
||||
Log.ForContext<BookedOpen>().Information("Submitting feedback for bike {bike} failed. COPRI returned an error.", SelectedBike);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.ForContext<BookedOpen>().Error("User selected availalbe bike {bike} but reserving failed. {@l_oException}", SelectedBike.Id, exception);
|
||||
Log.ForContext<BookedOpen>().Error("Submitting feedback for bike {bike} failed. {@l_oException}", SelectedBike.Id, exception);
|
||||
}
|
||||
|
||||
await ViewService.DisplayAlert(
|
||||
|
@ -325,6 +326,11 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
|||
}
|
||||
#endif
|
||||
|
||||
if (miniSurvey != null && miniSurvey.Questions.Count > 0)
|
||||
{
|
||||
await ViewService.PushModalAsync(ViewTypes.MiniSurvey);
|
||||
}
|
||||
|
||||
BikesViewModel.ActionText = AppResources.ActivityTextStartingUpdater;
|
||||
await ViewUpdateManager().StartUpdateAyncPeridically();
|
||||
BikesViewModel.ActionText = string.Empty;
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace TINK.ViewModel.Bikes.Bike.BluetoothLock
|
|||
public string LockitButtonText => GetType().Name;
|
||||
|
||||
/// <summary>
|
||||
/// Reference on view servcie to show modal notifications and to perform navigation.
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
private IViewService ViewService { get; }
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace TINK.ViewModel.Bikes
|
|||
protected ISmartDevice SmartDevice;
|
||||
|
||||
/// <summary>
|
||||
/// Reference on view servcie to show modal notifications and to perform navigation.
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
protected IViewService ViewService { get; }
|
||||
|
||||
|
@ -34,12 +34,12 @@ namespace TINK.ViewModel.Bikes
|
|||
/// </summary>
|
||||
private Exception m_oException;
|
||||
|
||||
/// <summary> Provides an connector object.</summary>
|
||||
/// <summary> Provides a connector object.</summary>
|
||||
protected Func<bool, IConnector> ConnectorFactory { get; }
|
||||
|
||||
protected IGeolocation Geolocation { get; }
|
||||
|
||||
/// <summary> Provides an connector object.</summary>
|
||||
/// <summary> Provides a connector object.</summary>
|
||||
protected ILocksService LockService { get; }
|
||||
|
||||
/// <summary> Delegate to retrieve connected state. </summary>
|
||||
|
@ -88,7 +88,7 @@ namespace TINK.ViewModel.Bikes
|
|||
/// <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>
|
||||
/// <param name="p_oViewService">Interface to actuate methodes on GUI.</param>
|
||||
/// <param name="viewService">Interface to actuate methodes on GUI.</param>
|
||||
public BikesViewModel(
|
||||
User user,
|
||||
IPermissions permissions,
|
||||
|
|
|
@ -195,7 +195,7 @@ namespace TINK.ViewModel.BikesAtStation
|
|||
// Switch to map page
|
||||
|
||||
#if USEMASTERDETAIL || USEFLYOUT
|
||||
ViewService.ShowPage(ViewTypes.ContactPage, m_oStation?.OperatorData?.Name ?? AppResources.MarkingFeedbackAndContact);
|
||||
ViewService.ShowPage(ViewTypes.ContactPage, AppResources.MarkingFeedbackAndContact);
|
||||
#else
|
||||
await ViewService.ShowPage("//LoginPage");
|
||||
#endif
|
||||
|
|
|
@ -226,8 +226,14 @@ namespace TINK.ViewModel.Info
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary> Text providing mail address and possilbe reasons to contact. </summary>
|
||||
public FormattedString MaliAddressAndMotivationsText
|
||||
public string ProviderNameText
|
||||
=> string.Format("Betreiber: {0}", SelectedStation?.OperatorData?.Name)
|
||||
;
|
||||
/// <summary> Text providing mail address and possilbe reasons to contact. </summary>
|
||||
public FormattedString MailAddressAndMotivationsText
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace TINK.ViewModel.Contact
|
|||
/// <summary> Holds the count of custom icons availalbe.</summary>
|
||||
private const int CUSTOM_ICONS_COUNT = 30;
|
||||
|
||||
/// <summary> Reference on view servcie to show modal notifications and to perform navigation. </summary>
|
||||
/// <summary> Reference on view service to show modal notifications and to perform navigation. </summary>
|
||||
private IViewService ViewService { get; }
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace TINK.ViewModel.Info.BikeInfo
|
|||
public class BikeInfoViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference on view servcie to show modal notifications and to perform navigation.
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
private readonly IViewService m_oViewService;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace TINK.ViewModel
|
|||
public class LoginPageViewModel : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference on view servcie to show modal notifications and to perform navigation.
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
private readonly IViewService m_oViewService;
|
||||
|
||||
|
@ -178,7 +178,7 @@ namespace TINK.ViewModel
|
|||
{
|
||||
if (CrossConnectivity.Current.IsConnected)
|
||||
{
|
||||
await m_oViewService.PushAsync(ViewTypes.RegisterPage);
|
||||
await m_oViewService.PushAsync(ViewTypes.RegisterPage);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace TINK.ViewModel.Map
|
|||
/// <summary> Holds the count of custom icons availalbe.</summary>
|
||||
private const int CUSTOM_ICONS_COUNT = 30;
|
||||
|
||||
/// <summary> Reference on view servcie to show modal notifications and to perform navigation. </summary>
|
||||
/// <summary> Reference on view service to show modal notifications and to perform navigation. </summary>
|
||||
private IViewService ViewService { get; }
|
||||
|
||||
/// <summary>
|
||||
|
@ -315,55 +315,52 @@ namespace TINK.ViewModel.Map
|
|||
// Update map page filter
|
||||
ActiveFilterMap = TinkApp.GroupFilterMapPage;
|
||||
|
||||
if (Pins.Count <= 0)
|
||||
{
|
||||
ActionText = AppResources.ActivityTextMyBikesLoadingBikes;
|
||||
ActionText = AppResources.ActivityTextMyBikesLoadingBikes;
|
||||
|
||||
// Check location permission
|
||||
var status = await PermissionsService.CheckPermissionStatusAsync<LocationPermission>();
|
||||
if (TinkApp.CenterMapToCurrentLocation
|
||||
&& !GeolocationService.IsSimulation
|
||||
&& status != Plugin.Permissions.Abstractions.PermissionStatus.Granted)
|
||||
{
|
||||
var permissionResult = await PermissionsService.RequestPermissionAsync<LocationPermission>();
|
||||
// Check location permission
|
||||
var status = await PermissionsService.CheckPermissionStatusAsync<LocationPermission>();
|
||||
if (TinkApp.CenterMapToCurrentLocation
|
||||
&& !GeolocationService.IsSimulation
|
||||
&& status != Plugin.Permissions.Abstractions.PermissionStatus.Granted)
|
||||
{
|
||||
var permissionResult = await PermissionsService.RequestPermissionAsync<LocationPermission>();
|
||||
|
||||
if (permissionResult != Plugin.Permissions.Abstractions.PermissionStatus.Granted)
|
||||
{
|
||||
var dialogResult = await ViewService.DisplayAlert(
|
||||
var dialogResult = await m_oViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
AppResources.MessageCenterMapLocationPermissionOpenDialog,
|
||||
AppResources.MessageAnswerYes,
|
||||
AppResources.MessageAnswerNo);
|
||||
|
||||
if (dialogResult)
|
||||
{
|
||||
// User decided to give access to locations permissions.
|
||||
PermissionsService.OpenAppSettings();
|
||||
ActionText = "";
|
||||
IsRunning = false;
|
||||
IsMapPageEnabled = true;
|
||||
return;
|
||||
}
|
||||
if (dialogResult)
|
||||
{
|
||||
// User decided to give access to locations permissions.
|
||||
PermissionsService.OpenAppSettings();
|
||||
ActionText = "";
|
||||
IsRunning = false;
|
||||
IsMapPageEnabled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Move and scale before getting stations and bikes which takes some time.
|
||||
ActionText = AppResources.ActivityTextCenterMap;
|
||||
Location currentLocation = null;
|
||||
try
|
||||
{
|
||||
currentLocation = TinkApp.CenterMapToCurrentLocation
|
||||
? await GeolocationService.GetAsync()
|
||||
: null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
|
||||
}
|
||||
|
||||
MoveAndScale(m_oMoveToRegionDelegate, TinkApp.Uris.ActiveUri, ActiveFilterMap, currentLocation);
|
||||
}
|
||||
|
||||
// Move and scale before getting stations and bikes which takes some time.
|
||||
ActionText = AppResources.ActivityTextCenterMap;
|
||||
Location currentLocation = null;
|
||||
try
|
||||
{
|
||||
currentLocation = TinkApp.CenterMapToCurrentLocation
|
||||
? await GeolocationService.GetAsync()
|
||||
: null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext<MapPageViewModel>().Error("Getting location failed. {Exception}", ex);
|
||||
}
|
||||
|
||||
MoveAndScale(m_oMoveToRegionDelegate, TinkApp.Uris.ActiveUri, ActiveFilterMap, currentLocation);
|
||||
|
||||
ActionText = AppResources.ActivityTextMapLoadingStationsAndBikes;
|
||||
IsConnected = TinkApp.GetIsConnected();
|
||||
var resultStationsAndBikes = await TinkApp.GetConnector(IsConnected).Query.GetBikesAndStationsAsync();
|
||||
|
|
153
TINKLib/ViewModel/MiniSurvey/MiniSurveyViewModel.cs
Normal file
153
TINKLib/ViewModel/MiniSurvey/MiniSurveyViewModel.cs
Normal file
|
@ -0,0 +1,153 @@
|
|||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.MiniSurvey;
|
||||
using TINK.MultilingualResources;
|
||||
using TINK.Repository.Exception;
|
||||
using TINK.View;
|
||||
using TINK.ViewModel.MiniSurvey.Question;
|
||||
|
||||
namespace TINK.ViewModel.MiniSurvey
|
||||
{
|
||||
public class MiniSurveyViewModel : ObservableCollection<IMiniSurveyQuestion>
|
||||
{
|
||||
/// <summary> Delegate to retrieve connected state. </summary>
|
||||
protected Func<bool> IsConnectedDelegate { get; }
|
||||
|
||||
/// <summary> Provides a connector object.</summary>
|
||||
private Func<bool, IConnector> ConnectorFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
private IViewService ViewService { get; }
|
||||
|
||||
private MiniSurveyModel MiniSurvey { get; }
|
||||
|
||||
/// <summary> Constructs mini survey view model.</summary>
|
||||
/// <param name="connectorFactory">Connects system to copri for purposes of requesting a bike/ cancel request.</param>
|
||||
/// <param name="viewService">Interface to actuate methodes on GUI.</param>
|
||||
public MiniSurveyViewModel(
|
||||
Func<bool> isConnectedDelegate,
|
||||
Func<bool, IConnector> connectorFactory,
|
||||
IViewService viewService)
|
||||
{
|
||||
IsConnectedDelegate = isConnectedDelegate
|
||||
?? throw new ArgumentException($"Can not instantiate {nameof(MiniSurveyViewModel)}-object. No connector available.");
|
||||
|
||||
ConnectorFactory = connectorFactory
|
||||
?? throw new ArgumentException($"Can not instantiate {nameof(MiniSurveyViewModel)}-object. No connector available.");
|
||||
|
||||
ViewService = viewService
|
||||
?? throw new ArgumentException($"Can not instantiate {nameof(MiniSurveyViewModel)}-object. No view available.");
|
||||
|
||||
MiniSurvey = new MiniSurveyModel
|
||||
{
|
||||
Title = "Bitte unterstützen Sie unsere Begleitforschung",
|
||||
Subtitle = "Ihre drei Antworten werden anonym gespeichert.",
|
||||
Footer = "Herzlichen Dank und viel Spaß bei der nächsten Fahrt!"
|
||||
};
|
||||
|
||||
MiniSurvey.Questions.Add(
|
||||
"q1",
|
||||
new MiniSurveyModel.QuestionModel
|
||||
{
|
||||
Text = "1. Was war der Hauptzweck dieser Ausleihe?",
|
||||
Type = MiniSurveyModel.Type.SingleAnswer
|
||||
});
|
||||
|
||||
MiniSurvey.Questions.Add(
|
||||
"q2",
|
||||
new MiniSurveyModel.QuestionModel
|
||||
{
|
||||
Text = "2. Welches Verkehrsmittel hätten Sie ansonsten benutzt?",
|
||||
Type = MiniSurveyModel.Type.SingleAnswer
|
||||
});
|
||||
|
||||
MiniSurvey.Questions.Add(
|
||||
"q3",
|
||||
new MiniSurveyModel.QuestionModel
|
||||
{
|
||||
Text = "3. Haben Sie Anmerkungen oder Anregungen?",
|
||||
Type = MiniSurveyModel.Type.CustomText
|
||||
});
|
||||
|
||||
MiniSurvey.Questions["q1"].PossibleAnswers.Add("opt1", "a. Einkauf");
|
||||
MiniSurvey.Questions["q1"].PossibleAnswers.Add("opt2", "b. Kinderbeförderung");
|
||||
MiniSurvey.Questions["q1"].PossibleAnswers.Add("opt3", "c. Lastentransport");
|
||||
MiniSurvey.Questions["q1"].PossibleAnswers.Add("opt4", "d. Freizeit");
|
||||
MiniSurvey.Questions["q1"].PossibleAnswers.Add("opt5", "e. Ausprobieren");
|
||||
MiniSurvey.Questions["q1"].PossibleAnswers.Add("opt6", "f. Sonstiges");
|
||||
|
||||
MiniSurvey.Questions["q2"].PossibleAnswers.Add("opt1", "a. Auto");
|
||||
MiniSurvey.Questions["q2"].PossibleAnswers.Add("opt2", "b. Motorrad oder Motorroller");
|
||||
MiniSurvey.Questions["q2"].PossibleAnswers.Add("opt3", "c. Bus oder Bahn");
|
||||
MiniSurvey.Questions["q2"].PossibleAnswers.Add("opt4", "d. Eigenes Fahrrad");
|
||||
MiniSurvey.Questions["q2"].PossibleAnswers.Add("opt5", "e. Zu Fuß");
|
||||
MiniSurvey.Questions["q2"].PossibleAnswers.Add("opt6", "f. Keines (ich hätte die Fahrt sonst nicht gemacht)");
|
||||
|
||||
Title = MiniSurvey.Title;
|
||||
Subtitle = MiniSurvey.Subtitle;
|
||||
Footer = MiniSurvey.Footer;
|
||||
|
||||
foreach (var question in MiniSurvey.Questions)
|
||||
{
|
||||
switch (question.Value.Type)
|
||||
{
|
||||
case MiniSurveyModel.Type.SingleAnswer:
|
||||
Add(new CheckOneViewModel(
|
||||
new KeyValuePair<string, string>(question.Key, question.Value.Text),
|
||||
question.Value.PossibleAnswers));
|
||||
break;
|
||||
|
||||
case MiniSurveyModel.Type.CustomText:
|
||||
Add(new FreeTextViewModel(new KeyValuePair<string, string>(question.Key, question.Value.Text)));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Title { get; set; }
|
||||
|
||||
public string Subtitle { get; set; }
|
||||
|
||||
public string Footer { get; set; }
|
||||
|
||||
/// <summary> Processes request to perform a copri action (reserve bike and cancel reservation). </summary>
|
||||
public System.Windows.Input.ICommand OnButtonClicked => new Xamarin.Forms.Command(async () =>
|
||||
{
|
||||
Log.ForContext<MiniSurveyViewModel>().Information($"User result {this[0].Answer.Value}, {this[1].Answer.Value}");
|
||||
|
||||
var isConnected = IsConnectedDelegate();
|
||||
try
|
||||
{
|
||||
await ConnectorFactory(isConnected).Command.DoSubmitMiniSurvey(this.ToDictionary(x => x.Question.Key, x => x.Answer.Key));
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
if (exception is ResponseException copriException)
|
||||
{
|
||||
// Copri server is not reachable.
|
||||
Log.ForContext<MiniSurveyViewModel>().Information("Submitting mini survay answer failed. COPRI returned an error.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.ForContext<MiniSurveyViewModel>().Error("Submitting mini survay answer failed. {@l_oException}", exception);
|
||||
}
|
||||
|
||||
await ViewService.DisplayAlert(
|
||||
AppResources.ErrorReturnSubmitFeedbackTitle,
|
||||
AppResources.ErrorReturnSubmitFeedbackMessage,
|
||||
AppResources.MessageAnswerOk);
|
||||
}
|
||||
|
||||
await ViewService.PopModalAsync();
|
||||
});
|
||||
}
|
||||
}
|
45
TINKLib/ViewModel/MiniSurvey/Question/CheckOneViewModel.cs
Normal file
45
TINKLib/ViewModel/MiniSurvey/Question/CheckOneViewModel.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace TINK.ViewModel.MiniSurvey.Question
|
||||
{
|
||||
public class CheckOneViewModel : IMiniSurveyQuestion
|
||||
{
|
||||
/// <summary> Constructs object. </summary>
|
||||
/// <param name="question">Holds the question with key asked to user.</param>
|
||||
/// <param name="answers">Holds the list of possible answers with their option keys.</param>
|
||||
public CheckOneViewModel(
|
||||
KeyValuePair<string, string> question,
|
||||
Dictionary<string, string> answers)
|
||||
{
|
||||
Question = question;
|
||||
Answers = answers ?? new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
/// <summary> Holds the question with key asked to user. </summary>
|
||||
public KeyValuePair<string, string> Question { get; }
|
||||
|
||||
/// <summary> Holds the question with key asked to user exposed to GUI. </summary>
|
||||
public string QuestionText => Question.Value;
|
||||
|
||||
/// <summary> Holds the list of possible answers with their option keys. </summary>
|
||||
public Dictionary<string, string> Answers { get; }
|
||||
|
||||
/// <summary> Holds the list of possible answers exposed to GUI. </summary>
|
||||
public IEnumerable<string> AnswersText
|
||||
{
|
||||
get => Answers.Select(x => x.Value).ToList();
|
||||
set => AnswersText = Answers.Select(x => x.Value).ToList();
|
||||
}
|
||||
|
||||
/// <summary> Holds the users selected answer (one of answers) with its option key. </summary>
|
||||
public KeyValuePair<string, string> Answer { get; private set; }
|
||||
|
||||
/// <summary> Holds the users selected answer (one of answers) in GUI. </summary>
|
||||
public string AnswerText
|
||||
{
|
||||
get => Answer.Value;
|
||||
set => Answer = Answers.FirstOrDefault(x => x.Value == value);
|
||||
}
|
||||
}
|
||||
}
|
32
TINKLib/ViewModel/MiniSurvey/Question/FreeTextViewModel.cs
Normal file
32
TINKLib/ViewModel/MiniSurvey/Question/FreeTextViewModel.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace TINK.ViewModel.MiniSurvey.Question
|
||||
{
|
||||
public class FreeTextViewModel : IMiniSurveyQuestion
|
||||
{
|
||||
/// <summary> Constructs object. </summary>
|
||||
/// <param name="question">Holds the question with key asked to user.</param>
|
||||
/// <param name="answers">Holds the list of possible answers with their option keys.</param>
|
||||
public FreeTextViewModel(
|
||||
KeyValuePair<string, string> question)
|
||||
{
|
||||
Question = question;
|
||||
}
|
||||
|
||||
/// <summary> Holds the question with key asked to user. </summary>
|
||||
public KeyValuePair<string, string> Question { get; }
|
||||
|
||||
/// <summary> Holds the question with key asked to user exposed to GUI. </summary>
|
||||
public string QuestionText => Question.Value;
|
||||
|
||||
/// <summary> Holds the users selected answer with its option key. </summary>
|
||||
public KeyValuePair<string, string> Answer { get; private set; }
|
||||
|
||||
/// <summary> Holds the list of possible answers exposed to GUI. </summary>
|
||||
public string AnswerText
|
||||
{
|
||||
get => null;
|
||||
set => Answer = new KeyValuePair<string, string>(value, null);
|
||||
}
|
||||
}
|
||||
}
|
13
TINKLib/ViewModel/MiniSurvey/Question/IMiniSurveyQuestion.cs
Normal file
13
TINKLib/ViewModel/MiniSurvey/Question/IMiniSurveyQuestion.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace TINK.ViewModel.MiniSurvey.Question
|
||||
{
|
||||
public interface IMiniSurveyQuestion
|
||||
{
|
||||
/// <summary> Holds the question with key asked to user. </summary>
|
||||
KeyValuePair<string, string> Question { get; }
|
||||
|
||||
/// <summary> Holds the users selected answer with its option key. </summary>
|
||||
KeyValuePair<string, string> Answer { get; }
|
||||
}
|
||||
}
|
|
@ -26,7 +26,7 @@ namespace TINK.ViewModel
|
|||
public class SettingsPageViewModel : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference on view servcie to show modal notifications and to perform navigation.
|
||||
/// Reference on view service to show modal notifications and to perform navigation.
|
||||
/// </summary>
|
||||
private IViewService m_oViewService;
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
WhatsNewPage,
|
||||
BikesAtStation,
|
||||
ContactPage,
|
||||
SelectStationPage
|
||||
SelectStationPage,
|
||||
MiniSurvey
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue