protected void Page_Load(object sender, EventArgs e) { SetTitle("日志 "); long spaceId = 0, type = -1; if (Request.QueryString["SpaceId"] == null) { SpaceAccount = CurrentAccount; } else if (long.TryParse(Request.QueryString["SpaceId"].ToString(), out spaceId)) { SpaceAccount = CY.UME.Core.Business.Account.Load(spaceId); } else { SpaceAccount = CurrentAccount; } if (Request.QueryString["Type"] != null) { long.TryParse(Request.QueryString["Type"].ToString(), out type); } if (!IsPostBack) { this.VisitorList.CurrentAccount = base.CurrentAccount; CY.UME.Core.PagingInfo pagingInfo = new CY.UME.Core.PagingInfo(); pagingInfo.CurrentPage = 1; pagingInfo.PageSize = 6; int BlogCount = 0; int viewSet; if (CurrentAccount != null && CurrentAccount.Id == SpaceAccount.Id) { viewSet = 0; } else if (CurrentAccount != null && CurrentAccount.HasFriendshipWith(SpaceAccount)) { viewSet = 1; } else { viewSet = 2; } CY.UME.Core.Business.Blog blog = new CY.UME.Core.Business.Blog(); BlogCount = blog.GetCountByAccountIdAndTypeAndViewSet(SpaceAccount, viewSet, type); blog_HiddenTotalRecords.Value = BlogCount.ToString(); blog_HiddenPageSize.Value = pagingInfo.PageSize.ToString(); blog_HiddenViewSet.Value = viewSet.ToString(); blog_HiddenType.Value = type.ToString(); blog_CurrentAccount.Value = CurrentAccount.Id.ToString(); blog_HiddenSiteUrl.Value = SiteUrl; blogFollower.CurrentFollower = SpaceAccount; IList<CY.UME.Core.Business.Blog> BlogList = blog.GetBlogsByAccountIdAndTypeAndViewSet(SpaceAccount, pagingInfo, viewSet, type); //BindType(); //selType.Value = type.ToString(); foreach (CY.UME.Core.Business.Blog b in BlogList) { string strContent = CY.Utility.Common.StringUtility.NoHTML(b.BlogContent); strContent = Server.HtmlDecode(strContent); strContent = strContent.Replace("\r\n", ""); strContent = CY.Utility.Common.StringUtility.CutString(strContent.Trim(), 400, "..."); strContent = strContent.Replace("&", "&"); b.BlogContent = strContent; b.Subject = Server.HtmlEncode( CY.Utility.Common.StringUtility.CutString(b.Subject, 30, "...") ); } RP_BlogList.DataSourceID = ""; RP_BlogList.DataSource = BlogList; RP_BlogList.DataBind(); UserInfo1.SpaceAccount = SpaceAccount; //blogList.SpaceAccount = SpaceAccount; //blogList.CurrentAccount = CurrentAccount; //blogList.Blogs = Blogs; //blogBriefList.Blogs = Blogs; //blogBriefList.spaceAccount = SpaceAccount; } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; CY.UME.Core.Business.Account spaceAccount; int pageSize; int pageNum; long spaceAccountId = 0, type = -1; int viewSet; if (!CY.Utility.Common.ParseUtility.TryParseInt64(context.Request.Form["spaceAccountId"], out spaceAccountId) || !CY.Utility.Common.ParseUtility.TryParseInt32(context.Request.Form["pageSize"], out pageSize) || !CY.Utility.Common.ParseUtility.TryParseInt32(context.Request.Form["pageNum"], out pageNum) || !CY.Utility.Common.ParseUtility.TryParseInt32(context.Request.Form["viewSet"], out viewSet)) { context.Response.Write("{success: false, msg: '参数错误!'}"); return; } if (context.Request.Form["type"] != null) { long.TryParse(context.Request.Form["type"].ToString(), out type); } try { StringBuilder sb = new StringBuilder(); if (spaceAccountId > 0) { spaceAccount = CY.UME.Core.Business.Account.Load(spaceAccountId); if (spaceAccount == null) { context.Response.Write("{success: false, msg: '参数错误!'}"); return; } CY.UME.Core.PagingInfo pagingInfo = new CY.UME.Core.PagingInfo(); pagingInfo.CurrentPage = pageNum; pagingInfo.PageSize = pageSize; CY.UME.Core.Business.Blog blog = new CY.UME.Core.Business.Blog(); IList<CY.UME.Core.Business.Blog> blogList = blog.GetBlogsByAccountIdAndTypeAndViewSet(spaceAccount, pagingInfo, viewSet, type); sb.Append("{success: true, blogs: ["); foreach (CY.UME.Core.Business.Blog a in blogList) { sb.Append("{Id: "); sb.Append(a.Id); sb.Append(", AccountId: '"); sb.Append(a.AccountId); sb.Append("', AccountName:'"); sb.Append(a.AccountName); sb.Append("',Title:"); sb.Append(CY.Utility.Common.JavaScriptUtility.ToEscapedJavaScriptString(a.Subject)); sb.Append(",ViewNum: "); sb.Append(a.ViewNum); sb.Append(",ReplyNum: "); sb.Append(a.ReplyNum); sb.Append(",Type:"); sb.Append(CY.Utility.Common.JavaScriptUtility.ToEscapedJavaScriptString(a.GetTypeNameByBlogId())); sb.Append(",DateCreated:'"); sb.Append(a.DateCreated); sb.Append("',Content:'"); // Constantine Modified string strContent = CY.Utility.Common.StringUtility.StripHtml(a.BlogContent); strContent = context.Server.HtmlDecode(strContent); strContent = strContent.Replace("\r\n", ""); strContent = CY.Utility.Common.StringUtility.CutString(strContent.Trim(), 400, "..."); strContent = strContent.Replace("&", "&"); strContent = CY.Utility.Common.StringUtility.EscapeString(strContent); sb.Append(strContent); sb.Append("'},"); } if (blogList.Count > 0) { sb.Remove(sb.Length - 1, 1); } sb.Append("]}"); context.Response.Write(sb.ToString()); } } catch { context.Response.Clear(); context.Response.Write("{success: false, msg: '服务器忙,请稍后再试!'}"); } }