From 26278f5b738eba7e6def0f7a862d310b4da75dbf Mon Sep 17 00:00:00 2001 From: Paul Woolcock <11843015+phw198@users.noreply.github.com> Date: Sat, 12 Oct 2024 13:59:31 +0100 Subject: [PATCH 1/5] O->G: Show Console warning message when items are excluded from Google. #1989 --- .../Google/GoogleCalendar.cs | 18 +++++++++---- .../Outlook/OutlookCalendar.cs | 27 +++++++++---------- src/OutlookGoogleCalendarSync/Recurrence.cs | 2 +- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/OutlookGoogleCalendarSync/Google/GoogleCalendar.cs b/src/OutlookGoogleCalendarSync/Google/GoogleCalendar.cs index b5e135f9..9d3edf29 100644 --- a/src/OutlookGoogleCalendarSync/Google/GoogleCalendar.cs +++ b/src/OutlookGoogleCalendarSync/Google/GoogleCalendar.cs @@ -283,7 +283,7 @@ public List GetCalendarEntriesInRange() { return GetCalendarEntriesInRange(profile.SyncStart, profile.SyncEnd); } - public List GetCalendarEntriesInRange(System.DateTime from, System.DateTime to) { + public List GetCalendarEntriesInRange(System.DateTime from, System.DateTime to, Boolean suppressAdvisories = false) { List result = new List(); ExcludedByColour = new Dictionary(); Events request = null; @@ -357,13 +357,13 @@ public List GetCalendarEntriesInRange(System.DateTime from, System.DateTi result = result.Except(endsOnSyncStart).ToList(); } + List colour = new(); List availability = new(); List allDays = new(); List privacy = new(); - List declined = new(); List subject = new(); + List declined = new(); List goals = new(); - List colour = new(); //Colours if (profile.ColoursRestrictBy == SettingsStore.Calendar.RestrictBy.Include) { @@ -387,7 +387,7 @@ public List GetCalendarEntriesInRange(System.DateTime from, System.DateTi } result = result.Except(colour).ToList(); - //Availability, Privacy + //Availability, All-Days, Privacy, Subject if (profile.SyncDirection.Id != Sync.Direction.OutlookToGoogle.Id) { //Sync direction means G->O will delete previously synced all-days if (profile.ExcludeFree) { availability = result.Where(ev => String.IsNullOrEmpty(ev.RecurringEventId) && ev.Transparency == "transparent").ToList(); @@ -440,8 +440,8 @@ public List GetCalendarEntriesInRange(System.DateTime from, System.DateTi } } + List allExcluded = colour.Concat(availability).Concat(allDays).Concat(privacy).Concat(subject).Concat(declined).Concat(goals).ToList(); if (profile.SyncDirection.Id == Sync.Direction.Bidirectional.Id) { - List allExcluded = colour.Concat(availability).Concat(allDays).Concat(privacy).Concat(subject).Concat(declined).Concat(goals).ToList(); for (int g = 0; g < allExcluded.Count(); g++) { Event ev = allExcluded[g]; if (CustomProperty.ExistAnyOutlookIDs(ev)) { @@ -451,7 +451,15 @@ public List GetCalendarEntriesInRange(System.DateTime from, System.DateTi } } } + if (!suppressAdvisories && allExcluded.Count > 0) { + String duplicateWarning = " If they exist in Outlook, they may be synced and appear as \"duplicates\"."; + if (result.Count == 0) + Forms.Main.Instance.Console.Update("Due to your OGCS Google settings, all Google items have been filtered out!" + duplicateWarning, Console.Markup.config, newLine: false, notifyBubble: true); + else if (profile.SyncDirection.Id == Sync.Direction.OutlookToGoogle.Id) + Forms.Main.Instance.Console.Update("Due to your OGCS Google settings, " + allExcluded.Count + " Google items have been filtered out." + duplicateWarning, Console.Markup.config, newLine: false); + } + log.Fine("Filtered down to " + result.Count); return result; } diff --git a/src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs b/src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs index 2b4e56c0..280d5481 100644 --- a/src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs +++ b/src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs @@ -282,20 +282,19 @@ public List FilterCalendarEntries(SettingsStore.Calendar profil result.Add(ai); } } - if (!suppressAdvisories) { - if (availabilityFiltered > 0) log.Info(availabilityFiltered + " Outlook items excluded due to availability."); - if (allDayFiltered > 0) log.Info(allDayFiltered + " Outlook all day items excluded."); - if (ExcludedByCategory.Count > 0) log.Info(ExcludedByCategory.Count + " Outlook items contain a category that is filtered out."); - if (subjectFiltered > 0) log.Info(subjectFiltered + " Outlook items with subject containing '" + profile.ExcludeSubjectText + "' filtered out."); - if (responseFiltered > 0) log.Info(responseFiltered + " Outlook items are invites not yet responded to."); - - if ((availabilityFiltered + allDayFiltered + ExcludedByCategory.Count + subjectFiltered + responseFiltered) > 0) { - if (result.Count == 0) - Forms.Main.Instance.Console.Update("Due to your OGCS Outlook settings, all Outlook items have been filtered out!", Console.Markup.config, notifyBubble: true); - else if (profile.SyncDirection.Id == Sync.Direction.GoogleToOutlook.Id) - Forms.Main.Instance.Console.Update("Due to your OGCS Outlook settings, Outlook items have been filtered out. " + - "If they exist in Google, they may be synced and appear as \"duplicates\".", Console.Markup.config); - } + if (availabilityFiltered > 0) log.Info(availabilityFiltered + " Outlook items excluded due to availability."); + if (allDayFiltered > 0) log.Info(allDayFiltered + " Outlook all day items excluded."); + if (ExcludedByCategory.Count > 0) log.Info(ExcludedByCategory.Count + " Outlook items contain a category that is filtered out."); + if (subjectFiltered > 0) log.Info(subjectFiltered + " Outlook items with subject containing '" + profile.ExcludeSubjectText + "' filtered out."); + if (responseFiltered > 0) log.Info(responseFiltered + " Outlook items are invites not yet responded to."); + + Int32 allExcluded = availabilityFiltered + allDayFiltered + ExcludedByCategory.Count + subjectFiltered + responseFiltered; + if (!suppressAdvisories && allExcluded > 0) { + String duplicateWarning = "If they exist in Google, they may be synced and appear as \"duplicates\"."; + if (result.Count == 0) + Forms.Main.Instance.Console.Update("Due to your OGCS Outlook settings, all Outlook items have been filtered out! " + duplicateWarning, Console.Markup.config, newLine: false, notifyBubble: true); + else if (profile.SyncDirection.Id == Sync.Direction.GoogleToOutlook.Id) + Forms.Main.Instance.Console.Update("Due to your OGCS Outlook settings, " + allExcluded + " Outlook items have been filtered out." + duplicateWarning, Console.Markup.config, newLine: false); } } log.Fine("Filtered down to " + result.Count); diff --git a/src/OutlookGoogleCalendarSync/Recurrence.cs b/src/OutlookGoogleCalendarSync/Recurrence.cs index 78f52448..559fb05e 100644 --- a/src/OutlookGoogleCalendarSync/Recurrence.cs +++ b/src/OutlookGoogleCalendarSync/Recurrence.cs @@ -517,7 +517,7 @@ public Event GetGoogleMasterEvent(AppointmentItem ai) { } } if (!haveMatchingEv) { - events = Ogcs.Google.Calendar.Instance.GetCalendarEntriesInRange(ai.Start.Date, ai.Start.Date.AddDays(1)); + events = Ogcs.Google.Calendar.Instance.GetCalendarEntriesInRange(ai.Start.Date, ai.Start.Date.AddDays(1), true); if (Sync.Engine.Calendar.Instance.Profile.SyncDirection.Id != Sync.Direction.GoogleToOutlook.Id) { List ais = new List(); ais.Add(ai); From 83e060ac0805afe5837a4c4966c5a510786fac9a Mon Sep 17 00:00:00 2001 From: Paul Woolcock <11843015+phw198@users.noreply.github.com> Date: Sun, 27 Oct 2024 14:44:50 +0000 Subject: [PATCH 2/5] Redirect Console URLs to default browser. --- src/OutlookGoogleCalendarSync/Console/Console.cs | 6 ++++++ src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs | 2 +- src/OutlookGoogleCalendarSync/Sync/Calendar.cs | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/OutlookGoogleCalendarSync/Console/Console.cs b/src/OutlookGoogleCalendarSync/Console/Console.cs index 1662a85e..c2ce39fe 100644 --- a/src/OutlookGoogleCalendarSync/Console/Console.cs +++ b/src/OutlookGoogleCalendarSync/Console/Console.cs @@ -204,6 +204,12 @@ private void console_DocumentCompleted(object sender, WebBrowserDocumentComplete private void console_Navigating(object sender, WebBrowserNavigatingEventArgs e) { if (!Forms.Main.Instance.Visible) return; + if (e.Url.Scheme != "about") { + Helper.OpenBrowser(e.Url.OriginalString); + e.Cancel = true; + return; + } + navigationStatus = NavigationStatus.navigating; log.UltraFine("Console navigating."); } diff --git a/src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs b/src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs index 280d5481..6fcdd169 100644 --- a/src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs +++ b/src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs @@ -119,7 +119,7 @@ public List GetCalendarEntriesInRange(SettingsStore.Calendar pr Ogcs.Exception.LogAsFail(ref ex); String wikiURL = "https://github.com/phw198/OutlookGoogleCalendarSync/wiki/Resolving-Outlook-Error-Messages#one-or-more-items-in-the-folder-you-synchronized-do-not-match"; ex.Data.Add("OGCS", ex.Message + "
Please view the wiki for suggestions on " + - "how to resolve conflicts within your Outlook account."); + "how to resolve conflicts within your Outlook account."); if (!suppressAdvisories && Ogcs.Extensions.MessageBox.Show("Your Outlook calendar contains conflicts that need resolving in order to sync successfully.\r\nView the wiki for advice?", "Outlook conflicts exist", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) Helper.OpenBrowser(wikiURL); diff --git a/src/OutlookGoogleCalendarSync/Sync/Calendar.cs b/src/OutlookGoogleCalendarSync/Sync/Calendar.cs index 25446d46..6f323852 100644 --- a/src/OutlookGoogleCalendarSync/Sync/Calendar.cs +++ b/src/OutlookGoogleCalendarSync/Sync/Calendar.cs @@ -209,7 +209,7 @@ public void StartSync(Boolean manualIgnition, Boolean updateSyncSchedule = true) $"Syncs completed: {Settings.Instance.CompletedSyncs}"; if (!Settings.Instance.UserIsBenefactor()) { syncStats += $"
Donate"; + Settings.Instance.GaccountEmail + "' onClick='javascript:mp(donateEvent)' style='color: grey'>Donate"; Telemetry.GA4Event donateEvent = new Telemetry.GA4Event(Telemetry.GA4Event.Event.Name.donate); donateEvent.events[0] .AddParameter("source", "console") @@ -838,7 +838,7 @@ private SyncResult extirpateCustomProperties(List outlookEntrie console.Update( "It is recommended to rerun the metadata cleanse to successful completion before using OGCS for normal syncing again.
" + "If this is not possible and you wish to continue using OGCS, please " + - "raise an issue on the GitHub project.", Console.Markup.warning); + "raise an issue on the GitHub project.", Console.Markup.warning); } } } From 50e6725e0dbe45632a66139dd1ab801a4760d420 Mon Sep 17 00:00:00 2001 From: Paul Woolcock <11843015+phw198@users.noreply.github.com> Date: Sun, 27 Oct 2024 16:35:52 +0000 Subject: [PATCH 3/5] Improved messaging in Console when excluding colours/categories. Apply exclusion filters to Google.GetCalendarEntry() Initialise ExcludedByColour and ExcludedByCategory only at start of sync. #1989 --- .../Google/GoogleCalendar.cs | 78 +++++++++++++------ .../Outlook/OutlookCalendar.cs | 27 +++++-- src/OutlookGoogleCalendarSync/Recurrence.cs | 3 + .../Sync/Calendar.cs | 3 + 4 files changed, 78 insertions(+), 33 deletions(-) diff --git a/src/OutlookGoogleCalendarSync/Google/GoogleCalendar.cs b/src/OutlookGoogleCalendarSync/Google/GoogleCalendar.cs index 9d3edf29..418382b8 100644 --- a/src/OutlookGoogleCalendarSync/Google/GoogleCalendar.cs +++ b/src/OutlookGoogleCalendarSync/Google/GoogleCalendar.cs @@ -47,7 +47,9 @@ public Calendar() { } public Ogcs.Google.Authenticator Authenticator; /// Google Events excluded through user config - public Dictionary ExcludedByColour { get; private set; } + public List ExcludedByConfig { get; set; } + /// Google Events excluded by colour through user config + public Dictionary ExcludedByColour { get; set; } private Ogcs.Google.EventColour colourPalette; @@ -267,9 +269,12 @@ public Event GetCalendarEntry(String eventId) { } } - if (request != null) - return request; - else + if (request != null) { + SettingsStore.Calendar profile = Settings.Profile.InPlay(); + List evList = new List() { request }; + applyExclusions(ref evList, profile); + return evList.FirstOrDefault(); + } else throw new System.Exception("Returned null"); } catch (System.Exception ex) { if (ex is ApplicationException) throw; @@ -285,7 +290,6 @@ public List GetCalendarEntriesInRange() { public List GetCalendarEntriesInRange(System.DateTime from, System.DateTime to, Boolean suppressAdvisories = false) { List result = new List(); - ExcludedByColour = new Dictionary(); Events request = null; String pageToken = null; Int16 pageNum = 1; @@ -357,6 +361,44 @@ public List GetCalendarEntriesInRange(System.DateTime from, System.DateTi result = result.Except(endsOnSyncStart).ToList(); } + List allExcluded = applyExclusions(ref result, profile); + if (allExcluded.Count > 0) { + if (!suppressAdvisories) { + String filterWarning = "Due to your OGCS Google settings, " + (result.Count == 0 ? "all" : result.Count) + " Google items have been filtered out" + (result.Count == 0 ? "!" : "."); + Forms.Main.Instance.Console.Update(filterWarning, Console.Markup.config, newLine: false, notifyBubble: (result.Count == 0)); + + filterWarning = ""; + if (profile.SyncDirection.Id != Sync.Direction.OutlookToGoogle.Id && ExcludedByColour.Count > 0 && profile.DeleteWhenColourExcluded) { + filterWarning = "If they exist in Outlook, they may get deleted. To avoid deletion, uncheck \"Delete synced items if excluded\"."; + if (!profile.DisableDelete) { + filterWarning += " Recover unintentional deletions from the Outlook 'Deleted Items' folder."; + if (profile.ConfirmOnDelete) + filterWarning += "

If prompted to confirm deletion and you opt not to delete them, this will reoccur every sync. " + + "Consider assigning an excluded category to those items in Outlook.

" + + "

See the wiki for tips if needing to resolve duplicates.

"; + } + } + if (!String.IsNullOrEmpty(filterWarning)) + Forms.Main.Instance.Console.Update(filterWarning, Console.Markup.warning, newLine: false); + } + if (profile.SyncDirection.Id == Sync.Direction.Bidirectional.Id) { + for (int g = 0; g < allExcluded.Count; g++) { + Event ev = allExcluded[g]; + if (CustomProperty.ExistAnyOutlookIDs(ev)) { + log.Debug("Previously synced Google item is now excluded. Removing Outlook metadata."); + //We don't want them getting automatically deleted if brought back in scope; better to create possible duplicate + CustomProperty.RemoveOutlookIDs(ref ev); + UpdateCalendarEntry_save(ref ev); + } + } + } + } + + log.Fine("Filtered down to " + result.Count); + return result; + } + + private List applyExclusions(ref List result, SettingsStore.Calendar profile) { List colour = new(); List availability = new(); List allDays = new(); @@ -383,7 +425,8 @@ public List GetCalendarEntriesInRange(System.DateTime from, System.DateTi log.Debug(colour.Count + " Google items contain a colour that is filtered out."); } foreach (Event ev in colour) { - ExcludedByColour.Add(ev.Id, CustomProperty.Get(ev, CustomProperty.MetadataId.oEntryId)); + if (!ExcludedByColour.ContainsKey(ev.Id)) + ExcludedByColour.Add(ev.Id, CustomProperty.Get(ev, CustomProperty.MetadataId.oEntryId)); } result = result.Except(colour).ToList(); @@ -441,26 +484,11 @@ public List GetCalendarEntriesInRange(System.DateTime from, System.DateTi } List allExcluded = colour.Concat(availability).Concat(allDays).Concat(privacy).Concat(subject).Concat(declined).Concat(goals).ToList(); - if (profile.SyncDirection.Id == Sync.Direction.Bidirectional.Id) { - for (int g = 0; g < allExcluded.Count(); g++) { - Event ev = allExcluded[g]; - if (CustomProperty.ExistAnyOutlookIDs(ev)) { - log.Debug("Previously synced Google item is now excluded. Removing Outlook metadata."); - CustomProperty.RemoveOutlookIDs(ref ev); - UpdateCalendarEntry_save(ref ev); - } - } - } - if (!suppressAdvisories && allExcluded.Count > 0) { - String duplicateWarning = " If they exist in Outlook, they may be synced and appear as \"duplicates\"."; - if (result.Count == 0) - Forms.Main.Instance.Console.Update("Due to your OGCS Google settings, all Google items have been filtered out!" + duplicateWarning, Console.Markup.config, newLine: false, notifyBubble: true); - else if (profile.SyncDirection.Id == Sync.Direction.OutlookToGoogle.Id) - Forms.Main.Instance.Console.Update("Due to your OGCS Google settings, " + allExcluded.Count + " Google items have been filtered out." + duplicateWarning, Console.Markup.config, newLine: false); + foreach (Event ev in allExcluded) { + if (!ExcludedByConfig.Contains(ev.Id)) + ExcludedByConfig.Add(ev.Id); } - - log.Fine("Filtered down to " + result.Count); - return result; + return allExcluded; } /// diff --git a/src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs b/src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs index 6fcdd169..f4bf2e54 100644 --- a/src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs +++ b/src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs @@ -63,7 +63,7 @@ public enum Service { public Outlook.EphemeralProperties EphemeralProperties = new EphemeralProperties(); /// Outlook Appointment excluded through user config - public Dictionary ExcludedByCategory { get; private set; } + public Dictionary ExcludedByCategory { get; set; } public Calendar() { InstanceConnect = true; @@ -144,7 +144,6 @@ public List FilterCalendarEntries(SettingsStore.Calendar profil List result = new List(); Items OutlookItems = null; - ExcludedByCategory = new(); if (profile is null) profile = Settings.Profile.InPlay(); @@ -274,6 +273,7 @@ public List FilterCalendarEntries(SettingsStore.Calendar profil } finally { if (filtered && profile.SyncDirection.Id == Sync.Direction.Bidirectional.Id && CustomProperty.ExistAnyGoogleIDs(ai)) { log.Debug("Previously synced Outlook item is now excluded. Removing Google metadata."); + //We don't want them getting automatically deleted if brought back in scope; better to create possible duplicate CustomProperty.RemoveGoogleIDs(ref ai); ai.Save(); } @@ -289,12 +289,23 @@ public List FilterCalendarEntries(SettingsStore.Calendar profil if (responseFiltered > 0) log.Info(responseFiltered + " Outlook items are invites not yet responded to."); Int32 allExcluded = availabilityFiltered + allDayFiltered + ExcludedByCategory.Count + subjectFiltered + responseFiltered; - if (!suppressAdvisories && allExcluded > 0) { - String duplicateWarning = "If they exist in Google, they may be synced and appear as \"duplicates\"."; - if (result.Count == 0) - Forms.Main.Instance.Console.Update("Due to your OGCS Outlook settings, all Outlook items have been filtered out! " + duplicateWarning, Console.Markup.config, newLine: false, notifyBubble: true); - else if (profile.SyncDirection.Id == Sync.Direction.GoogleToOutlook.Id) - Forms.Main.Instance.Console.Update("Due to your OGCS Outlook settings, " + allExcluded + " Outlook items have been filtered out." + duplicateWarning, Console.Markup.config, newLine: false); + if (allExcluded > 0 && !suppressAdvisories) { + String filterWarning = "Due to your OGCS Outlook settings, " + (result.Count == 0 ? "all" : result.Count) + " Outlook items have been filtered out" + (result.Count == 0 ? "!" : "."); + Forms.Main.Instance.Console.Update(filterWarning, Console.Markup.config, newLine: false, notifyBubble: (result.Count == 0)); + + filterWarning = ""; + if (profile.SyncDirection.Id != Sync.Direction.GoogleToOutlook.Id && ExcludedByCategory.Count > 0 && profile.DeleteWhenCategoryExcluded) { + filterWarning = "If they exist in Google, they may get deleted. To avoid deletion, uncheck \"Delete synced items if excluded\"."; + if (!profile.DisableDelete) { + filterWarning += " Recover unintentional deletions from the Google 'Bin'."; + if (profile.ConfirmOnDelete) + filterWarning += "

