From ef1fc8b0eeea6972964d8c62dfef7819bea49d1a Mon Sep 17 00:00:00 2001
From: qin <a@163.com>
Date: 星期五, 14 三月 2025 11:01:34 +0800
Subject: [PATCH] 提交文件

---
 Desktop/HStation.Desktop.Xhs.Core/Program.cs |   98 ++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 76 insertions(+), 22 deletions(-)

diff --git a/Desktop/HStation.Desktop.Xhs.Core/Program.cs b/Desktop/HStation.Desktop.Xhs.Core/Program.cs
index dcc7ae6..c4b8535 100644
--- a/Desktop/HStation.Desktop.Xhs.Core/Program.cs
+++ b/Desktop/HStation.Desktop.Xhs.Core/Program.cs
@@ -1,6 +1,8 @@
 using DevExpress.LookAndFeel;
 using Mapster;
 using System.Reflection;
+using Yw;
+using Yw.WinFrmUI;
 
 namespace HStation.Desktop
 {
@@ -10,7 +12,7 @@
         ///  The main entry point for the application.
         /// </summary>
         [STAThread]
-        static void Main()
+        private static void Main()
         {
             using (var mutex = new System.Threading.Mutex(true, Application.ProductName, out bool createNew))
             {
@@ -34,40 +36,64 @@
                 Application.ThreadException += Application_ThreadException;
                 //处理非UI线程异常
                 AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
+                //处理未被观察到的异常
+                TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
 
                 Application.EnableVisualStyles();
                 Application.SetCompatibleTextRenderingDefault(false);
 
                 //字体
-                // var font = new System.Drawing.Font("微软雅黑", 10);
-                // DevExpress.XtraEditors.WindowsFormsSettings.DefaultFont = font;
-                // DevExpress.XtraEditors.WindowsFormsSettings.DefaultMenuFont = font;
-                // DevExpress.Utils.AppearanceObject.DefaultFont = font;
+                var font = new System.Drawing.Font("微软雅黑", 10);
+                DevExpress.XtraEditors.WindowsFormsSettings.DefaultFont = font;
+                DevExpress.XtraEditors.WindowsFormsSettings.DefaultMenuFont = font;
+                DevExpress.Utils.AppearanceObject.DefaultFont = font;
 
                 //zh-Hans界面翻译
                 System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-Hans");
                 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);
+                //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 = HStation.Desktop.Xhs.Core.Properties.Resources.app;
 
-                //if (!LoginHelper.Login())
-                //{
-                //    return;
-                //}
+                #region 验证升级
 
-                Yw.FileFolderZipHelper.Zip(@"C:\Users\admin\Desktop\居家办公工作\循环水用例", @"C:\Users\admin\Desktop\居家办公工作\循环水用例.ywrvt");
+                try
+                {
 
-                //var json = RevitTestHelper.GenerateJson();
+                    if (AutoUpdateHelper.NeedExist())
+                        return;
+                }
+                catch (Exception ex)
+                {
+                    LogHelper.Error("验证升级错误", ex);
+                }
 
-                //var jsonFileName = @"C:\Users\admin\Desktop\居家办公工作\二开压缩文件\hydro.json";
-                //var jsonContent = File.ReadAllText(jsonFileName);
-                //var jsonModel = JsonHelper.Json2Object<HStation.Model.RevitModel>(jsonContent);
+                #endregion
+
+
+                if (!LoginHelper.Login())
+                {
+                    return;
+                }
+
+                Yw.Untity.UserRegister.Regist
+                       (
+                           Yw.WinFrmUI.LoginUserInfo.CorpID,
+                           Yw.WinFrmUI.LoginUserInfo.UserID,
+                           (int)Yw.WinFrmUI.LoginUserInfo.AdminType,
+                           Yw.WinFrmUI.LoginUserInfo.UserName,
+                           Yw.WinFrmUI.LoginUserInfo.UserTag,
+                           Yw.WinFrmUI.LoginUserInfo.LoginAccountID,
+                           Yw.WinFrmUI.LoginUserInfo.LoginTypeID,
+                           Yw.WinFrmUI.LoginUserInfo.ProjectID,
+                           Yw.WinFrmUI.LoginUserInfo.SoftwareID
+                       );
 
                 //扫描全局DTO映射
                 TypeAdapterConfig.GlobalSettings.Scan
@@ -81,30 +107,58 @@
                 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 vmoEx)
+            {
+                Yw.LogHelper.Error("系统出现内部异常,ERROR:249", vmoEx);
+                VmoExceptionTipFormHelper.Show(vmoEx);
+            }
+            else if (ex is Yw.Dto.InternalException internalEx)
+            {
+                Yw.LogHelper.Error("系统出现内部异常,ERROR:249", internalEx);
+
+            }
+            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}");
+            }
+        }
+
+        //
+        private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
+        {
+            //throw new NotImplementedException();
         }
 
     }

--
Gitblit v1.9.3