string userId = "a3e8f66f-3552-4626-9ee2-f7ddd8b106d8"; //GetUData.User_Id; public ActionResult Index() { ViewBag.RuteUrl = RuteUrl(); VipShopModel vshopMode = new VipShopModel(); var mql = TT_ShopSet.SelectAll().Where(TT_ShopSet.UserId.Equal(userId)); TT_Shop item = OPBiz.GetEntity(mql); if (item != null) { item.UserId = new Guid();//不显示给前端 安全考虑 var mqlimg = TT_FilesTransactSet.SelectAll().Where(TT_FilesTransactSet.SourceTable.Equal("TT_Shop").And(TT_FilesTransactSet.ToId.Equal(item.ShopId.ToString()))); List <TT_FilesTransact> listImg = OPFileBiz.GetOwnList(mqlimg); //List<FileJson> img = OPFileBiz.GetFList(listImg); //vshopMode.ImgList = img; vshopMode.ShopItem = item; ViewBag.listImgJson = OPFileBiz.GetJson(listImg); vshopMode.TransactionList = Transaction(); //ViewData.Model = item; return(View(vshopMode)); } else { return(RedirectToAction("Index", "User")); } }
public JsonResult GetInfo(string ID) { var mql2 = TT_FilesTransactSet.SelectAll().Where(TT_FilesTransactSet.FileId.Equal(ID)); TT_FilesTransact Rmodel = OPBiz.GetEntity(mql2); // groupsBiz.Add(rol); return(Json(Rmodel, JsonRequestBehavior.AllowGet)); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //context.Response.Write("Hello World"); string action = context.Request["action"]; HttpReSultMode jmsg = new HttpReSultMode(); switch (action) { case "addImg": //上传单图片 返回文件信息json jmsg = addImg(context); context.Response.Write(JsonHelper.ToJson(jmsg)); context.Response.End(); break; case "addFile": //上传文件 返回文件信息json jmsg = addFile(context); context.Response.Write(JsonHelper.ToJson(jmsg)); context.Response.End(); break; case "GetFileList": //根据id集获取文件列表 #region string id = context.Request["ToId"]; string SourceTable = context.Request["SourceTable"]; if (!string.IsNullOrEmpty(id)) { var mql = TT_FilesTransactSet.SelectAll().Where(TT_FilesTransactSet.ToId.Equal(id).And(TT_FilesTransactSet.SourceTable.Equal(SourceTable))); List <TT_FilesTransact> list = OPBiz.GetOwnList(mql); context.Response.Write(JsonHelper.ToJson(list, true)); } else { context.Response.Write("[]"); } context.Response.End(); #endregion break; case "SaveToid": //保存更改ToID #region string Tid = FilterTools.FilterSpecial(context.Request["ToId"]); string IdSet = FilterTools.FilterSpecial(context.Request["IdSet"]); if (!string.IsNullOrEmpty(context.Request["ToId"]) && !string.IsNullOrEmpty(context.Request["IdSet"])) { string sql = " update TT_FilesTransact set ToId='" + Tid + "' where FileId in (" + IdSet + ")"; int i = OPBiz.ExecuteSqlWithNonQuery(sql); if (i > 0) { jmsg.Code = 11; jmsg.Data = i.ToString(); jmsg.Msg = "上传成功"; } else { jmsg.Code = -11; jmsg.Data = "0"; jmsg.Msg = "上传失败"; } } else { jmsg.Code = -11; jmsg.Data = "0"; jmsg.Msg = "数据为空"; } context.Response.Write(JsonHelper.ToJson(jmsg, true)); context.Response.End(); #endregion break; case "Delfile": //删除文件 #region if (!string.IsNullOrEmpty(context.Request["IdSet"])) { string[] IDSet = context.Request["IdSet"].ToString().Split(','); var mql2 = TT_FilesTransactSet.FileId.In(IDSet); var selectm = TT_FilesTransactSet.SelectAll().Where(mql2); List <TT_FilesTransact> listDel = OPBiz.GetEntities(selectm); //数据库删除 int f = OPBiz.Remove <TT_FilesTransactSet>(mql2); if (f > 0) { jmsg.Code = 11; jmsg.Data = f.ToString(); jmsg.Msg = "删除成功"; #region 文件删除 try { string HttpFileRoute = ConfigurationManager.AppSettings["HttpFileRoute"].ToString(); //文件保存本地路径根目录 for (int i = 0; i < listDel.Count; i++) { string path = HttpFileRoute + listDel[i].RelativePath; ZFiles.FilePicDelete(path); } } catch (Exception ex) { //jmsg.Code = -13; //jmsg.Data = ex.Message; //jmsg.Msg = "删除失败"; } #endregion } else { jmsg.Code = -11; jmsg.Data = "0"; jmsg.Msg = "删除失败"; } } else { jmsg.Code = -11; jmsg.Data = "0"; jmsg.Msg = "数据为空"; } context.Response.Write(JsonHelper.ToJson(jmsg, true)); context.Response.End(); #endregion break; case "Download": #region if (!string.IsNullOrEmpty(context.Request["Url"])) { // 检查请求下载文件的有效性 string filePath = System.Web.HttpContext.Current.Server.MapPath(context.Request["Url"]); if (!System.IO.File.Exists(filePath)) { throw new ArgumentException("无效文件,文件不存在!"); } //WriteFile实现下载 string fileName = context.Request["fileName"]; //客户端保存的文件名 FileInfo fileInfo = new FileInfo(filePath); context.Response.Clear(); context.Response.ClearContent(); context.Response.ClearHeaders(); context.Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName); context.Response.AddHeader("Content-Length", fileInfo.Length.ToString()); context.Response.AddHeader("Content-Transfer-Encoding", "binary"); context.Response.ContentType = "application/octet-stream"; context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312"); context.Response.WriteFile(fileInfo.FullName); context.Response.Flush(); context.Response.End(); } #endregion break; } }