mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-19 11:37:28 +02:00
Version 3.0.337
This commit is contained in:
parent
fd0e63cf10
commit
573fe77e12
2336 changed files with 33688 additions and 86082 deletions
|
@ -1,10 +1,10 @@
|
|||
using Plugin.Messaging;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using Plugin.Messaging;
|
||||
using Serilog;
|
||||
using TINK.Model.Services.CopriApi.ServerUris;
|
||||
using TINK.Model.Station;
|
||||
using TINK.MultilingualResources;
|
||||
|
@ -17,6 +17,11 @@ namespace TINK.ViewModel.Info
|
|||
/// <summary> View model for contact page.</summary>
|
||||
public class ContactPageViewModel : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// Mail address for app related support.
|
||||
/// </summary>
|
||||
public const string APPSUPPORTMAILADDRESS = "hotline@sharee.bike";
|
||||
|
||||
/// <summary> Reference on view service to show modal notifications and to perform navigation. </summary>
|
||||
private IViewService ViewService { get; }
|
||||
|
||||
|
@ -84,17 +89,41 @@ namespace TINK.ViewModel.Info
|
|||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary> Command object to bind login button to view model. </summary>
|
||||
/// <summary> Command object to bind mail button to view model. </summary>
|
||||
public ICommand OnMailRequest
|
||||
=> new Command(
|
||||
async () => await DoSendMail(),
|
||||
async () =>
|
||||
{
|
||||
if (await DoSendMailToOperator())
|
||||
{
|
||||
// Mail sent to operator or no mailer availble.
|
||||
return;
|
||||
}
|
||||
|
||||
await DoSendMailAppRelated(
|
||||
new List<string> { MailAddressText },
|
||||
MailAddressText.ToUpper() != APPSUPPORTMAILADDRESS.ToUpper()
|
||||
? new List<string> { APPSUPPORTMAILADDRESS }
|
||||
: new List<string>());
|
||||
},
|
||||
() => IsSendMailAvailable);
|
||||
|
||||
/// <summary> Command object to bind mail app releated button to model. </summary>
|
||||
public ICommand OnSendAppFeedbackMailRequest
|
||||
=> new Command(
|
||||
async () => await DoSendMailToOperator(),
|
||||
() => IsSendMailAvailable);
|
||||
|
||||
/// <summary> Command object to bind mail app releated button to model. </summary>
|
||||
public ICommand OnMailAppRelatedRequest
|
||||
=> new Command(
|
||||
async () => await DoSendMailAppRelated(new List<string> { APPSUPPORTMAILADDRESS }, new List<string>()),
|
||||
() => IsSendMailAvailable);
|
||||
|
||||
/// <summary>True if sending mail is possible.</summary>
|
||||
public bool IsSendMailAvailable =>
|
||||
CrossMessaging.Current.EmailMessenger.CanSendEmail;
|
||||
|
||||
|
||||
|
||||
/// <summary>cTrue if doing a phone call is possible.</summary>
|
||||
public bool IsDoPhoncallAvailable
|
||||
|
@ -116,31 +145,52 @@ namespace TINK.ViewModel.Info
|
|||
public bool IsOperatorInfoAvaliable
|
||||
=> MailAddressText.Length > 0 || PhoneNumberText.Length > 0;
|
||||
|
||||
/// <summary> Request to do a phone call. </summary>
|
||||
public async Task DoSendMail()
|
||||
/// <returns> Returns true if eithe mail was sent or if no mailer available.</returns>
|
||||
public async Task<bool> DoSendMailToOperator()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!IsSendMailAvailable)
|
||||
{
|
||||
// Nothing to do because email can not be sent.
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
var tinkMail = await ViewService.DisplayAlert(
|
||||
// Ask whether mail is operator or app specific.
|
||||
var operatorRelatedMail = await ViewService.DisplayAlert(
|
||||
AppResources.QuestionTitle,
|
||||
string.Format(AppResources.QuestionSupportmailSubject, GetAppName(ActiveUri)),
|
||||
string.Format(AppResources.QuestionSupportmailAnswerOperator, GetAppName(ActiveUri)),
|
||||
string.Format(AppResources.QuestionSupportmailAnswerApp, GetAppName(ActiveUri)));
|
||||
|
||||
if (tinkMail)
|
||||
if (operatorRelatedMail)
|
||||
{
|
||||
// Send TINK- related support mail.
|
||||
// Send operator related support mail.
|
||||
await Email.ComposeAsync(new EmailMessage { To = new List<string> { MailAddressText }, Subject = $"{GetAppName(ActiveUri)} Anfrage" });
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Send a tink app related mail
|
||||
return false;
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("An unexpected error occurred sending mail to operator. {@Exception}", exception);
|
||||
await ViewService.DisplayAdvancedAlert(
|
||||
AppResources.MessageWaring,
|
||||
AppResources.ErrorSupportmailMailingFailed,
|
||||
exception.Message,
|
||||
AppResources.MessageAnswerOk);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Request to send a app related mail. </summary>
|
||||
public async Task DoSendMailAppRelated(List<string> to, List<string> cc)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Send app related mail
|
||||
var appendFile = false;
|
||||
appendFile = await ViewService.DisplayAlert(
|
||||
AppResources.QuestionTitle,
|
||||
|
@ -148,28 +198,34 @@ namespace TINK.ViewModel.Info
|
|||
AppResources.QuestionAnswerYes,
|
||||
AppResources.QuestionAnswerNo);
|
||||
|
||||
var message = new EmailMessage { To = new List<string> { MailAddressText }, Subject = $"{GetAppName(ActiveUri)}-App Anfrage" };
|
||||
var message = new EmailMessage
|
||||
{
|
||||
To = to,
|
||||
Cc = cc,
|
||||
Subject = $"{GetAppName(ActiveUri)}-App Anfrage"
|
||||
};
|
||||
|
||||
if (appendFile == false)
|
||||
{
|
||||
// Send a tink app related mail
|
||||
// Send without attachment
|
||||
await Email.ComposeAsync(message);
|
||||
return;
|
||||
}
|
||||
|
||||
// Send with attachment.
|
||||
var logFileName = string.Empty;
|
||||
try
|
||||
{
|
||||
logFileName = CreateAttachment();
|
||||
}
|
||||
catch (Exception l_oException)
|
||||
catch (Exception exception)
|
||||
{
|
||||
await ViewService.DisplayAdvancedAlert(
|
||||
AppResources.MessageWaring,
|
||||
AppResources.ErrorSupportmailCreateAttachment,
|
||||
l_oException.Message,
|
||||
exception.Message,
|
||||
AppResources.MessageAnswerOk);
|
||||
Log.Error("An error occurred creating attachment. {@l_oException)", l_oException);
|
||||
Log.Error("An error occurred creating attachment. {@Exception)", exception);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(logFileName))
|
||||
|
@ -180,19 +236,18 @@ namespace TINK.ViewModel.Info
|
|||
// Send a tink app related mail
|
||||
await Email.ComposeAsync(message);
|
||||
}
|
||||
catch (Exception p_oException)
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("An unexpected error occurred sending mail. {@Exception}", p_oException);
|
||||
Log.Error("An unexpected error occurred sending mail. {@Exception}", exception);
|
||||
await ViewService.DisplayAdvancedAlert(
|
||||
AppResources.MessageWaring,
|
||||
AppResources.ErrorSupportmailMailingFailed,
|
||||
p_oException.Message,
|
||||
AppResources.ErrorSupportmailMailingFailed,
|
||||
exception.Message,
|
||||
AppResources.MessageAnswerOk);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Command object to bind login button to view model. </summary>
|
||||
public ICommand OnSelectStationRequest
|
||||
#if USEFLYOUT
|
||||
|
@ -243,13 +298,13 @@ namespace TINK.ViewModel.Info
|
|||
CrossMessaging.Current.PhoneDialer.MakePhoneCall(PhoneNumberText);
|
||||
}
|
||||
}
|
||||
catch (Exception p_oException)
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("An unexpected error occurred doing a phone call. {@Exception}", p_oException);
|
||||
Log.Error("An unexpected error occurred doing a phone call. {@Exception}", exception);
|
||||
await ViewService.DisplayAdvancedAlert(
|
||||
AppResources.MessageWaring,
|
||||
AppResources.ErrorSupportmailPhoningFailed,
|
||||
p_oException.Message,
|
||||
AppResources.ErrorSupportmailPhoningFailed,
|
||||
exception.Message,
|
||||
AppResources.MessageAnswerOk);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ using TINK.View;
|
|||
using TINK.Model.Station;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using TINK.Model.Bike;
|
||||
using TINK.Model.Bikes;
|
||||
using TINK.Repository.Exception;
|
||||
using TINK.Model;
|
||||
using Serilog;
|
||||
|
@ -22,6 +22,7 @@ using TINK.MultilingualResources;
|
|||
using TINK.ViewModel.Info;
|
||||
using TINK.Repository;
|
||||
using TINK.Services.Geolocation;
|
||||
using TINK.Model.State;
|
||||
|
||||
namespace TINK.ViewModel.Contact
|
||||
{
|
||||
|
@ -385,6 +386,8 @@ namespace TINK.ViewModel.Contact
|
|||
AppResources.MessageMapPageErrorAuthcookieUndefined,
|
||||
AppResources.MessageAnswerOk);
|
||||
|
||||
IsConnected = TinkApp.GetIsConnected();
|
||||
|
||||
await TinkApp.GetConnector(IsConnected).Command.DoLogout();
|
||||
TinkApp.ActiveUser.Logout();
|
||||
}
|
||||
|
@ -483,16 +486,16 @@ namespace TINK.ViewModel.Contact
|
|||
"OK");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of station color for all stations.
|
||||
/// </summary>
|
||||
/// <param name="stationsId">Station id list to get color for.</param>
|
||||
/// <returns></returns>
|
||||
private static IList<Color> GetStationColors(
|
||||
IEnumerable<string> stationsId,
|
||||
BikeCollection bikesAll)
|
||||
private static IList<Color> GetStationColors(
|
||||
IEnumerable<string> stationsId,
|
||||
BikeCollection bikesAll)
|
||||
{
|
||||
if (stationsId == null)
|
||||
{
|
||||
|
@ -513,7 +516,7 @@ namespace TINK.ViewModel.Contact
|
|||
{
|
||||
// Get color of given station.
|
||||
var bikesAtStation = bikesAll.Where(x => x.StationId == stationId).ToList();
|
||||
if (bikesAtStation.FirstOrDefault(x => x.State.Value != Model.State.InUseStateEnum.Disposable) != null)
|
||||
if (bikesAtStation.FirstOrDefault(x => x.State.Value.IsOccupied()) != null)
|
||||
{
|
||||
// There is at least one requested or booked bike
|
||||
colors.Add(Color.LightBlue);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue