/// <summary> /// Function creates a schedule dump that is equivalent to schedule from RDBMS /// </summary> /// <returns></returns> virtual async public Task <ScheduleDump> CreateScheduleDump(TilerElements.Location requestLocation = null, ReferenceNow referenceNow = null, string notes = "") { referenceNow = referenceNow ?? this.Now; if (requestLocation == null) { requestLocation = TilerElements.Location.getDefaultLocation(); } return(await myAccount.ScheduleLogControl.CreateScheduleDump(this.getAllCalendarEvents(), myAccount.getTilerUser(), referenceNow, notes, requestLocation).ConfigureAwait(false)); }
public static Location ToLocationModel(this TilerElements.Location LocationEntry) { Location retValue = new Location(); retValue.Address = LocationEntry.Address; retValue.Tag = LocationEntry.Description; retValue.Long = LocationEntry.Longitude; retValue.Lat = LocationEntry.Latitude; retValue.isNull = LocationEntry.isNull; retValue.isVerified = LocationEntry.IsVerified; retValue.isAmbiguous = LocationEntry.IsAmbiguous; retValue.LocationId = LocationEntry.Id; return(retValue); }
public DB_Schedule(UserAccount AccountEntry, DateTimeOffset referenceNow, TilerElements.Location requestLocation, HashSet <DataRetrivalOption> retrievalOptions = null, TimeLine rangeOfLookup = null, bool createDump = true, HashSet <string> calendarIds = null) { myAccount = AccountEntry; if (retrievalOptions == null) { retrievalOptions = DataRetrievalSet.scheduleManipulationPerformance; } #if localDebugMode retrievalOptions.Add(DataRetrivalOption.Name); #endif this.retrievalOptions = retrievalOptions; this.RangeOfLookup = rangeOfLookup ?? new TimeLine(referenceNow.AddDays(Utility.defaultBeginDay), referenceNow.AddDays(Utility.defaultEndDay)); _CreateDump = createDump; Initialize(referenceNow, requestLocation, calendarIds).Wait(); }
public async Task SuggestionAnalysis(LogControl logControl, TilerElements.Location requestLocation) { if (logControl.Now == null) { logControl.Now = new ReferenceNow(DateTimeOffset.UtcNow, logControl.getTilerRetrievedUser().EndfOfDay, logControl.getTilerRetrievedUser().TimeZoneDifference); } else { logControl.Now = new ReferenceNow(logControl.Now.constNow, logControl.getTilerRetrievedUser().EndfOfDay, logControl.getTilerRetrievedUser().TimeZoneDifference); } DateTimeOffset nowTime = logControl.Now.constNow; TimeLine timeline = new TimeLine(logControl.Now.constNow.AddDays(-45), logControl.Now.constNow.AddDays(45)); List <IndexedThirdPartyAuthentication> AllIndexedThirdParty = await ScheduleController.getAllThirdPartyAuthentication(logControl.LoggedUserID, db).ConfigureAwait(false); List <GoogleTilerEventControl> AllGoogleTilerEvents = AllIndexedThirdParty.Select(obj => new GoogleTilerEventControl(obj, db)).ToList(); var tupleOfSUbEVentsAndAnalysis = await logControl.getSubCalendarEventForAnalysis(timeline, logControl.getTilerRetrievedUser()).ConfigureAwait(false); List <SubCalendarEvent> subEvents = tupleOfSUbEVentsAndAnalysis.Item1.ToList(); Analysis analysis = tupleOfSUbEVentsAndAnalysis.Item2; Task <ConcurrentBag <CalendarEvent> > GoogleCalEventsTask = GoogleTilerEventControl.getAllCalEvents(AllGoogleTilerEvents, timeline); IEnumerable <CalendarEvent> GoogleCalEvents = await GoogleCalEventsTask.ConfigureAwait(false); subEvents.AddRange(GoogleCalEvents.SelectMany(o => o.AllSubEvents)); foreach (CalendarEvent calEvent in new HashSet <CalendarEvent> (subEvents.Select(o => o.ParentCalendarEvent))) { calEvent.backUpAndresetDeadlineSuggestions(); calEvent.resetSleepDeadlineSuggestion(); } ScheduleSuggestionsAnalysis scheduleSuggestion = new ScheduleSuggestionsAnalysis(subEvents, logControl.Now, logControl.getTilerRetrievedUser(), analysis); var overoccupiedTimelines = scheduleSuggestion.getOverLoadedWeeklyTimelines(nowTime, scheduleSuggestion.getActiveRatio()); var suggestion = scheduleSuggestion.suggestScheduleChange(overoccupiedTimelines, scheduleSuggestion.getActiveRatio()); suggestion.updateDeadlineSuggestions(); var overoccupiedSleepTimelines = scheduleSuggestion.getOverLoadedWeeklyTimelines(nowTime, scheduleSuggestion.getSleepRatio()); var sleepSuggestionDeadlines = scheduleSuggestion.suggestScheduleChange(overoccupiedSleepTimelines, scheduleSuggestion.getSleepRatio()); foreach (KeyValuePair <CalendarEvent, TimeLine> kvp in sleepSuggestionDeadlines.DeadlineUpdates) { kvp.Key.updateSleepDeadlineSuggestion(kvp.Value.End); } List <CalendarEvent> calEvents = new HashSet <CalendarEvent>(subEvents.Select(o => o.ParentCalendarEvent)).ToList(); await logControl.Commit(calEvents, null, "0", logControl.Now, null, requestLocation); }
/// <summary> /// Creates a schedule dump and then persists it to the DB /// </summary> /// <returns></returns> virtual async public Task <ScheduleDump> CreateAndPersistScheduleDump(TilerElements.Location requestLocation = null, ScheduleDump scheduleDump = null, ReferenceNow now = null) { if (requestLocation == null) { requestLocation = TilerElements.Location.getDefaultLocation(); } ReferenceNow refNow = now ?? this.Now; scheduleDump = scheduleDump ?? await this.CreateScheduleDump(requestLocation, refNow).ConfigureAwait(false); scheduleDump.ReferenceNow = this.Now.constNow; scheduleDump.StartOfDay = this.Now.EndOfDay; myAccount.ScheduleLogControl.Database.ScheduleDumps.Add(scheduleDump); await persistToDB().ConfigureAwait(false); return(scheduleDump); }
public DB_Repetition(CalendarEvent parentCalendarEvent, IEnumerable <CalendarEvent> calEvents, int dayOfWeek = 7, bool notSubRepetition = false) { if (calEvents.Count() > 0 && !notSubRepetition) { if (calEvents.First().Calendar_EventID.getRepeatDayCalendarEventComponent() != "7") { initializeSubRepetitions(parentCalendarEvent, calEvents); } } else { RepetitionWeekDay = dayOfWeek; _RepetitionFrequency = Frequency.NONE; _RepetitionRange = new TimeLine(); _EnableRepeat = false; _Location = new TilerElements.Location(); _initializingRange = new TimeLine(); _DictionaryOfIDAndCalendarEvents = new SubEventDictionary <string, CalendarEvent>(calEvents); _DictionaryOfWeekDayToRepetition = new SubEventDictionary <int, Repetition>(); } }
public DB_ProcrastinateAllSubCalendarEvent(TilerUser user, TilerUserGroup group, string timeZone, TimeLine timeLine, EventID calendarEventId, TilerElements.Location location, ProcrastinateCalendarEvent calendarEvent, bool isEnabled, bool isCompleted) : base(user, group, timeZone, timeLine, calendarEventId, location, calendarEvent) { this._TimeZone = timeZone; updateStartTime(timeLine.Start); updateEndTime(timeLine.End); this._RigidSchedule = true; this.UniqueID = calendarEventId; this._Creator = user; this._Users = group; this._Enabled = isEnabled; this._Complete = isCompleted; this._ProfileOfNow = new NowProfile(); this._ProfileOfProcrastination = new Procrastination(new DateTimeOffset(), new TimeSpan()); _isProcrastinateEvent = true; this._calendarEvent = calendarEvent; }
public DB_SubCalendarEvent(CalendarEvent calendarEvent, TilerUser Creator, TilerUserGroup users, string timeZone, string MySubEventID, EventName name, BusyTimeLine MyBusylot, DateTimeOffset EventStart, DateTimeOffset EventDeadline, TimeSpan EventPrepTime, string myParentID, bool Rigid, bool Enabled, EventDisplay UiParam, MiscData Notes, bool completeFlag, TilerElements.Location EventLocation = null, TimeLine calendarEventRange = null, ConflictProfile conflicts = null) { if (EventDeadline < EventStart) { throw new Exception("SubCalendar Event cannot have an end time earlier than the start time"); } _TimeZone = timeZone; _Name = name; _Creator = Creator; _Users = users; if (conflicts == null) { conflicts = new ConflictProfile(); } _ConflictingEvents = conflicts; _CalendarEventRange = calendarEventRange; //string eventName, TimeSpan EventDuration, DateTimeOffset EventStart, DateTimeOffset EventDeadline, TimeSpan EventPrepTime, TimeSpan PreDeadline, bool EventRigidFlag, bool EventRepetition, int EventSplit updateStartTime(EventStart); updateEndTime(EventDeadline); _EventDuration = MyBusylot.End - MyBusylot.Start; BusyFrame = MyBusylot; _PrepTime = EventPrepTime; UniqueID = new EventID(MySubEventID); this._LocationInfo = EventLocation; _UiParams = UiParam; _DataBlob = Notes; _Complete = completeFlag; this._Enabled = Enabled; //EventSequence = new EventTimeLine(UniqueID.ToString(), StartDateTime, EndDateTime); _RigidSchedule = Rigid; _LastReasonStartTimeChanged = this.Start; _calendarEvent = calendarEvent; }
async virtual protected Task Initialize(DateTimeOffset referenceNow, DateTimeOffset StartOfDay, TilerElements.Location requestLocation, HashSet <string> calendarIds = null) { if (!myAccount.Status) { throw new Exception("Using non verified tiler Account, try logging into account first."); } _Now = new ReferenceNow(referenceNow, StartOfDay, myAccount.getTilerUser().TimeZoneDifference); this.RangeOfLookup = this.RangeOfLookup ?? new TimeLine(_Now.constNow.AddDays(Schedule.TimeLookUpDayStart), _Now.constNow.AddDays(Schedule.TimeLookUpDayEnd)); Tuple <Dictionary <string, CalendarEvent>, DateTimeOffset, Dictionary <string, Location>, Analysis> profileData = await myAccount.ScheduleData.getProfileInfo(RangeOfLookup, _Now, this.retrievalOptions, requestLocation, calendarIds : calendarIds).ConfigureAwait(false); myAccount.Now = _Now; TravelCache travelCache = await myAccount.ScheduleData.getTravelCache(myAccount.UserID).ConfigureAwait(false); updateTravelCache(travelCache); if (profileData != null) { this.setAnalysis(profileData.Item4); DateTimeOffset referenceDayTimeNow = new DateTimeOffset(Now.calculationNow.Year, Now.calculationNow.Month, Now.calculationNow.Day, profileData.Item2.Hour, profileData.Item2.Minute, profileData.Item2.Second, new TimeSpan());// profileData.Item2; ReferenceDayTIime = Now.calculationNow < referenceDayTimeNow?referenceDayTimeNow.AddDays(-1) : referenceDayTimeNow; initializeAllEventDictionary(profileData.Item1.Values); if (getAllEventDictionary != null) { EventID.Initialize((uint)(myAccount.LastEventTopNodeID)); initializeThirdPartyCalendars(); updateThirdPartyCalendars(ThirdPartyControl.CalendarTool.outlook, new List <CalendarEvent>() { }); CompleteSchedule = getTimeLine(); } Locations = profileData.Item3; } TilerUser = myAccount.getTilerUser(); }
async virtual protected Task Initialize(DateTimeOffset referenceNow, TilerElements.Location requestLocation, HashSet <string> calendarIds = null) { DateTimeOffset StartOfDay = myAccount.ScheduleData.getDayReferenceTime(); await Initialize(referenceNow, StartOfDay, requestLocation, calendarIds).ConfigureAwait(false); }
public DB_ProcrastinateCalendarEvent(EventID procrasstinaeAllId, EventName NameEntry, DateTimeOffset StartData, DateTimeOffset EndData, TimeSpan EventDuration, TimeSpan eventPrepTime, TimeSpan PreDeadlineTimeSpan, Repetition EventRepetitionEntry, TilerElements.Location EventLocation, EventDisplay UiData, MiscData NoteData, bool EnabledEventFlag, bool CompletionFlag, TilerUser creator, TilerUserGroup users, string timeZone, int splitCount, NowProfile nowProfile) : base(procrasstinaeAllId, NameEntry, StartData, EndData, EventDuration, eventPrepTime, PreDeadlineTimeSpan, EventRepetitionEntry, EventLocation, UiData, NoteData, EnabledEventFlag, CompletionFlag, creator, users, timeZone, splitCount, nowProfile) { UniqueID = procrasstinaeAllId; }
public async static Task <IEnumerable <CalendarEvent> > getAllCalEvents(IList <Event> AllSubCals, CalendarService CalendarServiceData, string UserID, EventID AuthenticationID, TimeLine CalculationTimeLine, bool retrieveLocationFromGoogle, Location defaultLocation = null) { List <Event> AllSubCalNoCancels = AllSubCals.Where(obj => obj.Status != "cancelled").ToList(); Dictionary <string, Event> RepeatingIDs = new Dictionary <string, Event>(); DateTimeOffset now = DateTimeOffset.UtcNow; ConcurrentBag <CalendarEvent> RetValue = new ConcurrentBag <CalendarEvent>(); if (CalculationTimeLine == null) { CalculationTimeLine = new TimeLine(now.AddDays(Utility.defaultBeginDay), now.AddDays(Utility.defaultEndDay)); } ConcurrentBag <TilerElements.Location> locations = new ConcurrentBag <TilerElements.Location>(); uint i = 0; for (; i < AllSubCalNoCancels.Count; i++) { Event GoogleEvent = AllSubCalNoCancels[(int)i]; if (GoogleEvent.Start.DateTime != null) { TimeLine EventRange = new TimeLine(GoogleEvent.Start.DateTime.Value.ToUniversalTime(), GoogleEvent.End.DateTime.Value.ToUniversalTime()); if (EventRange.InterferringTimeLine(CalculationTimeLine) != null || GoogleEvent.Recurrence != null) // took out manual check for repetition because of we set the property singleEvents in the function getGoogleEvents in class GoogleTilerEventControl.cs. If you need the manual look up run "git checkout 8db3dab166909255ce112" and jump back to this file you should see logic about this below. { GoogleIDs.Add(GoogleEvent.Id); CalendarEvent calEvent = GoogleCalendarEvent.convertFromGoogleToCalendarEvent(GoogleEvent.ToSubCal(AuthenticationID, i)); RetValue.Add(calEvent); locations.Add(calEvent.LocationObj); if (defaultLocation != null && (calEvent.LocationObj != null && (calEvent.LocationObj.isNull || calEvent.LocationObj.isDefault))) { calEvent.Location_DB = defaultLocation; foreach (var eachSubEvent in calEvent.AllSubEvents) { eachSubEvent.Location_DB = defaultLocation; } } } } } if (retrieveLocationFromGoogle) { batchValidateLocations(locations); } else { foreach (TilerElements.Location location in locations) { location.IsVerified = true; } } return(RetValue); }
virtual async public Task Commit(IEnumerable <CalendarEvent> AllEvents, CalendarEvent calendarEvent, String LatestID, ReferenceNow now, TravelCache travelCache, TilerElements.Location requestLocation) { await UserLog.Commit(AllEvents, calendarEvent, LatestID, now, travelCache, requestLocation).ConfigureAwait(false); }