duheng
2025-03-20 ece06ec62080cd3a8a2a8bdc882f3aaf16a71342
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
using DevExpress.LookAndFeel;
using HStation.WinFrmUI;
using Mapster;
 
namespace PBS.Desktop
{
    internal static class Program
    {
        /// <summary>
        ///  The main entry point for the application.
        /// </summary>
        [STAThread]
        private static void Main()
        {
            using (var mutex = new System.Threading.Mutex(true, Application.ProductName, out bool createNew))
            {
                if (!createNew)
                {
                    MessageBox.Show("³ÌÐòÕýÔÚÔËÐÐÖÐ...");
                    Application.Exit();
                    return;
                }
 
                //DevExpress.UserSkins.BonusSkins.Register();
                //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");
 
                //´¦Àíδ²¶»ñµÄÒì³£
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                //´¦ÀíUIÏß³ÌÒì³£
                Application.ThreadException += Application_ThreadException;
                //´¦Àí·ÇUIÏß³ÌÒì³£
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
 
                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;
 
                //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);
 
                // 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.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("HStation.BLL.Xhs.Core")
                    );
                DbFirstHelper.Initial();
                Application.Run(new MainForm());
            }
        }
 
        ///<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;
            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;
            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}");
            }
        }
    }
}