/// <summary> /// 获取好友最新更新博客 /// </summary> /// <param name="context"></param> /// <returns> 0 登录失败 -1请求失败 -2系统错误</returns> public string GetMiniBlogNoticeList(HttpContext context) { string email = String.Empty; CY.UME.Core.Business.Account currentAccount; CY.UME.Core.Business.Account author; if (context.Request.QueryString["email"] == null) { return "0"; } email = context.Request.QueryString["email"].ToString(); CY.UME.Core.Business.AccountExtend ae = CY.UME.Core.Business.AccountExtend.Load(email); if (ae == null) { return "0"; } currentAccount = CY.UME.Core.Business.Account.Load(ae.Id); string[] type = { "miniblog" }; IList<CY.UME.Core.Business.Notice> nList = GetNoticeList(currentAccount, type); StringBuilder sb = new StringBuilder(); long miniBlogId = 0; try { sb.Append("["); foreach (CY.UME.Core.Business.Notice notice in nList) { CY.UME.Core.Business.MiniBlog miniBlog = new CY.UME.Core.Business.MiniBlog(); if (!CY.Utility.Common.ParseUtility.TryParseInt64(notice.InstanceId, out miniBlogId)) { continue; } else { if (miniBlogId < 1) { continue; } else { miniBlog = CY.UME.Core.Business.MiniBlog.Load(miniBlogId); } } if (miniBlog == null) { notice.DeleteOnSave(); notice.Save(); continue; } author = CY.UME.Core.Business.Account.Load(notice.AuthorId); if (author == null) { continue; } CY.UME.Core.Business.MiniBlogExtend mbe = CY.UME.Core.Business.MiniBlogExtend.Load(miniBlogId); bool IsPhoneSended = false; string picurl = String.Empty; StringBuilder Refereds = new StringBuilder(); Refereds.Append("{"); if (mbe != null) { IsPhoneSended = mbe.IsPhoneSended; picurl = mbe.ImgPath; if (mbe.ReferedId > 0) { CY.UME.Core.Business.MiniBlogExtend mbeTemp = CY.UME.Core.Business.MiniBlogExtend.Load(mbe.Id); bool check = true; long orMiniBlogId = 0; int orTraNum = 0; int i = 0; Refereds.Append("\"TraInfo\":["); while (check) { if (i < 10) { Refereds.Append("{"); Refereds.Append("\"AccountId\":\"" + mbeTemp.AccountId+"\""); Refereds.Append(",\"Name\":\"" + (notice.AccountId == mbeTemp.AccountId ? "我" : mbeTemp.ReferedName) + "\""); Refereds.Append("},"); } i++; mbeTemp = CY.UME.Core.Business.MiniBlogExtend.Load(mbeTemp.ReferedId); if (mbeTemp == null || mbeTemp.ReferedId == 0) { check = false; } orMiniBlogId = mbeTemp.Id; orTraNum = mbeTemp.TransferedNum; } Refereds.Remove(Refereds.Length - 1, 1); Refereds.Append("]"); Refereds.Append(",\"Id\":\"" + orMiniBlogId+"\""); Refereds.Append(",\"TrasNum\":\"" + orTraNum+"\""); } } Refereds.Append("}"); sb.Append("{\"id\":\""); sb.Append(notice.Id + "\""); sb.Append(",\"type\":\"" + notice.Type+"\""); sb.Append(",\"authorId\":\""); sb.Append(notice.AuthorId + "\""); sb.Append(",\"authorName\":"); sb.Append(CY.Utility.Common.JavaScriptUtility.ToEscapedJavaScriptString(author.Id == notice.AccountId ? "我" : author.Name) ); sb.Append(",\"content\":"); sb.Append(CY.Utility.Common.JavaScriptUtility.ToEscapedJavaScriptString(notice.Content)); sb.Append(",\"miniBlogId\":\""); sb.Append(miniBlogId+"\""); sb.Append(",\"miniBlogContent\":"); sb.Append(CY.Utility.Common.JavaScriptUtility.ToEscapedJavaScriptString(miniBlog.Content) ); sb.Append(",\"miniBlogPubDate\":\""); sb.Append(CY.Utility.Common.StringUtility.getDateDifference(miniBlog.DatePublish) + "\""); sb.Append(",\"Refereds\":" + Refereds.ToString()); sb.Append(",\"TrasNum\":\"" + (mbe == null ? "0" : mbe.TransferedNum.ToString()) + "\""); sb.Append(",\"ReplyNum\":\"" + miniBlog.GetCommentCount() + "\""); sb.Append(",\"IsPhoneSended\":\"" + (IsPhoneSended ? "1" : "0") + "\""); sb.Append(",\"IsHasPic\":\"" + (picurl.Length == 0 ? "0" : "1") + "\""); sb.Append("},"); } sb.Remove(sb.Length - 1, 1); sb.Append("]"); return sb.ToString(); } catch { return "-2"; } }