public async Task <IHttpActionResult> GetCalEvent(string id, [FromUri] AuthorizedUser myUser) { UserAccount retrievedUser = await myUser.getUserAccount(db); await retrievedUser.Login(); TilerElements.CalendarEvent retrievedCalendarEvent = await retrievedUser.ScheduleLogControl.getCalendarEventWithID(id); PostBackData retValue = new PostBackData(retrievedCalendarEvent.ToCalEvent(), 0); return(Ok(retValue.getPostBack)); }
public static CalEvent ToDeletedCalEvent(this TilerElements.CalendarEvent CalendarEventEntry, TilerElements.TimeLine Range = null) { CalEvent retValue = new CalEvent(); retValue.ThirdPartyUserID = CalendarEventEntry.getCreator.Id; retValue.ID = CalendarEventEntry.getId; retValue.ThirdPartyType = CalendarEventEntry.ThirdpartyType.ToString(); retValue.CalendarName = CalendarEventEntry.getName?.NameValue; retValue.StartDate = (long)(CalendarEventEntry.Start - JSStartTime).TotalMilliseconds; retValue.EndDate = (long)(CalendarEventEntry.End - JSStartTime).TotalMilliseconds; retValue.TotalDuration = CalendarEventEntry.getActiveDuration; retValue.Rigid = CalendarEventEntry.isRigid; retValue.AddressDescription = CalendarEventEntry.Location.Description; retValue.Address = CalendarEventEntry.Location.Address; retValue.Longitude = CalendarEventEntry.Location.Longitude; retValue.Latitude = CalendarEventEntry.Location.Latitude; retValue.NumberOfSubEvents = CalendarEventEntry.AllSubEvents.Count();// CalendarEventEntry.NumberOfSplit;// AllSubEvents.Count(); retValue.RColor = CalendarEventEntry.getUIParam.UIColor.R; retValue.GColor = CalendarEventEntry.getUIParam.UIColor.G; retValue.BColor = CalendarEventEntry.getUIParam.UIColor.B; retValue.OColor = CalendarEventEntry.getUIParam.UIColor.O; retValue.ColorSelection = CalendarEventEntry.getUIParam.UIColor.User; retValue.NumberOfCompletedTasks = CalendarEventEntry.CompletionCount; retValue.NumberOfDeletedEvents = CalendarEventEntry.DeletionCount; retValue.OtherPartyID = CalendarEventEntry.ThirdPartyID; retValue.Notes = CalendarEventEntry.Notes.UserNote; retValue.isThirdParty = CalendarEventEntry.isThirdParty; TimeSpan FreeTimeLeft = CalendarEventEntry.RangeSpan - CalendarEventEntry.getActiveDuration; long TickTier1 = (long)(FreeTimeLeft.Ticks * (.667)); long TickTier2 = (long)(FreeTimeLeft.Ticks * (.865)); long TickTier3 = (long)(FreeTimeLeft.Ticks * (1)); retValue.Tiers = new long[] { TickTier1, TickTier2, TickTier3 }; if (Range != null) { retValue.AllSubCalEvents = CalendarEventEntry.AllSubEvents.Where(obj => !obj.isActive).Where(obj => obj.StartToEnd.InterferringTimeLine(Range) != null).Select(obj => obj.ToSubCalEvent(CalendarEventEntry)).ToList(); } else { retValue.AllSubCalEvents = CalendarEventEntry.AllSubEvents.Where(obj => !obj.isActive).Select(obj => obj.ToSubCalEvent(CalendarEventEntry)).ToList(); } return(retValue); }
public static SubCalEvent ToSubCalEvent(this TilerElements.PausedTimeLineEntry pausedTimeline, TilerElements.CalendarEvent CalendarEventEntry, bool includeCalendarEvent = true) { SubCalendarEvent pausedSubEvent = CalendarEventEntry.getSubEvent(pausedTimeline.getSubEventId()); DateTimeOffset CurrentTime = DateTimeOffset.UtcNow; SubCalEvent retValue = new SubCalEvent(); retValue.ThirdPartyUserID = CalendarEventEntry.getCreator.Id; retValue.ThirdPartyType = CalendarEventEntry.ThirdpartyType.ToString(); retValue.ThirdPartyEventID = CalendarEventEntry.ThirdPartyID; retValue.ID = pausedTimeline.Id; retValue.CalendarID = CalendarEventEntry.Calendar_EventID.getRepeatCalendarEventID(); retValue.SubCalStartDate = (long)(pausedTimeline.Start - JSStartTime).TotalMilliseconds; retValue.SubCalEndDate = (long)(pausedTimeline.End - JSStartTime).TotalMilliseconds; retValue.SubCalTotalDuration = pausedTimeline.TimelineSpan; retValue.SubCalRigid = CalendarEventEntry.isRigid; retValue.SubCalAddressDescription = pausedSubEvent.Location.Description; retValue.SubCalAddress = pausedSubEvent.Location.Address; retValue.ThirdPartyEventID = pausedSubEvent.ThirdPartyID; retValue.SubCalCalendarName = pausedSubEvent.Name?.NameValue; retValue.Notes = pausedSubEvent?.Notes?.UserNote; if (CalendarEventEntry != null) { retValue.CalRigid = CalendarEventEntry.isRigid; retValue.SubCalCalEventStart = (long)(CalendarEventEntry.Start - JSStartTime).TotalMilliseconds; retValue.SubCalCalEventEnd = (long)(CalendarEventEntry.End - JSStartTime).TotalMilliseconds; retValue.SuggestedDeadline = CalendarEventEntry.DeadlineSuggestion.ToUnixTimeMilliseconds(); retValue.SleepSuggestedDeadline = CalendarEventEntry.SleepDeadlineSuggestion.ToUnixTimeMilliseconds(); if (string.IsNullOrEmpty(CalendarEventEntry.ThirdPartyID)) { } else { retValue.ID = retValue.ThirdPartyEventID; } } retValue.SubCalEventLong = pausedSubEvent.Location.Longitude; retValue.SubCalEventLat = pausedSubEvent.Location.Latitude; retValue.SubCalCalendarName = pausedSubEvent.getName?.NameValue; TilerColor uiColor = TilerColor.pausedUIColor(); if (uiColor != null) { retValue.RColor = uiColor.R; retValue.GColor = uiColor.G; retValue.BColor = uiColor.B; retValue.OColor = uiColor.O; retValue.ColorSelection = uiColor.User; } retValue.isComplete = false; retValue.isEnabled = true; retValue.Duration = (long)pausedTimeline.TimelineSpan.TotalMilliseconds; retValue.ThirdPartyEventID = pausedSubEvent.ThirdPartyID; retValue.EventPreDeadline = (long)pausedSubEvent.getPreDeadline.TotalMilliseconds; retValue.Priority = pausedSubEvent.getEventPriority; retValue.Conflict = String.Join(",", pausedSubEvent.Conflicts.getConflictingEventIDs()); retValue.isPaused = false; retValue.isPauseAble = false; retValue.PauseStart = (long)(pausedTimeline.Start - JSStartTime).TotalMilliseconds; retValue.PauseEnd = (long)(pausedTimeline.End - JSStartTime).TotalMilliseconds; retValue.IsLocked = true; retValue.UserLocked = false; retValue.isThirdParty = pausedSubEvent.isThirdParty; retValue.isReadOnly = true; retValue.isTardy = false; retValue.isProcrastinateAll = false; retValue.isAllDay = pausedSubEvent.getActiveDuration >= Utility.LeastAllDaySubeventDuration; if (CalendarEventEntry != null && includeCalendarEvent) { retValue.CalEvent = CalendarEventEntry.ToCalEvent(includeSubevents: false); } return(retValue); }
public static CalEvent ToCalEvent(this TilerElements.CalendarEvent CalendarEventEntry, TilerElements.TimeLine Range = null, bool includeSubevents = true) { CalEvent retValue = new CalEvent(); retValue.ThirdPartyUserID = CalendarEventEntry.getCreator.Id; retValue.ID = CalendarEventEntry.getId; retValue.ThirdPartyType = CalendarEventEntry.ThirdpartyType.ToString(); retValue.CalendarName = CalendarEventEntry.getName?.NameValue; retValue.StartDate = (long)(CalendarEventEntry.Start - JSStartTime).TotalMilliseconds; retValue.EndDate = (long)(CalendarEventEntry.End - JSStartTime).TotalMilliseconds; retValue.TotalDuration = CalendarEventEntry.getActiveDuration; retValue.Rigid = CalendarEventEntry.isRigid; retValue.AddressDescription = CalendarEventEntry.Location.Description; retValue.Address = CalendarEventEntry.Location.Address; retValue.Longitude = CalendarEventEntry.Location.Longitude; retValue.Latitude = CalendarEventEntry.Location.Latitude; retValue.NumberOfSubEvents = CalendarEventEntry.NumberOfSplit; if (CalendarEventEntry.getUIParam != null && CalendarEventEntry.getUIParam.UIColor != null) { retValue.RColor = CalendarEventEntry.getUIParam.UIColor.R; retValue.GColor = CalendarEventEntry.getUIParam.UIColor.G; retValue.BColor = CalendarEventEntry.getUIParam.UIColor.B; retValue.OColor = CalendarEventEntry.getUIParam.UIColor.O; retValue.ColorSelection = CalendarEventEntry.getUIParam.UIColor.User; } retValue.NumberOfCompletedTasks = CalendarEventEntry.CompletionCount; retValue.NumberOfDeletedEvents = CalendarEventEntry.DeletionCount; retValue.OtherPartyID = CalendarEventEntry.ThirdPartyID; retValue.Notes = CalendarEventEntry?.Notes?.UserNote; retValue.isThirdParty = CalendarEventEntry.isThirdParty; retValue.isReadOnly = CalendarEventEntry.isReadOnly; retValue.SuggestedDeadline = CalendarEventEntry.DeadlineSuggestion.ToUnixTimeMilliseconds(); retValue.isProcrastinateAll = CalendarEventEntry.isProcrastinateEvent; retValue.LastSuggestedDeadline = CalendarEventEntry.LastDeadlineSuggestion.ToUnixTimeMilliseconds(); retValue.SleepSuggestedDeadline = CalendarEventEntry.SleepDeadlineSuggestion.ToUnixTimeMilliseconds(); TimeSpan FreeTimeLeft = CalendarEventEntry.RangeSpan - CalendarEventEntry.getActiveDuration; long TickTier1 = (long)(FreeTimeLeft.Ticks * (.667)); long TickTier2 = (long)(FreeTimeLeft.Ticks * (.865)); long TickTier3 = (long)(FreeTimeLeft.Ticks * (1)); retValue.Tiers = new long[] { TickTier1, TickTier2, TickTier3 }; bool canDoNow = false; if (!CalendarEventEntry.IsFromRecurring) { canDoNow = (CalendarEventEntry.AutoDeletionCount + CalendarEventEntry.DeletionCount + CalendarEventEntry.CompletionCount) < CalendarEventEntry.NumberOfSplit; } else { canDoNow = CalendarEventEntry.End > DateTimeOffset.UtcNow; } retValue.canDoNow = canDoNow; if (includeSubevents) { if (Range != null) { retValue.AllSubCalEvents = CalendarEventEntry.ActiveSubEvents.Where(obj => obj.StartToEnd.InterferringTimeLine(Range) != null).Select(obj => obj.ToSubCalEvent(CalendarEventEntry)).ToList(); } else { retValue.AllSubCalEvents = CalendarEventEntry.ActiveSubEvents.Select(obj => obj.ToSubCalEvent(CalendarEventEntry)).ToList(); } if (CalendarEventEntry.PausedTimeLines.Count > 0) { retValue.AllSubCalEvents = CalendarEventEntry.PausedTimeLines.Where(pausedImeline => pausedImeline.IsFinal && CalendarEventEntry.getSubEvent(pausedImeline.getSubEventId()) != null).Select(pausedImeline => pausedImeline.ToSubCalEvent(CalendarEventEntry)).Concat(retValue.AllSubCalEvents).ToList(); } } retValue.IsLocked = CalendarEventEntry.isLocked; retValue.UserLocked = CalendarEventEntry.userLocked; return(retValue); }