[实战]MVC5+EF6+MySql企业网盘实战(23)——文档列表
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了[实战]MVC5+EF6+MySql企业网盘实战(23)——文档列表,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3801字,纯文字阅读大概需要6分钟。
内容图文
= "Lists"; Layout = "~/Views/Shared/_Layout.cshtml"; } <script> $(function () { var imgElement = $(‘#docmentpage‘); var options = { size: "large", bootstrapMajorVersion: 3, //当前页 currentPage: 1, //可以改变显示的页码数 numberOfPages: 5, //总页数 totalPages: 5 }; function requestServer(pageIndex) { $.getJSON(‘/Document/GetDocuments?page=‘ + pageIndex, function (data) { console.log(data); data = JSON.parse(data); if (data.total <= pageIndex) { options.totalPages = pageIndex; } else { options.totalPages = data.total; }; $(‘#dvdocument‘).html(‘‘); $(‘<table class="table table-bordered table-hover table-striped table-top" id="tbdocument"><tr><th>文件名</th> <th>文件大小</th><th>创建时间</th> </tr></table>‘).appendTo($(‘#dvdocument‘));; for (var i = 0; i < data._data.length; i++) { var current = data._data[i]; $(‘<tr><td data-id=‘ + current.Id + ‘><img src="‘ + current.FileIcon + ‘">‘ + current.Name + ‘</td><td>‘ + current.Size + ‘</td><td>‘ + ChangeDateFormat(current.Dt) + ‘</td></tr>‘).appendTo($(‘#tbdocument‘)); }; imgElement.bootstrapPaginator(options); }); }; function loadData(pageIndex) { options.onPageClicked = function (e, originalEvent, type, page) { //页码单击事件 console.log(page); options.currentPage = page; requestServer(page); }; requestServer(pageIndex); imgElement.bootstrapPaginator(options); }; loadData(1); }); </script> <div class="tableContent" style="width:95%;" id="dvdocument"> </div> <div style="width:95%;position:relative;margin-top:10px"> <ul id=‘docmentpage‘ class="bjui-pageFooter" style="margin:0 auto; margin-left:30%;"></ul> </div>服务端代码
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Script.Serialization; using Wolfy.NetDisk.BLL; using Wolfy.NetDisk.IBLL; using Wolfy.NetDisk.Model; using Wolfy.NetDisk.Site.Models; namespace Wolfy.NetDisk.Site.Controllers { public class DocumentController : Controller { private IMyFileServiceRepository _myFileServiceRepository = new MyFileServiceRepository(); private ILogServiceRepository _logServiceRepository = new LogServiceRepository(); private IFileTypeServiceRepository fileTypeServiceRepository = new FileTypeServiceRepository(); // // GET: /Images/ public ActionResult Lists() { UserInfo user = Session["user"] as UserInfo; if (user == null) { return RedirectToAction("Login", "UserInfo"); } return View(); } [HttpGet] public JsonResult GetDocuments() { UserInfo userInfo = Session["user"] as UserInfo; int page = Convert.ToInt32(Request.Params["page"]); if (page <= 0) { page = 1; } if (userInfo == null) { RedirectToAction("Login", "UserInfo"); } int pageSize = 10; int recordCount = 0; var documentPaged = _myFileServiceRepository.FindPaged<DateTime>(page, pageSize, out recordCount, x => x.User.Id == userInfo.Id && x.IsDelete == false && (x.FileIcon.Contains("DocType.png") || x.FileIcon.Contains("XlsType.png") || x.FileIcon.Contains("PptType.png") || x.FileIcon.Contains("PdfType.png") || x.FileIcon.Contains("TxtType.png")), false, x => x.CreateDt); int totalPage = Convert.ToInt32(Math.Ceiling(recordCount * 1.0 / pageSize)); List<MyFileViewModel> lstMyFileViewModel = new List<MyFileViewModel>(); foreach (var item in documentPaged) { lstMyFileViewModel.Add(new MyFileViewModel() { Id = item.Id, FileIcon = item.FileIcon, FileServerUrl = "/NetDisk/" + item.FileMd5 + item.FileExt, Name = item.Name, FileThumnailUrl = string.Empty, Size = item.FileSize, Dt = item.CreateDt }); } return new JsonResult() { Data = new JavaScriptSerializer().Serialize(new { _data = lstMyFileViewModel, _code = 200, total = totalPage }), JsonRequestBehavior = JsonRequestBehavior.AllowGet }; } } }
测试
总结
实现起来还是比较简单的,马上就2016年了,祝大家元旦快乐。
[实战]MVC5+EF6+MySql企业网盘实战(23)——文档列表
标签:
本文系统来源:http://www.cnblogs.com/wolf-sun/p/5092633.html
内容总结
以上是互联网集市为您收集整理的[实战]MVC5+EF6+MySql企业网盘实战(23)——文档列表全部内容,希望文章能够帮你解决[实战]MVC5+EF6+MySql企业网盘实战(23)——文档列表所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。