/// <summary> /// 获取热门标签 /// </summary> /// <returns></returns> public static string GetHotTags() { DataTable dt = null; System.Web.HttpContext http = System.Web.HttpContext.Current; if (http.Cache["dt_sta"] != null) { dt = (DataTable)http.Cache["dt_sta"]; } try { object o = dt.Rows[0]["t_name"]; } catch { string sql = "select top 50 [t_name],[t_cnt] from [blog_tags] order by [t_cnt] desc"; dt = DB.GetTable(sql); http.Cache.Insert("dt_hottag", dt, null, DateTime.Now.AddDays(1), System.Web.Caching.Cache.NoSlidingExpiration); } StringBuilder sb = new StringBuilder(); foreach (DataRow row in dt.Select("", "t_name asc")) { sb.AppendFormat("<a href='/tag/{1}{3}' style='font-size:{2}px'>{0}</a> ", row["t_name"], row["t_name"].ToString().Replace(" ", "+"), Math.Min(((int)row["t_cnt"] + 9), 28), Settings.Ext); } return(sb.ToString()); }
public static void Setup() { DataTable dt = DB.GetTable("select [t_name] from [blog_tags] order by [t_name]"); foreach (DataRow row in dt.Rows) { Tag.Add(row[0].ToString().ToLower()); } }
private void Load() { string sql = "select * from [users] where [_name]='{0}';"; sql = String.Format(sql, _name.Replace("'", "")); DataTable dt = DB.GetTable(sql); if (dt == null || dt.Rows.Count == 0) { _name = ""; return; } DataRow row = dt.Rows[0]; _name = row["_name"].ToString(); _password = row["_password"].ToString(); _fullname = row["fullname"].ToString(); _sex = row["sex"].ToString(); try { _birthday = DateTime.Parse(row["birthday"].ToString()); } catch { _birthday = DateTime.Parse("1980-1-1"); } _email = row["email"].ToString(); _url = row["url"].ToString(); _hangye = row["hangye"].ToString(); _state = row["state"].ToString(); _city = row["city"].ToString(); _qq = row["qq"].ToString(); _msn = row["msn"].ToString(); _jianjie = row["jianjie"].ToString(); _xingqu = row["xingqu"].ToString(); _qianming = row["qianming"].ToString(); _blogtitle = row["blog_title"].ToString(); _blogsubtitle = row["blog_subtitle"].ToString(); try { _uptime = DateTime.Parse(row["uptime"].ToString()); } catch { _uptime = DateTime.Now; } _showbirthday = row["birthday_ok"].ToString() == "1"; _showemail = row["email_ok"].ToString() == "1"; _showqq = row["qq_ok"].ToString() == "1"; _showmsn = row["msn_ok"].ToString() == "1"; _view_count = (int)row["view_cnt"]; }