private void Btn_AddItem_Click(object sender, EventArgs e) { if (tb_Name.Text == "") { MessageBox.Show("Please give a Name for your item."); } else { string name = tb_Name.Text; bool isIllegal = true; if (rb_IllegalTrue.Checked) { isIllegal = true; } else if (rb_IllegalFalse.Checked) { isIllegal = false; } Occurance enumOccurance = (Occurance)cb_Occurance.SelectedValue; int occurance = (int)enumOccurance; int multiplier = Convert.ToInt32(num_Multiplier.Value); AddItemJson(name, isIllegal, occurance, multiplier); AddItemGridView(name, isIllegal, occurance, multiplier); } }
public override string ToString() { var text = ""; if (OccuranceType == OccuranceType.None) { text = "on the " + DayNumber.ToOrdinalString(); } else if (OccuranceType == OccuranceType.DayOfWeek) { text = "on the " + Occurance.ToString().ToLower() + " " + Day.ToString(); } else if (OccuranceType == OccuranceType.Day) { text = "on the " + Occurance.ToString().ToLower() + " day"; } else if (OccuranceType == OccuranceType.Weekday) { text = "on the " + Occurance.ToString().ToLower() + " weekday"; } if (Every == 1) { text += " of every month"; } else { text += " of every " + Every.ToString() + " months"; } return(text); }
public IActionResult AddOccurance(Occurance newOccurance) { if (HttpContext.Session.GetString("CurrentUser") != null) { if (ModelState.IsValid) { dbContext.Add(newOccurance); dbContext.SaveChanges(); return(Redirect("/dashboard")); } else { int? ID = HttpContext.Session.GetInt32("CurrentUserID"); int realId = (int)ID; User currentuser = dbContext.Users.FirstOrDefault(u => u.UserId == realId); int creatorid = currentuser.UserId; ViewBag.creatorId = creatorid; return(View("NewOccurance")); } } else { return(RedirectToAction("LoginUser")); } }
public List <AgentJudgement> AddMemory(Occurance newMemory) { List <AgentJudgement> result = JudgeMemory(newMemory); Memories.Add(newMemory); return(result); }
//This function groups goals for us private void addCommonOccur(List <Occurance> commonOccur) { if (commonOccur.Count > 1) { Occurance toAddPursue = new Occurance(); toAddPursue.Title = "Pursue A Goal"; toAddPursue.StartDayAndTime = commonOccur[0].StartDayAndTime; toAddPursue.EndDayAndTime = commonOccur[0].EndDayAndTime; toAddPursue.TimeInterval = commonOccur[0].TimeInterval; toAddPursue.IsEvent = false; toAddPursue.StatusColor = MainPage.account.goalColor; //Set text color if (toAddPursue.StatusColor.Luminosity > 0.8) { toAddPursue.textColor = Color.Black; } else { toAddPursue.textColor = Color.White; } List <Occurance> holder = new List <Occurance>(commonOccur); Debug.WriteLine("holder count before: " + holder.Count); toAddPursue.commonTimeOccurs = holder; //displayedOccurances.Add(toAddPursue); } else if (commonOccur.Count == 1) { displayedOccurances.Add(commonOccur[0]); } commonOccur.Clear(); hasItems = false; }
private void occuranceHappeningNow(Occurance occurance) { if (occurance.StartDayAndTime.TimeOfDay <= DateTime.Now.TimeOfDay && occurance.EndDayAndTime.TimeOfDay >= DateTime.Now.TimeOfDay) { occurance.updateBorderWidth(5); } }
private void EventsToOccurances(List <Event> events) { Debug.WriteLine("Entered EventsToOccurances"); try { todaysEvents.Clear(); foreach (Event dto in events) { Occurance toAdd = new Occurance(); toAdd.Title = dto.Title; toAdd.Description = dto.Description; toAdd.StartDayAndTime = dto.StartTime.LocalDateTime; toAdd.EndDayAndTime = dto.EndTime.LocalDateTime; toAdd.TimeInterval = dto.StartTime.LocalDateTime.ToString("t") + "-" + dto.EndTime.LocalDateTime.ToString("t"); toAdd.StatusColor = Color.FromHex("#67ABFC"); toAdd.Id = dto.Id; toAdd.IsEvent = true; toAdd.PicUrl = "calendarFive.png"; //Image must be a png todaysEvents.Add(toAdd); } } catch (Exception e) { DisplayAlert("Alert", "Error in TodaysListTest EventsToOccurances. Error: " + e.ToString(), "OK"); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Title")] Occurance occurance) { if (id != occurance.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(occurance); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OccuranceExists(occurance.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(occurance)); }
List <Occurance> EventsToOccurances(List <Event> events) { try { todaysEvents.Clear(); foreach (Event dto in events) { Occurance toAdd = new Occurance(); toAdd.Title = dto.Title; toAdd.Description = dto.Description; toAdd.StartDayAndTime = dto.StartTime.LocalDateTime; toAdd.EndDayAndTime = dto.EndTime.LocalDateTime; toAdd.TimeInterval = dto.StartTime.LocalDateTime.ToString("t") + "-" + dto.EndTime.LocalDateTime.ToString("t"); toAdd.StatusColor = Color.FromHex("#67ABFC"); //highlighting events happening now //if (DateTime.Now.TimeOfDay >= toAdd.StartDayAndTime.TimeOfDay && DateTime.Now.TimeOfDay <= toAdd.EndDayAndTime.TimeOfDay) // toAdd.StatusColor = Color.FromHex("#FFBD27"); //else toAdd.StatusColor = Color.FromHex("#9DB2CB"); toAdd.Id = dto.Id; toAdd.IsEvent = true; toAdd.PicUrl = "calendarFive.png"; //Image must be a png todaysEvents.Add(toAdd); } } catch (Exception EventsToOccurancesIssue) { Debug.WriteLine("THERE WAS A PROBLEM IN THE 'EventsToOccurances' FUNCTION: " + EventsToOccurancesIssue.Message); } return(todaysEvents); }
Occurance SortAndGetActivity(List <Occurance> occurances, List <Occurance> events, TimeSpan currDateTime) { Occurance curr = null; int i = 0; int j = 0; List <Occurance> merged = occurances.Concat(events).ToList(); Occurance.SortOccurances(merged); todaysOccurances = merged; foreach (Occurance activity in merged) { if (activity.StartDayAndTime.TimeOfDay <= currDateTime && activity.EndDayAndTime.TimeOfDay >= currDateTime) { if (curr == null) { curr = activity; } else { //Changes the activity if we see a more recent one if (activity.StartDayAndTime.TimeOfDay.Hours > curr.StartDayAndTime.TimeOfDay.Hours || (activity.StartDayAndTime.TimeOfDay.Hours == curr.StartDayAndTime.TimeOfDay.Hours && activity.StartDayAndTime.TimeOfDay.Minutes > curr.StartDayAndTime.TimeOfDay.Minutes)) { curr = activity; } } Debug.WriteLine("Title: " + curr.Title + ", StartTime: " + curr.StartDayAndTime.ToString()); } } return(curr); }
// Constructor public GoalStepsPage(Occurance occurance, SubOccurance subTask, string color) { InitializeComponent(); SetColorTheme(); SetTitleGridOnIOS(); SetGoalOccurance(occurance, subTask); SetGoalTaskLabel(); SetTaskInstructions(); }
public GoalsSpecialPage(Occurance occurance) { InitializeComponent(); SetTitleGridOnIOS(); SetColorTheme(); SetLocationDate(); SetGoalOccurance(occurance); SetSubTitleGoalLabel(); SetTasks(); }
public async Task <IActionResult> Create([Bind("Id,Title")] Occurance occurance) { if (ModelState.IsValid) { _context.Add(occurance); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(occurance)); }
// Judging a memory is to judge the role of each participant in the memory public List <AgentJudgement> JudgeMemory(Occurance memoryToJudge) { List <AgentJudgement> result = new List <AgentJudgement>(); foreach (string currRole in memoryToJudge.OccuranceRoles.Keys) { List <AgentJudgement> newJudgements = JudgeRole(memoryToJudge, currRole); result.AddRange(newJudgements); Judgements.AddRange(newJudgements); } return(result); }
//Used to update a goal/routine public static async Task <string> updateOccurance(Occurance currOccurance, bool inprogress, bool iscomplete, string url) { CheckTimeZone(); currOccurance.updateIsInProgress(inprogress); currOccurance.updateIsComplete(iscomplete); UpdateOccurance updateOccur = new UpdateOccurance(); updateOccur.id = currOccurance.Id; updateOccur.datetime_completed = currOccurance.Id; updateOccur.datetime_started = currOccurance.Id; updateOccur.is_in_progress = currOccurance.IsInProgress; updateOccur.is_complete = currOccurance.IsComplete; if (currOccurance.IsComplete == false && currOccurance.IsInProgress == false) { updateOccur.datetime_completed = ""; updateOccur.datetime_started = ""; } if (currOccurance.IsComplete == false && currOccurance.IsInProgress == true) { updateOccur.datetime_completed = ""; updateOccur.datetime_started = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt"); } if (currOccurance.IsComplete == true && currOccurance.IsInProgress == false) { updateOccur.datetime_completed = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt"); updateOccur.datetime_started = currOccurance.StartDayAndTime.ToString("yyyy-MM-dd hh:mm:ss tt"); } string toSend = updateOccur.updateOccurance(); Debug.WriteLine("LINE 85 " + toSend); var content = new StringContent(toSend); var res = await client.PostAsync(url, content); if (res.IsSuccessStatusCode) { Debug.WriteLine("Wrote to the datebase"); return("Success"); } else { Debug.WriteLine("Some error"); Debug.WriteLine(toSend); Debug.WriteLine(res.ToString()); return("Failure"); } //return "Failure"; }
// This function converts the list of occurances as a string into a list of occurance objects. public static List <Occurance> ToOccurances(OccuranceResponse occuranceResponse) { List <Occurance> todaysRoutines = null; try { if (occuranceResponse.result != null && occuranceResponse.result.Count != 0) { todaysRoutines = new List <Occurance>(); foreach (OccuranceDto dto in occuranceResponse.result) { Occurance toAdd = new Occurance(); if (dto.is_displayed_today == "True") { toAdd.Id = dto.gr_unique_id; toAdd.Title = dto.gr_title; toAdd.UserId = dto.user_id; toAdd.IsAvailable = DataParser.ToBool(dto.is_available); toAdd.IsComplete = DataParser.ToBool(dto.is_complete); toAdd.IsInProgress = DataParser.ToBool(dto.is_in_progress); toAdd.IsDisplayedToday = DataParser.ToBool(dto.is_displayed_today); toAdd.IsPersistent = DataParser.ToBool(dto.is_persistent); toAdd.IsSublistAvailable = DataParser.ToBool(dto.is_sublist_available); toAdd.PicUrl = dto.gr_photo; toAdd.StartDayAndTime = DataParser.ToDateTime(dto.gr_start_day_and_time); toAdd.EndDayAndTime = DataParser.ToDateTime(dto.gr_end_day_and_time); toAdd.CompletionTime = dto.gr_expected_completion_time; toAdd.DateTimeStarted = DataParser.ToDateTime(dto.gr_datetime_started); toAdd.DateTimeCompleted = DataParser.ToDateTime(dto.gr_datetime_completed); toAdd.ExpectedCompletionTime = DataParser.ToTimeSpan(dto.gr_expected_completion_time); toAdd.Repeat = DataParser.ToBool(dto.repeat); toAdd.RepeatEvery = dto.repeat_every; toAdd.RepeatFrequency = dto.repeat_frequency; toAdd.RepeatType = dto.repeat_type; toAdd.RepeatOccurences = dto.repeat_occurences; toAdd.RepeatEndsOn = DataParser.ToDateTime(dto.repeat_ends_on); toAdd.IsEvent = false; toAdd.NumSubOccurances = 0; toAdd.SubOccurancesCompleted = 0; toAdd.subOccurances = GetSubOccurances(dto.actions_tasks, ref toAdd); todaysRoutines.Add(toAdd); } } } } catch (Exception ToOccuranceIssue) { Debug.WriteLine("THERE WAS A PROBLEM IN THE 'ToOccurance' FUNCTION: " + ToOccuranceIssue.Message); } return(todaysRoutines); }
private void AddOccuranceOfHashCodeToLookupTable(int index, int hc) { Occurance firstOccurance; if (_LookupTable.TryGetValue(hc, out firstOccurance)) { firstOccurance.Next = new Occurance(index, firstOccurance.Next); } else { _LookupTable[hc] = new Occurance(index, null); } }
internal static Occur TermOccurance(Occurance o) { switch (o) { case Occurance.MUST: return(Occur.MUST); case Occurance.SHOULD: return(Occur.SHOULD); default: return(Occur.MUST_NOT); } }
// 2 hours on Sunday, 6th October 2019: // 8:00pm AWST - 9:30pm ACST - 10:00pm AEST - 1:00am NZST public static string GetDisplayString(this Occurance self) { StringBuilder builder = new StringBuilder(); builder.Append(TimeUtils.GetDurationString(self.GetDuration())); builder.Append(" on "); Instant instant = self.GetInstant(); builder.AppendLine(TimeUtils.GetDateString(instant)); builder.AppendLine(TimeUtils.GetTimeString(instant)); return(builder.ToString()); }
private static List <Occurance> GetOccurances(CarPool carPool, List <WeekDay> weekDays) { List <Occurance> occurances = new List <Occurance>(); foreach (WeekDay weekDay in weekDays) { Occurance occurance = new Occurance { CarPool = carPool, WeekDay = weekDay, DayID = weekDay.ID }; occurances.Add(occurance); } return(occurances); }
bool AllTaskNotStarted(Occurance occurance) { bool result = true; for (int i = 0; i < occurance.subOccurances.Count && i < 3; i++) { if (occurance.subOccurances[i].IsComplete == true) { result = false; break; } } return(result); }
public IActionResult DeleteOccurance(int occuranceID) { if (HttpContext.Session.GetString("CurrentUser") != null) { Occurance currentOccurance = dbContext.Occurances.Where(w => w.OccuranceId == occuranceID).FirstOrDefault(); dbContext.Remove(currentOccurance); dbContext.SaveChanges(); return(Redirect("/dashboard")); } else { return(Redirect("/")); } }
public IActionResult Leave(int occuranceID) { if (HttpContext.Session.GetString("CurrentUser") != null) { int? ID = HttpContext.Session.GetInt32("CurrentUserID"); int realId = (int)ID; Occurance currentOccurance = dbContext.Occurances.Include(w => w.Attendees).Where(w => w.OccuranceId == occuranceID).FirstOrDefault(); Association UserToLeave = currentOccurance.Attendees.FirstOrDefault(u => u.UserId == realId); dbContext.Associations.Remove(UserToLeave); dbContext.SaveChanges(); return(Redirect("/dashboard")); } else { return(Redirect("/")); } }
public void LogError() { // Arrange var db = new ErrorCollectModelContainer(); var mockClient = GetMockClient(); var mockException = GetMockException(); int timeout = 0; Func <Occurance> checkOccurance = () => { var occurance = db.Occurances .ToList() .FirstOrDefault(o => { var stack = (o.StackTrace ?? "") == mockException.StackTrace; var type = o.ExceptionLog != null && o.ExceptionLog.ExceptionType != null && o.ExceptionLog.ExceptionType.Name == "NullReferenceExceptionProxy"; var help = o.ExceptionLog != null && o.ExceptionLog.HelpLink != null && o.ExceptionLog.HelpLink.Link == mockException.HelpLink; var source = o.ExceptionLog != null && o.ExceptionLog.Source != null && o.ExceptionLog.Source.Application == mockException.Source; return(stack && type && help && source); }); return(occurance); }; using (var host = new ServiceHost(typeof(ErrorCollectService.ErrorCollectService))) { host.Open(); // Act mockClient.LogError(mockException); // Assert Occurance occurance = null; while (timeout++ < 1000 && (occurance = checkOccurance.Invoke()) == null) { System.Threading.Thread.Sleep(10); } Assert.IsNotNull(occurance); var session = db.Sessions.Find(mockClient.SessionId); db.Entry(session).State = System.Data.Entity.EntityState.Deleted; db.Entry(occurance).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); } }
// 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"))); }
internal static SearchTerm QueryFieldBetween <T>(string propertyName, object from, object to, Occurance occure = Occurance.MUST) where T : ParrotDocument { string field = ""; LuceneAnalysis analysis = MetaFinder.PropertyLuceneInfo <LuceneAnalysis>(typeof(T), propertyName); if (analysis != null) { field = analysis.Name; } else { LuceneField fld = MetaFinder.PropertyLuceneInfo <LuceneField>(typeof(T), propertyName); if (fld != null) { field = fld.Name; } } if (!string.IsNullOrEmpty(field)) { if (from.GetType() == typeof(DateTime) && to.GetType() == typeof(DateTime)) { return(new SearchTerm(field, (DateTime)from, (DateTime)to, TermOccurance(occure))); } else if (from.GetType() == typeof(int) && to.GetType() == typeof(int) || from.GetType() == typeof(short) && to.GetType() == typeof(short)) { return(new SearchTerm(field, (int)from, (int)to, TermOccurance(occure))); } else if ((from.GetType() == typeof(long) && to.GetType() == typeof(long))) { return(new SearchTerm(field, (decimal)from, (decimal)to, TermOccurance(occure))); } else if (from.GetType() == typeof(double) || to.GetType() == typeof(double) || from.GetType() == typeof(float) || to.GetType() == typeof(float) || from.GetType() == typeof(decimal) && to.GetType() == typeof(decimal)) { return(new SearchTerm(field, Convert.ToDouble(from), Convert.ToDouble(to), TermOccurance(occure))); } } return(null); }
public IActionResult ViewOccurance(int occuranceID) { if (HttpContext.Session.GetString("CurrentUser") != null) { Occurance currentOccurance = dbContext.Occurances.Include(w => w.Attendees).ThenInclude(w => w.User).Where(w => w.OccuranceId == occuranceID).FirstOrDefault(); ViewBag.occurance = currentOccurance; int? ID = HttpContext.Session.GetInt32("CurrentUserID"); int realId = (int)ID; User currentuser = dbContext.Users.FirstOrDefault(u => u.UserId == realId); int creatorID = currentOccurance.CreatorId; User Creator = dbContext.Users.FirstOrDefault(u => u.UserId == creatorID); ViewBag.creator = Creator; return(View("ViewOccurance")); } else { return(Redirect("/")); } }
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 checkSubOccurance(object sender, EventArgs args) { Grid myvar = (Grid)sender; Occurance currOccurance = myvar.BindingContext as Occurance; if (currOccurance.IsEvent) { // needs to use command parameter... goToEventsPage(currOccurance); return; } else { if (currOccurance.IsPersistent == true) { if (currOccurance.IsSublistAvailable) { SetCursor(todaysSchedule.ScrollY, currOccurance.Id); routineId = currOccurance.Id; await Navigation.PushAsync(new RoutinePage(), false); } else { UpdateOccurance(currOccurance); } } else if (currOccurance.IsPersistent == false) { if (currOccurance.IsSublistAvailable) { ProcessGoalRequest(currOccurance.Id); } else { UpdateOccurance(currOccurance); } } } }