一个门户网站下载频道的技术总结

 

【任务描述】

1、下载频道的后台设计,数据库设计;

2、分析下载频道的分类及分类级别(文章分类、文章,第一级资源分类、资源分类、资源、下载者的IP);

3、实现曾、删、改功能及上传、下载功能;

4、后台的搜索,又加了统计图的概念;

5、考虑前台优化问题,用Repeater调数据;

6、考虑到资源分类需要四级,最后一级不显示在前台所以写了(三个页面,分别是:Network.aspx(分类)、NetWorkSort.aspx(资源列表)、DownloadList.aspx((下载)而它的.cs页面需要接下载这的IP),文章列表(Information.aspx)文章(Article.aspx)搜索(Search.aspx

母板页显示头和尾而其他页面调用;

7、资源分类、资源列表、文章列表和搜索需要分页;

8、静态化;

9、整合前后台;

【技术点】

1MVC三层架构(Model+DAL+Web)

2URL重写;

3ajaxFCK编辑器;

4、单元测试;

5、封装ADO.NET,使DAL执行一条sql语句只要一行c#代码;

6、封装多条件查询功能;

7、上传、下载、分页、搜索及分页搜索和上一篇、下一篇;

8、前台的一个小的站点统计;

 

【收获体验】

经过三个月的学习,自己对代码有了一些熟练。在次学习中我得到了很多的启发,明白了一些道理。我还在次学习之中得到了很多人的认可,最最重要的是,知我认识到了知识的重要性和自己用了一定的自学能力。

前台调用母板页调数据

现在母板页的cs页面  定义

public Repeater lbNavPath1

    {

        get { return this.Repeater1; }

        set { this.Repeater1 = value; }

    }

然后在搜索的cs页面调用

  this.Master.lbNavPath1.DataSource = SortArticleDAL.GetClassDataSet();

                        this.Master.lbNavPath1.DataBind();

搜索分页:

  string sort = Request.Form["SearchSelect"];

        

            string operation = Request.QueryString["operation"];

                if (null == sort)

                {

                    if (null == operation)

                    {

                        this.Master.lbNavPath1.DataSource = SortArticleDAL.GetClassDataSet();

                        this.Master.lbNavPath1.DataBind();

                        Dictionary<string, string> param = null;

                        if ("POST".Equals(Request.HttpMethod))

                        {

                            param = new Dictionary<string, string>();

                            param.Add("sortid", Request.Form["sortid"]);

                            param.Add("title", Request.Form["title"]);

                            Session["_STUDENT_LIST2_PARAM_"] = param;

                        }

                        else if ("GET".Equals(Request.HttpMethod))

                        {

                            param = (Dictionary<string, string>)Session["_STUDENT_LIST2_PARAM_"];

                        }

                        int page = Request.QueryString["page"] == null ? 1 : int.Parse(Request.QueryString["page"]);

 

                        Pager pager = SortArticleDAL.SearchResource1(page, param);

 

                        this.Repeater4.DataSource = pager.DS;

                        this.Repeater4.DataBind();

 

                        this.pagerNav.InnerHtml = pager.getPagerHTML(100, "Search.aspx");

                    }

                    else if ("text".Equals(operation))

                    {

                        this.Master.lbNavPath1.DataSource = SortArticleDAL.GetClassDataSet1();

                        this.Master.lbNavPath1.DataBind();

                        Dictionary<string, string> param = null;

                        if ("POST".Equals(Request.HttpMethod))

                        {

                            param = new Dictionary<string, string>();

                            param.Add("sortid", Request.Form["sortid"]);

                            param.Add("title", Request.Form["title"]);

                            Session["_STUDENT_LIST2_PARAM_"] = param;

 

                        }

                        else if ("GET".Equals(Request.HttpMethod))

                        {

                            param = (Dictionary<string, string>)Session["_STUDENT_LIST2_PARAM_"];

                        }

 

                        int page = Request.QueryString["page"] == null ? 1 : int.Parse(Request.QueryString["page"]);

                        Pager pager = SortArticleDAL.SearchArticle1(page, param);

 

                        this.Repeater3.DataSource = pager.DS;

                        this.Repeater3.DataBind();

 

                        this.pagerNav.InnerHtml = pager.getPagerHTML(100, "Search.aspx");

 

                    }

                }

          else if ("resource".Equals(sort))

            {

                this.Master.lbNavPath1.DataSource = SortArticleDAL.GetClassDataSet();

                this.Master.lbNavPath1.DataBind();

                Dictionary<string, string> param = null;

                if ("POST".Equals(Request.HttpMethod))

                {

                    param = new Dictionary<string, string>();

                    param.Add("sortid", Request.Form["sortid"]);

                    param.Add("title", Request.Form["title"]);

                    Session["_STUDENT_LIST2_PARAM_"] = param;

                }

                else if ("GET".Equals(Request.HttpMethod))

                {

                    param = (Dictionary<string, string>)Session["_STUDENT_LIST2_PARAM_"];

                }

                int page = Request.QueryString["page"] == null ? 1 : int.Parse(Request.QueryString["page"]);

 

                Pager pager = SortArticleDAL.SearchResource1(page, param);

 

                this.Repeater4.DataSource = pager.DS;

                this.Repeater4.DataBind();

 

                this.pagerNav.InnerHtml = pager.getPagerHTML(100, "Search.aspx");

 

            }

            else if ("article".Equals(sort))

            {

                this.Master.lbNavPath1.DataSource = SortArticleDAL.GetClassDataSet1();

                this.Master.lbNavPath1.DataBind();

                Dictionary<string, string> param = null;

                if ("POST".Equals(Request.HttpMethod))

                {

                    param = new Dictionary<string, string>();

                    param.Add("sortid", Request.Form["sortid"]);

                    param.Add("title", Request.Form["title"]);

                    Session["_STUDENT_LIST2_PARAM_"] = param;

 

                }

                else if ("GET".Equals(Request.HttpMethod))

                {

                    param = (Dictionary<string, string>)Session["_STUDENT_LIST2_PARAM_"];

                }

 

                int page = Request.QueryString["page"] == null ? 1 : int.Parse(Request.QueryString["page"]);

                Pager pager = SortArticleDAL.SearchArticle1(page, param);

 

                this.Repeater3.DataSource = pager.DS;

                this.Repeater3.DataBind();

 

                this.pagerNav.InnerHtml = pager.getPagerHTML(100, "Search.aspx");

 

               

 

 

            }

前台的站点统计:

  protected string x;

 

    protected string xx;

 

    protected string ip;

protected string size;

 

 

            Resource x = new Resource();

            this.x = ResourceDAL.GetClassCount(x).ToString();

            this.DataBind();

            Article xx = new Article();

            this.xx = ArticleDAL.GetClassCount1(xx).ToString();

            this.DataBind();

 

            Download ip = new Download();

            this.ip = DownloadDAL.GetClassTotalCount(ip).ToString();

            this.DataBind();

            Resource size = new Resource();

<%=this.x%>

还要在DAL层写sql语句

后台的上传下载

 

        if (this.FileUpload1.HasFile)

        {// 判断是否有文件上传

            // 原来的扩展名(取得的扩展名包括“.”)

           

 

            Resource resource = new Resource();

            resource.Title = tbTitle.Text;

            resource.Sortid = int.Parse(ddlSortid.SelectedValue);

         

           

            string Ext = Path.GetExtension(this.FileUpload1.FileName).ToLower();

            resource.Path = Guid.NewGuid() + Ext;

            resource.Userid = this.GetLoginUserId();

            int OLdSize = FileUpload1.PostedFile.ContentLength;

            resource.Size = int.Parse(OLdSize.ToString());

            string OldType = FileUpload1.PostedFile.ContentType;

            resource.Ext = Ext.ToString();

             resource.Type = OldType;

             resource.Indate =System.DateTime.Now;

           resource.Language = tbLanguage.Text;

           resource.Sort = tbSort.Text;

           resource.Platform = tbPlatfrom.Text;

           resource.License = tbLicense.Text;

           resource.Authentication = tbAuthentication.Text;

           resource.Company = tbCompany.Text;

           resource.Connection = tbConnection.Text;

           resource.Keys = tbKeys.Text;

           resource.Clicktimes = int.Parse(tbClicktimes.Text);

           resource.Downloadtimes = int.Parse(tbDownloadtimes.Text);

 

           int x = ResourceDAL.AddResource(resource);

            string Url = "~/upload/download/" + resource.Path;

          

            string FullPath = HttpContext.Current.Server.MapPath(Url);

            try

            {

          

                this.FileUpload1.SaveAs(FullPath);

                HttpContext.Current.Response.Write("<script>alert('文件已成功上传。');</script>");

            }

            catch { }

        }

        else

        {

            HttpContext.Current.Response.Write("<script>alert('请选择上传的文件');</script>");

       }

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值