using CefSharp;
|
using DevExpress.XtraEditors;
|
using Gs.DevApp.ToolBox;
|
using System;
|
using System.Collections.Generic;
|
using System.Configuration;
|
using System.Data;
|
using System.Net;
|
using System.Windows.Documents;
|
using System.Windows.Forms;
|
|
namespace Gs.DevApp.UserControl
|
{
|
public partial class ShowUp : DevExpress.XtraEditors.XtraForm
|
{
|
|
/// <summary>
|
/// 回调事件
|
/// </summary>
|
public event EventHandler<UpdateParentEventArgs> UpdateParent;
|
|
string parentGuid = "";
|
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="_parentGuid">父亲guid</param>
|
/// <param name="isXls">如果是xls,显示相应的说明</param>
|
public ShowUp(string _parentGuid, bool isXls = false)
|
{
|
InitializeComponent();
|
this.parentGuid = _parentGuid;
|
this.ucUpFile1.parentGuid = _parentGuid;
|
ucUpFile1.UpChanged += UcUpFile1_UpChanged;
|
|
getBtn();
|
}
|
|
/// <summary>
|
/// 上传后刷新文件列表
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void UcUpFile1_UpChanged(object sender, EventArgs e)
|
{
|
UpdateParent?.Invoke(this,
|
new UpdateParentEventArgs { FilterList = null });
|
Close();
|
}
|
|
private void getBtn()
|
{
|
List<dynamic> lst = new List<dynamic>();
|
lst.Add(new
|
{
|
btnTxt = "检验工具\nXLS模板",
|
xls = "001检验工具.xls"
|
});
|
lst.Add(new
|
{
|
btnTxt = "检验项目\nXLS模板",
|
xls = "002检验项目.xls"//001
|
});
|
|
lst.Add(new
|
{
|
btnTxt = "物料检验项目\nXLS模板",
|
xls = "003物料检验项目.xls"
|
});
|
|
lst.Add(new
|
{
|
btnTxt = "工单后盖码\nXLS模板",
|
xls = "004工单后盖码.xls"
|
});
|
|
foreach (var obj in lst)
|
{
|
SimpleButton btn = new DevExpress.XtraEditors.SimpleButton();
|
btn.ImageOptions.Image = global::Gs.DevApp.Properties.Resources.printarea_32x32;
|
btn.ImageOptions.ImageToTextAlignment = DevExpress.XtraEditors.ImageAlignToText.TopCenter;
|
btn.Name = Guid.NewGuid().ToString();
|
btn.Size = new System.Drawing.Size(120, 120);
|
btn.TabIndex = 1;
|
btn.Text = obj.btnTxt;
|
btn.Margin = new System.Windows.Forms.Padding(10);
|
btn.Tag = obj.xls;
|
this.flowLayoutPanel1.Controls.Add(btn);
|
btn.Click += Btn_Click;
|
}
|
}
|
|
private void Btn_Click(object sender, EventArgs e)
|
{
|
string _guid = Guid.NewGuid().ToString();
|
SimpleButton btn = (SimpleButton)sender;
|
string urlPath = btn.Tag.ToString();//a697b909-5baa-4e74-8df4-87abb1f96240ico.png
|
using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog())
|
{
|
folderBrowserDialog.Description = "选择导出文件的保存路径";
|
DialogResult dialogResult = folderBrowserDialog.ShowDialog();
|
if (dialogResult == DialogResult.OK)
|
{
|
string _folder = folderBrowserDialog.SelectedPath;
|
string _folderName = _folder + "\\" + urlPath;
|
string _url = ConfigurationManager.AppSettings["WebApiUrl"].ToString() + "upload/" + urlPath;
|
using (WebClient client = new WebClient())
|
{
|
client.DownloadFile(_url, _folderName);
|
}
|
ToolBox.MsgHelper.ShowInformation("下载成功!");
|
}
|
}
|
}
|
}
|
}
|