From 260881e61c8e994449c32f3c8793827b1b0b754d Mon Sep 17 00:00:00 2001
From: lu <99954486@qq.com>
Date: 星期六, 09 十一月 2024 08:54:29 +0800
Subject: [PATCH] 附件

---
 DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs |   17 ++
 DevApp/Gs.DevApp/UserControl/ShowFile.Designer.cs    |   76 ++++++++++++
 DevApp/Gs.DevApp/UserControl/UCUpFile.cs             |   39 ++++--
 DevApp/Gs.DevApp/Gs.DevApp.csproj                    |    9 +
 DevApp/Gs.DevApp/UserControl/ShowFile.resx           |  120 ++++++++++++++++++++
 DevApp/Gs.DevApp/Program.cs                          |    8 +
 DevApp/Gs.DevApp/UserControl/ShowFile.cs             |   60 ++++++++++
 7 files changed, 309 insertions(+), 20 deletions(-)

diff --git a/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs b/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs
index 3d7cfae..ee5b32c 100644
--- a/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs
+++ b/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs
@@ -393,8 +393,8 @@
             var _obj = new
             {
                 guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //涓诲缓
-                fngDesc=txt_fngDesc.Text.Trim(),
-                lotNo1=txt_lotNo1.Text.Trim(),
+                fngDesc = txt_fngDesc.Text.Trim(),
+                lotNo1 = txt_lotNo1.Text.Trim(),
             };
             try
             {
@@ -625,7 +625,18 @@
                 return;
             if (e.Button.Index == 0)
             {
-                MsgHelper.Warning("鎻愮ず锛�" + "寮�鍙戜腑");
+                try
+                {
+                    var dr = gvMx3.GetDataRow(rowhandle);
+                    var urlPath = dr["urlPath"].ToString();
+                    Gs.DevApp.UserControl.ShowFile frm = new ShowFile(urlPath);
+                    frm.ShowDialog();
+                }
+                catch (Exception ex)
+                {
+                    Gs.DevApp.ToolBox.MsgHelper.ShowError(ex.Message);
+                }
+            
             }
         }
     }
diff --git a/DevApp/Gs.DevApp/Gs.DevApp.csproj b/DevApp/Gs.DevApp/Gs.DevApp.csproj
index 51dbbde..9498d85 100644
--- a/DevApp/Gs.DevApp/Gs.DevApp.csproj
+++ b/DevApp/Gs.DevApp/Gs.DevApp.csproj
@@ -459,6 +459,12 @@
     <Compile Include="UserControl\SelectCheckDt.Designer.cs">
       <DependentUpon>SelectCheckDt.cs</DependentUpon>
     </Compile>
+    <Compile Include="UserControl\ShowFile.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="UserControl\ShowFile.Designer.cs">
+      <DependentUpon>ShowFile.cs</DependentUpon>
+    </Compile>
     <Compile Include="UserControl\ShowLogcs.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -667,6 +673,9 @@
     <EmbeddedResource Include="UserControl\SelectCheckDt.resx">
       <DependentUpon>SelectCheckDt.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="UserControl\ShowFile.resx">
+      <DependentUpon>ShowFile.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="UserControl\ShowLogcs.resx">
       <DependentUpon>ShowLogcs.cs</DependentUpon>
     </EmbeddedResource>
diff --git a/DevApp/Gs.DevApp/Program.cs b/DevApp/Gs.DevApp/Program.cs
index f12f19f..040e7b3 100644
--- a/DevApp/Gs.DevApp/Program.cs
+++ b/DevApp/Gs.DevApp/Program.cs
@@ -2,6 +2,8 @@
 using System.Diagnostics;
 using System.IO;
 using System.Windows.Forms;
+using CefSharp.WinForms;
+using CefSharp;
 using Gs.DevApp.DevFrm;
 
 namespace Gs.DevApp
