Skip to content

Commit

Permalink
Recreate backgroundWorker upon retry request.
Browse files Browse the repository at this point in the history
Logging changes.
  • Loading branch information
phw198 committed Nov 16, 2021
1 parent 4e414a1 commit 282296c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/OutlookGoogleCalendarSync/OutlookOgcs/OutlookCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ public List<AppointmentItem> FilterCalendarEntries(SettingsStore.Calendar profil
try {
DateTime start = ai.Start;
} catch (System.NullReferenceException) {
log.Error("Appointment item seems unusable - no Start or End date! Discarding.");
try { log.Debug("Subject: " + ai.Subject); } catch { }
log.Fail("Appointment item seems unusable - no Start or End date! Discarding.");
continue;
}
log.Debug("Unable to get End date for: " + OutlookOgcs.Calendar.GetEventSummary(ai));
Expand Down
21 changes: 15 additions & 6 deletions src/OutlookGoogleCalendarSync/Sync/Calendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ public void StartSync(Boolean manualIgnition, Boolean updateSyncSchedule = true)
} else {
log.Info("User opted to retry sync straight away.");
mainFrm.Console.Clear();
Sync.Engine.Instance.bwSync = new AbortableBackgroundWorker() {
//Don't need thread to report back. The logbox is updated from the thread anyway.
WorkerReportsProgress = false,
WorkerSupportsCancellation = true
};
}
}

Expand Down Expand Up @@ -373,12 +378,16 @@ private SyncResult synchronize() {
entryID = outlookEntries[o].EntryID;
DateTime checkDates = ai.Start;
checkDates = ai.End;
} catch (System.Exception ex) {
//"Your server administrator has limited the number of items you can open simultaneously."
//Once we have the error code for above message, need to abort sync - and suggest using cached Exchange mode
OGCSexception.Analyse("Calendar item does not have a proper date range - cannot sync it. ExchangeMode=" +
OutlookOgcs.Calendar.Instance.IOutlook.ExchangeConnectionMode().ToString(), ex);
skipCorruptedItem(ref outlookEntries, outlookEntries[o], ex.Message);
} catch (System.Runtime.InteropServices.COMException ex) {
if (OGCSexception.GetErrorCode(ex, 0x0000FFFF) == "0x00004005") { //You must specify a time/hour
skipCorruptedItem(ref outlookEntries, outlookEntries[o], ex.Message);
} else {
//"Your server administrator has limited the number of items you can open simultaneously."
//Once we have the error code for above message, need to abort sync - and suggest using cached Exchange mode
OGCSexception.Analyse("Calendar item does not have a proper date range - cannot sync it. ExchangeMode=" +
OutlookOgcs.Calendar.Instance.IOutlook.ExchangeConnectionMode().ToString(), ex);
skipCorruptedItem(ref outlookEntries, outlookEntries[o], ex.Message);
}
ai = (AppointmentItem)OutlookOgcs.Calendar.ReleaseObject(ai);
continue;
}
Expand Down

0 comments on commit 282296c

Please sign in to comment.