public DB_SubCalendarEvent(SubCalendarEvent mySubCalEvent, NowProfile NowProfileData, Procrastination ProcrastinationData, CalendarEvent calendarEvent) { this.BusyFrame = mySubCalEvent.ActiveSlot; this._CalendarEventRange = mySubCalEvent.getCalendarEventRange; this._Name = mySubCalEvent.getName; this._EventDuration = mySubCalEvent.getActiveDuration; this._Complete = mySubCalEvent.getIsComplete; this._ConflictingEvents = mySubCalEvent.Conflicts; this._DataBlob = mySubCalEvent.Notes; this._Enabled = mySubCalEvent.isEnabled; updateEndTime(mySubCalEvent.End); this._EventPreDeadline = mySubCalEvent.getPreDeadline; this._EventScore = mySubCalEvent.Score; this._isEventRestricted = mySubCalEvent.getIsEventRestricted; this._LocationInfo = mySubCalEvent.LocationObj; this.OldPreferredIndex = mySubCalEvent.OldUniversalIndex; this._otherPartyID = mySubCalEvent.ThirdPartyID; this.preferredDayIndex = mySubCalEvent.UniversalDayIndex; this._PrepTime = mySubCalEvent.getPreparation; this._Priority = mySubCalEvent.getEventPriority; this._ProfileOfNow = NowProfileData; this._ProfileOfProcrastination = ProcrastinationData; this._RigidSchedule = mySubCalEvent.isRigid; updateStartTime(mySubCalEvent.Start); this._UiParams = mySubCalEvent.getUIParam; this.UniqueID = mySubCalEvent.SubEvent_ID; this._AutoDeleted = mySubCalEvent.getIsUserDeleted; this._Users = mySubCalEvent.getAllUsers(); this.Vestige = mySubCalEvent.isVestige; this._Name = mySubCalEvent.getName; this._Creator = mySubCalEvent.getCreator; this._Users = mySubCalEvent.getAllUsers(); this._TimeZone = mySubCalEvent.getTimeZone; this._calendarEvent = calendarEvent; }
internal DB_SubCalendarEventExtra(SubCalendarEvent mySubCalEvent, NowProfile NowProfileData, Procrastination ProcrastinationData) { this.BusyFrame = mySubCalEvent.ActiveSlot; this.CalendarEventRange = mySubCalEvent.getCalendarEventRange; this.FromRepeatEvent = mySubCalEvent.FromRepeat; this.EventName = mySubCalEvent.Name; this.EventDuration = mySubCalEvent.ActiveDuration; this.Complete = mySubCalEvent.isComplete; this.ConflictingEvents = mySubCalEvent.Conflicts; this.DataBlob = mySubCalEvent.Notes; this.DeadlineElapsed = mySubCalEvent.isDeadlineElapsed; this.Enabled = mySubCalEvent.isEnabled; this.EndDateTime = mySubCalEvent.End; this.EventPreDeadline = mySubCalEvent.PreDeadline; this.EventScore = mySubCalEvent.Score; this.isRestricted = mySubCalEvent.isEventRestricted; this.LocationInfo = mySubCalEvent.myLocation; this.OldPreferredIndex = mySubCalEvent.OldUniversalIndex; this.otherPartyID = mySubCalEvent.ThirdPartyID; this.preferredDayIndex = mySubCalEvent.UniversalDayIndex; this.PrepTime = mySubCalEvent.Preparation; this.Priority = mySubCalEvent.EventPriority; this.ProfileOfNow = NowProfileData; this.ProfileOfProcrastination = ProcrastinationData; //this.RepetitionFlag = mySubCalEvent.FromRepeat; this.RigidSchedule = mySubCalEvent.Rigid; this.StartDateTime = mySubCalEvent.Start; this.UiParams = mySubCalEvent.UIParam; this.UniqueID = mySubCalEvent.SubEvent_ID; this.UserDeleted = mySubCalEvent.isUserDeleted; this.UserIDs = mySubCalEvent.getAllUserIDs(); this.Vestige = mySubCalEvent.isVestige; this.OriginalStart = mySubCalEvent.OrginalStartInfo; }
override public void DeleteAppointment(SubCalendarEvent ActiveSection, string NameOfParentCalendarEvent = "", string entryID = "") { #if EnableOutlook if (entryID == "") { return; } Outlook.Application outlookApp = new Microsoft.Office.Interop.Outlook.Application(); Outlook.MAPIFolder calendar = outlookApp.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar); Outlook.Items calendarItems = calendar.Items; try { string SubJectString = ActiveSection.getId + "**" + NameOfParentCalendarEvent; if (ActiveSection.getIsComplete) { //SubJectString = ActiveSection.ID + "*\u221A*" + NameOfParentCalendarEvent; } Outlook.AppointmentItem item = calendarItems[SubJectString] as Outlook.AppointmentItem; item.Delete(); } catch (Exception e) { return; } #endif }
virtual public void WriteToOutlook(CalendarEvent MyEvent) { #if (EnableOutlook) int i = 0; if (!MyEvent.isActive) { return; } if (MyEvent.IsRecurring) { LoopThroughAddRepeatEvents(MyEvent.Repeat); } else { if (!allReadyAdded.Contains(MyEvent)) { SubCalendarEvent[] enableSubCalEVents = MyEvent.ActiveSubEvents; for (; i < enableSubCalEVents.Length; i++) { SubCalendarEvent pertinentSubCalEvent = enableSubCalEVents[i]; pertinentSubCalEvent.ThirdPartyID = AddAppointment(pertinentSubCalEvent, MyEvent.getName?.NameValue);///////////// } allReadyAdded.Add(MyEvent); } } #endif }
internal void InitializeCompleted(SubCalendarEvent SubCalendarEventData) { if (SubCalendarEventData.isComplete) { TimeSpan SPanShift = SubCalendarEventData.Start - this.Start; this.shiftEvent(SPanShift, true); this.Complete = SubCalendarEventData.isComplete; return; } throw new Exception("Trying to set uncomplete event as completed, check DB_SubCalendarEventFly"); }
internal void InitializeNowProfile(SubCalendarEvent SubCalendarEventData) { if (SubCalendarEventData.NowInfo.isInitialized) { TimeSpan SPanShift = SubCalendarEventData.Start - this.Start; this.shiftEvent(SPanShift, true); this.Enabled = SubCalendarEventData.isEnabled; return; } throw new Exception("Trying to Now event thats not set to Now"); }
internal void InitializeDisabled(SubCalendarEvent SubCalendarEventData) { if (!SubCalendarEventData.isEnabled) { TimeSpan SPanShift = SubCalendarEventData.Start - this.Start; this.shiftEvent(SPanShift, true); this.Enabled = SubCalendarEventData.isEnabled; return; } throw new Exception("Trying to set undelete event as deleted, check DB_SubCalendarEventFly"); }
override public string AddAppointment(SubCalendarEvent ActiveSection, string NameOfParentCalendarEvent = "") { if (!ActiveSection.isEnabled) { return(""); } #if EnableOutlook try { Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application(); Outlook.AppointmentItem newAppointment = (Outlook.AppointmentItem)app.CreateItem(Outlook.OlItemType.olAppointmentItem); /*(Outlook.AppointmentItem) * this.Application.CreateItem(Outlook.OlItemType.olAppointmentItem);*/ newAppointment.Start = ActiveSection.Start.toTimeZoneTime().DateTime; // DateTimeOffset.Now.AddHours(2); newAppointment.End = ActiveSection.End.toTimeZoneTime().DateTime; // DateTimeOffset.Now.AddHours(3); newAppointment.Location = "TBD"; newAppointment.Body = "JustTesting"; newAppointment.AllDayEvent = false; string SubJectString = ActiveSection.getId + "**" + NameOfParentCalendarEvent; if (ActiveSection.getIsComplete) { //SubJectString = ActiveSection.ID + "*\u221A*" + NameOfParentCalendarEvent; } newAppointment.Subject = SubJectString;// ActiveSection.ID + "**" + NameOfParentCalendarEvent; /*newAppointment.Recipients.Add("Roger Harui"); * Outlook.Recipients sentTo = newAppointment.Recipients; * Outlook.Recipient sentInvite = null; * sentInvite = sentTo.Add("Holly Holt"); * sentInvite.Type = (int)Outlook.OlMeetingRecipientType * .olRequired; * sentInvite = sentTo.Add("David Junca "); * sentInvite.Type = (int)Outlook.OlMeetingRecipientType * .olOptional; * sentTo.ResolveAll();*/ newAppointment.Save(); //newAppointment.EntryID; //newAppointment.Display(true); return(newAppointment.EntryID); } catch (Exception ex) { //MessageBox.Show("The following error occurred: " + ex.Message); return(""); } #endif return(""); }
public DB_SubCalendarEventRestricted(SubCalendarEvent mySubCalEvent, DB_RestrictionProfile restrictionData, CalendarEventRestricted parentCalendarEvent, ReferenceNow now) { this.BusyFrame = mySubCalEvent.ActiveSlot; this.HardCalendarEventRange = mySubCalEvent.getCalendarEventRange; this._ProfileOfRestriction = restrictionData; this.OldPreferredIndex = mySubCalEvent.UniversalDayIndex; this._otherPartyID = mySubCalEvent.ThirdPartyID; this.updateStartTime(mySubCalEvent.Start); this.updateEndTime(mySubCalEvent.End); //this.CalendarEventRange = CalendarEventRange.CreateCopy(); this._Complete = mySubCalEvent.getIsComplete; this._ConflictingEvents = mySubCalEvent.Conflicts; this._DataBlob = mySubCalEvent.Notes; this._Enabled = mySubCalEvent.isEnabled; this._ProfileOfProcrastination = mySubCalEvent.getProcrastinationInfo; this._EventDuration = mySubCalEvent.getActiveDuration; this._Name = mySubCalEvent.getName; this._EventPreDeadline = mySubCalEvent.getPreDeadline; //this.EventScore = mySubCalEvent.Score; //this.EventSequence = mySubCalEvent.EventSequence.CreateCopy(); //this.HumaneTimeLine = mySubCalEvent.hum HumaneTimeLine.CreateCopy(); //this.InterferringEvents = mySubCalEvent.inter this._isEventRestricted = true; this.Vestige = mySubCalEvent.isVestige; this._LocationInfo = mySubCalEvent.LocationObj; this.MiscIntData = mySubCalEvent.IntData; //this.NonHumaneTimeLine = mySubCalEvent.NonHumaneTimeLine.CreateCopy(); this._PrepTime = mySubCalEvent.getPreparation; this._Priority = mySubCalEvent.getEventPriority; this._RigidSchedule = mySubCalEvent.isRigid; this._UiParams = mySubCalEvent.getUIParam; this.UniqueID = mySubCalEvent.SubEvent_ID; this.UnUsableIndex = 0; this._AutoDeleted = mySubCalEvent.getIsUserDeleted; this._Name = mySubCalEvent.getName; this._Creator = mySubCalEvent.getCreator; this._Users = mySubCalEvent.getAllUsers(); this._TimeZone = mySubCalEvent.getTimeZone; this._Now = now; this._calendarEvent = parentCalendarEvent; initializeCalendarEventRange(restrictionData, this.HardCalendarEventRange); }
virtual public void RemoveFromOutlook(CalendarEvent MyEvent) { int i = 0; if (MyEvent.IsFromRecurringAndNotChildRepeatCalEvent) { LoopThroughRemoveRepeatEvents(MyEvent.Repeat); } else { for (i = 0; i < MyEvent.AllSubEvents.Length; i++) { SubCalendarEvent pertinentSubCalEvent = MyEvent.AllSubEvents[i]; DeleteAppointment(pertinentSubCalEvent, MyEvent.getName.NameValue, pertinentSubCalEvent.ThirdPartyID); } } allReadyAdded.Remove(MyEvent); }
public async Task <IHttpActionResult> GetSubEvent([FromUri] getEventModel eventModel) { this.authenticateUser(eventModel); UserAccount retrievedUser = await eventModel.getUserAccount(db); await retrievedUser.Login(); SubCalendarEvent retrievedSubCalendarEvent = await retrievedUser.ScheduleLogControl.getSubEventWithID(eventModel.EventID, includeRepetition : false); PostBackData retValue = new PostBackData(CustomErrors.Errors.Tile_Or_Event_ID_Cannot_Be_Found); if (retrievedSubCalendarEvent != null) { string json = JsonConvert.SerializeObject(retrievedSubCalendarEvent, Formatting.Indented, new SubCalendarEventConverter()); JObject jSubCalendarEvent = JObject.Parse(json); retValue = new PostBackData(jSubCalendarEvent, 0); } return(Ok(retValue.getPostBack)); }
public PeekResult(IEnumerable <IEnumerable <SubCalendarEvent> > AllInterferringEvents, DayTimeLine[] DayReferences, IEnumerable <SubCalendarEvent> ConflictingEvents) { PeekDays = AllInterferringEvents.Select((obj, i) => { TimeLine myDay = DayReferences[i]; TimeLine myTimeLine = new TimeLine(myDay.Start, myDay.End); myTimeLine.AddBusySlots(obj.Select(obj1 => obj1.ActiveSlot)); TimeSpan SleepSpan = myTimeLine.getAllFreeSlots().Max(obj1 => obj1.TimelineSpan); TimeSpan TotalActiveSpan = SubCalendarEvent.TotalActiveDuration(obj); double ActiveTimeDuration = TotalActiveSpan.TotalMilliseconds; double durationRatio = ActiveTimeDuration / DayReferences[i].TimelineSpan.TotalMilliseconds; var notBlobSubevent = obj.Where(o => !o.isBlobEvent).ToList(); var allSubEvents = notBlobSubevent.Concat(obj.Where(o => o.isBlobEvent).SelectMany(o => (o as BlobSubCalendarEvent).getSubCalendarEventsInBlob())); PeekDay MyPeekDay = new PeekDay { DayIndex = (int)myDay.Start.DayOfWeek, AllSubEvents = allSubEvents.Select(obj1 => obj1.ToSubCalEvent()).ToArray(), TotalDuration = TotalActiveSpan.TotalHours, DurationRatio = durationRatio, SleepTime = SleepSpan.TotalHours }; return(MyPeekDay); }).ToArray(); ConflictingCount = ConflictingEvents.Count(); }
abstract public string AddAppointment(SubCalendarEvent ActiveSection, string NameOfParentCalendarEvent = "");
abstract public void DeleteAppointment(SubCalendarEvent ActiveSection, string NameOfParentCalendarEvent = "", string entryID = "");
public async Task <IHttpActionResult> UpdateCalEvent([FromBody] EditSubCalEventModel editSubEventRequest) { this.authenticateUser(editSubEventRequest); UserAccount retrievedUser = await editSubEventRequest.getUserAccount(db); await retrievedUser.Login(); retrievedUser.getTilerUser().updateTimeZoneTimeSpan(editSubEventRequest.getTimeSpan); PostBackData retValue = new PostBackData("", 1); if (retrievedUser.Status) { string CalendarType = editSubEventRequest.ThirdPartyType.ToLower(); switch (CalendarType) { case "google": { DateTimeOffset myNow = editSubEventRequest.getRefNow(); var retrievalOption = DataRetrievalSet.scheduleManipulation; retrievalOption.Add(DataRetrivalOption.TimeLineHistory); DB_Schedule NewSchedule = new DB_Schedule(retrievedUser, myNow, editSubEventRequest.getCurrentLocation(), retrievalOption); NewSchedule.CurrentLocation = editSubEventRequest.getCurrentLocation(); Models.ThirdPartyCalendarAuthenticationModel AllIndexedThirdParty = await ScheduleController.getThirdPartyAuthentication(retrievedUser.UserID, editSubEventRequest.ThirdPartyUserID, "Google", db); GoogleTilerEventControl googleControl = new GoogleTilerEventControl(AllIndexedThirdParty, db); await googleControl.updateSubEvent(editSubEventRequest).ConfigureAwait(false); Dictionary <string, CalendarEvent> AllCalendarEvents = (await googleControl.getCalendarEvents(null, true).ConfigureAwait(false)).ToDictionary(obj => obj.getId, obj => obj); GoogleThirdPartyControl googleEvents = new GoogleThirdPartyControl(AllCalendarEvents, AllIndexedThirdParty.getTilerUser()); DB_UserActivity activity = new DB_UserActivity(myNow, UserActivity.ActivityType.ThirdPartyUpdate); retrievedUser.ScheduleLogControl.updateUserActivty(activity); await NewSchedule.updateDataSetWithThirdPartyDataAndTriggerNewAddition(new Tuple <ThirdPartyControl.CalendarTool, IEnumerable <CalendarEvent> >(ThirdPartyControl.CalendarTool.google, new List <CalendarEvent> { googleEvents.getThirdpartyCalendarEvent() })).ConfigureAwait(false); retValue = new PostBackData("\"Success\"", 0); } break; case "tiler": { DateTimeOffset myNow = editSubEventRequest.getRefNow(); myNow = editSubEventRequest.getRefNow(); HashSet <string> calendarIds = new HashSet <string>() { editSubEventRequest.EventID }; Task <Tuple <ThirdPartyControl.CalendarTool, IEnumerable <CalendarEvent> > > thirdPartyDataTask = ScheduleController.updatemyScheduleWithGoogleThirdpartyCalendar(retrievedUser.UserID, db); DB_Schedule schedule = new DB_Schedule(retrievedUser, myNow, editSubEventRequest.getCurrentLocation(), retrievalOptions: DataRetrievalSet.scheduleManipulationWithUpdateHistory, calendarIds: calendarIds); schedule.CurrentLocation = editSubEventRequest.getCurrentLocation(); var thirdPartyData = await thirdPartyDataTask.ConfigureAwait(false); schedule.updateDataSetWithThirdPartyData(thirdPartyData); long StartLong = Convert.ToInt64(editSubEventRequest.Start); long EndLong = Convert.ToInt64(editSubEventRequest.End); long LongBegin = Convert.ToInt64(editSubEventRequest.CalStart); long LongDeadline = Convert.ToInt64(editSubEventRequest.CalEnd); DateTimeOffset newStart = TilerElementExtension.JSStartTime.AddMilliseconds(StartLong); DateTimeOffset newEnd = TilerElementExtension.JSStartTime.AddMilliseconds(EndLong); DateTimeOffset Begin = TilerElementExtension.JSStartTime.AddMilliseconds(LongBegin); if (LongBegin == 0) { Begin = Utility.BeginningOfTime; } DateTimeOffset Deadline = TilerElementExtension.JSStartTime.AddMilliseconds(LongDeadline); if (LongDeadline == 0) { Deadline = Utility.BeginningOfTime; } int SplitCount = (int)editSubEventRequest.Split; if (SplitCount >= 1) { SubCalendarEvent subEventedited = schedule.getSubCalendarEvent(editSubEventRequest.EventID); Tuple <CustomErrors, Dictionary <string, CalendarEvent> > ScheduleUpdateMessage = await schedule.BundleChangeUpdate(editSubEventRequest.EventID, new EventName(retrievedUser.getTilerUser(), subEventedited, editSubEventRequest.EventName), newStart, newEnd, Begin, Deadline, SplitCount, editSubEventRequest.EscapedNotes).ConfigureAwait(false); DB_UserActivity activity = new DB_UserActivity(myNow, UserActivity.ActivityType.InternalUpdate, new List <String>() { editSubEventRequest.EventID }); retrievedUser.ScheduleLogControl.updateUserActivty(activity); await schedule.persistToDB().ConfigureAwait(false); //EventID eventId = new EventID(myUser.EventID); //CalendarEvent calendarEvent = schedule.getCalendarEvent(eventId); //SubCalendarEvent subEvent = calendarEvent.ActiveSubEvents.FirstOrDefault(); //SubCalEvent subCalEvent = subEvent.ToSubCalEvent(calendarEvent); //JObject retSubEvent = new JObject(); //retSubEvent.Add("subEvent", JObject.FromObject(subCalEvent)); //retValue = new PostBackData(retSubEvent, 0); retValue = new PostBackData(); } else { CustomErrors error = new CustomErrors(CustomErrors.Errors.TilerConfig_Zero_SplitCount); retValue = new PostBackData(error); } } break; default: break; } } await AnalysisController.updateSuggestionAnalysis(retrievedUser.ScheduleLogControl).ConfigureAwait(false); TilerFront.SocketHubs.ScheduleChange scheduleChangeSocket = new TilerFront.SocketHubs.ScheduleChange(); scheduleChangeSocket.triggerRefreshData(retrievedUser.getTilerUser()); return(Ok(retValue.getPostBack)); }
public override void DeleteAppointment(SubCalendarEvent ActiveSection, string NameOfParentCalendarEvent = "", string entryID = "") { throw new NotImplementedException(); }
public override string AddAppointment(SubCalendarEvent ActiveSection, string NameOfParentCalendarEvent = "") { throw new NotImplementedException(); }
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 override Task <Tuple <CustomErrors, Dictionary <string, CalendarEvent> > > BundleChangeUpdate(string EventId, EventName NewName, DateTimeOffset newStart, DateTimeOffset newEnd, int newSplitCount, string notes, bool forceRecalculation = false, SubCalendarEvent triggerSubEvent = null) { Task <TilerEvent> pendingNameAndMisc = null; //dynamic pendingNameAndMisc = null; bool useSubEvent = triggerSubEvent != null && triggerSubEvent.NameId.isNot_NullEmptyOrWhiteSpace() && triggerSubEvent.DataBlobId.isNot_NullEmptyOrWhiteSpace(); if (useSubEvent) { if (this.myAccount.ScheduleLogControl.Database != null) { pendingNameAndMisc = Task <TilerEvent> .Run(async() => { SubCalendarEvent subRetValue = await this.myAccount.ScheduleLogControl.Database.SubEvents .Include(eachSubEvent => eachSubEvent.DataBlob_EventDB) .Include(eachSubEvent => eachSubEvent.Name) .Include(eachSubEvent => eachSubEvent.SentimentAnalysis_DB) .FirstAsync(eachSubEvent => eachSubEvent.Id == triggerSubEvent.Id).ConfigureAwait(false); TilerEvent tileRetValue = (TilerEvent)subRetValue; return(tileRetValue); }); } } else { var calEent = getCalendarEvent(EventId); if (calEent != null) { if (this.myAccount.ScheduleLogControl.Database != null) { pendingNameAndMisc = Task <TilerEvent> .Run(async() => { CalendarEvent calRetValue = await this.myAccount.ScheduleLogControl.Database.CalEvents .Include(eachSubEvent => eachSubEvent.DataBlob_EventDB) .Include(eachSubEvent => eachSubEvent.Name) .FirstAsync(eachSubEvent => eachSubEvent.Id == calEent.Id).ConfigureAwait(false); TilerEvent tileRetValue = (TilerEvent)calRetValue; return(tileRetValue); }); } } } var retValue = base.BundleChangeUpdate(EventId, NewName, newStart, newEnd, newSplitCount, notes, forceRecalculation, triggerSubEvent); TilerEvent tilerEvent = null; if (!useSubEvent) { tilerEvent = getCalendarEvent(EventId); } else { tilerEvent = triggerSubEvent; } if (pendingNameAndMisc != null) { pendingNameAndMisc.Wait(); var pendingNameAndMiscResult = pendingNameAndMisc.Result; EventName oldName = pendingNameAndMiscResult.getName; MiscData miscData = pendingNameAndMiscResult.Notes; SentimentAnalysis sentimentAnalysis = pendingNameAndMiscResult.SentimentAnalysis_DB; bool isNameChange = NewName.NameValue != oldName?.NameValue; if (isNameChange) { string emojiString = Task.Run(async() => await OpenAIService.Instance().getEmojis(NewName.NameValue)).GetAwaiter().GetResult(); if (sentimentAnalysis != null) { sentimentAnalysis.updateEmoji(emojiString); } else { sentimentAnalysis = new SentimentAnalysis(); tilerEvent.SentimentAnalysis_DB = sentimentAnalysis; sentimentAnalysis.updateEmoji(emojiString); } tilerEvent.updateEventName(NewName.NameValue); } var note = miscData; if (note != null) { note.UserNote = notes; } } return(retValue); }
public async Task <IHttpActionResult> pushedEvent([FromBody] WhatIfModel UserData) { AuthorizedUser myAuthorizedUser = UserData.User; UserAccount retrievedUser = await UserData.getUserAccount(db); await retrievedUser.Login(); retrievedUser.getTilerUser().updateTimeZoneTimeSpan(UserData.getTimeSpan); PostBackData returnPostBack; if (retrievedUser.Status) { Task <Tuple <ThirdPartyControl.CalendarTool, IEnumerable <CalendarEvent> > > thirdPartyDataTask = ScheduleController.updatemyScheduleWithGoogleThirdpartyCalendar(retrievedUser.UserID, db); DB_Schedule schedule = new DB_Schedule(retrievedUser, myAuthorizedUser.getRefNow(), UserData.getCurrentLocation()); var thirdPartyData = await thirdPartyDataTask.ConfigureAwait(false); schedule.updateDataSetWithThirdPartyData(thirdPartyData); schedule.CurrentLocation = myAuthorizedUser.getCurrentLocation(); Tuple <Health, Health> evaluation; SubCalendarEvent subEvent = null; try { if (String.IsNullOrEmpty(UserData.EventId)) { var calEventAndSubEvent = schedule.getNearestEventToNow(); subEvent = calEventAndSubEvent.Item2; EventID eventId = new EventID(calEventAndSubEvent.Item2.getId); evaluation = await schedule.TimeStone.PushSingleEvent(UserData.Duration, eventId, null); } else { evaluation = await schedule.TimeStone.PushSingleEvent(UserData.Duration, new EventID(UserData.EventId), null); } JObject before = evaluation.Item1.ToJson(); JObject after = evaluation.Item2.ToJson(); JObject resultData = new JObject(); if (subEvent != null) { SubCalEvent subcalevent = subEvent.ToSubCalEvent(); JObject jsonSubcal = JObject.FromObject(subcalevent); resultData.Add("subEvent", jsonSubcal); } resultData.Add("before", before); resultData.Add("after", after); returnPostBack = new PostBackData(resultData, 0); return(Ok(returnPostBack.getPostBack)); } catch (CustomErrors error) { returnPostBack = new PostBackData(error); return(Ok(returnPostBack.getPostBack)); } } else { returnPostBack = new PostBackData("", 1); } return(Ok(returnPostBack.getPostBack)); }