public static IEnumerable<TwitterStatus> SelectMany(string[] ids) { // validate the id's by converting to a long array, also limit request to 50 id's var idList = new long[ids.Length]; var maxLength = (ids.Length < 50) ? ids.Length : 50; for (int i = 0; i < maxLength; i++) { idList[i] = long.Parse(ids[i]); } using (var db = new ToketeeData().Context) { var tweets = (from a in db.TwitterStatuses where idList.Contains(a.Id) select a).Distinct().ToArray().ToList(); var notFound = (from a in idList where !tweets.Select(status => status.Id).Contains(a) select a); if (notFound.Any()) { using (var queue = new Queue()) { var statusClient = new StatusClient(TwitterDelegates.GetOAuth, 117547746); foreach (var value in notFound) { var statusResult = statusClient.Show(value.ToString()); if (statusResult != null) { var result = TranslateStatus.ToInternal(statusResult.Data); DbTwitterStatus.Insert(result.Id, result.CreatedAt.FromEpoch(), Json.Serialize(result)); tweets.Add(new TwitterStatus { Id = Parse.Long(result.Id), Data = Encoding.UTF8.GetBytes(Json.Serialize(result)), Sent = result.CreatedAt.FromEpoch() }); //var result = queue.GetBrowser("id = " + value.ToString()); //foreach (var item in result) //{ // var msg = (Apache.NMS.ActiveMQ.Commands.ActiveMQTextMessage) item; // msg.Acknowledge(); // Queue.SingleSend(msg.Text, MsgPriority.Highest); //} } } } } return tweets; } }