Ejemplo n.º 1
0
        void Fetch()
        {
            DbProviderFactory fact = DbProviderFactories.GetFactory("System.Data.SQLite");

            using (SQLiteConnection cnn = (SQLiteConnection)fact.CreateConnection())
            {
                cnn.ConnectionString = "Data Source=" + FilePath;
                cnn.Open();

                SQLiteCommand command = new SQLiteCommand(
                    "SELECT PK_SessionId, Name, StartTime, TotalElapsedTime, TotalDistance, AverageStrokeRate, AverageHeartRate, AverageSpeed, SpeedInput FROM Sessions", cnn);

                SQLiteDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    int        id               = (int)(long)reader[0];
                    string     name             = (string)reader[1];
                    DateTime   startTime        = NKDateTimeConverter.NKToClr((long)reader[2]);
                    int        totalElapsedTime = (int)(long)reader[3];
                    int        totalDistance    = (int)(long)reader[4];
                    double     strokeRate       = Convert.ToDouble((long)reader[5]) / 2;
                    int        averageHeartRate = reader.IsDBNull(6) ? 0 : (int)(long)reader[6];
                    double     speed            = ((double)reader[7]) / 100;
                    SpeedInput input            = (SpeedInput)(long)reader[8];

                    Sessions.Add(new Session(id, name, startTime, totalElapsedTime, totalDistance, strokeRate, averageHeartRate, speed, input));
                }

                reader.Close();
            }
        }
Ejemplo n.º 2
0
 public Session(int id, string name, DateTime startTime, int totalElapsedTime, int totalDistance, double averageStrokeRate, int averageHeartRate, double averageSpeed, SpeedInput speedInput)
 {
     Id                = id;
     Name              = name;
     StartTime         = startTime;
     TotalElapsedTime  = totalElapsedTime;
     TotalDistance     = totalDistance;
     AverageStrokeRate = averageStrokeRate;
     AverageHeartRate  = averageHeartRate;
     AverageSpeed      = AverageSpeed;
     SpeedInput        = speedInput;
 }