diff --git a/FileManager/Configuration.cs b/FileManager/Configuration.cs
index 31a8069f..2c182afd 100644
--- a/FileManager/Configuration.cs
+++ b/FileManager/Configuration.cs
@@ -259,7 +259,11 @@ namespace FileManager
var endingContents = JsonConvert.SerializeObject(jObj, Formatting.Indented);
if (startingContents != endingContents)
+ {
+ try { Serilog.Log.Logger.Information("Libation files changed {@DebugInfo}", new { APPSETTINGS_JSON, LIBATION_FILES_KEY, directory }); }
+ catch { }
File.WriteAllText(APPSETTINGS_JSON, endingContents);
+ }
return true;
diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj
index 9f844b32..b32e3d1c 100644
--- a/LibationLauncher/LibationLauncher.csproj
+++ b/LibationLauncher/LibationLauncher.csproj
@@ -13,7 +13,7 @@
win-x64
- 5.2.0.3
+ 5.2.0.13
diff --git a/LibationLauncher/Program.cs b/LibationLauncher/Program.cs
index a4a3f87b..7db329cc 100644
--- a/LibationLauncher/Program.cs
+++ b/LibationLauncher/Program.cs
@@ -310,13 +310,15 @@ namespace LibationLauncher
private static void checkForUpdate(Configuration config)
{
+ string zipUrl;
+ string selectedPath;
+
try
{
- var gitHubClient = new Octokit.GitHubClient(new Octokit.ProductHeaderValue("Libation"));
-
- // https://octokitnet.readthedocs.io/en/latest/releases/
- var releases = gitHubClient.Repository.Release.GetAll("rmcrackan", "Libation").GetAwaiter().GetResult();
- var latest = releases.First(r => !r.Draft && !r.Prerelease);
+ // timed out
+ var latest = getLatestRelease(TimeSpan.FromSeconds(30));
+ if (latest is null)
+ return;
var latestVersionString = latest.TagName.Trim('v');
if (!Version.TryParse(latestVersionString, out var latestRelease))
@@ -328,41 +330,53 @@ namespace LibationLauncher
// we have an update
var zip = latest.Assets.FirstOrDefault(a => a.BrowserDownloadUrl.EndsWith(".zip"));
- var zipUrl = zip?.BrowserDownloadUrl;
+ zipUrl = zip?.BrowserDownloadUrl;
if (zipUrl is null)
{
MessageBox.Show(latest.HtmlUrl, "New version available");
return;
}
- var result = MessageBox.Show($"New version available @ {latest.HtmlUrl}\r\nDownload the zip file?", "New version available", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
+ var result = MessageBox.Show($"New version available @ {latest.HtmlUrl}\r\nDownload the zip file?", "New version available", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result != DialogResult.Yes)
return;
using var fileSelector = new SaveFileDialog { FileName = zip.Name, Filter = "Zip Files (*.zip)|*.zip|All files (*.*)|*.*" };
if (fileSelector.ShowDialog() != DialogResult.OK)
return;
- var selectedPath = fileSelector.FileName;
-
- try
- {
- LibationWinForms.BookLiberation.ProcessorAutomationController.DownloadFile(zipUrl, selectedPath, true);
- }
- catch (Exception ex)
- {
- Error(ex, "Error downloading update");
- }
+ selectedPath = fileSelector.FileName;
}
catch (Exception ex)
{
- Error(ex, "Error checking for update");
+ MessageBoxAlertAdmin.Show("Error checking for update", "Error checking for update", ex);
+ return;
+ }
+
+ try
+ {
+ LibationWinForms.BookLiberation.ProcessorAutomationController.DownloadFile(zipUrl, selectedPath, true);
+ }
+ catch (Exception ex)
+ {
+ MessageBoxAlertAdmin.Show("Error downloading update", "Error downloading update", ex);
}
}
- private static void Error(Exception ex, string message)
+ private static Octokit.Release getLatestRelease(TimeSpan timeout)
{
- Log.Logger.Error(ex, message);
- MessageBox.Show($"{message}\r\nSee log for details");
+ var task = System.Threading.Tasks.Task.Run(() => getLatestRelease());
+ if (task.Wait(timeout))
+ return task.Result;
+ return null;
+ }
+ private static Octokit.Release getLatestRelease()
+ {
+ var gitHubClient = new Octokit.GitHubClient(new Octokit.ProductHeaderValue("Libation"));
+
+ // https://octokitnet.readthedocs.io/en/latest/releases/
+ var releases = gitHubClient.Repository.Release.GetAll("rmcrackan", "Libation").GetAwaiter().GetResult();
+ var latest = releases.First(r => !r.Draft && !r.Prerelease);
+ return latest;
}
private static void logStartupState(Configuration config)
diff --git a/LibationWinForms/Dialogs/AccountsDialog.cs b/LibationWinForms/Dialogs/AccountsDialog.cs
index 2902fb83..0884bcfc 100644
--- a/LibationWinForms/Dialogs/AccountsDialog.cs
+++ b/LibationWinForms/Dialogs/AccountsDialog.cs
@@ -125,7 +125,7 @@ namespace LibationWinForms.Dialogs
}
catch (Exception ex)
{
- MessageBox.Show($"Error: {ex.Message}", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ MessageBoxAlertAdmin.Show("Error attempting to save accounts", "Error saving accounts", ex);
}
}
diff --git a/LibationWinForms/Dialogs/IndexLibraryDialog.cs b/LibationWinForms/Dialogs/IndexLibraryDialog.cs
index f3b6594c..e534cc28 100644
--- a/LibationWinForms/Dialogs/IndexLibraryDialog.cs
+++ b/LibationWinForms/Dialogs/IndexLibraryDialog.cs
@@ -35,9 +35,10 @@ namespace LibationWinForms.Dialogs
}
catch (Exception ex)
{
- var msg = "Error importing library. Please try again. If this still happens after 2 or 3 tries, stop and contact administrator";
- Serilog.Log.Logger.Error(ex, msg);
- MessageBox.Show(msg, "Error importing library", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ MessageBoxAlertAdmin.Show(
+ "Error importing library. Please try again. If this still happens after 2 or 3 tries, stop and contact administrator",
+ "Error importing library",
+ ex);
}
}
diff --git a/LibationWinForms/Dialogs/LibationFilesDialog.cs b/LibationWinForms/Dialogs/LibationFilesDialog.cs
index a278b4a8..c6c67383 100644
--- a/LibationWinForms/Dialogs/LibationFilesDialog.cs
+++ b/LibationWinForms/Dialogs/LibationFilesDialog.cs
@@ -35,7 +35,7 @@ namespace LibationWinForms.Dialogs
if (!System.IO.Directory.Exists(libationDir))
{
- MessageBox.Show("Not saving change to Libation Files location. This folder does not exist:\r\n" + libationDir);
+ MessageBox.Show("Not saving change to Libation Files location. This folder does not exist:\r\n" + libationDir, "Folder does not exist", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
diff --git a/LibationWinForms/Dialogs/MessageBoxAlertAdminDialog.Designer.cs b/LibationWinForms/Dialogs/MessageBoxAlertAdminDialog.Designer.cs
new file mode 100644
index 00000000..6568285e
--- /dev/null
+++ b/LibationWinForms/Dialogs/MessageBoxAlertAdminDialog.Designer.cs
@@ -0,0 +1,155 @@
+
+namespace LibationWinForms.Dialogs
+{
+ partial class MessageBoxAlertAdminDialog
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MessageBoxAlertAdminDialog));
+ this.pictureBox1 = new System.Windows.Forms.PictureBox();
+ this.descriptionLbl = new System.Windows.Forms.Label();
+ this.label1 = new System.Windows.Forms.Label();
+ this.githubLink = new System.Windows.Forms.LinkLabel();
+ this.okBtn = new System.Windows.Forms.Button();
+ this.logsLink = new System.Windows.Forms.LinkLabel();
+ this.exceptionTb = new System.Windows.Forms.TextBox();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
+ this.SuspendLayout();
+ //
+ // pictureBox1
+ //
+ this.pictureBox1.Location = new System.Drawing.Point(12, 12);
+ this.pictureBox1.Name = "pictureBox1";
+ this.pictureBox1.Size = new System.Drawing.Size(64, 64);
+ this.pictureBox1.TabIndex = 0;
+ this.pictureBox1.TabStop = false;
+ //
+ // descriptionLbl
+ //
+ this.descriptionLbl.AutoSize = true;
+ this.descriptionLbl.Location = new System.Drawing.Point(82, 12);
+ this.descriptionLbl.Name = "descriptionLbl";
+ this.descriptionLbl.Size = new System.Drawing.Size(89, 45);
+ this.descriptionLbl.TabIndex = 0;
+ this.descriptionLbl.Text = "[Error message]\r\n[Error message]\r\n[Error message]";
+ //
+ // label1
+ //
+ this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(12, 244);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(269, 90);
+ this.label1.TabIndex = 2;
+ this.label1.Text = resources.GetString("label1.Text");
+ //
+ // githubLink
+ //
+ this.githubLink.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.githubLink.AutoSize = true;
+ this.githubLink.Location = new System.Drawing.Point(271, 274);
+ this.githubLink.Name = "githubLink";
+ this.githubLink.Size = new System.Drawing.Size(116, 15);
+ this.githubLink.TabIndex = 3;
+ this.githubLink.TabStop = true;
+ this.githubLink.Text = "Click to go to github";
+ this.githubLink.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.githubLink_LinkClicked);
+ //
+ // okBtn
+ //
+ this.okBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.okBtn.Location = new System.Drawing.Point(256, 347);
+ this.okBtn.Name = "okBtn";
+ this.okBtn.Size = new System.Drawing.Size(75, 23);
+ this.okBtn.TabIndex = 5;
+ this.okBtn.Text = "OK";
+ this.okBtn.UseVisualStyleBackColor = true;
+ this.okBtn.Click += new System.EventHandler(this.okBtn_Click);
+ //
+ // logsLink
+ //
+ this.logsLink.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.logsLink.AutoSize = true;
+ this.logsLink.Location = new System.Drawing.Point(271, 289);
+ this.logsLink.Name = "logsLink";
+ this.logsLink.Size = new System.Drawing.Size(155, 15);
+ this.logsLink.TabIndex = 4;
+ this.logsLink.TabStop = true;
+ this.logsLink.Text = "Click to open log files folder";
+ this.logsLink.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.logsLink_LinkClicked);
+ //
+ // exceptionTb
+ //
+ this.exceptionTb.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.exceptionTb.Location = new System.Drawing.Point(12, 82);
+ this.exceptionTb.Multiline = true;
+ this.exceptionTb.Name = "exceptionTb";
+ this.exceptionTb.ReadOnly = true;
+ this.exceptionTb.ScrollBars = System.Windows.Forms.ScrollBars.Both;
+ this.exceptionTb.Size = new System.Drawing.Size(560, 159);
+ this.exceptionTb.TabIndex = 1;
+ //
+ // MessageBoxAlertAdminDialog
+ //
+ this.AcceptButton = this.okBtn;
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(584, 382);
+ this.Controls.Add(this.exceptionTb);
+ this.Controls.Add(this.logsLink);
+ this.Controls.Add(this.okBtn);
+ this.Controls.Add(this.githubLink);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.descriptionLbl);
+ this.Controls.Add(this.pictureBox1);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "MessageBoxAlertAdminDialog";
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "MessageBoxAlertAdmin";
+ this.Load += new System.EventHandler(this.MessageBoxAlertAdminDialog_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.PictureBox pictureBox1;
+ private System.Windows.Forms.Label descriptionLbl;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.LinkLabel githubLink;
+ private System.Windows.Forms.Button okBtn;
+ private System.Windows.Forms.LinkLabel logsLink;
+ private System.Windows.Forms.TextBox exceptionTb;
+ }
+}
\ No newline at end of file
diff --git a/LibationWinForms/Dialogs/MessageBoxAlertAdminDialog.cs b/LibationWinForms/Dialogs/MessageBoxAlertAdminDialog.cs
new file mode 100644
index 00000000..14f2e76f
--- /dev/null
+++ b/LibationWinForms/Dialogs/MessageBoxAlertAdminDialog.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using Dinah.Core;
+
+namespace LibationWinForms.Dialogs
+{
+ public partial class MessageBoxAlertAdminDialog : Form
+ {
+ public MessageBoxAlertAdminDialog() => InitializeComponent();
+
+ ///
+ /// Displays a message box with specified text and caption.
+ ///
+ /// The text to display in the message box.
+ /// The text to display in the title bar of the message box.
+ /// Exception to display
+ public MessageBoxAlertAdminDialog(string text, string caption, Exception exception) : this()
+ {
+ this.descriptionLbl.Text = text;
+ this.Text = caption;
+ this.exceptionTb.Text = $"{exception.Message}\r\n\r\n{exception.StackTrace}";
+ }
+
+ private void MessageBoxAlertAdminDialog_Load(object sender, EventArgs e)
+ {
+ if (this.DesignMode)
+ return;
+
+ System.Media.SystemSounds.Hand.Play();
+ pictureBox1.Image = SystemIcons.Error.ToBitmap();
+ }
+
+ private void githubLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
+ => Go.To.Url("https://github.com/rmcrackan/Libation/issues");
+
+ private void logsLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
+ => Go.To.Folder(FileManager.Configuration.Instance.LibationFiles);
+
+ private void okBtn_Click(object sender, EventArgs e)
+ {
+ this.DialogResult = DialogResult.OK;
+ this.Close();
+ }
+ }
+}
diff --git a/LibationWinForms/Dialogs/MessageBoxAlertAdminDialog.resx b/LibationWinForms/Dialogs/MessageBoxAlertAdminDialog.resx
new file mode 100644
index 00000000..be1522cd
--- /dev/null
+++ b/LibationWinForms/Dialogs/MessageBoxAlertAdminDialog.resx
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ If you'd like to report this error to an advinistrator:
+
+Step 1: Go to Libation's "issues" page on github
+Step 2: Find your log files
+Setp 3: Click "New issue" button
+Step 4: Drag/drop your log files
+
+
\ No newline at end of file
diff --git a/LibationWinForms/Dialogs/SettingsDialog.cs b/LibationWinForms/Dialogs/SettingsDialog.cs
index 680a058a..57faf818 100644
--- a/LibationWinForms/Dialogs/SettingsDialog.cs
+++ b/LibationWinForms/Dialogs/SettingsDialog.cs
@@ -60,7 +60,7 @@ namespace LibationWinForms.Dialogs
if (string.IsNullOrWhiteSpace(newBooks))
{
- MessageBox.Show("Cannot set Books Location to blank");
+ MessageBox.Show("Cannot set Books Location to blank", "Location is blank", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
@@ -68,7 +68,7 @@ namespace LibationWinForms.Dialogs
{
if (booksSelectControl.SelectedDirectoryIsCustom)
{
- MessageBox.Show($"Not saving change to Books location. This folder does not exist:\r\n{newBooks}");
+ MessageBox.Show($"Not saving change to Books location. This folder does not exist:\r\n{newBooks}", "Folder does not exist", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
diff --git a/LibationWinForms/Form1.cs b/LibationWinForms/Form1.cs
index f4b43cbe..a2617f3f 100644
--- a/LibationWinForms/Form1.cs
+++ b/LibationWinForms/Form1.cs
@@ -338,8 +338,7 @@ namespace LibationWinForms
}
catch (Exception ex)
{
- Serilog.Log.Logger.Error(ex, "Error attempting to export library");
- MessageBox.Show("Error attempting to export your library. Error message:\r\n\r\n" + ex.Message, "Error exporting", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ MessageBoxAlertAdmin.Show("Error attempting to export your library.", "Error exporting", ex);
}
}
#endregion
@@ -409,7 +408,7 @@ namespace LibationWinForms
if (!Configuration.Instance.TrySetLibationFiles(libationFilesDialog.SelectedDirectory))
{
- MessageBox.Show("Not saving change to Libation Files location. This folder does not exist:\r\n" + libationFilesDialog.SelectedDirectory);
+ MessageBox.Show("Not saving change to Libation Files location. This folder does not exist:\r\n" + libationFilesDialog.SelectedDirectory, "Error saving change", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
diff --git a/LibationWinForms/MessageBoxAlertAdmin.cs b/LibationWinForms/MessageBoxAlertAdmin.cs
new file mode 100644
index 00000000..8e97f09c
--- /dev/null
+++ b/LibationWinForms/MessageBoxAlertAdmin.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using LibationWinForms.Dialogs;
+
+namespace LibationWinForms
+{
+ public static class MessageBoxAlertAdmin
+ {
+ ///
+ /// Logs error. Displays a message box dialog with specified text and caption.
+ ///
+ /// The text to display in the message box.
+ /// The text to display in the title bar of the message box.
+ /// Exception to log
+ /// One of the System.Windows.Forms.DialogResult values.
+ public static System.Windows.Forms.DialogResult Show(string text, string caption, Exception exception)
+ {
+ Serilog.Log.Logger.Error(exception, "Alert admin error: {@DebugText}", new { text, caption });
+
+ using var form = new MessageBoxAlertAdminDialog(text, caption, exception);
+ return form.ShowDialog();
+ }
+ }
+}
diff --git a/LibationWinForms/ProductsGrid.cs b/LibationWinForms/ProductsGrid.cs
index f4cd7fc9..6b1a36e1 100644
--- a/LibationWinForms/ProductsGrid.cs
+++ b/LibationWinForms/ProductsGrid.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Windows.Forms;
using ApplicationServices;
using DataLayer;
+using Dinah.Core;
using Dinah.Core.Collections.Generic;
using Dinah.Core.DataBinding;
using Dinah.Core.Windows.Forms;
@@ -178,7 +179,7 @@ namespace LibationWinForms
if (FileManager.AudibleFileStorage.Audio.Exists(productId))
{
var filePath = FileManager.AudibleFileStorage.Audio.GetPath(productId);
- System.Diagnostics.Process.Start("explorer.exe", $"/select, \"{filePath}\"");
+ Go.To.File(filePath);
return;
}