Пример #1
0
        private IEnumerable <LogEntry> QueryFromFileSystem(IEnumerable <FileInfo> foundFiles)
        {
            List <LogEntry> foundLogs = new List <LogEntry>();

            foreach (FileInfo file in foundFiles)
            {
                string[] fileLines = File.ReadAllLines(file.FullName);
                foundLogs.Add(new LogEntry(
                                  int.Parse(fileLines[0]),                        // id
                                  tourEntryDAO.FindById(int.Parse(fileLines[1])), // mediaItemId
                                  DateTime.Parse(fileLines[2]),                   // logDate
                                  fileLines[3],                                   // report
                                  Double.Parse(fileLines[4]),                     // distance
                                  TimeSpan.Parse(fileLines[5]),                   // totalTime
                                  Double.Parse(fileLines[6])                      // rating
                                  ));
            }

            return(foundLogs);
        }
Пример #2
0
        private IEnumerable <LogEntry> QueryLogsFromDb(DbCommand command)
        {
            List <LogEntry> logList = new List <LogEntry>();

            using (IDataReader reader = database.ExecuteReader(command))
            {
                while (reader.Read())
                {
                    logList.Add(new LogEntry(
                                    (int)reader["log_ID"],
                                    tourEntryDAO.FindById((int)reader["tour_ID_FK"]),
                                    (DateTime)reader["log_date"],
                                    (string)reader["report"],
                                    (double)reader["distance"],
                                    (TimeSpan)reader["total_time"],
                                    (double)reader["rating"]
                                    ));
                }
            }

            return(logList);
        }