Esempio n. 1
0
 public void SetVirtualRiderDetails(VirtualRider rider)
 {
     string userId = Context.User.Identity.Name;
       rider.SaveDetails(userId);
       // This may have changed the configuration - kill the existing virtual processor
       CycliManager.Instance.Kill(rider.UserId);
 }
Esempio n. 2
0
File: Rider.cs Progetto: Cycli/Cycli
        public static VirtualRider[] LoadAll(string userId)
        {
            List<VirtualRider> riders = new List<VirtualRider>();
             SQLiteDatabase db = new SQLiteDatabase();
             string sql = @"select UserId, Username, PowerMinimum, Power1Hr, Power5Min, Power1Min, Power5Sec, Aggression " +
               "From cycli_virtual_riders r " +
            "where OwnerId=@u and Status='Active'";
             // Only load active accounts
             DataTable dtUser = db.GetDataTable(sql,"@u", userId);
              foreach (DataRow dr in dtUser.Rows)
              {

               VirtualRider thisRider = new VirtualRider();
               thisRider.UserName = dr.Field<string>("Username");
               thisRider.UserId = dr.Field<string>("UserId");
               thisRider.OwnerId = userId;
               thisRider.BikeWheelSizeMm = 700;
               thisRider.PowerMin = (int)dr.Field<long>("PowerMinimum");
               thisRider.Power1Hr = (int)dr.Field<long>("Power1Hr");
               thisRider.Power5Min = (int)dr.Field<long>("Power5Min");
               thisRider.Power1Min = (int)dr.Field<long>("Power1Min");
               thisRider.Power5Sec = (int)dr.Field<long>("Power5Sec");
               thisRider.Aggression = (int)dr.Field<long>("Aggression");
               riders.Add(thisRider);
             }
             db.Close();
             return riders.ToArray();
        }
Esempio n. 3
0
File: Rider.cs Progetto: Cycli/Cycli
        public static VirtualRider New(string userId)
        {
            VirtualRider r = new VirtualRider();
             UserRider u = UserRider.Load(userId);
             r.UserId = Guid.NewGuid().ToString();
             r.OwnerId = userId;
             r.UserName = "******";
             r.BikeWheelSizeMm = 700;

             r.EstimatedPower = false;
             r.TurboIsCalibrated = false;
             r.CurrentTurbo = "";
             r.Aggression = 50;
             r.PowerMin = 150;
             r.Power1Hr = 200;
             r.Power5Min = 250;
             r.Power1Min = 300;
             r.Power5Sec = 500;

             // It's a new profile
             string sqlCount = @"select count(*) from cycli_virtual_riders where OwnerId=@o";

             string sqlRider = @"insert into cycli_virtual_riders (UserId, OwnerId, Username, PowerMinimum, Power1Hr, Power5Min, Power1Min, Power5Sec, Aggression) " +
                         "values (@u, @o, @n, @p4, @p3, @p2, @p1, @p0, @a) ";
             SQLiteDatabase db = new SQLiteDatabase();
             try
             {
               // This is a backstop test - the front end should prevent extra riders
               if (int.Parse(db.ExecuteScalar(sqlCount, "@o", userId)) < u.MaximumVirtualRiders)
               {

             db.ExecuteNonQuery(sqlRider,
                                 "@u", r.UserId,
                                 "@o", r.OwnerId,
                                 "@n", r.UserName,
                                 "@p4", r.PowerMin,
                                 "@p3", r.Power1Hr,
                                 "@p2", r.Power5Min,
                                 "@p1", r.Power1Min,
                                 "@p0", r.Power5Sec,
                                 "@a", r.Aggression);
               }
             }
             finally
             {
               db.Close();
             }
             return r;
        }
Esempio n. 4
0
File: Rider.cs Progetto: Cycli/Cycli
 public static VirtualRider Load(string riderId)
 {
     VirtualRider thisRider = null;
      SQLiteDatabase db = new SQLiteDatabase();
      string sql = @"select OwnerId,UserId, Username, PowerMinimum, Power1Hr, Power5Min, Power1Min, Power5Sec, Aggression " +
        "From cycli_virtual_riders r " +
     "where UserId=@u and Status='Active'";
      // Only load active accounts
      DataTable dtUser = db.GetDataTable(sql,"@u", riderId);
      if (dtUser.Rows.Count > 0)
      {
        DataRow dr = dtUser.Rows[0];
        thisRider = new VirtualRider();
        thisRider.UserName = dr.Field<string>("Username");
        thisRider.UserId = dr.Field<string>("UserId");
        thisRider.OwnerId = dr.Field<string>("OwnerId");
        thisRider.BikeWheelSizeMm = 700;
        thisRider.PowerMin = (int)dr.Field<long>("PowerMinimum");
        thisRider.Power1Hr = (int)dr.Field<long>("Power1Hr");
        thisRider.Power5Min = (int)dr.Field<long>("Power5Min");
        thisRider.Power1Min = (int)dr.Field<long>("Power1Min");
        thisRider.Power5Sec = (int)dr.Field<long>("Power5Sec");
        thisRider.Aggression = (int)dr.Field<long>("Aggression");
      }
      db.Close();
      return thisRider;
 }