public Plan(Database dat, User user) { this.user = user; this.dat = dat; groups = new Dictionary <string, MuscleGroupQueue>(); groups.Add("chest", new MuscleGroupQueue("chest", 1.0)); groups.Add("back", new MuscleGroupQueue("back", 1.0)); groups.Add("legs", new MuscleGroupQueue("legs", 1.0)); groups.Add("shoulders", new MuscleGroupQueue("shoulders", 0.8)); groups.Add("arms", new MuscleGroupQueue("arms", 0.8)); groups.Add("abdominals", new MuscleGroupQueue("abdominals", 0.8)); allExercises = Exercise.getAllExercises(dat); QueryResult days = dat.query("SELECT * FROM workoutdays WHERE associateduser='******';"); oldDays = new List <WorkoutDay>(); for (int i = 0; i < days.Rows; i++) { this.oldDays.Add(new WorkoutDay { workoutItems = new List <workoutItem> { }, primaryGroup = days.GetField("primarygroup", i).asString(), secondaryGroup = days.GetField("secondarygroup", i).asString(), date = days.GetField("workoutdate", i).asDate(), uuid = days.GetField("dayid", i).asString() }); } foreach (WorkoutDay d in oldDays) { QueryResult items = dat.query("SELECT * FROM workoutitems WHERE associatedday ='" + d.uuid + "';"); for (int i = 0; i < items.Rows; i++) { Exercise exercise = null; String uuid = items.GetField("itemid", i).asString(); foreach (Exercise ex in allExercises) { if (ex.exerciseName == items.GetField("exercisename", i).asString()) { exercise = ex; } } QueryResult setQuery = dat.query("SELECT * FROM workoutsets WHERE associateditem ='" + uuid + "';"); List <set> exerciseSets = new List <set>(); for (int j = 0; j < setQuery.Rows; j++) { exerciseSets.Add(new set { percent1RM = setQuery.GetField("percent1rm", j).asInt(), reps = setQuery.GetField("reps", j).asInt(), restTime = TimeSpan.FromSeconds((float)setQuery.GetField("resttime", j).asDouble()), repsCompleted = setQuery.GetField("feedbackreps", j).asInt() }); } d.workoutItems.Add(new workoutItem { uuid = uuid, ex = exercise, sets = exerciseSets, difficulty = items.GetField("feedbackdifficulty", i).asInt() }); } } }
static void Main(string[] args) { string host = "localhost"; if (args.Length >= 1) { host = args[0]; } string connection = "Server=" + host + ";Port=5432;Username=postgres;Password=postpass;Database=postgres"; Database db = new Database(connection); ResetDatabase(db); Exercise.getAllExercises(db); UserManager manager = new UserManager(db); var us = manager.getUser("*****@*****.**", Util.hash("bob" + "*****@*****.**")); ProgressStatistics st = new ProgressStatistics(); for (int i = 0; i < 200; i++) { st.AddDataPoint(DateTime.Now + TimeSpan.FromMinutes(i), (i / 200.0) * Math.Sin(i * 0.1)); } st.Finish(); var fout = new FileStream("output.pdf", FileMode.Create); st.MakePdf("One-Rep-Max over time", fout); //using (UserDataAccess ac = new UserDataAccess(db, us)) { // for(int d = 0; d < 50; ++d) { // WorkoutSession session = new WorkoutSession(); // session.workoutItems = new List<WorkoutItem>(); // session.uuid = Guid.NewGuid().ToString(); // session.date = DateTime.Now + TimeSpan.FromDays(d - 25); // session.primaryGroup = ((BodyPart)(1 + Util.rand(6))).ToString(); // session.secondaryGroup = "this does not matter"; // for (int i = 0; i < 6; i++) { // WorkoutItem item = new WorkoutItem(); // item.ex = Exercise.globalExercises.randomElement(); // item.oneRepMax = Util.rand(0.0, 50.0); // item.sets = new List<WorkoutSet>(); // item.uuid = Guid.NewGuid().ToString(); // item.difficulty = 2; // for(int j = 0; j < (3 + Util.rand(3)); j++) { // WorkoutSet set = new WorkoutSet(); // set.percent1RM = 75; // set.uuid = Guid.NewGuid().ToString(); // set.reps = 10; // set.repsCompleted = 10; // set.doneWithRest = true; // set.restTime = TimeSpan.FromSeconds(4); // item.sets.Add(set); // } // session.workoutItems.Add(item); // } // ac.AddDay(session); // } // ac.Store(); // WorkoutGenerator gen = new WorkoutGenerator(ac); // Console.WriteLine(gen.ToString()); //} //User bob = manager.createUser("bob", "bobtest"); //UserDataAccess bobaccess = new UserDataAccess(db, bob); //WorkoutGenerator bobs = new WorkoutGenerator(bobaccess); //WorkoutSession sesh = new WorkoutSession(); //sesh.date = DateTime.Now - TimeSpan.FromDays(1.0); ////sesh.primaryGroup = "Chest"; ////sesh.secondaryGroup = "Back"; //sesh.uuid = Guid.NewGuid().ToString(); //sesh.workoutItems = new List<WorkoutItem>(); //for(int i = 0; i < 3; ++i) { // WorkoutItem item = new WorkoutItem(); // item.difficulty = 2; // item.ex = Exercise.globalExercises[3]; //} //bobaccess.AddDay(new WorkoutSession()) mpBase root = new mpBase(); mpServer server = new mpServer(); server.start(root.restful, "http://*:8080/"); SetupRegistrationManager(root, db, manager); SetupLoginManager(root, db, manager); SetupExerciseInfoManager(root, db, manager); SetupExerciseCalibrationManager(root, db, manager); SetupExerciseFeedbackManager(root, db, manager); Console.ReadKey(); server.stop(); }