private string HandlerData(HttpContext context) { StringBuilder returnvalue = new StringBuilder(); string itemCode = context.Request["code"]; string itemDes = context.Request["des"]; bool issucess = false; try { CY.GFive.Core.Business.FileDown fileDown = new CY.GFive.Core.Business.FileDown(); fileDown.Date = DateTime.Now; fileDown.DownLoader = DownLoader; fileDown.FileItemCode = itemCode; fileDown.Des = "this is downLoad"; fileDown.Save(); issucess = true; } catch (Exception ex) { throw ex; } finally { if (issucess) { returnvalue.Append("{ result: true}"); } else { returnvalue.Append("{ result: false}"); } } return returnvalue.ToString(); }
protected void Gv_FileItem_RowCommand(object sender, GridViewCommandEventArgs e) { bool issucess = false; if (e.CommandName == "DownLoad") { int Id = 0; try { if (int.TryParse(Gv_FileItem.DataKeys[int.Parse(e.CommandArgument.ToString())].Values["Id"].ToString(), out Id) && Id > 0) { if (CY.GFive.Utility.Extend.FileDownLoad.FileItemDownLoad(Id, Gv_FileItem.DataKeys[int.Parse(e.CommandArgument.ToString())].Values["ItemAddress"].ToString(), Gv_FileItem.DataKeys[int.Parse(e.CommandArgument.ToString())].Values["ItemName"].ToString())) { CY.GFive.Core.Business.FileDown fileDown = new CY.GFive.Core.Business.FileDown(); fileDown.DownLoader = UserCode; fileDown.Date = DownLoadTime; fileDown.FileItemCode = Gv_FileItem.DataKeys[int.Parse(e.CommandArgument.ToString())].Values["FileItemCode"].ToString(); fileDown.Save(); issucess = true; } } } catch (Exception ex) { throw ex; } finally { if (!issucess) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('下载错误,文件可能被移除,请联系管理员!');window.location.href='filelist.aspx';</script>"); } } } }