public static List <BoardOrder> GetBoardOrdersText(string connString) { var boardOrders = new List <BoardOrder>(); var query = $@"SELECT FilePath, FileText, FROM [dbo].[BoardOrders]"; using (var conn = new SqlConnection(connString)) { var command = new SqlCommand(query, conn); conn.Open(); using (var reader = command.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { var order = new BoardOrder() { Path = reader.GetString(reader.GetOrdinal("FilePath")), Text = reader.GetString(reader.GetOrdinal("FileText")), }; boardOrders.Add(order); } } } conn.Close(); } return(boardOrders); }
public static List <BoardOrder> GetResponses(string connString) { var orderResponses = new List <BoardOrder>(); using (var conn = new SqlConnection(connString)) { var query = $@"SELECT Response, FilePath FROM [dbo].[Google]"; var command = new SqlCommand(query, conn); conn.Open(); using (var reader = command.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { var order = new BoardOrder(reader.GetString(reader.GetOrdinal("Response"))) { Path = reader.GetString(reader.GetOrdinal("FilePath")), }; orderResponses.Add(order); } } } conn.Close(); } return(orderResponses); }
public static List <BoardOrder> GetBoardOrders(string path = "") { var boardOrders = new List <BoardOrder>(); var files = Directory.EnumerateFiles(path); foreach (var file in files) { var order = new BoardOrder() { Path = file, Text = File.ReadAllText(file), }; boardOrders.Add(order); } return(boardOrders); }