Beispiel #1
0
        public static TurboTrainer Load(string userId, string turboType, bool turboIsCalibrated)
        {
            TurboTrainer thisTurbo = null;
              SQLiteDatabase db = new SQLiteDatabase();

              string sqlNonCalibrated = @"select t.type, t.power_model_c1, t.power_model_c2, t.power_model_c3 from " +
            "cycli_turbos t where t.type=@t";

              string sqlCalibrated = @"select t.type, t.power_model_c1, t.power_model_c2, t.power_model_c3 from " +
            "cycli_rider_turbos t where t.UserId=@u and t.type=@t";

              DataTable dtUser = null;
              if (turboIsCalibrated)
              {
            dtUser = db.GetDataTable(sqlCalibrated,"@u",userId,"@t",turboType);
            // Not defined yet - use the non standard values
            if (dtUser.Rows.Count == 0)
            {
              dtUser = db.GetDataTable(sqlNonCalibrated, "@t", turboType);
            }
              }
              else
              {
            dtUser = db.GetDataTable(sqlNonCalibrated, "@t", turboType);
              }

              if (dtUser.Rows.Count > 0)
              {
            DataRow dr = dtUser.Rows[0];
            thisTurbo = new TurboTrainer();
            thisTurbo.UserId = userId;
            thisTurbo.Type = (string)(dr["type"]);
            thisTurbo.Coefficients = new double[]{(double)dr["power_model_c1"],(double)dr["power_model_c2"],(double)dr["power_model_c3"]};
              }
              db.Close();
              return thisTurbo;
        }
Beispiel #2
0
 public void SetTurboDetails(TurboTrainer turbo)
 {
     string userId = Context.User.Identity.Name;
       turbo.Save(userId);
 }
Beispiel #3
0
        public static TurboTrainer[] LoadAll()
        {
            TurboTrainer[] turbos = new TurboTrainer[]{};

            SQLiteDatabase db = new SQLiteDatabase();
            string sql = @"select type, power_model_c1, power_model_c2, power_model_c3 from cycli_turbos order by type";
            DataTable dtTurbos = db.GetDataTable(sql);
            db.Close();

            if (dtTurbos.Rows.Count > 0)
            {
            turbos = dtTurbos.AsEnumerable().Select(p => new TurboTrainer
            {
                Type = (string)(p["type"]),
                Coefficients = new double[] { (double)p["power_model_c1"], (double)p["power_model_c2"], (double)p["power_model_c3"] }
            }).ToArray();
            }
            return turbos;
        }
Beispiel #4
0
 public void SetRiderEquipment(UserRider rider, TurboTrainer turbo)
 {
     string userId = Context.User.Identity.Name;
     rider.SaveEquipment(userId);
     if (turbo != null)
     {
     turbo.Save(userId);
     }
     // This may have changed the configuration - kill the existing processor
     CycliManager.Instance.Kill(userId);
 }