Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (23)--Document list

Source: Internet
Author: User
Tags mysql code

Write in front

The previous article implements the picture list, this article implements the document list to be pro, because the logic basically resembles, only then the query condition is different. This is where the txt,doc,docx,ppt,pptx,xls,xlsx files are grouped into a list of documents.

Series Articles

[Ef]vs15+ef6+mysql Code First mode

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (1)

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (2)--User Registration

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (3)--Verification code

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (4)--Upload Avatar

[Bootstrap]modal Popup box

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (5)--login interface, avatar and other proportional compression

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (5)--page template

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (5)--ajax mode registration

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (6)--ajax mode login

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (7)--File upload

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (8)--File download, delete

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (9)--Edit file name

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (10)--New Folder

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (11)--New Folder 2

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (12)--new folder and upload file

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (13)--Edit folder

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (14)--Logical reconstruction

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (14)--thinking

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (15)--Logical refactoring 2

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (16)--Logical refactoring 3

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (17)--Thinking 2

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (18)--File upload, download, modify

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (--BJUI) and Ztree

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (--bootstrap) Paginator

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (21)--Network disk operation log

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (22)--image list

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (23)--Document list

Realize

The code is basically the same as the picture list, considering whether to use a template, but think about how you would like to expand the list of files for each type later, or put it in a single controller. Think about whether there is a better way to achieve it. This is the first thing to do here.

Front-end Code

@{Viewbag.title="Lists"; Layout="~/views/shared/_layout.cshtml";
} <script>$ (function () {varImgElement = $ ('#docmentpage'); varOptions ={size:"Large", Bootstrapmajorversion:3,
            //Current PageCurrentPage:1,
            //You can change the number of pages displayedNumberofpages:5,
            //Total PagesTotalPages: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 > FileName </th> <th> file size </th><th> creation time </th> </tr></table>'). AppendTo ($ ('#dvdocument'));;  for(vari =0; i < data._data.length; i++) {
                    varCurrent =Data._data[i]; $('<TR><TD data-id='+ Current. Id +'>'+ 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) {//page Number Click event
Console.log (page); Options.currentpage=page;

            Requestserver (page);
            };
            Requestserver (PageIndex);

        Imgelement.bootstrappaginator (options);

        }; LoadData (1);
}); </script> <divclass="tablecontent"style="width:95%;"Id="dvdocument"> </div> <div style="width:95%;p osition:relative;margin-top:10px"> <ul id='Docmentpage' class="Bjui-pagefooter"style="margin:0 Auto; margin-left:30%;"></ul> </div>

Service-side code

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;usingSYSTEM.WEB.MVC;usingSystem.Web.Script.Serialization;usingWolfy.NetDisk.BLL;usingWolfy.NetDisk.IBLL;usingWolfy.NetDisk.Model;usingWolfy.NetDisk.Site.Models; namespaceWolfy.NetDisk.Site.Controllers { Public classDocumentcontroller:controller {PrivateImyfileservicerepository _myfileservicerepository =Newmyfileservicerepository (); PrivateIlogservicerepository _logservicerepository =Newlogservicerepository (); PrivateIfiletypeservicerepository filetypeservicerepository =Newfiletypeservicerepository (); //
        //GET:/images/
         PublicActionResult Lists () {UserInfo user= session["User"] asUserInfo; if(User = =NULL)
            {
                returnRedirecttoaction ("Login","UserInfo"); }
            returnView (); } [HttpGet] PublicJsonresult getdocuments () {UserInfo UserInfo= session["User"] asUserInfo; intpage = Convert.ToInt32 (request.params["page"]); if(Page <=0) {page=1; }
            if(UserInfo = =NULL) {redirecttoaction ("Login","UserInfo"); }
            intPageSize =Ten; intRecordCount =0; vardocumentpaged = _myfileservicerepository.findpaged<datetime> (page, PageSize, outRecordCount, 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); intTotalpage = Convert.ToInt32 (math.ceiling (RecordCount *1.0/pageSize)); List<MyFileViewModel> Lstmyfileviewmodel =NewList<myfileviewmodel>(); foreach(varIteminchdocumentpaged) {Lstmyfileviewmodel.add (NewMyfileviewmodel () {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 NewJsonresult () {Data =NewJavaScriptSerializer (). Serialize (New{_data = Lstmyfileviewmodel, _code = $, total = Totalpage}), Jsonrequestbehavior =Jsonrequestbehavior.allowget}; }

    }
}

Test

Summarize

Implementation is still relatively simple, immediately on the 2016, I wish you a happy New Year's day.

Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (23)--Document list

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.