|
@@ -47,6 +47,28 @@ namespace PRSDesktop
|
|
|
DynamicGridOption.SelectColumns);
|
|
|
}
|
|
|
|
|
|
+ private class MobileLinkData : BaseObject
|
|
|
+ {
|
|
|
+ [TextBoxEditor]
|
|
|
+ [EditorSequence(1)]
|
|
|
+ public string ServerURLS { get; set; } = "";
|
|
|
+
|
|
|
+ [TextBoxEditor]
|
|
|
+ [EditorSequence(2)]
|
|
|
+ public string From { get; set; } = "";
|
|
|
+
|
|
|
+ [TextBoxEditor]
|
|
|
+ [EditorSequence(3)]
|
|
|
+ public string To { get; set; } = "";
|
|
|
+
|
|
|
+ [IntegerEditor(ToolTip = "Enter link expiry time (mins)")]
|
|
|
+ [EditorSequence(4)]
|
|
|
+ public int ExpiryTime { get; set; } = 10;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static readonly string IOSLink = @"prsmobile://open/";
|
|
|
+ private static readonly string AndroidLink = @"http://www.prsmobile.com/open/";
|
|
|
+
|
|
|
private bool SendEmail(CoreRow? row)
|
|
|
{
|
|
|
if (row is null)
|
|
@@ -54,55 +76,59 @@ namespace PRSDesktop
|
|
|
|
|
|
User user = row.ToObject<User>();
|
|
|
|
|
|
- var menu = new ContextMenu();
|
|
|
- menu.AddItem("PRS Site App", null, () =>
|
|
|
+ var data = new MobileLinkData
|
|
|
{
|
|
|
- CreateLink(user, @"prssite://open/", @"http://www.prssite.com/open/", CreateURLs(new string[] { "remote.com-al.com.au:8050" }));
|
|
|
- });
|
|
|
-
|
|
|
- menu.AddItem("PRS Timebench", null, () =>
|
|
|
+ ServerURLS = string.Join(';', App.DatabaseSettings.URLs),
|
|
|
+ From = EmailUtils.GetAddressFromUserOrNull() ?? "",
|
|
|
+ To = user.EmailAddress,
|
|
|
+ ExpiryTime = 10
|
|
|
+ };
|
|
|
+ if (DynamicGridUtils.Edit(data, customiseGrid: (grid) =>
|
|
|
{
|
|
|
- CreateLink(user, @"prsmobile://open/", @"http://www.prsmobile.com/open/", CreateURLs(App.DatabaseSettings.URLs));
|
|
|
- });
|
|
|
- menu.IsOpen = true;
|
|
|
- return true;
|
|
|
+ grid.OnLoadEditorButtons += (item, buttons) =>
|
|
|
+ {
|
|
|
+ buttons.Add("Scan for URL", null, null, (s, o) =>
|
|
|
+ {
|
|
|
+ Progress.Show("Looking for available Servers...");
|
|
|
+ var settings = DataBaseConfiguration.AutoDiscoverServer();
|
|
|
+ Progress.Close();
|
|
|
+ if(settings is not null && settings.Protocol == SerializerProtocol.RPC)
|
|
|
+ {
|
|
|
+ data.ServerURLS = string.Join(';', settings.URLs);
|
|
|
+ MessageWindow.ShowMessage("Server found.", "Success");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MessageWindow.ShowMessage("No RPC server found.", "Not found");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+ }))
|
|
|
+ {
|
|
|
+ CreateLink(user, data);
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
- private static void CreateLink(User user, string ioslink, string androidlink, string URLs)
|
|
|
+ private static void CreateLink(User user, MobileLinkData data)
|
|
|
{
|
|
|
- if (string.IsNullOrWhiteSpace(ioslink))
|
|
|
- return;
|
|
|
+ var URLs = CreateURLs(data.ServerURLS.Split(';'));
|
|
|
+ var toEncrypt = URLs + "," + user.UserID + "," + user.Password + "," + DateTime.Now.AddMinutes(data.ExpiryTime);
|
|
|
+ var encrypted = Encryption.Encrypt(toEncrypt, "logindetailslink", true);
|
|
|
|
|
|
- var edt = new NumberEdit("Enter link expiry time in minutes", 10, 300, 10);
|
|
|
- bool result = (bool)edt.ShowDialog();
|
|
|
- if (!result)
|
|
|
- return;
|
|
|
+ var emailcontent = $"Please ensure PRS Mobile is closed, then choose a link below:\n\n" +
|
|
|
+ $"For Apple devices, click this link: {IOSLink}{encrypted}\n\n" +
|
|
|
+ $"For Android devices (Samsung, Google, Xiaomi, Oppo, Vivo, Huawei, Motorola etc), click this link: {AndroidLink}{encrypted}\n\n" +
|
|
|
+ $"Please restart the app after loading from the link.\n\nThese links will expire after {data.ExpiryTime} minutes.";
|
|
|
|
|
|
- var expiry = edt.Value;
|
|
|
-
|
|
|
- string toEncrypt = URLs + "," + user.UserID + "," + user.Password + "," + DateTime.Now.AddMinutes(expiry);
|
|
|
- string encrypted = Encryption.Encrypt(toEncrypt, "logindetailslink", true);
|
|
|
-
|
|
|
- ioslink += encrypted;
|
|
|
- androidlink += encrypted;
|
|
|
-
|
|
|
- string emailcontent = "Please ensure PRS Mobile is closed, then choose a link below:" + Environment.NewLine + Environment.NewLine +
|
|
|
- "For Apple devices, click this link: " + ioslink + Environment.NewLine + Environment.NewLine
|
|
|
- + "For Android devices (Samsung, Google, Xiaomi, Oppo, Vivo, Huawei, Motorola etc), click this link: " + androidlink + Environment.NewLine + Environment.NewLine +
|
|
|
- "Please restart the app after loading from the link." + Environment.NewLine + Environment.NewLine +
|
|
|
- "These links will expire after " + expiry + " minutes.";
|
|
|
-
|
|
|
- EmailUtils.CreateEMLFile(user.EmailAddress, "PRS Mobile Configuration Links", emailcontent);
|
|
|
+ var message = EmailUtils.CreateMessage(from: data.From, subject: "PRS Mobile Configuration Links", body: emailcontent, to: data.To);
|
|
|
+ EmailUtils.OpenEmail(message);
|
|
|
}
|
|
|
|
|
|
- private string CreateURLs(string[] urls)
|
|
|
+ private static string CreateURLs(string[] urls)
|
|
|
{
|
|
|
- string URLs = "";
|
|
|
- foreach (var url in urls)
|
|
|
- {
|
|
|
- URLs = URLs + url + ",";
|
|
|
- }
|
|
|
- return URLs + "ENDURLS";
|
|
|
+ return string.Join("", urls.Select(x => $"{x},")) + "ENDURLS";
|
|
|
}
|
|
|
|
|
|
private BitmapImage? EmailImage(CoreRow? arg)
|