private void Load(UserConfiguration configuration) { try { using (RecipientInfoCache recipientInfoCache = RecipientInfoCache.Create(configuration)) { try { this.cacheEntries = recipientInfoCache.Load("AutoCompleteCache"); this.syncTime = recipientInfoCache.LastModifiedTime; } finally { recipientInfoCache.DetachUserConfiguration(); } } } catch (XmlException ex) { ExTraceGlobals.CoreTracer.TraceError <string>(0L, "Parser threw an XML exception: {0}'", ex.Message); this.ClearCache(); this.Commit(configuration, true); } catch (CorruptDataException ex2) { ExTraceGlobals.CoreTracer.TraceError <string>(0L, "Parser threw a CorruptDataException exception: {0}'", ex2.Message); this.ClearCache(); this.Commit(configuration, true); } }
public RecipientInfoCacheSyncProvider(MailboxSession mailboxSession, int maxEntries) { if (maxEntries <= 0) { throw new ArgumentException("MaxEntries must be a positive number"); } this.recipientInfoCache = RecipientInfoCache.Create(mailboxSession, "OWA.AutocompleteCache"); try { this.entryList = this.recipientInfoCache.Load("AutoCompleteCache"); for (int i = this.entryList.Count - 1; i >= 0; i--) { if (string.IsNullOrEmpty(this.entryList[i].SmtpAddress) || (!string.Equals(this.entryList[i].RoutingType, "SMTP", StringComparison.OrdinalIgnoreCase) && !string.Equals(this.entryList[i].RoutingType, "EX", StringComparison.OrdinalIgnoreCase))) { this.entryList.RemoveAt(i); } } } catch (CorruptDataException) { this.entryList = new List <RecipientInfoCacheEntry>(0); this.recipientInfoCache.Save(this.entryList, "AutoCompleteCache", 100); } this.maxNumEntries = maxEntries; this.disposeTracker = this.GetDisposeTracker(); }
protected virtual void Commit(UserConfiguration configuration, bool forceSave) { if (this.userContext.CanActAsOwner) { if (this.cacheEntries.Count == 0 && !this.isDirty && !forceSave) { return; } using (RecipientInfoCache recipientInfoCache = RecipientInfoCache.Create(configuration)) { try { recipientInfoCache.Save(this.cacheEntries, "AutoCompleteCache", (int)this.cacheSize); } finally { recipientInfoCache.DetachUserConfiguration(); } } } this.isDirty = false; }