public List<BaseCollectionItem> GetAllFromQueue() { var itemCollection = new List<BaseCollectionItem>(); foreach (var baseCollectionItem in InMemoryCollectionItemQueue.InMemoryCollectionItems) { var baseCollectionItemData = new BaseCollectionItemData { ItemID = baseCollectionItem.ItemId, ItemTitle = baseCollectionItem.ItemTitle, ItemUrl = baseCollectionItem.ItemUrl, ItemContent_Image = "", ItemContent_Raw = "", ItemDescription = baseCollectionItem.ItemDescription, ItemTags = baseCollectionItem.ItemTags, ItemProcessedDate = DateTime.Today }; itemCollection.Add(new BaseCollectionItem { Id = Guid.NewGuid(), Data = baseCollectionItemData }); } return itemCollection; }
public List<BaseCollectionItem> GetAllFromQueue() { //DONE: implement method to get batch repository items // gets unprocessed items this.MySqlClient.Open(); Log.Info("Connected to the database"); ////DONE: Select data from table in MYSQL Successfully and get it back in .NET ////TODO: filter if processed or not? MySqlCommand myCommand = new MySqlCommand("SELECT * FROM collectionitemqueue", this.MySqlClient); MySqlDataReader myReader = myCommand.ExecuteReader(); Log.Info("Retreiving Items from Queue"); //DONE: enumerate through data , create collection to return ; List<BaseCollectionItem> itemCollection = new List<BaseCollectionItem>(); while (myReader.Read()) { Log.Info(myReader.GetString(1) + ":" + myReader.GetString(2)); //DONE: convert list of tags separated by commas into a List of strings ////List<string> itemTags = new List<string>(myReader.GetString(4).Split(',')); var baseCollectionItemData = new BaseCollectionItemData { ItemID = myReader.GetInt32(0), ItemTitle = myReader.GetString(1), ItemUrl = myReader.GetString(2), ItemContent_Image = "", ItemContent_Raw = "", ItemDescription = myReader.GetString(3), ItemTags = myReader.GetString(4), ItemProcessedDate = DateTime.Today }; itemCollection.Add(new BaseCollectionItem { Id = Guid.NewGuid(), Data = baseCollectionItemData } ); } // close out stuff myReader.Close(); this.MySqlClient.Close(); return itemCollection; }