async void TapGestureRecognizer_Tapped(System.Object sender, System.EventArgs e) { foreach (int i in processedSteps) { await RdsConnect.updateInstruction(true, items[i]); } //foreach (Instruction i in parent.instructions) //{ // await RdsConnect.updateInstruction(true, i); //} if (processedSteps.Count != 0) { if (processedSteps.Count == parent.instructions.Count) { parentIsComplete(); } else { if (parent.IsComplete != true) { parentIsComplete(); } } } await Navigation.PopAsync(false); }
private async void initialiseTodaysOccurances(string userID) { try { TimeSettings timeSettings = await RdsConnect.getTimeSettings(userID); if (timeSettings != null) { DateTime morning = today.Date + timeSettings.MorningStartTime; morningStart = morning; DateTime afternoon = today.Date + timeSettings.AfterNoonStartTime; afternoonStart = afternoon; DateTime evening = today.Date + timeSettings.EveningStartTime; eveningStart = evening; Debug.WriteLine(morningStart.ToString() + ", " + afternoonStart.ToString() + ", " + eveningStart.ToString()); } string url = AppConstants.BaseUrl + AppConstants.goalsAndRoutinesUrl + "/" + userID; todaysOccurances = await RdsConnect.getOccurances(url); todaysOccurances = todaysOccurances.Concat(todaysEvents).ToList(); SortOccurancesAndGroupGoals(); CreateList(); } catch (Exception e) { await DisplayAlert("Alert", "Error in TodaysListTest initialiseTodaysOccurances. Error: " + e.ToString(), "OK"); } }
async void NavigateToInstructionsPage(System.Object sender, System.EventArgs e) { var s = (StackLayout)sender; var gesture = (TapGestureRecognizer)s.GestureRecognizers[0]; var task = (SubOccurance)gesture.CommandParameter; if (task.instructions != null && task.instructions.Count != 0) { await Navigation.PushAsync(new GoalStepsPage(goalOccurance, task, Color.Blue.ToString()), false); } else { string url = AppConstants.BaseUrl + AppConstants.updateActionAndTask; if (task.statusIcon == null) { task.updateStatusIcon = "greenCheckMarkIcon"; await RdsConnect.updateOccurance(task, false, true, url); SetParticles(AllTasksAreDone(taskSource)); } else { if (task.statusIcon == "greenCheckMarkIcon") { task.updateStatusIcon = null; await RdsConnect.updateOccurance(task, false, false, url); SetParticles(AllTasksAreDone(taskSource)); } } } }
async void UpdateTaskBasedOnDoneButton() { string url = AppConstants.BaseUrl + AppConstants.updateActionAndTask; task.updateStatusIcon = "greenCheckMarkIcon"; await RdsConnect.updateOccurance(task, false, true, url); }
async void UpdateGoalOnDoneButton() { string url = AppConstants.BaseUrl + AppConstants.updateGoalAndRoutine; if (goalOccurance.NumSubOccurances == 1) { await RdsConnect.updateOccurance(goalOccurance, false, true, url); } else if (goalOccurance.NumSubOccurances > 1) { if (!AllTaskNotStarted(goalOccurance)) { if (AllTaskCompleted(goalOccurance)) { await RdsConnect.updateOccurance(goalOccurance, false, true, url); } else { await RdsConnect.updateOccurance(goalOccurance, true, false, url); } } else { await RdsConnect.updateOccurance(goalOccurance, false, false, url); } } }
async void RegistedStep(int i, bool status, bool isVisible) { items[i].isGreenCheckMarkIconVisible = isVisible; items[i].IsComplete = status; items[i].updateisGreenCheckMarkIconVisible(); await RdsConnect.updateInstruction(status, items[i]); }
async void ProcessGoalRequest(string goalID) { string url = AppConstants.BaseUrl + AppConstants.actionsAndInstructions + goalID; List <Occurance> goalList = await RdsConnect.getOccurances(url); if (goalList != null && goalList.Count != 0) { if (goalList[0].NumSubOccurances == 1 && goalList[0].subOccurances != null && goalList[0].subOccurances[0].instructions == null) { // Case 1: 1 Task with no instructions await Navigation.PushAsync((new GoalsSpecialPage(goalList[0])), false); } else if (goalList[0].NumSubOccurances == 1 && goalList[0].subOccurances != null && goalList[0].subOccurances[0].instructions != null && goalList[0].subOccurances[0].instructions.Count != 0) { // Case 2: 1 Task with instructions await Navigation.PushAsync(new GoalStepsPage(goalList[0], goalList[0].subOccurances[0], Color.Blue.ToString()), false); } else if (goalList[0].NumSubOccurances > 1) { // Case 3: More than 1 task await Navigation.PushAsync((new GoalsSpecialPage(goalList[0])), false); } } }
async void parentIsInProgress() { string url = AppConstants.BaseUrl + AppConstants.updateActionAndTask; string res = await RdsConnect.updateOccurance(parent, true, false, url); if (res == "Failure") { await DisplayAlert("Error", "There was an error writing to the database.", "OK"); } //currRoutine.SubOccurancesCompleted++; updateRoutine(); }
async void userDone(System.Object sender, System.EventArgs e) { // cases if it all steps are done, if none are done, if some are done if (parent.IsComplete != true) { foreach (Instruction steps in items) { await RdsConnect.updateInstruction(true, steps); } parentIsComplete(); } //parentIsComplete(); //if (processedSteps.Count != 0) //{ // if (processedSteps.Count == parent.instructions.Count) // { // parentIsComplete(); // } // else // { // parentIsInProgress(); // } //} //foreach (int i in processedSteps) //{ // await RdsConnect.updateInstruction(true, items[i]); //} //if (processedSteps.Count == parent.instructions.Count) //{ // foreach (Instruction i in parent.instructions) // { // await RdsConnect.updateInstruction(true, i); // } // parentIsComplete(); //} //else //{ // foreach (Instruction i in parent.instructions) // { // await RdsConnect.updateInstruction(true, i); // } // parentIsInProgress(); //} await Navigation.PopAsync(false); }
private async void initializeUser(string uid) { try { string res = await RdsConnect.getUser(uid); if (res == "Failure") { await DisplayAlert("Alert", "Error in getUser() in initializeUser() in AboutMePage", "OK"); } //Debug.WriteLine("ABOUT ME: " + res); UserResponse userResponse = JsonConvert.DeserializeObject <UserResponse>(res); ToUser(userResponse); userName.Text = user.FirstName + " " + user.LastName; //userImage.Source = user.PicUrl; if (user.user_birth_date == null) { userBirthDate.Text = "Date of birth: N/A"; } else { try { var date = DateTime.Parse(user.user_birth_date); Debug.WriteLine("DATE OF BIRTH: " + date.ToString("dd MMMM yyyy")); userBirthDate.Text = "Date of birth: " + date.ToString("dd MMMM yyyy"); } catch (Exception birthDate) { //await DisplayAlert("Oops", "Please sign in again to retrieve your account information. Thank you!", "OK"); userBirthDate.Text = "Date of birth: N/A"; } } if (user.PicUrl != null && user.PicUrl != "") { userPic.Source = user.PicUrl; } CreateList(); } catch (Exception a) { } }
// This function updates the occurance state locally and remotely. async void UpdateOccurance(Occurance occurance) { string url = AppConstants.BaseUrl + AppConstants.updateGoalAndRoutine; if (occurance.IsComplete != true) { occurance.updateIsInProgress(false); occurance.updateIsComplete(true); await RdsConnect.updateOccurance(occurance, false, true, url); } else { occurance.updateIsInProgress(false); occurance.updateIsComplete(false); await RdsConnect.updateOccurance(occurance, false, false, url); } }
async void UpdateOccurance(Occurance occurance) { string url = AppConstants.BaseUrl + AppConstants.updateGoalAndRoutine; if (occurance.IsComplete != true) { await RdsConnect.updateOccurance(occurance, false, true, url); } else { await RdsConnect.updateOccurance(occurance, false, false, url); } DateTime start = DateTime.Today + new TimeSpan(0, 0, 0); DateTime end = DateTime.Today + new TimeSpan(23, 59, 59); Application.Current.MainPage = new NavigationPage(new GoalsPage(start.ToString("t"), end.ToString("t"))); }
private async void initializeUser(string uid) { try { string res = await RdsConnect.getUser(uid); if (res == "Failure") { await DisplayAlert("Alert", "Error in getUser() in initializeUser() in AboutMePage", "OK"); return; } Debug.WriteLine("ABOUT ME: " + res); UserResponse userResponse = JsonConvert.DeserializeObject <UserResponse>(res); ToUser(userResponse); var startDate = DateTime.Parse(user.datetime); var startDateCopy = DateTime.Parse(user.datetime); var endDate = DateTime.Now; startDateLabel.Text = startDate.ToString("MM/dd/yyyy"); endDateLabel.Text = endDate.ToString("MM/dd/yyyy"); int totalDays = -1; while (startDateCopy < endDate) { startDateCopy = startDateCopy.AddDays(1); totalDays++; } //var firstDayOfMonth = new DateTime(date.Year, date.Month, 1); //var lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1); start = startDate; rangeSliderAge.MinimumValue = 0; rangeSliderAge.LowerValue = 0; rangeSliderAge.MaximumValue = (float)totalDays; rangeSliderAge.UpperValue = (float)totalDays; GetHistoryData(startDate.ToString("yyyy-MM-dd"), endDate.ToString("yyyy-MM-dd")); } catch (Exception a) { } }
async Task UpdateGoal() { string url = AppConstants.BaseUrl + AppConstants.updateGoalAndRoutine; if (!AllTasksNotStarted(taskSource)) { if (AllTasksAreDone(taskSource)) { await RdsConnect.updateOccurance(goalOccurance, false, true, url); } else { await RdsConnect.updateOccurance(goalOccurance, true, false, url); } } else { await RdsConnect.updateOccurance(goalOccurance, false, false, url); } }
async void GetCurrOccurance() { if (account != null) { string url = AppConstants.BaseUrl + AppConstants.goalsAndRoutinesUrl + "/" + account.userID; List <Occurance> todaysOccurances = await RdsConnect.getOccurances(url); if (todaysOccurances == null) { return; } if (account.isCalendarActive) { await CallGetEvents(); } DateTime dateTime = DateTime.Now; currOccurance = SortAndGetActivity(todaysOccurances, todaysEvents, dateTime.TimeOfDay); if (currOccurance == null) { currOccurance = new Occurance(); currentActivity = "Free Time"; currOccurance.Title = "Pursue a Goal"; } else if (currOccurance.IsEvent == true) { currentActivity = "Event"; } else if (currOccurance.IsPersistent == true) { currentActivity = "Routine"; } else if (currOccurance.IsPersistent == false) { currentActivity = "Goal"; } CenterCircle.Text = currentActivity + ": " + currOccurance.Title; } }
async void GetGoals() { if (MainPage.account.isGoalsActive) { try { string url = AppConstants.BaseUrl + AppConstants.goalsActInstrUrl + "/" + MainPage.account.userID; currentOccurances = await RdsConnect.getOccurances(url); SetGoals(); } catch (Exception GetGoalsIssue) { Debug.WriteLine("THERE WAS A PROBLEM IN THE 'GetGoals' FUNCTION: " + GetGoalsIssue.Message); } } else { await DisplayAlert("Oops", "Goals are not active. Please go to the 'Settings Page' and make your goals active. Thanks!", "OK"); } }
private async void initialiseTodaysOccurances(string userID) { try { await CheckVersion(); TimeSettings timeSettings = await RdsConnect.getTimeSettings(userID); if (timeSettings != null) { DateTime morning = today.Date + timeSettings.MorningStartTime; morningStart = morning; DateTime afternoon = today.Date + timeSettings.AfterNoonStartTime; afternoonStart = afternoon; DateTime evening = today.Date + timeSettings.EveningStartTime; eveningStart = evening; Debug.WriteLine(morningStart.ToString() + ", " + afternoonStart.ToString() + ", " + eveningStart.ToString()); previousTimeSettings = timeSettings; } string url = AppConstants.BaseUrl + AppConstants.goalsAndRoutinesUrl + "/" + userID; Debug.WriteLine("ENDPOINT: " + url); todaysOccurances = await RdsConnect.getOccurances(url); // COMMENT OUT EVENTS if (MainPage.account.isCalendarActive) { await CallGetEvents(); } UserDialogs.Instance.ShowLoading("Loading..."); todaysOccurances = todaysOccurances.Concat(todaysEvents).ToList(); SortOccurancesAndGroupGoals(); CreateList(); UserDialogs.Instance.HideLoading(); } catch (Exception e) { await DisplayAlert("Alert", "Error in TodaysListTest initialiseTodaysOccurances. Error: " + e.ToString(), "OK"); } }
async void UpateTask() { string url = AppConstants.BaseUrl + AppConstants.updateActionAndTask; if (!AllInstructionsNotStarted(items)) { if (AllInstructionsAreCompleted(items)) { task.updateStatusIcon = "greenCheckMarkIcon"; await RdsConnect.updateOccurance(task, false, true, url); } else { task.updateStatusIcon = "yellowCheckMarkIcon"; await RdsConnect.updateOccurance(task, true, false, url); } } else { task.updateStatusIcon = null; await RdsConnect.updateOccurance(task, false, false, url); } }
async void updateRoutine() { string url = AppConstants.BaseUrl + AppConstants.updateGoalAndRoutine; if (currRoutine.IsInProgress == false && currRoutine.IsComplete == false) { string res = await RdsConnect.updateOccurance(currRoutine, true, false, url); if (res == "Failure") { await DisplayAlert("Error", "There was an error writing to the database.", "OK"); } } else if (currRoutine.IsInProgress == true && currRoutine.IsComplete == false && currRoutine.NumSubOccurances == currRoutine.SubOccurancesCompleted) { string res = await RdsConnect.updateOccurance(currRoutine, false, true, url); if (res == "Failure") { await DisplayAlert("Error", "There was an error writing to the database.", "OK"); } } }
private async void initializeUser(string uid) { try { string res = await RdsConnect.getUser(uid); if (res == "Failure") { await DisplayAlert("Alert", "Error in getUser() in initializeUser() in AboutMePage", "OK"); } Debug.WriteLine("ABOUT ME: " + res); UserResponse userResponse = JsonConvert.DeserializeObject <UserResponse>(res); ToUser(userResponse); userName.Text = user.FirstName + " " + user.LastName; //userImage.Source = user.PicUrl; if (user.user_birth_date == null) { userBirthDate.Text = "Date of birth: N/A"; } else { try { var date = DateTime.Parse(user.user_birth_date); Debug.WriteLine("DATE OF BIRTH: " + date.ToString("dd MMMM yyyy")); userBirthDate.Text = "Date of birth: " + date.ToString("dd MMMM yyyy"); } catch (Exception birthDate) { //await DisplayAlert("Oops", birthDate.Message, "OK"); userBirthDate.Text = "Date of birth: N/A"; } } if (user.MessageCard != null) { messageCard.Text = user.MessageCard; } if (user.MessageDay != null) { messageDay.Text = user.MessageDay; } if (user.MajorEvents != null) { majorEvents.Text = user.MajorEvents; } if (user.MyHistory != null) { myHistory.Text = user.MyHistory; } if (user.PicUrl != null && user.PicUrl != "") { userPic.Source = user.PicUrl; } double height = Math.Max(messageCard.Text.Length + messageCard.Text.Length, messageDay.Text.Length + messageDay.Text.Length); Debug.WriteLine("HEIGHT: " + height); frameMessageCard.HeightRequest = height; frameMessageDay.HeightRequest = height; height = Math.Max(majorEvents.Text.Length + majorEvents.Text.Length, myHistory.Text.Length + myHistory.Text.Length); Debug.WriteLine("HEIGHT: " + height); frameMajorEvent.HeightRequest = height; frameMyHistory.HeightRequest = height; } catch (Exception a) { } }
async void AllDone(System.Object sender, System.EventArgs e) { // user gets a complete check mark at the parent level in all cases string url = AppConstants.BaseUrl + AppConstants.updateActionAndTask; string url2 = AppConstants.BaseUrl + AppConstants.updateGoalAndRoutine; parent.IsComplete = true; parent.IsInProgress = false; string res = await RdsConnect.updateOccurance(parent, false, true, url); if (currRoutine.subOccurances.Count == 1) { currRoutine.IsComplete = true; currRoutine.IsInProgress = false; string res2 = await RdsConnect.updateOccurance(currRoutine, false, true, url2); } else { //currRoutine.IsComplete = false; //currRoutine.IsInProgress = true; //string res2 = await RdsConnect.updateOccurance(currRoutine, true, false, url2); var status = true; foreach (SubOccurance i in currRoutine.subOccurances) { if (!(i.IsComplete == true && i.IsInProgress == false)) { status = false; break; } } if (status) { currRoutine.IsComplete = true; currRoutine.IsInProgress = false; await RdsConnect.updateOccurance(currRoutine, false, true, url2); } else { currRoutine.IsComplete = false; currRoutine.IsInProgress = true; await RdsConnect.updateOccurance(currRoutine, true, false, url2); } } //Application.Current.MainPage = new RoutinePage(); Debug.WriteLine(Navigation.NavigationStack[0]); string pageType = Navigation.NavigationStack[0].ToString(); NavigationPage root = new NavigationPage(new MainPage()); if (pageType == "Manifest.Views.TodaysListPage") { root.PushAsync(new TodaysListPage(), false); } else if (pageType == "Manifest.Views.RoutinesPage") { root.PushAsync(new RoutinesPage(), false); } root.PushAsync(new RoutinePage(), false); Application.Current.MainPage = root; }
async void NotDone(System.Object sender, System.EventArgs e) { string url = AppConstants.BaseUrl + AppConstants.updateActionAndTask; string url2 = AppConstants.BaseUrl + AppConstants.updateGoalAndRoutine; var totalNumberOfCompleteInstructions = 0; foreach (Instruction instruction in items) { if (instruction.IsComplete == true) { totalNumberOfCompleteInstructions++; } } if (totalNumberOfCompleteInstructions == 0) { parent.IsComplete = false; parent.IsInProgress = false; string res = await RdsConnect.updateOccurance(parent, false, false, url); if (currRoutine.subOccurances.Count == 1) { currRoutine.IsComplete = false; currRoutine.IsInProgress = false; string res2 = await RdsConnect.updateOccurance(currRoutine, false, false, url2); } else { currRoutine.IsComplete = false; currRoutine.IsInProgress = true; string res2 = await RdsConnect.updateOccurance(currRoutine, true, false, url2); } } else { parent.IsComplete = false; parent.IsInProgress = true; string res = await RdsConnect.updateOccurance(parent, true, false, url); currRoutine.IsComplete = false; currRoutine.IsInProgress = true; string res2 = await RdsConnect.updateOccurance(currRoutine, true, false, url2); } //Application.Current.MainPage = new RoutinePage(); Debug.WriteLine(Navigation.NavigationStack[0]); string pageType = Navigation.NavigationStack[0].ToString(); NavigationPage root = new NavigationPage(new MainPage()); if (pageType == "Manifest.Views.TodaysListPage") { root.PushAsync(new TodaysListPage(), false); } else if (pageType == "Manifest.Views.RoutinesPage") { root.PushAsync(new RoutinesPage(), false); } root.PushAsync(new RoutinePage(), false); Application.Current.MainPage = root; }
async void RegistedStep(int i, bool status, string newImage, Instruction step) { items[i].PhotoUpdate = newImage; items[i].IsComplete = true; await RdsConnect.updateInstruction(status, step); }