mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 04:59:30 -07:00
Fixed #3590372 by showing a MessageBox where the problem is displayed and the user can re-try.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2322 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
9bacaf060c
commit
c517787d23
3 changed files with 30 additions and 32 deletions
|
@ -181,8 +181,7 @@ namespace GreenshotOfficePlugin {
|
||||||
return ShowPickerMenu(false, surface, captureDetails, destinations);
|
return ShowPickerMenu(false, surface, captureDetails, destinations);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
OutlookEmailExporter.ExportToOutlook(conf.OutlookEmailFormat, tmpFile, FilenameHelper.FillPattern(conf.EmailSubjectPattern, captureDetails, false), attachmentName, conf.EmailTo, conf.EmailCC, conf.EmailBCC);
|
exportInformation.ExportMade = OutlookEmailExporter.ExportToOutlook(conf.OutlookEmailFormat, tmpFile, FilenameHelper.FillPattern(conf.EmailSubjectPattern, captureDetails, false), attachmentName, conf.EmailTo, conf.EmailCC, conf.EmailBCC);
|
||||||
exportInformation.ExportMade = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ProcessExport(exportInformation, surface);
|
ProcessExport(exportInformation, surface);
|
||||||
|
|
|
@ -28,6 +28,9 @@ using Microsoft.Win32;
|
||||||
using Greenshot.Interop;
|
using Greenshot.Interop;
|
||||||
using Greenshot.Interop.IE;
|
using Greenshot.Interop.IE;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using GreenshotPlugin.Core;
|
||||||
|
|
||||||
namespace Greenshot.Interop.Office {
|
namespace Greenshot.Interop.Office {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -360,36 +363,26 @@ namespace Greenshot.Interop.Office {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// So not save, otherwise the email is always stored in Draft folder.. (newMail.Save();)
|
// So not save, otherwise the email is always stored in Draft folder.. (newMail.Save();)
|
||||||
try {
|
do {
|
||||||
newMail.Display(false);
|
try {
|
||||||
newMail.GetInspector().Activate();
|
newMail.Display(false);
|
||||||
} catch (Exception ex) {
|
newMail.GetInspector().Activate();
|
||||||
LOG.Warn("Problem displaying the new email, retrying to display it. Problem:", ex);
|
break;
|
||||||
Thread retryDisplayEmail = new Thread(delegate() {
|
} catch (Exception ex) {
|
||||||
int retries = 10;
|
// Test for rejected
|
||||||
int retryInXSeconds = 5;
|
LOG.Warn("Problem displaying the new email, retrying to display it. Problem:", ex);
|
||||||
while (retries-- > 0) {
|
COMException comEx = ex.InnerException as COMException;
|
||||||
Thread.Sleep(retryInXSeconds * 1000);
|
if (comEx != null && (comEx.ErrorCode == COMWrapper.RPC_E_CALL_REJECTED || comEx.ErrorCode == COMWrapper.RPC_E_FAIL)) {
|
||||||
try {
|
DialogResult result = MessageBox.Show(PluginUtils.Host.GreenshotForm, Language.GetFormattedString("com_rejected", "Outlook "), Language.GetString("com_rejected_title"), MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
|
||||||
newMail.Display(false);
|
if (result == DialogResult.OK) {
|
||||||
newMail.GetInspector().Activate();
|
continue;
|
||||||
LOG.InfoFormat("Managed to display the message.");
|
|
||||||
return;
|
|
||||||
} catch (Exception displayEx) {
|
|
||||||
LOG.WarnFormat("Error displaying message: {0}, retrying to show email in {1} seconds... Retries left: {2}", displayEx, retryInXSeconds, retries);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG.WarnFormat("Retry failed, saving message to draft.");
|
// Not rejected OR pressed cancel
|
||||||
try {
|
throw ex;
|
||||||
newMail.Save();
|
}
|
||||||
} catch (Exception saveEx) {
|
} while (true);
|
||||||
LOG.WarnFormat("Saving message to draft failed: {0}", saveEx);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
retryDisplayEmail.Name = "Retry to display email";
|
|
||||||
retryDisplayEmail.IsBackground = true;
|
|
||||||
retryDisplayEmail.Start();
|
|
||||||
}
|
|
||||||
if (newItem != null) {
|
if (newItem != null) {
|
||||||
newItem.Dispose();
|
newItem.Dispose();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,8 @@ namespace Greenshot.Interop {
|
||||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(COMWrapper));
|
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(COMWrapper));
|
||||||
private const int MK_E_UNAVAILABLE = -2147221021;
|
private const int MK_E_UNAVAILABLE = -2147221021;
|
||||||
private const int CO_E_CLASSSTRING = -2147221005;
|
private const int CO_E_CLASSSTRING = -2147221005;
|
||||||
private const int RPC_E_CALL_REJECTED = unchecked((int)0x80010001);
|
public const int RPC_E_CALL_REJECTED = unchecked((int)0x80010001);
|
||||||
|
public const int RPC_E_FAIL = unchecked((int)0x80004005);
|
||||||
|
|
||||||
#region Private Data
|
#region Private Data
|
||||||
|
|
||||||
|
@ -661,7 +662,12 @@ namespace Greenshot.Interop {
|
||||||
// Test for rejected
|
// Test for rejected
|
||||||
COMException comEx = ex as COMException;
|
COMException comEx = ex as COMException;
|
||||||
if (comEx != null && comEx.ErrorCode == RPC_E_CALL_REJECTED) {
|
if (comEx != null && comEx.ErrorCode == RPC_E_CALL_REJECTED) {
|
||||||
DialogResult result = MessageBox.Show(Language.GetString("com_rejected"), Language.GetString("com_rejected_title"), MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
|
ComProgIdAttribute progIDAttribute = ComProgIdAttribute.GetAttribute(_InterceptType);
|
||||||
|
string destinationName = "";
|
||||||
|
if (progIDAttribute != null) {
|
||||||
|
destinationName = progIDAttribute.Value + " ";
|
||||||
|
}
|
||||||
|
DialogResult result = MessageBox.Show(PluginUtils.Host.GreenshotForm, Language.GetFormattedString("com_rejected", destinationName), Language.GetString("com_rejected_title"), MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
|
||||||
if (result == DialogResult.OK) {
|
if (result == DialogResult.OK) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue