public static string BuildNewsFeed(UserEntity entity) { StringBuilder sb = new StringBuilder(); IList <EventEntity> list = EventFeed.ListEvent(entity.id, 100, 0); IEnumerable <EventEntity> stick = from e in list where e.type == EventType.Important select e; IEnumerable <EventEntity> normal = from e in list where e.type == EventType.Normal select e; //stick 消息 if (stick != null && stick.Count() > 0) { sb.Append("<div class=\"s_story\"><div class=\"s_title\">重要的消息</div>"); foreach (EventEntity se in stick) { EventTemplateData ede = new EventTemplateData(se); sb.Append(EventTemplate.Build(ede)); } sb.Append("</div>"); } //普通消息 if (normal != null && normal.Count() > 0) { foreach (EventEntity ee in normal) { EventTemplateData ede = new EventTemplateData(ee); sb.Append("<div class=\"s_story\"><div class=\"ef\">"); sb.Append(EventTemplate.Build(ede)); sb.Append("</div></div>"); } } return(sb.ToString()); }
public static string Build(EventTemplateData ede) { Func <EventTemplateData, string> template = GetTemplate(ede.TemplateName); if (template != null) { return(template(ede)); } return(string.Empty); }
public static string BuildRecentFeed(UserEntity entity) { StringBuilder sb = new StringBuilder(); IList <EventEntity> list = EventData.ListUserPublicEvent(entity.id, 20); if (list != null && list.Count > 0) { foreach (EventEntity ee in list) { EventTemplateData ede = new EventTemplateData(ee); sb.Append("<div class=\"s_story\"><div class=\"ef\">"); sb.Append(EventTemplate.Build(ede)); sb.Append("</div></div>"); } } return(sb.ToString()); }