public static CachedAttachmentInfo GetInstance(string mailboxSmtpAddress, string ewsAttachmentId, string sessionId, SecurityIdentifier logonSid, string cultureName) { string cacheKey = CachedAttachmentInfo.GetCacheKey(mailboxSmtpAddress, ewsAttachmentId); CachedAttachmentInfo cachedAttachmentInfo = CachedAttachmentInfo.GetFromCache(cacheKey); if (cachedAttachmentInfo != null) { OwaApplication.GetRequestDetailsLogger.Set(WacRequestHandlerMetadata.CacheHit, true); return(cachedAttachmentInfo); } CachedAttachmentInfo result; lock (CachedAttachmentInfo.factorySynchronizer) { cachedAttachmentInfo = CachedAttachmentInfo.GetFromCache(cacheKey); if (cachedAttachmentInfo != null) { OwaApplication.GetRequestDetailsLogger.Set(WacRequestHandlerMetadata.CacheHit, true); result = cachedAttachmentInfo; } else { OwaApplication.GetRequestDetailsLogger.Set(WacRequestHandlerMetadata.CacheHit, false); string domain = ((SmtpAddress)mailboxSmtpAddress).Domain; string logonSmtpAddress; string logonDisplayName; string logonPuid; CachedAttachmentInfo.GetLogonUserInfo(logonSid, domain, out logonSmtpAddress, out logonDisplayName, out logonPuid); cachedAttachmentInfo = new CachedAttachmentInfo(mailboxSmtpAddress, logonSmtpAddress, logonDisplayName, logonPuid, logonSid, cultureName, ewsAttachmentId, sessionId); cachedAttachmentInfo.InsertIntoCache(cacheKey); result = cachedAttachmentInfo; } } return(result); }
private bool ReadyToSend() { bool result; lock (this.asyncResult) { if (this.asyncResult.IsCompleted) { result = true; } else { base.CallContext.ProtocolLog.Set(SynchronizeWacAttachmentMetadata.Count, this.checks); string primarySmtpAddress = base.CallContext.MailboxIdentityPrincipal.MailboxInfo.PrimarySmtpAddress.ToString(); string cacheKey = CachedAttachmentInfo.GetCacheKey(primarySmtpAddress, this.attachmentId); CachedAttachmentInfo fromCache = CachedAttachmentInfo.GetFromCache(cacheKey); if (fromCache == null) { base.CallContext.ProtocolLog.Set(SynchronizeWacAttachmentMetadata.Result, SynchronizeWacAttachment.AttachmentState.NoCachedInfo); result = true; } else { base.CallContext.ProtocolLog.Set(SynchronizeWacAttachmentMetadata.SessionId, fromCache.SessionId); if (fromCache.CobaltStore == null) { if (fromCache.LockCount == 0) { base.CallContext.ProtocolLog.Set(SynchronizeWacAttachmentMetadata.Result, SynchronizeWacAttachment.AttachmentState.NoLocks); result = true; } else { base.CallContext.ProtocolLog.Set(SynchronizeWacAttachmentMetadata.Result, SynchronizeWacAttachment.AttachmentState.HasLocks); result = false; } } else if (fromCache.CobaltStore.EditorCount == 0) { base.CallContext.ProtocolLog.Set(SynchronizeWacAttachmentMetadata.Result, SynchronizeWacAttachment.AttachmentState.NoEditors); result = true; } else { base.CallContext.ProtocolLog.Set(SynchronizeWacAttachmentMetadata.Result, SynchronizeWacAttachment.AttachmentState.HasEditors); result = false; } } } } return(result); }
public static bool ShouldUpdateAttachment(string mailboxSmtpAddress, string ewsAttachmentId, out CobaltStoreSaver saver) { string cacheKey = CachedAttachmentInfo.GetCacheKey(mailboxSmtpAddress, ewsAttachmentId); CachedAttachmentInfo fromCache = CachedAttachmentInfo.GetFromCache(cacheKey); if (fromCache == null || fromCache.CobaltStore == null) { saver = null; return(false); } saver = fromCache.CobaltStore.Saver; return(saver != null); }