Skip to content

Commit

Permalink
Added parameter to GetCalendarEntriesInRange() for retrieving series …
Browse files Browse the repository at this point in the history
…exceptions.

Always SeparateGoogleExceptions() at the end before returning.
#2034
  • Loading branch information
phw198 committed Jan 2, 2025
1 parent 04c2f11 commit 4585bcc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
14 changes: 11 additions & 3 deletions src/OutlookGoogleCalendarSync/Google/GoogleCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public void GetCalendars() {
this.CalendarList = result;
}

/// <summary>Retrieve all instances for a recurring series.</summary>
public List<Event> GetCalendarEntriesInRecurrence(String recurringEventId) {
List<Event> result = new List<Event>();
Events request = null;
Expand Down Expand Up @@ -280,12 +281,16 @@ public Event GetCalendarEntry(String eventId) {
}
}

public List<Event> GetCalendarEntriesInRange() {
/// <summary>Get calendar Events occurring between the sync date ranges</summary>
/// <returns>Single events, recurring master and exceptions</returns>
public List<Event> GetCalendarEntriesInRange(String recurringId = null) {
SettingsStore.Calendar profile = Settings.Profile.InPlay();
return GetCalendarEntriesInRange(profile.SyncStart, profile.SyncEnd);
return GetCalendarEntriesInRange(profile.SyncStart, profile.SyncEnd, false, recurringId);
}

public List<Event> GetCalendarEntriesInRange(System.DateTime from, System.DateTime to, Boolean suppressAdvisories = false) {
/// <summary>Get calendar Events occurring between the specified dates</summary>
/// <returns>Single events, recurring master and exceptions</returns>
public List<Event> GetCalendarEntriesInRange(System.DateTime from, System.DateTime to, Boolean suppressAdvisories = false, String recurringId = null) {
List<Event> result = new List<Event>();
Events request = null;
String pageToken = null;
Expand All @@ -303,6 +308,7 @@ public List<Event> GetCalendarEntriesInRange(System.DateTime from, System.DateTi
lr.ShowDeleted = false;
lr.SingleEvents = false;
lr.EventTypes = permittedEventTypes;
if (!string.IsNullOrEmpty(recurringId)) lr.ICalUID = recurringId + "@google.com";

int backoff = 0;
while (backoff < BackoffLimit) {
Expand Down Expand Up @@ -391,6 +397,8 @@ public List<Event> GetCalendarEntriesInRange(System.DateTime from, System.DateTi
}
}

Recurrence.SeparateGoogleExceptions(result);

log.Fine("Filtered down to " + result.Count);
return result;
}
Expand Down
10 changes: 4 additions & 6 deletions src/OutlookGoogleCalendarSync/Sync/Calendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -373,12 +373,10 @@ private SyncResult synchronize() {
ex.Data["OGCS"] += " Please try again.";
throw;
}
Recurrence.Instance.SeparateGoogleExceptions(googleEntries);
if (Recurrence.Instance.GoogleExceptions != null && Recurrence.Instance.GoogleExceptions.Count > 0) {
console.Update(googleEntries.Count + " Google calendar entries found.");
console.Update(Recurrence.Instance.GoogleExceptions.Count + " are exceptions to recurring events.", Console.Markup.sectionEnd, newLine: false);
} else
console.Update(googleEntries.Count + " Google calendar entries found.", Console.Markup.sectionEnd, newLine: false);
String consoleOutput = googleEntries.Count + " Google calendar entries found.";
if (Recurrence.Instance.GoogleExceptions != null && Recurrence.Instance.GoogleExceptions.Count > 0)
consoleOutput += "<br/>" + Recurrence.Instance.GoogleExceptions.Count + " additional exceptions to recurring events.";
console.Update(consoleOutput, Console.Markup.sectionEnd, newLine: false);

if (Sync.Engine.Instance.CancellationPending) return SyncResult.UserCancelled;
#endregion
Expand Down

0 comments on commit 4585bcc

Please sign in to comment.