zoule 4 сар өмнө
parent
commit
8158852e52

+ 3 - 0
DW5S.App/DW5S.App.csproj

@@ -45,6 +45,9 @@
       <Generator>SettingsSingleFileGenerator</Generator>
       <LastGenOutput>Settings.Designer.cs</LastGenOutput>
     </None>
+    <None Update="Tips.txt">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
 
 </Project>

+ 1 - 0
DW5S.App/MainForm.cs

@@ -52,6 +52,7 @@ namespace DW5S
         Dictionary<string, Type> ctrlTypes = new Dictionary<string, Type>();
         public MainForm()
         {
+            WebApiHelper.Start(AppConfigHelper.Get("HttpPort", 8090), dllKey: "DW5S");
             InitializeComponent();
             ribbon.UseDefault();
             tabbedView1.UseDefault();

+ 24 - 26
DW5S.App/Program.cs

@@ -61,33 +61,31 @@ namespace DW5S
         [STAThread]
         static void Main()
         {
-            WebApiHelper.Start(AppConfigHelper.Get("HttpPort", 8090));
-            //WindowsFormsSettings.AllowDpiScale = true;
-            //WindowsFormsSettings.AllowHoverAnimation = DevExpress.Utils.DefaultBoolean.True;
-            //WindowsFormsSettings.AllowDefaultSvgImages = DevExpress.Utils.DefaultBoolean.True;
-            //WindowsFormsSettings.AllowRoundedWindowCorners = DevExpress.Utils.DefaultBoolean.True;
-            //WindowsFormsSettings.AnimationMode = AnimationMode.EnableAll;
-            //WindowsFormsSettings.BackgroundSkinningMode = BackgroundSkinningMode.AllColors;
-            //WindowsFormsSettings.DefaultAllowHtmlDraw = true;
-            //WindowsFormsSettings.DefaultLookAndFeel.SetSkinStyle(SkinStyle.WXICompact);
-            //WindowsFormsSettings.DefaultFont = new System.Drawing.Font("微软雅黑", 10f);
-            //WindowsFormsSettings.SetPerMonitorDpiAware();
-            //if (Debugger.IsAttached)
-            //{
-            //    //DevExpress23.2以上版本查看未本地化的资源
-            //    DevExpress.Utils.Localization.XtraLocalizer.EnableTraceSource();
-            //}
-            //string screenTitle = AppConfigHelper.Get("SystemName", "");
-            //string screenCompany = AppConfigHelper.Get("Company", "");
-            //DxHelper.WaitHelper.SetSplashTips("Tips.txt");
-            //ChsLocalizer.UseChs();
-
-            //DxHelper.WaitHelper.ShowSplashScreen(screenTitle, screenCompany);
-            //DxHelper.WaitHelper.UpdateSplashMessage("正在加载程序资源文件...");
-            //MainForm mainForm = new MainForm() { Text = screenTitle };
-            //DxHelper.WaitHelper.UpdateSplashMessage("正在初始化...");
-            //System.Windows.Forms.Application.Run(mainForm);
+            WindowsFormsSettings.AllowDpiScale = true;
+            WindowsFormsSettings.AllowHoverAnimation = DevExpress.Utils.DefaultBoolean.True;
+            WindowsFormsSettings.AllowDefaultSvgImages = DevExpress.Utils.DefaultBoolean.True;
+            WindowsFormsSettings.AllowRoundedWindowCorners = DevExpress.Utils.DefaultBoolean.True;
+            WindowsFormsSettings.AnimationMode = AnimationMode.EnableAll;
+            WindowsFormsSettings.BackgroundSkinningMode = BackgroundSkinningMode.AllColors;
+            WindowsFormsSettings.DefaultAllowHtmlDraw = true;
+            WindowsFormsSettings.DefaultLookAndFeel.SetSkinStyle(SkinStyle.WXICompact);
+            WindowsFormsSettings.DefaultFont = new System.Drawing.Font("微软雅黑", 10f);
+            WindowsFormsSettings.SetPerMonitorDpiAware();
+            if (Debugger.IsAttached)
+            {
+                //DevExpress23.2以上版本查看未本地化的资源
+                DevExpress.Utils.Localization.XtraLocalizer.EnableTraceSource();
+            }
+            string screenTitle = AppConfigHelper.Get("SystemName", "");
+            string screenCompany = AppConfigHelper.Get("Company", "");
+            DxHelper.WaitHelper.SetSplashTips("Tips.txt");
+            ChsLocalizer.UseChs();
 
+            DxHelper.WaitHelper.ShowSplashScreen(screenTitle, screenCompany);
+            DxHelper.WaitHelper.UpdateSplashMessage("正在加载程序资源文件...");
+            MainForm mainForm = new MainForm() { Text = screenTitle };
+            DxHelper.WaitHelper.UpdateSplashMessage("正在初始化...");
+            System.Windows.Forms.Application.Run(mainForm);
         }
     }
 }

+ 6 - 0
DW5S.App/Tips.txt

