134 lines
5.7 KiB
C#
134 lines
5.7 KiB
C#
using _29WxOrderWpf.BaseWindows;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Media.Imaging;
|
|
using Work;
|
|
using Work.BaseForms;
|
|
|
|
namespace _29WxOrderWpf
|
|
{
|
|
/// <summary>
|
|
/// App.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class App : Application
|
|
{
|
|
public static string[] args = new List<string>().ToArray();
|
|
protected override void OnStartup(StartupEventArgs e)
|
|
{
|
|
base.OnStartup(e);
|
|
if (e.Args.Length > 0)
|
|
{
|
|
args = e.Args;
|
|
}
|
|
|
|
try
|
|
{
|
|
//设置应用程序处理异常方式:ThreadException处理
|
|
//Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
|
|
//处理UI线程异常
|
|
//Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
|
|
Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
|
|
//处理非UI线程异常
|
|
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
|
|
|
|
//StartUp.Init();
|
|
new Initialization().Get();
|
|
|
|
#region 贴牌
|
|
//本地缓存文件
|
|
string IgPakFile = "locales/ig.pak";//贴牌客服端码
|
|
string OenVersionFile = "locales/igv.pak";//贴牌资源配置版本
|
|
string IaPakFile = "locales/ia.pak";//logo
|
|
string IbPakFile = "locales/ib.pak";//ico
|
|
string IcPakFile = "locales/ic.pak";//功能配置
|
|
//OenMechanism(IgPakFile, OenVersionFile, IaPakFile, IbPakFile, IcPakFile);
|
|
|
|
#region 后台修改logo 贴牌用
|
|
//// 替换字典程序logo等
|
|
//Uri imageUri = new Uri("pack://application:,,,/Resources/WindowBoxes/close.hover.png"); // 新的图片路径
|
|
//BitmapImage newBitmapImage = new BitmapImage(imageUri);
|
|
//// 获取资源字典
|
|
//ResourceDictionary dict = Application.Current.Resources;
|
|
//// 添加或更新资源
|
|
//dict["main29WeixinIcon"] = newBitmapImage;
|
|
#endregion
|
|
#endregion
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string str = GetExceptionMsg(ex, string.Empty);
|
|
NaiBa.Util.Helper.LogHelper.WriteWithTime("SystemError:" + str);
|
|
//BaseMsgForm.ShowError(str, "系统错误");
|
|
BaseMsgWindow.ShowError(null, str, "系统错误");
|
|
}
|
|
}
|
|
|
|
//static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
|
|
//{
|
|
// string str = GetExceptionMsg(e.Exception, e.ToString());
|
|
// NaiBa.Util.Helper.LogHelper.WriteWithTime("SystemError:" + str);
|
|
// BaseMsgWindow.ShowError(null, str, "系统错误");
|
|
//}
|
|
|
|
private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
|
|
{
|
|
string str = GetExceptionMsg(e.Exception, e.ToString());
|
|
NaiBa.Util.Helper.LogHelper.WriteWithTime("SystemError:" + str);
|
|
BaseMsgWindow.ShowError(null, str, "系统错误");
|
|
}
|
|
|
|
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
|
{
|
|
string str = GetExceptionMsg(e.ExceptionObject as Exception, e.ToString());
|
|
NaiBa.Util.Helper.LogHelper.WriteWithTime("SystemError:" + str);
|
|
BaseMsgWindow.ShowError(null, str, "系统错误");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 生成自定义异常消息
|
|
/// </summary>
|
|
/// <param name="ex">异常对象</param>
|
|
/// <param name="backStr">备用异常消息:当ex为null时有效</param>
|
|
/// <returns>异常字符串文本</returns>
|
|
static string GetExceptionMsg(Exception ex, string backStr)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.AppendLine("****************************异常文本****************************");
|
|
sb.AppendLine("【出现时间】:" + DateTime.Now.ToString());
|
|
if (ex != null)
|
|
{
|
|
sb.AppendLine("【异常类型】:" + ex.GetType().Name);
|
|
sb.AppendLine("【异常信息】:" + ex.Message);
|
|
sb.AppendLine("【堆栈调用】:" + ex.StackTrace);
|
|
}
|
|
else
|
|
{
|
|
sb.AppendLine("【未处理异常】:" + backStr);
|
|
}
|
|
sb.AppendLine("***************************************************************");
|
|
NaiBa.Util.Helper.LogHelper.WriteWithTime("Error:" + sb);
|
|
BaseMsgWindow.ShowError(null, sb.ToString(), "系统错误");
|
|
return sb.ToString();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Oen贴牌机制
|
|
/// </summary>
|
|
/// <param name="sIgPakFile">贴牌商客户端码文件</param>
|
|
/// <param name="sOenVersionFile">贴牌配置版本号文件</param>
|
|
/// <param name="sIaPakFile">ico本地缓存文件</param>
|
|
/// <param name="sIbPakFile">logo本地缓存文件</param>
|
|
/// <param name="sIcPakFile">贴牌配置本地缓存文件</param>
|
|
private static void OenMechanism(string IgPakFile, string OenVersionFile, string IaPakFile, string IbPakFile, string IcPakFile)
|
|
{
|
|
//todo: 贴牌相关处理逻辑
|
|
}
|
|
}
|
|
}
|