@@ -36,9 +38,11 @@
         /// </summary>
         private static void _startLogin()
         {
-            //Application.Run(new TestForm.XtraForm3());
+            //Application.Run(new  ShowFile("dsfs"));
             //return;
-
+            CefSettings settings = new CefSettings();
+            settings.Locale = "zh-CN";
+            Cef.Initialize(settings);
             var fmLogin = new FrmLogin();
             if (fmLogin.IsDisposed == false)
             {
diff --git a/DevApp/Gs.DevApp/UserControl/ShowFile.Designer.cs b/DevApp/Gs.DevApp/UserControl/ShowFile.Designer.cs
new file mode 100644
index 0000000..1e396eb
--- /dev/null
+++ b/DevApp/Gs.DevApp/UserControl/ShowFile.Designer.cs
@@ -0,0 +1,76 @@
+锘縩amespace Gs.DevApp.UserControl
+{
+    partial class ShowFile
+    {
+        /// <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()
+        {
+            this.txtUrl = new DevExpress.XtraEditors.TextEdit();
+            this.pane1 = new DevExpress.XtraEditors.PanelControl();
+            ((System.ComponentModel.ISupportInitialize)(this.txtUrl.Properties)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.pane1)).BeginInit();
+            this.SuspendLayout();
+            // 
+            // txtUrl
+            // 
+            this.txtUrl.Dock = System.Windows.Forms.DockStyle.Top;
+            this.txtUrl.Location = new System.Drawing.Point(0, 0);
+            this.txtUrl.Name = "txtUrl";
+            this.txtUrl.Size = new System.Drawing.Size(905, 24);
+            this.txtUrl.TabIndex = 0;
+            // 
+            // pane1
+            // 
+            this.pane1.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.pane1.Location = new System.Drawing.Point(0, 24);
+            this.pane1.Name = "pane1";
+            this.pane1.Size = new System.Drawing.Size(905, 469);
+            this.pane1.TabIndex = 1;
+            // 
+            // ShowFile
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 18F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(905, 493);
+            this.Controls.Add(this.pane1);
+            this.Controls.Add(this.txtUrl);
+            this.IconOptions.Image = global::Gs.DevApp.Properties.Resources.logo_png_black;
+            this.Name = "ShowFile";
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+            this.Text = "鏂囦欢棰勮";
+            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
+            ((System.ComponentModel.ISupportInitialize)(this.txtUrl.Properties)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.pane1)).EndInit();
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+
+        private DevExpress.XtraEditors.TextEdit txtUrl;
+        private DevExpress.XtraEditors.PanelControl pane1;
+    }
+}
\ No newline at end of file
diff --git a/DevApp/Gs.DevApp/UserControl/ShowFile.cs b/DevApp/Gs.DevApp/UserControl/ShowFile.cs
new file mode 100644
index 0000000..479b224
--- /dev/null
+++ b/DevApp/Gs.DevApp/UserControl/ShowFile.cs
@@ -0,0 +1,60 @@
+锘縰sing CefSharp;
+using CefSharp.WinForms;
+using System;
+using System.Configuration;
+using System.IO;
+using System.Windows.Forms;
+
+namespace Gs.DevApp.UserControl
+{
+    public partial class ShowFile : DevExpress.XtraEditors.XtraForm
+    {
+        private static readonly string WebApiUrl =
+        ConfigurationManager.AppSettings["WebApiUrl"];
+        private ChromiumWebBrowser chromeBrowser;
+        string urlPath;
+        public ShowFile(string _urlPath)
+        {
+            InitializeComponent();
+            this.urlPath = _urlPath;
+            this.Load += ShowFile_Load;
+            this.FormClosed += ShowFile_FormClosed;
+        }
+
+        private void ShowFile_FormClosed(object sender, FormClosedEventArgs e)
+        {
+            chromeBrowser.Dispose();
+        }
+
+        private void ShowFile_Load(object sender, EventArgs e)
+        {
+            string _h5 = GetFileType(urlPath);
+            string _url = WebApiUrl + "upload/" + _h5 + "?filePath=" + urlPath + "&mid=" + Guid.NewGuid().ToString();
+            chromeBrowser = new ChromiumWebBrowser(_url);
+            this.pane1.Controls.Add(chromeBrowser);
+            chromeBrowser.Dock = DockStyle.Fill;
+            txtUrl.Text = _url;
+            txtUrl.ReadOnly = true;
+        }
+
+        public static string GetFileType(string fileName)
+        {
+            // 鑾峰彇鏂囦欢鎵╁睍鍚�
+            string extension = Path.GetExtension(fileName);
+            // 鏍规嵁鎵╁睍鍚嶅垽鏂枃浠剁被鍨�
+            switch (extension.ToLowerInvariant())
+            {
+                case ".jpg":
+                case ".jpeg":
+                case ".png":
+                    return "h5Image.html";
+                case ".pdf":
+                    return "h5Pdf.html";
+                // 娣诲姞鍏朵粬鏂囦欢绫诲瀷
+                // ...
+                default:
+                    return "h5Other.html";
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/DevApp/Gs.DevApp/UserControl/ShowFile.resx b/DevApp/Gs.DevApp/UserControl/ShowFile.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/DevApp/Gs.DevApp/UserControl/ShowFile.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>
\ No newline at end of file
diff --git a/DevApp/Gs.DevApp/UserControl/UCUpFile.cs b/DevApp/Gs.DevApp/UserControl/UCUpFile.cs
index 5ea7d68..beb75dc 100644
--- a/DevApp/Gs.DevApp/UserControl/UCUpFile.cs
+++ b/DevApp/Gs.DevApp/UserControl/UCUpFile.cs
@@ -35,7 +35,7 @@
         ///     鏀瑰彉浜嬩欢
         /// </summary>
         public event EventHandler UpChanged;
-      
+
         #region 鏂囦欢涓婁紶
 
         /// <summary>
@@ -74,7 +74,8 @@
             var WebApiUrl = ConfigurationSettings.AppSettings.Get("WebApiUrl");
             var address = WebApiUrl + "MesFile/UploadFile";
             var filePath = txtUpUrl.Text.Trim();
-            if (string.IsNullOrEmpty(filePath)) {
+            if (string.IsNullOrEmpty(filePath))
+            {
                 Gs.DevApp.ToolBox.MsgHelper.ShowError("璇烽�夋嫨浣犻渶瑕佷笂浼犵殑鏂囦欢锛�");
                 return;
             }
@@ -88,21 +89,29 @@
             UcLoading _loading = new UcLoading();
             string _parentGuid = parentGuid;
             using (var httpClient = new HttpClient())
-            using (var form = new MultipartFormDataContent())
-            {
-                httpClient.DefaultRequestHeaders.Add("token",
-                    UtilityHelper.GetBasicAuthTicket());
-                using (var fs = File.OpenRead(filePath))
-                using (var streamContent = new StreamContent(fs))
+                try
                 {
-                    form.Add(streamContent, "file", _parentGuid + "~" + Path.GetFileName(filePath));
-                    var response = await httpClient.PostAsync(url, form);
-                    var responseString =
-                        await response.Content.ReadAsStringAsync();
-                    //  MessageBox.Show(responseString);
-                    txtUpUrl.Text = "";
+                    using (var form = new MultipartFormDataContent())
+                    {
+                        httpClient.DefaultRequestHeaders.Add("token",
+                            UtilityHelper.GetBasicAuthTicket());
+                        using (var fs = File.OpenRead(filePath))
+                        using (var streamContent = new StreamContent(fs))
+                        {
+                            form.Add(streamContent, "file", _parentGuid + "~" + Path.GetFileName(filePath));
+                            var response = await httpClient.PostAsync(url, form);
+                            var responseString =
+                                await response.Content.ReadAsStringAsync();
+                            //  MessageBox.Show(responseString);
+                            txtUpUrl.Text = "";
+                        }
+                    }
                 }
-            }
+                catch (Exception ex)
+                {
+                    Gs.DevApp.ToolBox.MsgHelper.ShowError(ex.Message);
+
+                }
             _loading.Close();
         }
 

--
Gitblit v1.9.3