lixiaojun
2025-01-21 13e336388e5978749e88be829d1465a2350c5645
增加VMO异常处理
已修改3个文件
已添加3个文件
335 ■■■■■ 文件已修改
Desktop/HStation.Desktop.Xhs.Core/Program.cs 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/Yw.WinFrmUI.Core/12-exception/VmoExceptionInfoDlg.Designer.cs 155 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/Yw.WinFrmUI.Core/12-exception/VmoExceptionInfoDlg.cs 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/Yw.WinFrmUI.Core/12-exception/VmoExceptionInfoDlg.resx 120 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/Yw.WinFrmUI.Core/Yw.WinFrmUI.Core.csproj 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WinFrmUI/Yw.WinFrmUI.Core/Yw.WinFrmUI.Core.csproj.user 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Desktop/HStation.Desktop.Xhs.Core/Program.cs
@@ -97,11 +97,12 @@
        private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            var ex = e.Exception;
            if (ex is Yw.Dto.InternalException internalEx)
            if (ex is Yw.Vmo.VException internalEx)
            {
                Yw.LogHelper.Error("系统出现内部异常,ERROR:249", internalEx);
                MessageBoxHelper.ShowError(internalEx.ErrorMsg);
                var dlg = new Yw.WinFrmUI.VmoExceptionInfoDlg();
                dlg.SetBindingData(internalEx);
                dlg.ShowDialog();
            }
            else
            {
@@ -113,10 +114,12 @@
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var ex = e.ExceptionObject as Exception;
            if (ex is Yw.Dto.InternalException internalEx)
            if (ex is Yw.Vmo.VException internalEx)
            {
                Yw.LogHelper.Error("系统出现内部异常,ERROR:249", internalEx);
                MessageBoxHelper.ShowError(internalEx.ErrorMsg);
                var dlg = new Yw.WinFrmUI.VmoExceptionInfoDlg();
                dlg.SetBindingData(internalEx);
                dlg.ShowDialog();
            }
            else
            {
WinFrmUI/Yw.WinFrmUI.Core/12-exception/VmoExceptionInfoDlg.Designer.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,155 @@
namespace Yw.WinFrmUI
{
    partial class VmoExceptionInfoDlg
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            layoutControl1 = new LayoutControl();
            txtStackTrace = new MemoEdit();
            txtErrorMsg = new MemoEdit();
            txtErrorCode = new TextEdit();
            Root = new LayoutControlGroup();
            layoutControlItem1 = new LayoutControlItem();
            layoutControlItem2 = new LayoutControlItem();
            layoutControlItem3 = new LayoutControlItem();
            ((ISupportInitialize)layoutControl1).BeginInit();
            layoutControl1.SuspendLayout();
            ((ISupportInitialize)txtStackTrace.Properties).BeginInit();
            ((ISupportInitialize)txtErrorMsg.Properties).BeginInit();
            ((ISupportInitialize)txtErrorCode.Properties).BeginInit();
            ((ISupportInitialize)Root).BeginInit();
            ((ISupportInitialize)layoutControlItem1).BeginInit();
            ((ISupportInitialize)layoutControlItem2).BeginInit();
            ((ISupportInitialize)layoutControlItem3).BeginInit();
            SuspendLayout();
            //
            // layoutControl1
            //
            layoutControl1.Controls.Add(txtStackTrace);
            layoutControl1.Controls.Add(txtErrorMsg);
            layoutControl1.Controls.Add(txtErrorCode);
            layoutControl1.Dock = DockStyle.Fill;
            layoutControl1.Location = new Point(0, 0);
            layoutControl1.Name = "layoutControl1";
            layoutControl1.Root = Root;
            layoutControl1.Size = new Size(622, 326);
            layoutControl1.TabIndex = 0;
            layoutControl1.Text = "layoutControl1";
            //
            // txtStackTrace
            //
            txtStackTrace.Location = new Point(76, 111);
            txtStackTrace.Name = "txtStackTrace";
            txtStackTrace.Size = new Size(534, 203);
            txtStackTrace.StyleController = layoutControl1;
            txtStackTrace.TabIndex = 3;
            //
            // txtErrorMsg
            //
            txtErrorMsg.Location = new Point(76, 36);
            txtErrorMsg.Name = "txtErrorMsg";
            txtErrorMsg.Size = new Size(534, 71);
            txtErrorMsg.StyleController = layoutControl1;
            txtErrorMsg.TabIndex = 2;
            //
            // txtErrorCode
            //
            txtErrorCode.Location = new Point(76, 12);
            txtErrorCode.Name = "txtErrorCode";
            txtErrorCode.Size = new Size(534, 20);
            txtErrorCode.StyleController = layoutControl1;
            txtErrorCode.TabIndex = 0;
            //
            // Root
            //
            Root.EnableIndentsWithoutBorders = DefaultBoolean.True;
            Root.GroupBordersVisible = false;
            Root.Items.AddRange(new BaseLayoutItem[] { layoutControlItem1, layoutControlItem2, layoutControlItem3 });
            Root.Name = "Root";
            Root.Size = new Size(622, 326);
            Root.TextVisible = false;
            //
            // layoutControlItem1
            //
            layoutControlItem1.Control = txtErrorCode;
            layoutControlItem1.Location = new Point(0, 0);
            layoutControlItem1.Name = "layoutControlItem1";
            layoutControlItem1.Size = new Size(602, 24);
            layoutControlItem1.Text = "错误编码:";
            layoutControlItem1.TextSize = new Size(52, 14);
            //
            // layoutControlItem2
            //
            layoutControlItem2.Control = txtErrorMsg;
            layoutControlItem2.Location = new Point(0, 24);
            layoutControlItem2.Name = "layoutControlItem2";
            layoutControlItem2.Size = new Size(602, 75);
            layoutControlItem2.Text = "错误信息:";
            layoutControlItem2.TextSize = new Size(52, 14);
            //
            // layoutControlItem3
            //
            layoutControlItem3.Control = txtStackTrace;
            layoutControlItem3.Location = new Point(0, 99);
            layoutControlItem3.Name = "layoutControlItem3";
            layoutControlItem3.Size = new Size(602, 207);
            layoutControlItem3.Text = "错误堆栈:";
            layoutControlItem3.TextSize = new Size(52, 14);
            //
            // VmoExceptionInfoDlg
            //
            AutoScaleDimensions = new SizeF(7F, 14F);
            AutoScaleMode = AutoScaleMode.Font;
            ClientSize = new Size(622, 326);
            Controls.Add(layoutControl1);
            Name = "VmoExceptionInfoDlg";
            StartPosition = FormStartPosition.CenterParent;
            Text = "异常提示";
            ((ISupportInitialize)layoutControl1).EndInit();
            layoutControl1.ResumeLayout(false);
            ((ISupportInitialize)txtStackTrace.Properties).EndInit();
            ((ISupportInitialize)txtErrorMsg.Properties).EndInit();
            ((ISupportInitialize)txtErrorCode.Properties).EndInit();
            ((ISupportInitialize)Root).EndInit();
            ((ISupportInitialize)layoutControlItem1).EndInit();
            ((ISupportInitialize)layoutControlItem2).EndInit();
            ((ISupportInitialize)layoutControlItem3).EndInit();
            ResumeLayout(false);
        }
        #endregion
        private LayoutControl layoutControl1;
        private LayoutControlGroup Root;
        private MemoEdit txtErrorMsg;
        private TextEdit txtErrorCode;
        private LayoutControlItem layoutControlItem1;
        private LayoutControlItem layoutControlItem2;
        private MemoEdit txtStackTrace;
        private LayoutControlItem layoutControlItem3;
    }
}
WinFrmUI/Yw.WinFrmUI.Core/12-exception/VmoExceptionInfoDlg.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,41 @@
using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Yw.WinFrmUI
{
    /// <summary>
    ///
    /// </summary>
    public partial class VmoExceptionInfoDlg : DevExpress.XtraEditors.XtraForm
    {
        /// <summary>
        ///
        /// </summary>
        public VmoExceptionInfoDlg()
        {
            InitializeComponent();
            this.IconOptions.Icon = GlobalParas.AppIcon;
            this.layoutControl1.SetupLayoutControl();
        }
        /// <summary>
        /// ç»‘定
        /// </summary>
        public void SetBindingData(Yw.Vmo.VException ex)
        {
            this.txtErrorCode.EditValue = ex.ErrorCode;
            this.txtErrorMsg.EditValue = ex.ErrorMsg;
            this.txtStackTrace.EditValue = ex.ErrorSource?.StackTrace;
        }
    }
}
WinFrmUI/Yw.WinFrmUI.Core/12-exception/VmoExceptionInfoDlg.resx
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
  <!--
    Microsoft ResX Schema
    Version 2.0
    The primary goals of this format is to allow a simple XML format
    that is mostly human readable. The generation and parsing of the
    various data types are done through the TypeConverter classes
    associated with the data types.
    Example:
    ... ado.net/XML headers & schema ...
    <resheader name="resmimetype">text/microsoft-resx</resheader>
    <resheader name="version">2.0</resheader>
    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
        <value>[base64 mime encoded serialized .NET Framework object]</value>
    </data>
    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
        <comment>This is a comment</comment>
    </data>
    There are any number of "resheader" rows that contain simple
    name/value pairs.
    Each data row contains a name, and value. The row also contains a
    type or mimetype. Type corresponds to a .NET class that support
    text/value conversion through the TypeConverter architecture.
    Classes that don't support this are serialized and stored with the
    mimetype set.
    The mimetype is used for serialized objects, and tells the
    ResXResourceReader how to depersist the object. This is currently not
    extensible. For a given mimetype the value must be set accordingly:
    Note - application/x-microsoft.net.object.binary.base64 is the format
    that the ResXResourceWriter will generate, however the reader can
    read any of the formats listed below.
    mimetype: application/x-microsoft.net.object.binary.base64
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
            : and then encoded with base64 encoding.
    mimetype: application/x-microsoft.net.object.bytearray.base64
    value   : The object must be serialized into a byte array
            : using a System.ComponentModel.TypeConverter
            : and then encoded with base64 encoding.
    -->
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
</root>
WinFrmUI/Yw.WinFrmUI.Core/Yw.WinFrmUI.Core.csproj
@@ -29,7 +29,8 @@
  <ItemGroup>
    <PackageReference Include="DevExpress.Win.Design" Version="23.2.4" />
    <PackageReference Include="Yw.Untity.Core" Version="3.0.3" />
    <PackageReference Include="Yw.Untity.Core" Version="3.0.6" />
    <PackageReference Include="Yw.Vmo.Core" Version="3.1.0" />
  </ItemGroup>
  <ItemGroup>
WinFrmUI/Yw.WinFrmUI.Core/Yw.WinFrmUI.Core.csproj.user
@@ -25,5 +25,8 @@
    <Compile Update="09-common\12-ok-cancel\GeneralOkAndCancelCtrl.cs">
      <SubType>UserControl</SubType>
    </Compile>
    <Compile Update="12-exception\VmoExceptionInfoDlg.cs">
      <SubType>Form</SubType>
    </Compile>
  </ItemGroup>
</Project>