SVN r1211
SVN-Revision: r1211
This commit is contained in:
@@ -38,14 +38,27 @@ namespace Lskj.Control
|
||||
/// <param name="msg"></param>
|
||||
public static DialogResult Show(string msg)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(msg) && msg.Contains("与另一个进程被死锁在"))
|
||||
if (msg.Contains("未将对象引用设置到对象的实例"))
|
||||
{
|
||||
try
|
||||
{
|
||||
string callStackInfo = GetBusinessCallStack();
|
||||
msg = "未将对象引用设置到对象的实例\r\n" + callStackInfo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(msg) && msg.Contains("与另一个进程被死锁在")&& !SystemInfo.Instance.PromptDeadlock)
|
||||
msg = "网络连接超时,请稍候再试!";
|
||||
if (Business.Impl.LanguageTranslation.Translatable)
|
||||
{
|
||||
msg = Business.Impl.LanguageTranslation.GetTranslatedText(msg);
|
||||
}
|
||||
|
||||
return XtraMessageBox.Show(msg, ResourceKeys.SystemTip, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -58,9 +71,21 @@ namespace Lskj.Control
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="msg"></param>
|
||||
public static DialogResult Show(string msg, string errorMessage )
|
||||
public static DialogResult Show(string msg, string errorMessage)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(errorMessage) && errorMessage.Contains("与另一个进程被死锁在"))
|
||||
if (errorMessage.Contains("未将对象引用设置到对象的实例"))
|
||||
{
|
||||
try
|
||||
{
|
||||
string callStackInfo = GetBusinessCallStack();
|
||||
errorMessage = "未将对象引用设置到对象的实例\r\n" + callStackInfo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(errorMessage) && errorMessage.Contains("与另一个进程被死锁在") && !SystemInfo.Instance.PromptDeadlock)
|
||||
{
|
||||
errorMessage = "网络连接超时,请稍候再试!";
|
||||
if (Business.Impl.LanguageTranslation.Translatable)
|
||||
@@ -69,8 +94,8 @@ namespace Lskj.Control
|
||||
}
|
||||
return XtraMessageBox.Show(errorMessage, ResourceKeys.SystemTip, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(errorMessage) && errorMessage.Contains("事务在触发器中结束。批处理已中止"))
|
||||
|
||||
if (!string.IsNullOrEmpty(errorMessage) && errorMessage.Contains("事务在触发器中结束。批处理已中止"))
|
||||
{
|
||||
if (Business.Impl.LanguageTranslation.Translatable)
|
||||
{
|
||||
@@ -89,11 +114,11 @@ namespace Lskj.Control
|
||||
if (dr != DialogResult.Yes && !string.IsNullOrWhiteSpace(errorMessage))
|
||||
{
|
||||
errorMessage = ErrorMessage.StackTrace;
|
||||
if (SystemInfo.Instance.HideErrorSQL)
|
||||
if (SystemInfo.Instance.HideErrorSQL)
|
||||
{
|
||||
errorMessage= errorMessage.Split(new string[] { "SQL=[" }, StringSplitOptions.None)[0];
|
||||
errorMessage = errorMessage.Split(new string[] { "SQL=[" }, StringSplitOptions.None)[0];
|
||||
}
|
||||
XtraMessageBox.Show(errorMessage, ResourceKeys.SystemTip, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
XtraMessageBox.Show(errorMessage, ResourceKeys.SystemTip, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
DevExpress.XtraEditors.Controls.Localizer.Active = null;
|
||||
return DialogResult.OK;
|
||||
@@ -111,10 +136,32 @@ namespace Lskj.Control
|
||||
/// <returns>DialogResult.</returns>
|
||||
public static DialogResult Show(Exception ex)
|
||||
{
|
||||
if (ex.Message.Contains("未将对象引用设置到对象的实例"))
|
||||
{
|
||||
try
|
||||
{
|
||||
//string callStackInfo = GetBusinessCallStack();
|
||||
//string msgnew = "未将对象引用设置到对象的实例\r\n" + callStackInfo;
|
||||
|
||||
string errorInfo = $"【报错时间】:{DateTime.Now}\n" +
|
||||
$"【异常类型】:{ex.GetType().Name}\n" +
|
||||
$"【错误消息】:{ex.Message}\n" +
|
||||
$"【报错方法】:{ex.TargetSite?.DeclaringType?.FullName}.{ex.TargetSite?.Name}\n" +
|
||||
$"【完整调用栈】:\n{ex.StackTrace}\n" +
|
||||
$"【内部异常】:{ex.InnerException?.Message}";
|
||||
|
||||
|
||||
return XtraMessageBox.Show(errorInfo, ResourceKeys.SystemTip, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
string msg = ex == null ? ResourceKeys.UnKownErrorTip : ex.StackTrace;
|
||||
if (!string.IsNullOrEmpty(msg) && msg.Contains("与另一个进程被死锁在"))
|
||||
if (!string.IsNullOrEmpty(msg) && msg.Contains("与另一个进程被死锁在") && !SystemInfo.Instance.PromptDeadlock)
|
||||
msg = "网络连接超时,请稍候再试!";
|
||||
if (Business.Impl.LanguageTranslation.Translatable)
|
||||
{
|
||||
@@ -125,7 +172,7 @@ namespace Lskj.Control
|
||||
else
|
||||
{
|
||||
string msg = ex == null ? ResourceKeys.UnKownErrorTip : ex.Message; //ResourceKeys.SystemErrorTip + "\r\n" + ex.Message + "\r\n" + ex.StackTrace;
|
||||
if (!string.IsNullOrEmpty(msg) && msg.Contains("与另一个进程被死锁在"))
|
||||
if (!string.IsNullOrEmpty(msg) && msg.Contains("与另一个进程被死锁在") && !SystemInfo.Instance.PromptDeadlock)
|
||||
msg = "网络连接超时,请稍候再试!";
|
||||
if (Business.Impl.LanguageTranslation.Translatable)
|
||||
{
|
||||
@@ -155,8 +202,67 @@ namespace Lskj.Control
|
||||
/// <param name="buttons">The buttons.</param>
|
||||
public static DialogResult Show(string msg, MessageBoxButtons buttons)
|
||||
{
|
||||
|
||||
if (msg.Contains("未将对象引用设置到对象的实例"))
|
||||
{
|
||||
try
|
||||
{
|
||||
string callStackInfo = GetBusinessCallStack();
|
||||
msg = "未将对象引用设置到对象的实例\r\n" + callStackInfo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (Business.Impl.LanguageTranslation.Translatable)
|
||||
{
|
||||
msg = Business.Impl.LanguageTranslation.GetTranslatedText(msg);
|
||||
}
|
||||
return XtraMessageBox.Show(msg, ResourceKeys.SystemTip, buttons, M
|
||||
return XtraMessageBox.Show(msg, ResourceKeys.SystemTip, buttons, MessageBoxIcon.Information);
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:弹出是否对话框</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-12-07 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="ex">The ex.</param>
|
||||
/// <param name="buttons">The buttons.</param>
|
||||
/// <returns>DialogResult.</returns>
|
||||
public static DialogResult Show(Exception ex, MessageBoxButtons buttons)
|
||||
{
|
||||
string msg = ex == null ? "未知提示." : ex.StackTrace;
|
||||
if (Business.Impl.LanguageTranslation.Translatable)
|
||||
{
|
||||
msg = Business.Impl.LanguageTranslation.GetTranslatedText(msg);
|
||||
}
|
||||
return XtraMessageBox.Show(msg, ResourceKeys.SystemTip, buttons, MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取业务代码的调用栈(过滤框架/自身方法,只保留业务层调用)
|
||||
/// </summary>
|
||||
private static string GetBusinessCallStack()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 创建堆栈跟踪,true 表示包含文件路径和行号(需生成pdb文件)
|
||||
StackTrace stackTrace = new StackTrace(true);
|
||||
StackFrame[] frames = stackTrace.GetFrames();
|
||||
|
||||
if (frames == null) return "无法获取调用栈";
|
||||
|
||||
// 过滤堆栈帧:跳过当前方法(GetBusinessCallStack)和 Show 方法,只保留业务调用层
|
||||
var businessFrames = frames
|
||||
.SkipWhile(frame =>
|
||||
frame.GetMethod()?.DeclaringType == typeof(MessageUtil) // 跳过当前类的方法
|
||||
|| frame.GetMethod()?.Module.ScopeName.StartsWith("System.") == true // 跳过系统框架方法
|
||||
|| fr
|
||||
Reference in New Issue
Block a user