public ActionResult SaveNews(IFormCollection collection) { tzb news = new tzb(); Tuple <tzb, attach> Models = Tuple.Create(new tzb(), new attach()); var model = HttpContext.Session.Get("CurrentUser"); //获取session if (model == null) { return(Success("/qian/USER/Login")); } try { if (ModelState.IsValid) { var updateResult = TryUpdateModelAsync <Tuple <tzb, attach> >(Models); //将传递过来的对象转换 news = Models.Item1; using (var db = tzbRepository.Connection) { string hex = System.Text.Encoding.Default.GetString(model); //获取json数据 ry sta = JsonConvert.DeserializeObject <ry>(hex); //转换成model数据 string userID = sta.id; string userName = sta.yhm; FTPHelper ftps = new FTPHelper(_FtpConnection.Value.FtpServerIP, _FtpConnection.Value.FtpRemotePath + "/" + news.id, _FtpConnection.Value.FtpUserID, _FtpConnection.Value.FtpPassword); List <FileStruct> files = ftps.GetFileAndDirectoryList(_FtpConnection.Value.FtpRemotePath + "/tbz/" + news.id + "/"); if (files != null) { foreach (var file in files) { attach attach = new attach(); attach.tp_name = file.Name; attach.yw_id = news.id; attach.create_time = DateTime.Now; attach.tp_lj = _FtpConnection.Value.FtpRemotePath + "/tbz/" + news.id; attachRepository.AddFile(attach, userName, attach.tp_name); } } tzbRepository.AddNews(news, userName); if (news.TSTATUS == 0) { return(Success("保存成功。")); } else { return(Success("未插入成功。")); } } } else { return(View()); } } catch (Exception ex) { return(Error("保存数据库出错")); } }
public IActionResult ft(string keyValue) { tzb Models = new tzb(); IList <attach> attach = attachRepository.GetPicById(keyValue); Models.id = Guid.NewGuid().ToString(); return(View(Tuple.Create(Models, attach))); }
public IActionResult tail(string keyValue) { //打开当前页即可 //帖子和帖子对应的附件 tzb tzb = this.tzbRepository.GetById(keyValue); //一条贴子可能对应多张图片 List <attach> attach = this.attachRepository.GetATTACH(tzb.id); //回复的内容---- List <yjfk> yjfk = this.yjfkRepository.Gethflb(tzb.id); mh_attach_tzb_yjfk mh_attach_tzb_yjfk = new mh_attach_tzb_yjfk(); mh_attach_tzb_yjfk.tzb = tzb; mh_attach_tzb_yjfk.yjfk = yjfk; mh_attach_tzb_yjfk.attach = attach; return(View(mh_attach_tzb_yjfk)); }