[實戰]MVC5+EF6+MySql企業網盤實戰(28)——其他列表

來源:互聯網
上載者:User

標籤:

寫在前面

本篇文章將實現,其他檔案類型的列表。

系列文章

[EF]vs15+ef6+mysql code first方式

[實戰]MVC5+EF6+MySql企業網盤實戰(1)

[實戰]MVC5+EF6+MySql企業網盤實戰(2)——使用者註冊

[實戰]MVC5+EF6+MySql企業網盤實戰(3)——驗證碼

[實戰]MVC5+EF6+MySql企業網盤實戰(4)——上傳頭像

[Bootstrap]modal彈出框

[實戰]MVC5+EF6+MySql企業網盤實戰(5)——登入介面,頭像等比例壓縮

[實戰]MVC5+EF6+MySql企業網盤實戰(5)——頁面模板

[實戰]MVC5+EF6+MySql企業網盤實戰(5)——ajax方式註冊

[實戰]MVC5+EF6+MySql企業網盤實戰(6)——ajax方式登入

[實戰]MVC5+EF6+MySql企業網盤實戰(7)——檔案上傳

[實戰]MVC5+EF6+MySql企業網盤實戰(8)——檔案下載、刪除

[實戰]MVC5+EF6+MySql企業網盤實戰(9)——編輯檔案名稱

[實戰]MVC5+EF6+MySql企業網盤實戰(10)——建立檔案夾

[實戰]MVC5+EF6+MySql企業網盤實戰(11)——建立檔案夾2

[實戰]MVC5+EF6+MySql企業網盤實戰(12)——建立檔案夾和上傳檔案

[實戰]MVC5+EF6+MySql企業網盤實戰(13)——編輯檔案夾

[實戰]MVC5+EF6+MySql企業網盤實戰(14)——邏輯重構

[實戰]MVC5+EF6+MySql企業網盤實戰(14)——思考

[實戰]MVC5+EF6+MySql企業網盤實戰(15)——邏輯重構2

[實戰]MVC5+EF6+MySql企業網盤實戰(16)——邏輯重構3

[實戰]MVC5+EF6+MySql企業網盤實戰(17)——思考2

[實戰]MVC5+EF6+MySql企業網盤實戰(18)——檔案上傳,下載,修改

[實戰]MVC5+EF6+MySql企業網盤實戰(19)——BJUI和ztree

[實戰]MVC5+EF6+MySql企業網盤實戰(20)——Bootstrap Paginator

[實戰]MVC5+EF6+MySql企業網盤實戰(21)——網盤動作記錄

[實戰]MVC5+EF6+MySql企業網盤實戰(22)——圖片列表

[實戰]MVC5+EF6+MySql企業網盤實戰(23)——文檔列表

 [實戰]MVC5+EF6+MySql企業網盤實戰(24)——視頻列表

 [實戰]MVC5+EF6+MySql企業網盤實戰(25)——種子列表

 [實戰]MVC5+EF6+MySql企業網盤實戰(26)——音樂列表

[實戰]MVC5+EF6+MySql企業網盤實戰(27)——應用列表

[實戰]MVC5+EF6+MySql企業網盤實戰(28)——其他列表

實現

這裡同樣很好實現,因為在上傳檔案的時候,已經通過檔案的表徵圖進行區別了,這裡尋找的時候,只需根據表徵圖篩選就行了。

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 OtherController : 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 GetOthers()        {            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("OtherType.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 };        }    }}
View Code

前端代碼

@{    ViewBag.Title = "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(‘/Other/GetOthers?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>
View Code

測試

總結

頁面上面的除了我的分享功能,其他的功能基本上都實現了。

[實戰]MVC5+EF6+MySql企業網盤實戰(28)——其他列表

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.