If prompted to confirm deletion and you opt not to delete them, this will reoccur every sync. " + + "Consider assigning an excluded colour to those items in Google.

" + + "

See the wiki for tips if needing to resolve duplicates.

"; + } + } + if (!String.IsNullOrEmpty(filterWarning)) + Forms.Main.Instance.Console.Update(filterWarning, Console.Markup.warning, newLine: false); } } log.Fine("Filtered down to " + result.Count); diff --git a/src/OutlookGoogleCalendarSync/Recurrence.cs b/src/OutlookGoogleCalendarSync/Recurrence.cs index 559fb05e..4326ddd4 100644 --- a/src/OutlookGoogleCalendarSync/Recurrence.cs +++ b/src/OutlookGoogleCalendarSync/Recurrence.cs @@ -513,6 +513,9 @@ public Event GetGoogleMasterEvent(AppointmentItem ai) { events.Add(ev); haveMatchingEv = true; log.Fine("Found single hard-matched Event."); + } else if (Ogcs.Google.Calendar.Instance.ExcludedByConfig.Contains(googleIdValue)) { + log.Debug("The master Google Event has been excluded by config."); + return null; } } } diff --git a/src/OutlookGoogleCalendarSync/Sync/Calendar.cs b/src/OutlookGoogleCalendarSync/Sync/Calendar.cs index 6f323852..b419d845 100644 --- a/src/OutlookGoogleCalendarSync/Sync/Calendar.cs +++ b/src/OutlookGoogleCalendarSync/Sync/Calendar.cs @@ -315,6 +315,9 @@ private SyncResult synchronize() { List outlookEntries = null; List googleEntries = null; + Ogcs.Outlook.Calendar.Instance.ExcludedByCategory = new Dictionary(); + Ogcs.Google.Calendar.Instance.ExcludedByColour = new Dictionary(); + Ogcs.Google.Calendar.Instance.ExcludedByConfig = new List(); if (!Ogcs.Google.Calendar.IsInstanceNull) Ogcs.Google.Calendar.Instance.EphemeralProperties.Clear(); Outlook.Calendar.Instance.EphemeralProperties.Clear(); From 40a64d50a80b2cdd14b76452b7a275cf46a725d4 Mon Sep 17 00:00:00 2001 From: Paul Woolcock <11843015+phw198@users.noreply.github.com> Date: Sun, 27 Oct 2024 16:38:14 +0000 Subject: [PATCH 4/5] If delete prompt due to exclusion, don't remove metadata. Two-way sync only. #1989 --- src/OutlookGoogleCalendarSync/Google/GoogleCalendar.cs | 8 ++++++-- src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/OutlookGoogleCalendarSync/Google/GoogleCalendar.cs b/src/OutlookGoogleCalendarSync/Google/GoogleCalendar.cs index 418382b8..e2d6245f 100644 --- a/src/OutlookGoogleCalendarSync/Google/GoogleCalendar.cs +++ b/src/OutlookGoogleCalendarSync/Google/GoogleCalendar.cs @@ -1237,8 +1237,12 @@ private Boolean deleteCalendarEntry(Event ev) { MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) { doDelete = false; if (Sync.Engine.Calendar.Instance.Profile.SyncDirection.Id == Sync.Direction.Bidirectional.Id && CustomProperty.ExistAnyOutlookIDs(ev)) { - CustomProperty.RemoveOutlookIDs(ref ev); - UpdateCalendarEntry_save(ref ev); + if (Ogcs.Outlook.Calendar.Instance.ExcludedByCategory.ContainsKey(CustomProperty.Get(ev, CustomProperty.MetadataId.oEntryId))) { + log.Fine("Refrained from removing Outlook metadata from Event; avoids duplication back into Outlook."); + } else { + CustomProperty.RemoveOutlookIDs(ref ev); + UpdateCalendarEntry_save(ref ev); + } } Forms.Main.Instance.Console.Update("Not deleted: " + eventSummary, anonSummary?.Prepend("Not deleted: "), Console.Markup.calendar); } else { diff --git a/src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs b/src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs index f4bf2e54..b4875c5f 100644 --- a/src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs +++ b/src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs @@ -863,8 +863,12 @@ private Boolean deleteCalendarEntry(AppointmentItem ai) { MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) { doDelete = false; if (Sync.Engine.Calendar.Instance.Profile.SyncDirection.Id == Sync.Direction.Bidirectional.Id && CustomProperty.ExistAnyGoogleIDs(ai)) { - CustomProperty.RemoveGoogleIDs(ref ai); - ai.Save(); + if (Ogcs.Google.Calendar.Instance.ExcludedByColour.ContainsKey(CustomProperty.Get(ai, CustomProperty.MetadataId.gEventID))) { + log.Fine("Refrained from removing Google metadata from Appointment; avoids duplication back into Google."); + } else { + CustomProperty.RemoveGoogleIDs(ref ai); + ai.Save(); + } } Forms.Main.Instance.Console.Update("Not deleted: " + eventSummary, anonSummary?.Prepend("Not deleted: "), Console.Markup.calendar); } else { From 68a04b54ec78d33a64af98c9e4d43d5420a130de Mon Sep 17 00:00:00 2001 From: Paul Woolcock <11843015+phw198@users.noreply.github.com> Date: Sun, 27 Oct 2024 21:50:18 +0000 Subject: [PATCH 5/5] Fix excluded count in Console message. #1989 --- src/OutlookGoogleCalendarSync/Google/GoogleCalendar.cs | 2 +- src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OutlookGoogleCalendarSync/Google/GoogleCalendar.cs b/src/OutlookGoogleCalendarSync/Google/GoogleCalendar.cs index e2d6245f..c744d58c 100644 --- a/src/OutlookGoogleCalendarSync/Google/GoogleCalendar.cs +++ b/src/OutlookGoogleCalendarSync/Google/GoogleCalendar.cs @@ -364,7 +364,7 @@ public List GetCalendarEntriesInRange(System.DateTime from, System.DateTi List allExcluded = applyExclusions(ref result, profile); if (allExcluded.Count > 0) { if (!suppressAdvisories) { - String filterWarning = "Due to your OGCS Google settings, " + (result.Count == 0 ? "all" : result.Count) + " Google items have been filtered out" + (result.Count == 0 ? "!" : "."); + String filterWarning = "Due to your OGCS Google settings, " + (result.Count == 0 ? "all" : allExcluded.Count) + " Google items have been filtered out" + (result.Count == 0 ? "!" : "."); Forms.Main.Instance.Console.Update(filterWarning, Console.Markup.config, newLine: false, notifyBubble: (result.Count == 0)); filterWarning = ""; diff --git a/src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs b/src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs index b4875c5f..4cc1945b 100644 --- a/src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs +++ b/src/OutlookGoogleCalendarSync/Outlook/OutlookCalendar.cs @@ -290,7 +290,7 @@ public List FilterCalendarEntries(SettingsStore.Calendar profil Int32 allExcluded = availabilityFiltered + allDayFiltered + ExcludedByCategory.Count + subjectFiltered + responseFiltered; if (allExcluded > 0 && !suppressAdvisories) { - String filterWarning = "Due to your OGCS Outlook settings, " + (result.Count == 0 ? "all" : result.Count) + " Outlook items have been filtered out" + (result.Count == 0 ? "!" : "."); + String filterWarning = "Due to your OGCS Outlook settings, " + (result.Count == 0 ? "all" : allExcluded) + " Outlook items have been filtered out" + (result.Count == 0 ? "!" : "."); Forms.Main.Instance.Console.Update(filterWarning, Console.Markup.config, newLine: false, notifyBubble: (result.Count == 0)); filterWarning = "";