public Routine changeRoutineName(int routineID, string name) { using (var context = new Layer2Container()) { Routine rc = new Routine(); try { Routine rtn = context.Routines.Where(x => x.id == routineID).FirstOrDefault(); if (rtn != null && rtn.name != name.Trim()) { rtn.name = name.Trim(); context.Routines.ApplyCurrentValues(rtn); context.SaveChanges(); } rc = rtn; } catch (NullReferenceException e) { Console.WriteLine(e.Message + Environment.NewLine + e.StackTrace); // write off the execeptions to my error.log file StreamWriter wrtr = new StreamWriter(System.Web.HttpContext.Current.ApplicationInstance.Server.MapPath("~/assets/documents/" + @"\" + "error.log"), true); wrtr.WriteLine(DateTime.Now.ToString() + " | Error: " + e); wrtr.Close(); } return rc; } }
public void AddEvent(Routine action, int delay) { if (delay < 0) throw ( new ArgumentException() ); //var oldEvs = from TimeEvent ev in m_events where ev.Routine == action && ev.Time == m_tick + delay select ev; m_events.RemoveAll((TimeEvent ev) => (ev.Routine == action && ev.Time == m_tick + delay)); m_events.Add(new TimeEvent(action, m_tick + delay)); }
protected void btnConfirm_Click(object sender, EventArgs e) { exercises = Session["exercises"] != null ? (List<Exercise>)Session["exercises"] : null; Routine rt = new Routine(); ICollection<Exercise> exerciseList = convertListBox(lbSelected); // user id to be changed later so that function createNewRoutine makes a routine for specified user if (exerciseList != null && Convert.ToInt32(userID) != -1) rt = routManager.createNewRoutine(tbRoutineName.Text.Trim(), userID, exerciseList); clearAll(); // redirect page to itself (refresh) Response.Redirect(Request.RawUrl); }
// Still missing stuff like: exercise goals, logged exercises, and scheduled routines // Also need to have a test user to actually test this on // exercise goals would be the exercise set to be in the routine public Routine createNewRoutine(String routineName, int userID) { using (var context = new Layer2Container()) { Routine rc = new Routine(); try { LimitBreaker lb = context.LimitBreakers.Where(x => x.id == userID).FirstOrDefault(); if (lb != null) { rc.name = routineName.Trim(); rc.LimitBreaker = lb; rc.last_modified = new DateTime(); } } catch (NullReferenceException e) { Console.WriteLine(e.Message + Environment.NewLine + e.StackTrace); } return rc; } }
void Start() { if(!StaticDemo) NavAgent.enabled = true; //We enable the nav agent again, having now positioned the agent. DialogManager.SetDialog("..."); //We initialise the dialog and thoughts to create a small initial size for the speech and thought bubbles. ThoughtManager.SetDialog("(...)"); IsAlert = true; if (!StaticDemo) { routine = new Routine(DailyRoutine); curTask = routine.GetCurrentTask(DaylightScript.GetCurrentTime()); if (useStateVector) { stateVector.setupTasks(routine); } } if (!StaticDemo) CurrentGoal = new Goal_Scheduler(this, curTask); else CurrentGoal = new Goal_Scheduler(this, Task.Idle); }
public RoutineInfo( InputController.ButtonType newButton = InputController.ButtonType.Invalid, Routine newFunctionName = Routine.Invalid, bool newIsRepeatableAction = false ) { button = newButton; functionName = newFunctionName; isRepeatableAction = newIsRepeatableAction; }
// return the routine created public Routine createNewRoutine(String routineName, int userID, ICollection<Exercise> exerciseList) { using (var context = new Layer2Container()) { Routine rc = new Routine(); try { LimitBreaker lb = context.LimitBreakers.Where(x => x.id == userID).FirstOrDefault(); Exercise exc = new Exercise(); if (lb != null) { rc.name = routineName.Trim(); rc.LimitBreaker = lb; rc.lastModified = DateTime.Now; foreach (Exercise ex in exerciseList) { #if DEBUG response.Write("Exercise: " + ex.name + "<br/> ID: " + ex.id + "<br/>"); #endif // to prevent object out of context error exc = context.Exercises.Where(x => x.id == ex.id).FirstOrDefault(); rc.Exercises.Add(exc); exc = new Exercise(); } context.Routines.AddObject(rc); context.SaveChanges(); } } catch (NullReferenceException e) { Console.WriteLine(e.Message + Environment.NewLine + e.StackTrace); // write off the execeptions to my error.log file StreamWriter wrtr = new StreamWriter(System.Web.HttpContext.Current.ApplicationInstance.Server.MapPath("~/assets/documents/" + @"\" + "error.log"), true); wrtr.WriteLine(DateTime.Now.ToString() + " | Error: " + e); wrtr.Close(); } return rc; } }
public Timer(MonoBehaviour monoOwner, Action<string> setTime) { routine = new Routine(monoOwner); this.setTime = setTime; sbSeconds = new StringBuilder(); }
void Start() { timeoutRoutine = Timer.CreateMillisecondTimer(Timer.ConvertSecondsToMilliseconds(failureTimeoutInSeconds), OnDownloadTimeout); DoLoad(); }
public void setupTasks(Routine routine) { tasks = new List<Task>(); if (allowAllTasks) { int numAllTasks = System.Enum.GetNames(typeof(Task)).Length; for (int i = 0; i < numAllTasks; i++) { Task currentTask = (Task)i; if((currentTask != Task.Idle)&&(currentTask != Task.Custom)) tasks.Add(currentTask); } } else { Task[] allTasks = routine.getTasks(); int numAllTasks = allTasks.Length; for (int i = 0; i < numAllTasks; i++) { if (!tasks.Contains(allTasks[i])) tasks.Add(allTasks[i]); } } numTasks = tasks.Count; modValues = new float[numTasks, numStates]; for (int i = 0; i < numTasks; i++) for (int j = 0; j < numStates; j++) modValues[i, j] = Random.Range(-0.1f, 0.1f); }
public JsonResult SetRoutine(Routine routine, string oper, string Id, string Category, string ExerciseName, string Value, string sortOrder) { string cn = UmbracoCustom.GetParameterValue(UmbracoType.Connection); switch (oper) { case "add": NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(Request.UrlReferrer.Query); int documentId = int.Parse(nameValueCollection["id"]); Document document = new Document(documentId); Document parentDocument = new Document(document.ParentId); SqlHelper.ExecuteNonQuery(cn, CommandType.StoredProcedure, "InsertRoutine", new SqlParameter { ParameterName = "@Id", Value = routine.Id, Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Int }, new SqlParameter { ParameterName = "@DocumentId", Value = parentDocument.Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int }, new SqlParameter { ParameterName = "@ExerciseId", Value = int.Parse(ExerciseName), Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int }, new SqlParameter { ParameterName = "@MemberId", Value = Convert.ToInt32(parentDocument.getProperty("member").Value), Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int }, new SqlParameter { ParameterName = "@TrainerId", Value = Convert.ToInt32(parentDocument.getProperty("trainer").Value), Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int }, new SqlParameter { ParameterName = "@WorkoutId", Value = document.Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int }, new SqlParameter { ParameterName = "@Value", Value = Value, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Decimal } ); break; case "edit": SqlHelper.ExecuteNonQuery(cn, CommandType.StoredProcedure, "UpdateRoutine", new SqlParameter { ParameterName = "@Id", Value = Id, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int }, new SqlParameter { ParameterName = "@ExerciseId", Value = int.Parse(ExerciseName), Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int }, new SqlParameter { ParameterName = "@Value", Value = Value, Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Decimal } ); break; case "del": break; } return Json("Success Save"); }
public TimeEvent(Routine action, int time) { m_time = time; m_action = action; }
/// <summary> /// Start a co-routine function. /// </summary> /// <param name="routine">The IEnumerator returns by the co-routine function the user is invoking.</param> /// <returns>Returns a ID that can be passed into Stop() to halt the co-routine.</returns> public static int Run(IEnumerator routine) { Routine r = new Routine(routine); return(r.ID); }
public IEnumerable <Routine> GetRoutines() { List <Routine> routines = new List <Routine>(); Routine routine = new Routine(); routine.Id = 1; routine.Name = "Push Pull Legs"; routine.Exercises = new List <Exercise>(); Exercise exercise = new Exercise(); exercise.Description = "Bench Press 2x8"; exercise.CurrentWeight = 80; routine.Exercises.Add(exercise); exercise = new Exercise(); exercise.Description = "Chest Flyes 3x8"; exercise.CurrentWeight = 60; routine.Exercises.Add(exercise); exercise = new Exercise(); exercise.Description = "Shoulder Seated Press 3x5"; exercise.CurrentWeight = 65; routine.Exercises.Add(exercise); exercise = new Exercise(); exercise.Description = "Lateral Raise 2x8"; exercise.CurrentWeight = 30; routine.Exercises.Add(exercise); exercise = new Exercise(); exercise.Description = "Triceps 2x8"; exercise.CurrentWeight = 57.5M; routine.Exercises.Add(exercise); exercise = new Exercise(); exercise.Description = "Squat 2x8"; exercise.CurrentWeight = 95; routine.Exercises.Add(exercise); exercise = new Exercise(); exercise.Description = "Lunges 2x8"; exercise.CurrentWeight = 60; routine.Exercises.Add(exercise); exercise = new Exercise(); exercise.Description = "Leg Curl 2x10"; exercise.CurrentWeight = 140; routine.Exercises.Add(exercise); exercise = new Exercise(); exercise.Description = "Stiff Legged Deadlift 2x12"; exercise.CurrentWeight = 90; routine.Exercises.Add(exercise); exercise = new Exercise(); exercise.Description = "Calf Raise 2x10"; exercise.CurrentWeight = 150; routine.Exercises.Add(exercise); routines.Add(routine); routine = new Routine(); routine.Id = 2; routine.Name = "Texas Method"; routine.Exercises = new List <Exercise>(); exercise = new Exercise(); exercise.Description = "Squat 3x5"; exercise.CurrentWeight = 130; routine.Exercises.Add(exercise); exercise = new Exercise(); exercise.Description = "Bench Press 3x5"; exercise.CurrentWeight = 90; routine.Exercises.Add(exercise); exercise = new Exercise(); exercise.Description = "SDSL 3x5"; exercise.CurrentWeight = 47.5M; routine.Exercises.Add(exercise); exercise = new Exercise(); exercise.Description = "Incline Chest Flyes/Press"; exercise.CurrentWeight = 55; routine.Exercises.Add(exercise); routines.Add(routine); routines.Add(new Routine() { Id = 3, Name = "Test1" }); routines.Add(new Routine() { Id = 3, Name = "Test2" }); routines.Add(new Routine() { Id = 3, Name = "Test3" }); routines.Add(new Routine() { Id = 3, Name = "Test4" }); return(routines); }
private void OnClickReverseButton() { Routine.Start(WaitForReversedFuture()); }