static List<VideoCard> readFile(String filename) { string text = System.IO.File.ReadAllText(filename); System.Console.WriteLine("Contents of radeonCards.csv = {0}", text); string[] lines = System.IO.File.ReadAllLines(filename); System.Console.WriteLine("Contents of WriteLines2.txt"); List<VideoCard> cardList = new List<VideoCard>(); for (int i = 0; i < lines.Length; i++) { string line = lines[i]; VideoCard video = new VideoCard(); Console.WriteLine("\t" + line); if (line.Contains('"')) { List<string> quotes = line.Split('"').ToList<string>(); List<string> parsedInfo = quotes[2].Split(',').ToList<string>(); video.SetCardName(quotes[1]); video.SetHashRate(Convert.ToInt32(parsedInfo[1])); } else { List<string> parsedInfo = line.Split(',').ToList<string>(); video.SetCardName(parsedInfo[0]); video.SetHashRate(Convert.ToInt32(parsedInfo[1])); } video.SetId(i); cardList.Add(video); } return cardList; }
static void Main(string[] args) { //grab cards from excel sheet and compute average hashes List<VideoCard> basicInfoList = new List<VideoCard>(); basicInfoList = readFile(@"C:\radeon.csv"); //delete JSON values from previous program execution deletePreviousResults(); int status = 0; // List<VideoCard> cardsFromEbay = new List<VideoCard>(); List<RefVideoCard> almostDoneCards = calculateAverageHash(basicInfoList); RefVideoCard resultCardStats = new RefVideoCard(); List<RefVideoCard> cardStatsList = new List<RefVideoCard>(); List<VideoCard> cashAveragedCards = new List<VideoCard>(); for (int i = 0; i < cardsOfInterest.Length; i++) { //grab cards from ebay from list of interesting cards //cardsFromEbay List = GrabPricesFromEbay("Radeon 5970"); cardsFromEbay = GrabPricesFromEbay(cardsOfInterest[i]); //we now find the AveragePrice, CardCount, and ID of the list of Radeon 5970s resultCardStats = calculateAverages(cardsFromEbay, cardsOfInterest[i]); cardStatsList.Add(resultCardStats); VideoCard cashedCard = new VideoCard(); cashedCard.SetCardName(resultCardStats.GetCardName()); cashedCard.SetId(resultCardStats.GetId()); cashedCard.SetPrice(Convert.ToDouble(resultCardStats.GetAveragePrice())); cashAveragedCards.Add(cashedCard); //We now append the AveragePrice, CardCount, and ID info to the JSON file (in later version this could be an API call that returns JSON) //WriteEbayPricesToSQLServer(resultCardStats.GetId()); } List<FinishedVideoCard> finishedCards = CalculateHashForCash(cashAveragedCards, almostDoneCards); for (int i = 0; i < cardsOfInterest.Length; i++) { if (i == 0) { status = 0; } else if (i == cardsOfInterest.Length - 1) { status = 2; } else { status = 1; } writeEbayPricesToJSON(cardStatsList[i], status, finishedCards[i]); } Console.WriteLine("It got to here! Yay! :)"); Console.ReadKey(); }