diff --git a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj index c081f3c5..dcc69df1 100644 --- a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj +++ b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj @@ -1208,6 +1208,7 @@ + @@ -12886,6 +12887,13 @@ PersonUnitList.aspx + + PersonListImg.aspx + ASPXCodeBehind + + + PersonListImg.aspx + WorkPostStatistic.aspx ASPXCodeBehind diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonList.aspx b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonList.aspx index a73c2c13..ec75cc74 100644 --- a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonList.aspx +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonList.aspx @@ -140,6 +140,9 @@ FieldType="Date" Renderer="Date" RendererArgument="yyyy-MM-dd" HeaderText="出场时间" HeaderTextAlign="Center" TextAlign="Center"> + @@ -173,6 +176,10 @@ + protected global::FineUIPro.Window WindowPunishRecord; + /// + /// WindowAtt 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Window WindowAtt; + /// /// Menu1 控件。 /// diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonListImg.aspx b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonListImg.aspx new file mode 100644 index 00000000..3048c539 --- /dev/null +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonListImg.aspx @@ -0,0 +1,157 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PersonListImg.aspx.cs" Inherits="FineUIPro.Web.AttachFile.PersonListImg" %> + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ 注:本多附件上传支持的浏览器版本为:Chrome、Firefox、Safari、IE10+ 。 + + + + + + diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonListImg.aspx.cs b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonListImg.aspx.cs new file mode 100644 index 00000000..5d871c68 --- /dev/null +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonListImg.aspx.cs @@ -0,0 +1,540 @@ +using System; +using System.IO; +using System.Linq; +using BLL; +using Newtonsoft.Json.Linq; +using WIA; +using System.Collections.Generic; +using System.Text; + +namespace FineUIPro.Web.AttachFile +{ + public partial class PersonListImg : PageBase + { + private static readonly string sessionName = "AttachFile.webuploader"; + protected string ParamStr; + + #region 定义项 + public string ToKeyId + { + get + { + return (string)ViewState["ToKeyId"]; + } + set + { + ViewState["ToKeyId"] = value; + } + } + + public string AttachPath + { + get + { + return (string)ViewState["AttachPath"]; + } + set + { + ViewState["AttachPath"] = value; + } + } + + public string MenuId + { + get + { + return (string)ViewState["MenuId"]; + } + set + { + ViewState["MenuId"] = value; + } + } + public string Type + { + get + { + return (string)ViewState["Type"]; + } + set + { + ViewState["Type"] = value; + } + } + + public string Source + { + get + { + return (string)ViewState["Source"]; + } + set + { + ViewState["Source"] = value; + } + } + public string JointCheck + { + get + { + return (string)ViewState["JointCheck"]; + } + set + { + ViewState["JointCheck"] = value; + } + } + #endregion + + #region 加载页面 + /// + /// 加载页面 + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + // 删除选中行 + this.btnDelete.OnClientClick = Grid1.GetNoSelectionAlertReference("请至少选择一项!"); + this.btnDelete.ConfirmText = String.Format("你确定要删除选中的  个文件吗?", Grid1.GetSelectedCountReference()); + Session[sessionName] = null; + this.ToKeyId = Request.QueryString["toKeyId"]; + this.AttachPath = Request.QueryString["path"]; + this.ParamStr = sessionName + "|" + AttachPath; + this.MenuId = Request.QueryString["menuId"]; + this.Type = Request.Params["type"]; + this.GetButtonPower(); + this.BindGrid(); + } + else + { + if (GetRequestEventArgument() == "RebindGrid") + { + this.BindGrid(); + } + } + } + #endregion + + #region BindGrid + /// + /// 绑定GV + /// + private void BindGrid() + { + + Grid1.DataSource = SourceData(); + Grid1.DataBind(); + } + + #endregion + + /// + /// 文件柜专用 + /// + /// + private JArray SourceData() + { + if (Session[sessionName] == null && !string.IsNullOrEmpty(ToKeyId)) + { + JArray temp = new JArray(); + Session[sessionName] = temp; + StringBuilder stxt = new StringBuilder(); + List listToKeyId = new List(); + listToKeyId.Add(ToKeyId + "#1"); + listToKeyId.Add(ToKeyId + "#2"); + listToKeyId.Add(ToKeyId + "#3"); + listToKeyId.Add(ToKeyId + "#4"); + listToKeyId.Add(ToKeyId + "#5"); + IList sourlist = Funs.DB.AttachFile.Where(p => listToKeyId.Contains(p.ToKeyId)).ToList(); + + if (sourlist.Count > 0) + { + + + foreach (var sour in sourlist) + { + JArray jarrayTwo = JArray.Parse(sour.AttachSource); + for (int i = 0; i < jarrayTwo.Count; i++) + { + var tempo = jarrayTwo[i]; + if (sour.ToKeyId == (ToKeyId + "#1")) + { + tempo["FileType"] = "身份证正面"; + } + else if (sour.ToKeyId == (ToKeyId + "#2")) + { + tempo["FileType"] = "保险"; + } + else if(sour.ToKeyId == (ToKeyId + "#3")) + { + tempo["FileType"] = "体检证明"; + } + else if (sour.ToKeyId == (ToKeyId + "#4")) + { + tempo["FileType"] = "安全生产考核合格证书/特种作业操作证"; + } + else if (sour.ToKeyId == (ToKeyId + "#5")) + { + tempo["FileType"] = "身份证背面"; + } + temp.Add(tempo); + } + } + + } + } + + return (JArray)Session[sessionName]; + } + + #region Events + /// + /// 删除按钮 + /// + /// + /// + protected void btnDelete_Click(object sender, EventArgs e) + { + foreach (string rowId in Grid1.SelectedRowIDArray) + { + DeleteRow(rowId); + } + + BindGrid(); + } + + /// + /// 行事件 + /// + /// + /// + protected void Grid1_RowCommand(object sender, GridCommandEventArgs e) + { + if (e.CommandName == "Delete") + { + DeleteRow(e.RowID); + BindGrid(); + } + + if (e.CommandName == "Attach") + { + JArray source = GetSourceData(); + for (int i = 0, count = source.Count; i < count; i++) + { + JObject item = source[i] as JObject; + if (item.Value("id") == e.RowID) + { + try + { + + string savedName = item.Value("savedName"); + string folder = item.Value("folder"); + string xnUrl = AttachPath + "\\" + savedName; + if (!string.IsNullOrEmpty(folder)) + { + xnUrl = folder + savedName; + } + + string url = Funs.RootPath + xnUrl; + if (savedName.Contains("FileUpLoad")) + { + url = Funs.RootPath + savedName.Replace('/', '\\'); + } + FileInfo info = new FileInfo(url); + if (!info.Exists || string.IsNullOrEmpty(savedName)) + { + url = Funs.RootPath + "Images//Null.jpg"; + info = new FileInfo(url); + } + + if (Path.GetExtension(savedName) == ".mp4" || Path.GetExtension(savedName).ToLower() == ".mp4" || Path.GetExtension(savedName) == ".m4v") + { + PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../AttachFile/player.aspx?url={0}", xnUrl.Replace('\\', '/'), "播放 - "))); + } + else + { + if (Path.GetExtension(savedName) == ".gif" || Path.GetExtension(savedName) == ".jpg" || Path.GetExtension(savedName) == ".jpeg" || Path.GetExtension(savedName) == ".bmp" || Path.GetExtension(savedName) == ".png") + { + string httpUrl = Funs.SGGLUrl + xnUrl; + ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", ""); + } + else + { + string fileName = Path.GetFileName(url); + long fileSize = info.Length; + System.Web.HttpContext.Current.Response.Clear(); + //System.Web.HttpContext.Current.Response.ContentType = "application/x-zip-compressed"; + System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream"; + System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); + System.Web.HttpContext.Current.Response.AddHeader("Content-Length", fileSize.ToString()); + System.Web.HttpContext.Current.Response.TransmitFile(url, 0, fileSize); + System.Web.HttpContext.Current.Response.Flush(); + System.Web.HttpContext.Current.Response.End(); + break; + } + } + } + catch (Exception) + { + + } + } + } + } + } + #endregion + + #region GetSourceData + /// + /// 得到Session + /// + /// + private JArray GetSourceData() + { + if (Session[sessionName] == null && !string.IsNullOrEmpty(ToKeyId)) + { + Session[sessionName] = new JArray(); + Model.AttachFile sour = new Model.AttachFile(); + + + sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == ToKeyId); + + + if (sour != null) + { + string url = sour.AttachUrl.Replace('\\', '/'); + List list = Funs.GetStrListByStr(url, ','); + if (list.Count() > 0) + { + int i = 0; + foreach (var item in list) + { + string atturl = Funs.RootPath + item.Replace(';', ' ').Trim(); + if (File.Exists(atturl)) + { + i += 1; + break; + } + } + if (i > 0) + { + Session[sessionName] = JArray.Parse(sour.AttachSource); + } + } + } + } + + return (JArray)Session[sessionName]; + } + + /// + /// + /// + /// + private void DeleteRow(string rowId) + { + JArray source = GetSourceData(); + for (int i = 0, count = source.Count; i < count; i++) + { + JObject item = source[i] as JObject; + if (item.Value("id") == rowId) + { + try + { + string savedName = item.Value("savedName"); + string attachUrl = AttachPath + "\\" + savedName; + if (!string.IsNullOrEmpty(item.Value("folder"))) + { + attachUrl = item.Value("folder") + savedName; + } + File.Delete(Server.MapPath("~/" + attachUrl)); + BLL.LogService.AddSys_Log(this.CurrUser, "删除附件!", null, this.MenuId, BLL.Const.BtnDelete); + } + catch (Exception) + { + // 尝试删除物理文件失败,不做处理 + } + source.RemoveAt(i); + break; + } + } + Session[sessionName] = source; + } + #endregion + + #region 保存按钮事件 + /// + /// 保存按钮事件 + /// + /// + /// + protected void btnSave_Click(object sender, EventArgs e) + { + JArray source = GetSourceData(); + if (!string.IsNullOrEmpty(source.ToString())) + { + string attachUrl = string.Empty; + for (int i = 0, count = source.Count; i < count; i++) + { + JObject item = source[i] as JObject; + if (!string.IsNullOrEmpty(item.Value("folder"))) + { + attachUrl += item.Value("folder") + item.Value("savedName") + ","; + } + else + { + attachUrl += AttachPath + "/" + DateTime.Now.ToString("yyyy-MM") + "/" + item.Value("savedName") + ","; + } + } + if (!string.IsNullOrEmpty(attachUrl)) + { + attachUrl = attachUrl.Substring(0, attachUrl.LastIndexOf(",")).Replace('\\', '/'); + } + ///保存方法 + this.SaveData(source.ToString(), attachUrl); + ShowNotify("保存成功!", MessageBoxIcon.Success); + PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); + } + } + #endregion + + /// + /// 保存附件 + /// + /// + /// + private void SaveData(string source, string attachUrl) + { + UploadFileService.SaveAttachUrl(source, attachUrl, MenuId, ToKeyId); + } + + /// + /// 扫描文件 + /// + /// + /// + protected void btnImageMagnify_Click(object sender, EventArgs e) + { + try + { + DeviceManager manager = new DeviceManagerClass(); + Device device = null; + foreach (DeviceInfo info in manager.DeviceInfos) + { + if (info.Type != WiaDeviceType.ScannerDeviceType) + continue; + device = info.Connect(); + break; + } + Item item = device.Items[1]; + CommonDialogClass cdc = new WIA.CommonDialogClass(); + ImageFile imageFile = null; + imageFile = cdc.ShowAcquireImage(WIA.WiaDeviceType.ScannerDeviceType, + WIA.WiaImageIntent.TextIntent, + WIA.WiaImageBias.MaximizeQuality, + "{00000000-0000-0000-0000-000000000000}", + true, + true, + false); + if (imageFile != null) + { + var buffer = imageFile.FileData.get_BinaryData() as byte[]; + using (MemoryStream ms = new MemoryStream()) + { + ms.Write(buffer, 0, buffer.Length); + string filePath = Server.MapPath("~/") + AttachPath; ///文件夹 + if (!Directory.Exists(filePath)) + { + Directory.CreateDirectory(filePath); + } + string name = "\\"; + var menu = BLL.SysMenuService.GetSysMenuByMenuId(this.MenuId); + if (menu != null) + { + name += menu.MenuName; + + } + name += Funs.GetNewFileName() + ".jpg"; + string url = filePath + name; + if (!string.IsNullOrEmpty(url)) + { + using (FileStream fs = new FileStream(url, FileMode.Create, FileAccess.Write)) + { + ms.WriteTo(fs); + string attachUrl = AttachPath + name; + if (!string.IsNullOrEmpty(attachUrl)) + { + attachUrl = attachUrl.Replace('/', '\\'); + } + string oldSrouce = string.Empty; + string FullPath = string.Empty; + Model.AttachFile att = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == this.ToKeyId); + if (att != null && !string.IsNullOrEmpty(att.AttachUrl)) + { + FullPath = att.AttachUrl + "," + attachUrl; + oldSrouce = att.AttachSource; + } + else + { + FullPath = attachUrl; + } + string source = BLL.UploadFileService.GetSourceByAttachUrl(attachUrl, buffer.Length, oldSrouce); + //this.SaveData(source, FullPath); ///保存方法 + Session[sessionName] = JArray.Parse(source); + } + + this.BindGrid(); + ShowNotify("扫描完成!", MessageBoxIcon.Success); + + } + } + } + } + catch + { + ShowNotify("请检查扫描仪是否连接正确!", MessageBoxIcon.Warning); + } + } + + #region 获取权限按钮 + /// + /// 获取按钮权限 + /// + /// + /// + private void GetButtonPower() + { + if (this.Type == "0") + { + this.toolBar.Hidden = false; + } + else if (this.Type == "-1") + { + this.toolBar.Hidden = true; + } + else + { + if (this.CurrUser != null && this.MenuId != Const.ProjectPunishNoticeStatisticsMenuId) + { + var buttonList = CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, MenuId); + if (buttonList.Count > 0) + { + if (buttonList.Contains(Const.BtnSave) || buttonList.Contains(Const.BtnAuditing)) + { + this.toolBar.Hidden = false; + } + } + } + } + } + #endregion + + protected void btnPlay_Click(object sender, EventArgs e) + { + + } + } +} diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonListImg.aspx.designer.cs b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonListImg.aspx.designer.cs new file mode 100644 index 00000000..62c758dc --- /dev/null +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonListImg.aspx.designer.cs @@ -0,0 +1,107 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace FineUIPro.Web.AttachFile +{ + + + public partial class PersonListImg + { + + /// + /// form1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// PageManager1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.PageManager PageManager1; + + /// + /// Grid1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Grid Grid1; + + /// + /// toolBar 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Toolbar toolBar; + + /// + /// btnImageMagnify 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnImageMagnify; + + /// + /// btnSelectFiles 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnSelectFiles; + + /// + /// btnDelete 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnDelete; + + /// + /// ToolbarSeparator2 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.ToolbarSeparator ToolbarSeparator2; + + /// + /// btnSave 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnSave; + + /// + /// Window1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Window Window1; + } +}