Version 3.0.373

This commit is contained in:
Anja 2023-09-22 11:38:42 +02:00
parent f1cbab1d0a
commit 06428d96d9
87 changed files with 1796 additions and 1208 deletions

View file

@ -6,7 +6,6 @@ using System.Windows.Input;
using Plugin.Messaging;
using Serilog;
using TINK.Model;
using TINK.Model.Stations;
using TINK.Model.Stations.StationNS;
using TINK.MultilingualResources;
using TINK.View;
@ -90,25 +89,23 @@ namespace TINK.ViewModel.Info
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PhoneNumberText)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ProviderNameText)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsOperatorInfoAvaliable)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsDoPhoncallAvailable)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsSendMailAvailable)));
await Task.CompletedTask;
}
/// <summary> Command object to bind mail button to view model. </summary>
public ICommand OnMailToOperatorRequest
=> new Command(
async () => await DoSendMailToOperator(),
() => IsSendMailAvailable);
=> new Command(async () => await DoSendMailToOperator());
/// <summary> Command object to bind mail app related button to model. </summary>
public ICommand OnMailAppRelatedRequest
=> new Command(
async () => await DoSendMailAppRelated(),
() => IsSendMailAvailable);
=> new Command(async () => await DoSendMailAppRelated());
/// <summary>True if sending mail is possible.</summary>
public bool IsSendMailAvailable =>
CrossMessaging.Current.EmailMessenger.CanSendEmail;
public bool IsSendMailAvailable
=> CrossMessaging.Current.EmailMessenger.CanSendEmail;
/// <summary>cTrue if doing a phone call is possible.</summary>
@ -134,91 +131,107 @@ namespace TINK.ViewModel.Info
/// <returns> Returns true if either mail was sent or if no mailer available.</returns>
public async Task DoSendMailToOperator()
{
try
if (!IsSendMailAvailable)
{
if (!IsSendMailAvailable)
{
// Nothing to do because email can not be sent.
return;
}
// Send operator related support mail to operator.
await Email.ComposeAsync(new EmailMessage
{
To = new List<string> { MailAddressText },
Cc = APPSUPPORTMAILADDRESS.ToUpper() != MailAddressText.ToUpper() // do not sent copy if same mail address
&& MailAddressText != "konrad@sharee.bike" // do not sent copy if Mein konrad
? new List<string> { APPSUPPORTMAILADDRESS } : new List<string>(),
Subject = string.Format(AppResources.SupportmailSubjectOperatormail, AppFlavorName, SelectedStation?.Id),
Body = TinkApp.ActiveUser.Mail != null ? $"{AppResources.SupportmailBodyText}\r\n\r\n\r\n\r\n{string.Format(AppResources.MarkingLoggedInStateInfoLoggedIn, TinkApp.ActiveUser.Mail)}" : $"{AppResources.SupportmailBodyText}\r\n\r\n\r\n\r\n{string.Format(AppResources.SupportmailBodyNotLoggedIn)}"
});
return;
}
catch (Exception exception)
{
Log.Error("An unexpected error occurred sending mail to operator. {@Exception}", exception);
await ViewService.DisplayAdvancedAlert(
AppResources.MessageWaring,
await ViewService.DisplayAlert(
String.Empty,
AppResources.ErrorSupportmailMailingFailed,
exception.Message,
AppResources.MessageAnswerOk);
return;
}
else
{
try
{
// Send operator related support mail to operator.
await Email.ComposeAsync(new EmailMessage
{
To = new List<string> { MailAddressText },
Cc = APPSUPPORTMAILADDRESS.ToUpper() != MailAddressText.ToUpper() // do not sent copy if same mail address
&& MailAddressText != "konrad@sharee.bike" // do not sent copy if Mein konrad
? new List<string> { APPSUPPORTMAILADDRESS } : new List<string>(),
Subject = string.Format(AppResources.SupportmailSubjectOperatormail, AppFlavorName, SelectedStation?.Id),
Body = TinkApp.ActiveUser.Mail != null ? $"{AppResources.SupportmailBodyText}\r\n\r\n\r\n\r\n{string.Format(AppResources.MarkingLoggedInStateInfoLoggedIn, TinkApp.ActiveUser.Mail)}" : $"{AppResources.SupportmailBodyText}\r\n\r\n\r\n\r\n{string.Format(AppResources.SupportmailBodyNotLoggedIn)}"
});
return;
}
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;
}
}
}
/// <summary> Request to send a app related mail. </summary>
public async Task DoSendMailAppRelated()
{
try
if (!IsSendMailAvailable)
{
// Ask for permission to append diagnostics.
await ViewService.DisplayAlert(
AppResources.QuestionSupportmailAttachmentTitle,
AppResources.QuestionSupportmailAttachment,
String.Empty,
AppResources.ErrorSupportmailMailingFailed,
AppResources.MessageAnswerOk);
var message = new EmailMessage
{
To = new List<string> { APPSUPPORTMAILADDRESS },
Subject = SelectedStation?.Id != null ? string.Format(AppResources.SupportmailSubjectAppmailWithStation, AppFlavorName, SelectedStation?.Id) : string.Format(AppResources.SupportmailSubjectAppmail, AppFlavorName),
Body = TinkApp.ActiveUser.Mail != null ? $"{AppResources.SupportmailBodyText}\r\n\r\n\r\n\r\n{string.Format(AppResources.MarkingLoggedInStateInfoLoggedIn, TinkApp.ActiveUser.Mail)}" : $"{AppResources.SupportmailBodyText}\r\n\r\n\r\n\r\n{string.Format(AppResources.SupportmailBodyNotLoggedIn)}"
};
// Send with attachment.
var logFileName = string.Empty;
return;
}
else
{
try
{
logFileName = CreateAttachment();
// Ask for permission to append diagnostics.
await ViewService.DisplayAlert(
AppResources.QuestionSupportmailAttachmentTitle,
AppResources.QuestionSupportmailAttachment,
AppResources.MessageAnswerOk);
var message = new EmailMessage
{
To = new List<string> { APPSUPPORTMAILADDRESS },
Subject = SelectedStation?.Id != null ? string.Format(AppResources.SupportmailSubjectAppmailWithStation, AppFlavorName, SelectedStation?.Id) : string.Format(AppResources.SupportmailSubjectAppmail, AppFlavorName),
Body = TinkApp.ActiveUser.Mail != null ? $"{AppResources.SupportmailBodyText}\r\n\r\n\r\n\r\n{string.Format(AppResources.MarkingLoggedInStateInfoLoggedIn, TinkApp.ActiveUser.Mail)}" : $"{AppResources.SupportmailBodyText}\r\n\r\n\r\n\r\n{string.Format(AppResources.SupportmailBodyNotLoggedIn)}"
};
// Send with attachment.
var logFileName = string.Empty;
try
{
logFileName = CreateAttachment();
}
catch (Exception exception)
{
await ViewService.DisplayAdvancedAlert(
AppResources.MessageWaring,
AppResources.ErrorSupportmailCreateAttachment,
exception.Message,
AppResources.MessageAnswerOk);
Log.ForContext<ContactPageViewModel>().Error("An error occurred creating attachment for app mail. {@Exception)", exception);
}
if (!string.IsNullOrEmpty(logFileName))
{
message.Attachments.Add(new Xamarin.Essentials.EmailAttachment(logFileName));
}
// Send a tink app related mail
await Email.ComposeAsync(message);
}
catch (Exception exception)
{
Log.ForContext<ContactPageViewModel>().Error("An unexpected error occurred sending mail. {@Exception}", exception);
await ViewService.DisplayAdvancedAlert(
AppResources.MessageWaring,
AppResources.ErrorSupportmailCreateAttachment,
AppResources.ErrorSupportmailMailingFailed,
exception.Message,
AppResources.MessageAnswerOk);
Log.ForContext<ContactPageViewModel>().Error("An error occurred creating attachment for app mail. {@Exception)", exception);
return;
}
if (!string.IsNullOrEmpty(logFileName))
{
message.Attachments.Add(new Xamarin.Essentials.EmailAttachment(logFileName));
}
// Send a tink app related mail
await Email.ComposeAsync(message);
}
catch (Exception exception)
{
Log.ForContext<ContactPageViewModel>().Error("An unexpected error occurred sending mail. {@Exception}", exception);
await ViewService.DisplayAdvancedAlert(
AppResources.MessageWaring,
AppResources.ErrorSupportmailMailingFailed,
exception.Message,
AppResources.MessageAnswerOk);
return;
}
}
@ -257,31 +270,37 @@ namespace TINK.ViewModel.Info
/// <summary> Command object to bind phone call button. </summary>
public ICommand OnPhoneRequest
=> new Command(
async () => await DoPhoneCall(),
() => IsDoPhoncallAvailable);
=> new Command(async () => await DoPhoneCall());
/// <summary> Request to do a phone call. </summary>
public async Task DoPhoneCall()
{
try
if (!IsDoPhoncallAvailable)
{
// Make Phone Call
if (IsDoPhoncallAvailable)
{
CrossMessaging.Current.PhoneDialer.MakePhoneCall(PhoneNumberText);
}
}
catch (Exception exception)
{
Log.Error("An unexpected error occurred doing a phone call. {@Exception}", exception);
await ViewService.DisplayAdvancedAlert(
AppResources.MessageWaring,
await ViewService.DisplayAlert(
String.Empty,
AppResources.ErrorSupportmailPhoningFailed,
exception.Message,
AppResources.MessageAnswerOk);
return;
}
else
{
try
{
// Make Phone Call
CrossMessaging.Current.PhoneDialer.MakePhoneCall(PhoneNumberText);
}
catch (Exception exception)
{
Log.Error("An unexpected error occurred doing a phone call. {@Exception}", exception);
await ViewService.DisplayAdvancedAlert(
AppResources.MessageWaring,
AppResources.ErrorSupportmailPhoningFailed,
exception.Message,
AppResources.MessageAnswerOk);
return;
}
}
}
/// <summary> Text providing the id of the selected station.</summary>