/// <summary> /// 获取主推文的子推文 /// </summary> /// <param name="allTwitterStatuses"></param> /// <param name="masterTwitterStatuses"></param> /// <returns></returns> private List <TwitterStatuses> GetChildTwitterStatuses(List <TwitterStatuses> allTwitterStatuses, TwitterStatuses masterTwitterStatuses) { List <TwitterStatuses> childs = new List <TwitterStatuses>(); //获取第一代 var temp = allTwitterStatuses.Where(t => t.InRStatusId == masterTwitterStatuses.StatusesId).ToList(); //获取第N代 int count = 0; while (temp.IsValid() && count < 1024) { childs.AddRange(temp); temp = allTwitterStatuses.Where(t => temp.Any(tt => tt.StatusesId == t.InRStatusId)).ToList(); count++; } //按时间排序 childs.Sort((l, r) => { return(DateTime.Compare(l.CreateTime.Value, r.CreateTime.Value)); }); return(childs); }
/// <summary> /// 获取所有推文 /// </summary> /// <param name="context"></param> /// <returns></returns> private List <TwitterStatuses> GetAllTwitterStatuses(SqliteContext context) { var items = context.Find(new SQLiteString("SELECT s.XLY_DataType,s.status_id,(SELECT username FROM users WHERE user_id = s.author_id) as username,(SELECT name FROM users WHERE user_id = s.author_id) as author_name,s.in_r_user_id,(SELECT name FROM users WHERE user_id = s.in_r_user_id) as in_r_user_name,s.in_r_status_id,s.content,s.created,s.source,s.favorited,s.retweeted,s.favorite_count,s.retweet_count FROM statuses s ORDER BY s.created")).Select(d => TwitterStatuses.DyConvert(d)).Cast <TwitterStatuses>().Where(i => i.StatusesId.IsValid() && i.StatusesId != "0").ToList(); return(DataTypeFilter(items, (ls, i) => ls.Any(ii => ii.StatusesId == i.StatusesId))); }