@@ -0,0 +1,6 @@
+小提示:Ctrl+Shift+V可复制表格单元格内容
+小提示:双击文本框可全选内容
+小提示:点击主窗体中的消息忽略会将消息复制到剪贴板
+小提示:按住Shift+鼠标左键可对表格进行连续多行选择
+小提示:按住Ctrl+鼠标左键可对表格进行多行选择,Ctrl+A可全选
+小提示:没有特别说明时间都使用系统设置时区的本地时间

+ 7 - 7
DW5S.Basic/AppDomainExtents.cs

@@ -9,12 +9,12 @@ public static class AppDomainExtents
     /// <param name="prefix">程序集前缀</param>
     /// <remarks>如果某个dll被反射加载,同时程序被发布为自包含的单个exe程序,这种dll目前检测不到</remarks>
     /// <returns></returns>
-    public static Assembly[] GetAllAssemblies(this AppDomain domain, string prefix = "DW5S")
+    public static Assembly[] GetAllAssemblies(this AppDomain domain, string dllKey = "DW5S")
     {
         Dictionary<string, Assembly> dic = new Dictionary<string, Assembly>();
         var exe = Assembly.GetEntryAssembly();
         dic[exe.FullName] = exe;
-        var files = Directory.GetFiles(domain.BaseDirectory, prefix + "*.dll", SearchOption.AllDirectories);
+        var files = Directory.GetFiles(domain.BaseDirectory, "*" + dllKey + "*.dll", SearchOption.AllDirectories);
         foreach (var item in files)
         {
             //如果一个dll在项目中被反射加载,这种情况需要需要从目录中检索dll
@@ -24,22 +24,22 @@ public static class AppDomainExtents
         domain.GetAssemblies().ToList().ForEach(i =>
         {
             if (dic.ContainsKey(i.FullName)) return;
-            if (i.FullName != null && i.FullName.ToUpper().StartsWith(prefix.ToUpper()))
+            if (i.FullName != null && i.FullName.ToUpper().Contains(dllKey.ToUpper()))
                 dic[i.FullName] = i;
-            GetReferanceAssemblies(i, dic, prefix);
+            GetReferanceAssemblies(i, dic, dllKey);
         });
         var res = dic.Values.OrderBy(p => p.FullName).ToArray();
         return res;
     }
-    static void GetReferanceAssemblies(Assembly assembly, Dictionary<string, Assembly> dic, string prefix)
+    static void GetReferanceAssemblies(Assembly assembly, Dictionary<string, Assembly> dic, string dllKey)
     {
         assembly.GetReferencedAssemblies().ToList().ForEach(i =>
         {
             if (dic.ContainsKey(i.FullName)) return;
-            if (i.Name == null || !i.Name.ToUpper().StartsWith(prefix.ToUpper())) return;
+            if (i.Name == null || !i.Name.ToUpper().Contains(dllKey.ToUpper())) return;
             var ass = Assembly.Load(i);
             dic[i.FullName] = ass;
-            GetReferanceAssemblies(ass, dic, prefix);
+            GetReferanceAssemblies(ass, dic, dllKey);
         });
     }
 }

+ 2 - 2
DW5S.WebApi/BaseController.cs

@@ -29,10 +29,10 @@ namespace DW5S.WebApi
         }
 
         /// <summary>
-        /// 确保Controller程序集被加载
+        /// 发布为单文件App时确保可以找到Controller程序集
         /// </summary>
         [NonAction]
-        public void EnsureAssemblyLoaded()
+        internal static void EnsureAssemblyLoaded()
         { 
         }
         /// <summary>

+ 4 - 3
DW5S.WebApi/WebApiHelper.cs

@@ -40,8 +40,9 @@ namespace DW5S.WebApi
         /// <param name="staticDir">要启用的静态目录预览及文件下载的目录(已经包含upload、download、logs三个目录)</param>
         /// <param name="prefix">使用DI注入时程序集的前缀</param>
         /// <exception cref="Exception"></exception>
-        public static void Start(int _localPort, string dtoXmlName = null, string[] staticDir = null, string controllerXmlName = null, string prefix = "ips")
+        public static void Start(int _localPort, string dtoXmlName = null, string[] staticDir = null, string controllerXmlName = null, string dllKey = "DW5S")
         {
+            BaseController.EnsureAssemblyLoaded();
             _cts = new CancellationTokenSource();
             if (controllerXmlName == null)
                 controllerXmlName = $"{AppDomain.CurrentDomain.FriendlyName}.xml";
@@ -65,10 +66,10 @@ namespace DW5S.WebApi
                 listDir.Add("logs");
             }
             staticDir = listDir.ToArray();
-            var assemblies = AppDomain.CurrentDomain.GetAllAssemblies(prefix);
+            var assemblies = AppDomain.CurrentDomain.GetAllAssemblies(dllKey);
             if (assemblies == null)
             {
-                throw new Exception($"未扫描到{prefix}前缀的程序集");
+                throw new Exception($"未扫描到包含{dllKey}字符串的程序集");
             }
             foreach (var item in assemblies)
             {