Exemple #1
0
    /// <summary>
    /// 初始化菜单列表
    /// </summary>
    public void InitMenuList()
    {
        using (HelloWordEntities entity = new HelloWordEntities())
        {
            StringBuilder sb = new StringBuilder();
            List<tbhw_Category> categoryList = entity.tbhw_Category.Where(m => m.category_parent_ky == 0 && m.category_state_code == 0).ToList();
            for (int i = 0; i < categoryList.Count; i++)
            {
                sb.Append("<div class=\"menu_title\">" + categoryList[i].category_name + "</div>");
                int category_ky = categoryList[i].category_ky;
                List<tbhw_Category> childCategoryList = entity.tbhw_Category.Where(m => m.category_parent_ky == category_ky && m.category_state_code == 0).ToList();
                for (int j = 0; j < childCategoryList.Count; j++)
                {
                    if (j == 0)
                    {
                        if (i == 0)
                        {
                            sb.Append(" <div class=\"menu_content\">");

                        }
                        else
                        {
                            sb.Append(" <div class=\"menu_content\" style='display:none'>");
                        }
                    }
                    sb.Append(" <div style='text-align:left;padding-left:15px;'><a href=\"Category/" + Tools.Encrypt(childCategoryList[j].category_name) + "\">" + childCategoryList[j].category_name + "</a></div>");
                    if ((j + 1) == childCategoryList.Count)
                    {
                        sb.Append("</div>");
                    }
                }
            }
            this.menuListHtml.InnerHtml = sb.ToString();
        }
    }
Exemple #2
0
 /// <summary>
 /// 初始化文档排行榜
 /// </summary>
 public void InitDocument()
 {
     HelloWordEntities entity = new HelloWordEntities();
     IQueryable<tbhw_Document> documentList = entity.tbhw_Document.Where(m => m.document_state_code == 0).OrderByDescending(m => m.document_down_count).Take(20);
     this.repDocumentList.DataSource = documentList.ToList();
     this.repDocumentList.DataBind();
 }
Exemple #3
0
 /// <summary>
 /// 初始化文章信息
 /// </summary>
 public void InitArticleList()
 {
     using (HelloWordEntities entity = new HelloWordEntities())
     {
         List<tbhw_Article> articleList = entity.tbhw_Article.Where(m => m.article_state_code == 0).OrderByDescending(m => m.article_add_time).Take(500).ToList();
         this.AspNetPager1.RecordCount = articleList.Count();
         this.repArticleList.DataSource = articleList.Where(m => m.article_state_code == 0).OrderByDescending(m => m.article_add_time).Skip((AspNetPager1.CurrentPageIndex - 1) * AspNetPager1.PageSize).Take(AspNetPager1.PageSize);
         this.repArticleList.DataBind();
     }
 }
Exemple #4
0
    /// <summary>
    /// 获取用户头像
    /// </summary>
    /// <param name="user_ky"></param>
    /// <returns></returns>
    public string GetUserFace(object user_ky)
    {
        int user_ky_1 = Convert.ToInt16(user_ky);
        using (HelloWordEntities entity = new HelloWordEntities())
        {
            tbhw_User user = entity.tbhw_User.Where(m => m.user_ky == user_ky_1).FirstOrDefault();
            if (user == null)
            {
                return "<img src='/userzone/user_face/user_not_face.jpg' class='img-rounded' style='border: solid 1px #ccc; width: 60px; height: 60px'/>";
            }
            else if (user.user_face_img == null || user.user_face_img.Length == 0)
            {
                return "<a href='User/" + Tools.Encrypt(user_ky.ToString()) + "'><img src='/userzone/user_face/user_not_face.jpg' class='img-rounded' style='border: solid 1px #ccc; width: 60px; height: 60px'/></a>";

            }
            else
            {
                return " <a href='User/" + Tools.Encrypt(user_ky.ToString()) + "'><img src='" + user.user_face_img + "' class='img-rounded' style='border: solid 1px #ccc; width: 60px; height: 60px'/></a>";

            }
        }
    }
Exemple #5
0
 /// <summary>
 /// 初始化用户信息
 /// </summary>
 public void InitUser()
 {
     HelloWordEntities entity = new HelloWordEntities();
     var r = (from a in entity.tbhw_User
              join b in entity.tbhw_Article on a.user_ky equals b.article_user_ky
              where a.user_state_code == 0 && b.article_state_code == 0
              group new { a.user_ky, a.user_nick_name, b.article_user_ky, b.article_ky } by new { a.user_ky }
                  into result
                  select new
                  {
                      result.Key,
                      user_nick_name = result.Min(m => m.user_nick_name),
                      article_count = result.Count(m => m.article_ky > 0)
                  }
                      into Q
                      orderby Q.article_count descending
                      select Q).Take(50);
     List<Temp_UserList> list = new List<Temp_UserList>();
     foreach (var item in r)
     {
         list.Add(new Temp_UserList { user_ky = Tools.Encrypt(item.Key.ToString()), user_nick_name = item.user_nick_name, article_count = item.article_count.ToString() });
     }
     this.repUserList.DataSource = list;
     this.repUserList.DataBind();
 }
Exemple #6
0
 /// <summary>
 /// 初始化统计信息
 /// </summary>
 public void InitStatistics()
 {
     HelloWordEntities entity = new HelloWordEntities();
     int article_count = entity.tbhw_Article.Where(m => m.article_state_code == 0).Count();
     int software_count = entity.tbhw_Software.Where(m => m.software_state_code == 0).Count();
     this.spanArticleCount.InnerHtml = article_count.ToString();
     this.spanSoftCount.InnerHtml = software_count.ToString();
 }
Exemple #7
0
 /// <summary>
 /// 初始化软件排行列表
 /// </summary>
 public void InitSoftware()
 {
     HelloWordEntities entity = new HelloWordEntities();
     IQueryable<tbhw_Software> softwareList = entity.tbhw_Software.Where(m => m.software_state_code == 0).OrderByDescending(m => m.software_down_count).Take(20);
     this.repSoftwareList.DataSource = softwareList.ToList();
     repSoftwareList.DataBind();
 }
Exemple #8
0
 /// <summary>
 /// 初始化阅读排行文章信息
 /// </summary>
 public void InitOrderbyRead()
 {
     HelloWordEntities entity = new HelloWordEntities();
     List<tbhw_Article> list = entity.tbhw_Article.Where(m => m.article_state_code == 0).OrderByDescending(m => m.article_view_count).Take(50).ToList();
     this.repReadList.DataSource = list;
     this.repReadList.DataBind();
 }