| | |
| | | using CefSharp.WinForms; |
| | | using System; |
| | | using System.Configuration; |
| | | using System.Data.SqlClient; |
| | | using System.IO; |
| | | using System.Windows.Forms; |
| | | |
| | |
| | | { |
| | | public partial class ShowFile : DevExpress.XtraEditors.XtraForm |
| | | { |
| | | string strConn = "Data Source=192.168.1.146,12468;Initial Catalog=GS_MES;User ID=mesUser;Password =qixi1qaz@WSXmes"; |
| | | private static readonly string WebApiUrl = |
| | | ConfigurationManager.AppSettings["WebApiUrl"]; |
| | | private ChromiumWebBrowser chromeBrowser; |
| | |
| | | |
| | | private void ShowFile_Load(object sender, EventArgs e) |
| | | { |
| | | string filePath = System.Uri.EscapeUriString(urlPath); |
| | | string fileType = GetFileType(urlPath); |
| | | string filePath = ""; |
| | | //这是guid,不是路径,根据guid 读取到它的路径 |
| | | if (urlPath.Length == 36) |
| | | { |
| | | System.Text.StringBuilder sb = new System.Text.StringBuilder(" select top 1 url_Path from [dbo].[MES_FILE] where parent_Guid='" + urlPath + "'"); |
| | | object obj = GetSingle(sb.ToString()); |
| | | if (obj != null) |
| | | { |
| | | filePath = System.Uri.EscapeUriString(obj.ToString()); |
| | | fileType = GetFileType(filePath); |
| | | } |
| | | else |
| | | filePath = System.Uri.EscapeUriString(urlPath); |
| | | } |
| | | else |
| | | filePath = System.Uri.EscapeUriString(urlPath); |
| | | string _url = WebApiUrl + "upload/h5/site.html?fileType=" + fileType + "&filePath=" + filePath + "&mid=" + Guid.NewGuid().ToString(); |
| | | chromeBrowser = new ChromiumWebBrowser(_url); |
| | | this.pane1.Controls.Add(chromeBrowser); |
| | |
| | | return "other"; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 执行一条计算查询结果语句,返回查询结果(object)。 |
| | | /// </summary> |
| | | /// <param name="SQLString">计算查询结果语句</param> |
| | | /// <returns>查询结果(object)</returns> |
| | | private object GetSingle(string SQLString) |
| | | { |
| | | using (var connection = new SqlConnection(strConn)) |
| | | { |
| | | using (var cmd = new SqlCommand(SQLString, connection)) |
| | | { |
| | | try |
| | | { |
| | | connection.Open(); |
| | | var obj = cmd.ExecuteScalar(); |
| | | if (Equals(obj, null) || Equals(obj, DBNull.Value)) |
| | | return null; |
| | | return obj; |
| | | } |
| | | catch (SqlException e) |
| | | { |
| | | connection.Close(); |
| | | throw new Exception(e.Message); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |