lu
2024-11-09 260881e61c8e994449c32f3c8793827b1b0b754d
附件
已添加3个文件
已修改4个文件
329 ■■■■■ 文件已修改
DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DevApp/Gs.DevApp/Gs.DevApp.csproj 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DevApp/Gs.DevApp/Program.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DevApp/Gs.DevApp/UserControl/ShowFile.Designer.cs 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DevApp/Gs.DevApp/UserControl/ShowFile.cs 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DevApp/Gs.DevApp/UserControl/ShowFile.resx 120 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DevApp/Gs.DevApp/UserControl/UCUpFile.cs 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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);
                }
            }
        }
    }
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>
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)
            {
DevApp/Gs.DevApp/UserControl/ShowFile.Designer.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,76 @@
namespace 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;
    }
}
DevApp/Gs.DevApp/UserControl/ShowFile.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,60 @@
using 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";
            }
        }
    }
}
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>
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();
        }