Shuxia Ning
2025-02-06 aac8f8fb4a9ec6b388117bd76f891195edfa7cab
Desktop/PBS.Desktop.Core/Program.cs
@@ -1,10 +1,12 @@
using DevExpress.LookAndFeel;
using HStation.WinFrmUI;
using Mapster;
using System.Reflection;
namespace PBS.Desktop
{
    internal static class Program
    {
    {
        /// <summary>
        ///  The main entry point for the application.
        /// </summary>
@@ -21,8 +23,8 @@
                }
                //DevExpress.UserSkins.BonusSkins.Register();
                DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Bezier");//Visual Studio 2013 Light
                DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(SkinSvgPalette.Bezier.OfficeColorful);
                //DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Bezier");//Visual Studio 2013 Light
                //DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(SkinSvgPalette.Bezier.OfficeColorful);
                DevExpress.Skins.SkinManager.EnableFormSkins();
                System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-Hans");
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("zh-Hans");
@@ -48,52 +50,90 @@
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("zh-Hans");
                //皮肤
                DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(SkinStyle.WXICompact);
                DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(SkinStyle.WXICompact);
                // To customize application configuration such as set high DPI settings or default font,
                // see https://aka.ms/applicationconfiguration.
                ApplicationConfiguration.Initialize();
                Yw.WinFrmUI.GlobalParas.AppIcon = PBS.Desktop.Core.Properties.Resources.app;
                //#region 验证升级
                //try
                //{
                //    if (AutoUpdateHelper.NeedExist())
                //        return;
                //}
                //catch (Exception ex)
                //{
                //    LogHelper.Error("验证升级错误", ex);
                //}
                //#endregion
                //if (!LoginHelper.Login())
                //{
                //    return;
                //}
                //扫描全局DTO映射
                TypeAdapterConfig.GlobalSettings.Scan
                    (
                    //Assembly.Load("Yw.BLL.Auth.Core"),
                    //Assembly.Load("Yw.BLL.Bimface.Core"),
                    //Assembly.Load("Yw.BLL.Hydro.Core"),
                    //Assembly.Load("Yw.BLL.Map.Core"),
                    //Assembly.Load("PBS.BLL.Core")
                        //Assembly.Load("Yw.BLL.Auth.Core"),
                        //Assembly.Load("Yw.BLL.Bimface.Core"),
                        //Assembly.Load("Yw.BLL.Hydro.Core"),
                        //Assembly.Load("Yw.BLL.Map.Core"),
                        //Assembly.Load("HStation.BLL.Xhs.Core")
                    );
                DbFirstHelper.Initial();
                Yw.WinFrmUI.GlobalParas.AppIcon = PBS.Desktop.Core.Properties.Resources.app;
                //DbFirstHelper.Initial();
                Application.Run(new MainForm());
            }
        }
        ///<summary>
        ///  这就是我们要在发生未处理异常时处理的方法,我这是写出错详细信息到文本,如出错后弹出一个漂亮的出错提示窗体,给大家做个参考
        ///  做法很多,可以是把出错详细信息记录到文本、数据库,发送出错邮件到作者信箱或出错后重新初始化等等
        ///  这就是仁者见仁智者见智,大家自己做了。
        ///</summary>
        ///</summary>d
        ///<param name="sender"> </param>
        ///<param name="e"> </param>
        private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            var ex = e.Exception;
            Yw.LogHelper.Error("系统出现未知异常,ERROR:249", ex);
            MessageBox.Show($"系统出现未知异常,请重启系统!\r\n{ex.Message}");
            if (ex is Yw.Vmo.VException internalEx)
            {
                Yw.LogHelper.Error("系统出现内部异常,ERROR:249", internalEx);
                var dlg = new Yw.WinFrmUI.VmoExceptionInfoDlg();
                dlg.SetBindingData(internalEx);
                dlg.ShowDialog();
            }
            else
            {
                Yw.LogHelper.Error("系统出现未知异常,ERROR:249", ex);
                MessageBoxHelper.ShowError($"系统出现未知异常,请重启系统!\r\n{ex.Message}");
            }
        }
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var ex = e.ExceptionObject as Exception;
            Yw.LogHelper.Error("系统出现未知异常,ERROR:255", ex);
            MessageBox.Show($"系统出现未知异常,请重启系统!\r\n{ex.Message}");
            if (ex is Yw.Vmo.VException internalEx)
            {
                Yw.LogHelper.Error("系统出现内部异常,ERROR:249", internalEx);
                var dlg = new Yw.WinFrmUI.VmoExceptionInfoDlg();
                dlg.SetBindingData(internalEx);
                dlg.ShowDialog();
            }
            else
            {
                Yw.LogHelper.Error("系统出现未知异常,ERROR:255", ex);
                MessageBoxHelper.ShowError($"系统出现未知异常,请重启系统!\r\n{ex.Message}");
            }
        }
    }
}