public void GroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId destinationFolderId, StoreObjectId[] itemIds, GroupOperationResult result, bool onBeforeNotification, CallbackContext callbackContext) { EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation"); EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags"); }
public CowClientOperationSensitivity SkipGroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId sourceFolderId, StoreObjectId destinationFolderId, ICollection <StoreObjectId> itemIds, bool onBeforeNotification, bool onDumpster, CallbackContext callbackContext) { EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation"); EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags"); MailboxSession mailboxSession = sourceSession as MailboxSession; if (mailboxSession == null) { return(CowClientOperationSensitivity.Skip); } if (onBeforeNotification && (COWTriggerAction.Copy == operation || COWTriggerAction.HardDelete == operation || COWTriggerAction.Move == operation || COWTriggerAction.MoveToDeletedItems == operation || COWTriggerAction.SoftDelete == operation)) { StoreObjectId auditsFolderId = dumpster.AuditsFolderId; StoreObjectId adminAuditLogsFolderId = dumpster.AdminAuditLogsFolderId; if (settings.CurrentFolderId != null && (COWTriggerAction.HardDelete != operation || LogonType.SystemService != sourceSession.LogonType || !settings.IsMrmAction())) { this.CheckAccessOnAuditFolders(mailboxSession, settings.CurrentFolderId, dumpster, false); } if (itemIds != null) { foreach (StoreObjectId storeObjectId in itemIds) { if (storeObjectId != null) { if (storeObjectId.IsMessageId) { if (settings.CurrentFolderId == null && (COWTriggerAction.HardDelete != operation || LogonType.SystemService != sourceSession.LogonType || !settings.IsMrmAction())) { StoreObjectId parentIdFromMessageId = IdConverter.GetParentIdFromMessageId(storeObjectId); if (parentIdFromMessageId.Equals(auditsFolderId)) { throw new AccessDeniedException(ServerStrings.ExAuditsUpdateDenied); } if (parentIdFromMessageId.Equals(adminAuditLogsFolderId)) { throw new AccessDeniedException(ServerStrings.ExAdminAuditLogsUpdateDenied); } if (dumpster.IsAuditFolder(parentIdFromMessageId)) { throw new AccessDeniedException((auditsFolderId != null) ? ServerStrings.ExAuditsUpdateDenied : ServerStrings.ExAdminAuditLogsUpdateDenied); } } } else if (storeObjectId.IsFolderId) { this.CheckAccessOnAuditFolders(mailboxSession, storeObjectId, dumpster, true); } } } } } return(CowClientOperationSensitivity.Skip); }
public CowClientOperationSensitivity SkipGroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId sourceFolderId, StoreObjectId destinationFolderId, ICollection <StoreObjectId> itemIds, bool onBeforeNotification, bool onDumpster, CallbackContext callbackContext) { EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation"); EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags"); return(CowClientOperationSensitivity.Skip); }
public void CaptureActivityAfterFolderChange(FolderChangeOperation operation, FolderChangeOperationFlags flags, IList <StoreObjectId> itemIdsBeforeChange, IList <StoreObjectId> itemIdsAfterChange, StoreObjectId sourceFolder, StoreObjectId targetFolder) { if (itemIdsBeforeChange == null || itemIdsBeforeChange.Count <= 0) { return; } IList <Activity> activities; if ((operation == FolderChangeOperation.HardDelete || operation == FolderChangeOperation.SoftDelete || operation == FolderChangeOperation.MoveToDeletedItems) && this.TryCreateDeleteActivities(operation, flags, itemIdsBeforeChange, sourceFolder, out activities)) { this.Log(activities); } if ((operation == FolderChangeOperation.HardDelete || operation == FolderChangeOperation.SoftDelete || operation == FolderChangeOperation.MoveToDeletedItems || operation == FolderChangeOperation.Move) && this.TryCreateMoveActivities(operation, itemIdsBeforeChange, itemIdsAfterChange, sourceFolder, targetFolder, out activities)) { this.Log(activities); } }
private bool TryCreateDeleteActivities(FolderChangeOperation operation, FolderChangeOperationFlags flags, IList <StoreObjectId> itemIdsBeforeMove, StoreObjectId sourceFolder, out IList <Activity> activities) { activities = null; string value; switch (operation) { case FolderChangeOperation.MoveToDeletedItems: value = "MoveToDeletedItems"; break; case FolderChangeOperation.SoftDelete: value = "SoftDelete"; break; case FolderChangeOperation.HardDelete: value = "HardDelete"; break; default: return(false); } ActivityId? activityId = null; DefaultFolderType defaultFolderType = (sourceFolder == null) ? DefaultFolderType.None : this.session.IsDefaultFolderType(sourceFolder); if (defaultFolderType == DefaultFolderType.Inbox) { activityId = new ActivityId?(ActivityId.DeleteFromInbox); } else if (defaultFolderType == DefaultFolderType.Clutter) { activityId = new ActivityId?(ActivityId.DeleteFromClutter); } bool flag = (flags & FolderChangeOperationFlags.EmptyFolder) == FolderChangeOperationFlags.EmptyFolder; bool flag2 = (flags & FolderChangeOperationFlags.DeleteAllClutter) == FolderChangeOperationFlags.DeleteAllClutter; activities = new List <Activity>(itemIdsBeforeMove.Count); foreach (StoreObjectId storeObjectId in itemIdsBeforeMove) { if (storeObjectId != null) { Activity item = new Activity(ActivityId.Delete, this.clientInfo.Id, ExDateTime.UtcNow, this.clientSessionId, this.clientInfo.Version, Interlocked.Increment(ref this.sequenceNumber), this.session, storeObjectId, null, new Dictionary <string, string> { { "DeleteType", value }, { "DeletedByEmptyFolder", flag ? bool.TrueString : bool.FalseString }, { "DeletedByDeleteAllClutter", flag2 ? bool.TrueString : bool.FalseString }, { "SourceDefaultFolderType", defaultFolderType.ToString() } }); activities.Add(item); if (activityId != null) { activities.Add(new Activity(activityId.Value, this.clientInfo.Id, ExDateTime.UtcNow, this.clientSessionId, this.clientInfo.Version, Interlocked.Increment(ref this.sequenceNumber), this.session, storeObjectId, null, null)); } } } return(true); }
public static bool TryCreate(MailboxSession mailboxSession, FolderChangeOperation operation, FolderChangeOperationFlags flags, GroupOperationResult result, StoreObjectId sourceFolderId, StoreObjectId destinationFolderId, out UserMoveActionHandler handler) { handler = null; if (operation == FolderChangeOperation.Move && result != null && result.OperationResult != OperationResult.Failed && result.ResultObjectIds != null && result.ResultObjectIds.Count > 0 && ClutterUtilities.IsClutterEnabled(mailboxSession, mailboxSession.MailboxOwner.GetConfiguration()) && sourceFolderId != null && destinationFolderId != null && !sourceFolderId.Equals(destinationFolderId)) { bool flag = mailboxSession.LogonType == LogonType.Owner || flags.HasFlag(FolderChangeOperationFlags.ClutterActionByUserOverride); handler = new UserMoveActionHandler(mailboxSession, sourceFolderId, destinationFolderId, result.ResultObjectIds, flag); return(true); } return(false); }
public bool OnBeforeFolderChange(FolderChangeOperation operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId sourceFolderId, StoreObjectId destinationFolderId, ICollection <StoreObjectId> itemIds, CallbackContext callbackContext) { PublicFolderCOWSession.< > c__DisplayClass4 CS$ < > 8__locals1 = new PublicFolderCOWSession.< > c__DisplayClass4(); CS$ < > 8__locals1.sourceSession = sourceSession; CS$ < > 8__locals1.sourceFolderId = sourceFolderId; CS$ < > 8__locals1.< > 4__this = this; this.CheckDisposed("OnBeforeFolderChange"); EnumValidator.ThrowIfInvalid <FolderChangeOperation>(operation, "operation"); EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags"); Util.ThrowOnNullArgument(callbackContext, "callbackContext"); if (this.InCallback) { return(false); } base.Results = new COWResults(this.publicFolderSession, itemIds); this.InCallback = true; try { PublicFolderCOWSession.< > c__DisplayClass7 CS$ < > 8__locals2 = new PublicFolderCOWSession.< > c__DisplayClass7(); CS$ < > 8__locals2.CS$ < > 8__locals5 = CS$ < > 8__locals1; CS$ < > 8__locals2.action = COWSessionBase.GetTriggerAction(operation); if (itemIds.Count == 0 || !COWSessionBase.IsDeleteOperation(CS$ < > 8__locals2.action)) { ExTraceGlobals.SessionTracer.TraceDebug <FolderChangeOperation, int>((long)this.StoreSession.GetHashCode(), "PublicFolderCOWSession::OnBeforeFolderChange - Skipping operation {0} for {1} items", operation, itemIds.Count); return(false); } CS$ < > 8__locals2.messagesToSoftDelete = new List <StoreObjectId>(itemIds.Count); List <StoreObjectId> list = new List <StoreObjectId>(itemIds.Count); CS$ < > 8__locals2.messageIds = COWSessionBase.InternalFilterItems(itemIds); foreach (StoreObjectId storeObjectId in COWSessionBase.InternalFilterFolders(itemIds)) { bool flag = CS$ < > 8__locals1.sourceFolderId != null && storeObjectId.Equals(CS$ < > 8__locals1.sourceFolderId); if (flag) { ExTraceGlobals.SessionTracer.TraceError <StoreObjectId>((long)this.StoreSession.GetHashCode(), "PublicFolderCOWSession::OnBeforeFolderChange - Folder {0} skipped. We currently don't support EmptyFolder operation for public folders", storeObjectId); base.Results.AddResult(new GroupOperationResult(OperationResult.PartiallySucceeded, new StoreObjectId[] { storeObjectId }, new StoragePermanentException(ServerStrings.ErrorEmptyFolderNotSupported))); } else { list.Add(storeObjectId); } } if (CS$ < > 8__locals2.messageIds.Count > 0 && (flags & FolderChangeOperationFlags.IncludeItems) == FolderChangeOperationFlags.IncludeItems) { Util.ThrowOnNullArgument(CS$ < > 8__locals1.sourceFolderId, "sourceFolderId"); ExTraceGlobals.SessionTracer.TraceDebug <COWTriggerAction, int, StoreObjectId>((long)this.StoreSession.GetHashCode(), "PublicFolderCOWSession::OnBeforeFolderChange - Processing action {0} for {1} messages in folder {2}", CS$ < > 8__locals2.action, CS$ < > 8__locals2.messageIds.Count, CS$ < > 8__locals1.sourceFolderId); if (CS$ < > 8__locals2.action == COWTriggerAction.HardDelete) { if (CS$ < > 8__locals2.messageIds.Count == itemIds.Count) { ExTraceGlobals.SessionTracer.TraceDebug <int>((long)this.StoreSession.GetHashCode(), "PublicFolderCOWSession::OnBeforeFolderChange - Skipping hard delete for all {0} messages", CS$ < > 8__locals2.messageIds.Count); return(false); } this.Execute(delegate() { using (Folder folder = Folder.Bind(CS$ < > 8__locals2.CS$ < > 8__locals5.sourceSession, CS$ < > 8__locals2.CS$ < > 8__locals5.sourceFolderId)) { CS$ < > 8__locals2.CS$ < > 8__locals5.< > 4__this.Results.AddResult(folder.InternalDeleteItems(DeleteItemFlags.HardDelete | DeleteItemFlags.SuppressReadReceipt, CS$ < > 8__locals2.messageIds.ToArray())); } }, CS$ < > 8__locals2.messageIds); } else { List <StoreObjectId> messagesFailed = new List <StoreObjectId>(CS$ < > 8__locals2.messageIds.Count); using (List <StoreObjectId> .Enumerator enumerator2 = CS$ < > 8__locals2.messageIds.GetEnumerator()) { while (enumerator2.MoveNext()) { StoreObjectId itemId = enumerator2.Current; if (itemId is OccurrenceStoreObjectId) { ExTraceGlobals.SessionTracer.TraceDebug <StoreObjectId>((long)this.StoreSession.GetHashCode(), "PublicFolderCOWSession::OnBeforeFolderChange - Skipping item {0} since it is an OccurrenceStoreObjectId", itemId); } else { this.Execute(delegate() { using (Item item = Item.Bind(CS$ < > 8__locals1.< > 4__this.publicFolderSession, itemId, PublicFolderCOWSession.propertiesToLoadForItems)) { if ((item.PropertyBag.GetValueOrDefault <EffectiveRights>(StoreObjectSchema.EffectiveRights, EffectiveRights.None) & EffectiveRights.Delete) == EffectiveRights.None) { ExTraceGlobals.SessionTracer.TraceError <StoreObjectId>((long)CS$ < > 8__locals1.< > 4__this.StoreSession.GetHashCode(), "PublicFolderCOWSession::OnBeforeFolderChange - User does not have delete permission for message id {0}", itemId); messagesFailed.Add(itemId); } else { CS$ < > 8__locals2.messagesToSoftDelete.Add(itemId); } } }, itemId); } } } if (messagesFailed.Count > 0) { ExTraceGlobals.SessionTracer.TraceError <int>((long)this.StoreSession.GetHashCode(), "PublicFolderCOWSession::OnBeforeFolderChange - {0} messages skipped due to insufficient permissions", messagesFailed.Count); base.Results.AddResult(new GroupOperationResult(OperationResult.PartiallySucceeded, messagesFailed, new AccessDeniedException(ServerStrings.NotEnoughPermissionsToPerformOperation))); } } }
public CowClientOperationSensitivity SkipGroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId sourceFolderId, StoreObjectId destinationFolderId, ICollection <StoreObjectId> itemIds, bool onBeforeNotification, bool onDumpster, CallbackContext callbackContext) { EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation"); EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags"); Util.ThrowOnNullArgument(settings, "settings"); Util.ThrowOnNullArgument(sourceSession, "sourceSession"); if (onDumpster) { return(CowClientOperationSensitivity.Skip); } if (!onBeforeNotification) { return(CowClientOperationSensitivity.Skip); } bool flag; if (!settings.HoldEnabled()) { flag = true; } else { switch (operation) { case COWTriggerAction.Move: case COWTriggerAction.MoveToDeletedItems: { Util.ThrowOnNullArgument(sourceSession, "sourceSession"); if (destinationSession == null) { flag = true; ExTraceGlobals.SessionTracer.TraceDebug((long)dumpster.StoreSession.GetHashCode(), "Destination session is null, meaning item moving to same mailbox, so don't keep a copy."); goto IL_187; } Guid mailboxGuid = destinationSession.MailboxGuid; Guid mailboxGuid2 = sourceSession.MailboxGuid; if (destinationSession.MailboxGuid == sourceSession.MailboxGuid) { flag = true; ExTraceGlobals.SessionTracer.TraceDebug((long)dumpster.StoreSession.GetHashCode(), "Mailbox guids are the same, meaning item moving to same mailbox, so don't keep a copy."); goto IL_187; } if (destinationSession is MailboxSession && sourceSession is MailboxSession && string.Compare(((MailboxSession)sourceSession).MailboxOwner.LegacyDn, ((MailboxSession)destinationSession).MailboxOwner.LegacyDn, StringComparison.OrdinalIgnoreCase) == 0) { flag = true; ExTraceGlobals.SessionTracer.TraceDebug((long)dumpster.StoreSession.GetHashCode(), "MailboxOwner.LegacyDistinguishedName is the same, meaning same person owns both mailboxes (eg primary and archive), so don't keep a copy."); goto IL_187; } flag = false; ExTraceGlobals.SessionTracer.TraceDebug((long)dumpster.StoreSession.GetHashCode(), "Item moving to a different mailbox owned by someone else. Keep a copy."); goto IL_187; } case COWTriggerAction.HardDelete: flag = (settings.IsMrmAction() && DumpsterFolderHelper.IsDumpsterFolder(callbackContext.SessionWithBestAccess, sourceFolderId)); goto IL_187; case COWTriggerAction.DoneWithMessageDelete: flag = false; goto IL_187; } flag = true; } IL_187: if (flag) { return(CowClientOperationSensitivity.Skip); } if (COWSession.IsDelegateSession(sourceSession)) { return(CowClientOperationSensitivity.Capture); } return(CowClientOperationSensitivity.CaptureAndPerformOperation); }
private static ClientIntentFlags GetClientIntentFromFolderChangeOperationFlags(FolderChangeOperationFlags flags, string previousAction, ClientIntentFlags carryOverIntent) { ClientIntentFlags result; if ((flags & FolderChangeOperationFlags.DeclineCalendarItemWithoutResponse) == FolderChangeOperationFlags.DeclineCalendarItemWithoutResponse) { result = ClientIntentFlags.DeletedWithNoResponse; } else if ((flags & FolderChangeOperationFlags.DeclineCalendarItemWithResponse) == FolderChangeOperationFlags.DeclineCalendarItemWithResponse) { result = ClientIntentFlags.RespondedDecline; } else if ((flags & FolderChangeOperationFlags.CancelCalendarItem) == FolderChangeOperationFlags.CancelCalendarItem) { result = ClientIntentFlags.MeetingCanceled; } else { result = ((CalendarLoggingHelper.updateActionString == previousAction) ? carryOverIntent : ClientIntentFlags.None); } return(result); }
public void GroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId destinationFolderId, StoreObjectId[] itemIds, GroupOperationResult result, bool onBeforeNotification, CallbackContext callbackContext) { EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation"); EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags"); int num = 0; if (itemIds != null) { foreach (StoreObjectId storeObjectId in itemIds) { if (!(storeObjectId is OccurrenceStoreObjectId)) { num++; } } } if (itemIds == null || num == itemIds.Length) { dumpster.MoveItemsToDumpster(callbackContext.SessionWithBestAccess, dumpster.RecoverableItemsDeletionsFolderId, itemIds); return; } if (num > 0) { StoreObjectId[] array = new StoreObjectId[num]; num = 0; foreach (StoreObjectId storeObjectId2 in itemIds) { if (!(storeObjectId2 is OccurrenceStoreObjectId)) { array[num] = storeObjectId2; num++; } } dumpster.MoveItemsToDumpster(callbackContext.SessionWithBestAccess, dumpster.RecoverableItemsDeletionsFolderId, array); } }
public void GroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId destinationFolderId, StoreObjectId[] itemIds, GroupOperationResult result, bool onBeforeNotification, CallbackContext callbackContext) { EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation"); EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags"); if (settings.CurrentFolderId.Equals(dumpster.RecoverableItemsPurgesFolderId)) { ExTraceGlobals.SessionTracer.TraceDebug((long)dumpster.StoreSession.GetHashCode(), "Attempt to hard delete items in the dumpster purges folder"); throw new RecoverableItemsAccessDeniedException("Purges"); } if (settings.CurrentFolderId.Equals(dumpster.RecoverableItemsDiscoveryHoldsFolderId)) { ExTraceGlobals.SessionTracer.TraceDebug((long)dumpster.StoreSession.GetHashCode(), "Attempt to hard delete items in the dumpster discoveryholds folder"); throw new RecoverableItemsAccessDeniedException("DiscoveryHolds"); } if (COWTriggerAction.HardDelete == operation) { try { StoreObjectId storeObjectId; if (settings.IsOnlyInPlaceHoldEnabled()) { settings.Session.CowSession.CheckAndCreateDiscoveryHoldsFolder(callbackContext.SessionWithBestAccess); storeObjectId = dumpster.RecoverableItemsDiscoveryHoldsFolderId; } else { storeObjectId = dumpster.RecoverableItemsPurgesFolderId; } if (!settings.CurrentFolderId.Equals(storeObjectId)) { dumpster.MoveItemsToDumpster(callbackContext.SessionWithBestAccess, storeObjectId, itemIds); } return; } catch (DumpsterOperationException) { if (dumpster.Results.AnyPartialResultFailure()) { throw; } List <GroupOperationResult> partialResults = dumpster.Results.GetPartialResults(); ExTraceGlobals.SessionTracer.TraceWarning <GroupOperationResult>((long)dumpster.StoreSession.GetHashCode(), "DumpsterOperationException during HardDelete and Partial success: leave the current results {0}", partialResults[partialResults.Count - 1]); return; } } dumpster.CopyItemsToDumpster(callbackContext.SessionWithBestAccess, dumpster.RecoverableItemsPurgesFolderId, itemIds, COWTriggerAction.DoneWithMessageDelete == operation); }
public CowClientOperationSensitivity SkipGroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId sourceFolderId, StoreObjectId destinationFolderId, ICollection <StoreObjectId> itemIds, bool onBeforeNotification, bool onDumpster, CallbackContext callbackContext) { EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation"); EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags"); Util.ThrowOnNullArgument(settings, "settings"); Util.ThrowOnNullArgument(sourceSession, "sourceSession"); if (onDumpster) { return(CowClientOperationSensitivity.Skip); } if (!onBeforeNotification) { return(CowClientOperationSensitivity.Skip); } if (operation != COWTriggerAction.SoftDelete) { return(CowClientOperationSensitivity.Skip); } if (COWSession.IsDelegateSession(sourceSession)) { return(CowClientOperationSensitivity.Capture); } return(CowClientOperationSensitivity.CaptureAndPerformOperation); }
public CowClientOperationSensitivity SkipGroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId sourceFolderId, StoreObjectId destinationFolderId, ICollection <StoreObjectId> itemIds, bool onBeforeNotification, bool onDumpster, CallbackContext callbackContext) { if (!COWContactLogging.COWContactLoggingConfiguration.Instance.IsLoggingEnabled()) { return(CowClientOperationSensitivity.Skip); } EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation"); EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags"); Util.ThrowOnNullArgument(sourceSession, "sourceSession"); if (!onBeforeNotification) { COWContactLogging.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLogging.SkipGroupOperation: not OnBeforeNotification"); return(CowClientOperationSensitivity.Skip); } COWContactLogging.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLogging.SkipGroupOperation: SourceFolderId.ObjectType={0}, DestinationFolderId.ObjectType={1}", new object[] { (sourceFolderId == null) ? "<<Null>>" : sourceFolderId.ObjectType, (destinationFolderId == null) ? "<<Null>>" : destinationFolderId.ObjectType }); bool flag = true; if ((sourceFolderId != null && sourceFolderId.ObjectType == StoreObjectType.ContactsFolder) || (destinationFolderId != null && destinationFolderId.ObjectType == StoreObjectType.ContactsFolder)) { flag = false; } else if (itemIds != null) { foreach (StoreObjectId storeObjectId in itemIds) { COWContactLogging.Tracer.TraceDebug <StoreObjectType>((long)this.GetHashCode(), "COWContactLogging.SkipGroupOperation: ItemId.ObjectType = {0}", storeObjectId.ObjectType); if (storeObjectId.ObjectType == StoreObjectType.Contact || storeObjectId.ObjectType == StoreObjectType.DistributionList) { flag = false; break; } } } if (!flag) { foreach (IContactChangeTracker contactChangeTracker in COWContactLogging.ChangeTrackers) { if (contactChangeTracker.ShouldLogGroupOperation(operation, sourceSession, sourceFolderId, destinationSession, destinationFolderId, itemIds)) { COWContactLogging.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLogging.SkipGroupOperation: A tracker interested."); COWContactLogging.ContactChangeLogEvent contactChangeLogEvent = new COWContactLogging.ContactChangeLogEvent(); contactChangeLogEvent.Add("Action", operation.ToString()); contactChangeLogEvent.Add("FolderChangeOperationFlags", flags.ToString()); contactChangeLogEvent.Add("ClientInfo", sourceSession.ClientInfoString); if (destinationSession != null && destinationSession.ClientInfoString != sourceSession.ClientInfoString) { contactChangeLogEvent.Add("DestinationClientInfo", destinationSession.ClientInfoString); } if (sourceFolderId != null) { contactChangeLogEvent.Add("FolderId", sourceFolderId.ToString()); } if (destinationFolderId != null && !object.Equals(sourceFolderId, destinationFolderId)) { contactChangeLogEvent.Add("DestinationFolderId", destinationFolderId.ToString()); } if (destinationSession != null && !object.Equals(sourceSession.MailboxGuid, destinationSession.MailboxGuid)) { contactChangeLogEvent.Add("DestinationMailboxGuid", destinationSession.MailboxGuid.ToString()); } string value = this.SanitizePropertyValueForLogging(itemIds); contactChangeLogEvent.Add("ItemIds", value); ContactChangeLogger contactChangeLogger = new ContactChangeLogger(sourceSession); contactChangeLogger.LogEvent(contactChangeLogEvent); break; } } } return(CowClientOperationSensitivity.Skip); }
private bool PerformFolderCopyOnWrite(COWSettings settings, IDumpsterItemOperations dumpster, ICoreItem item, MailboxSession sessionWithBestAccess, COWTriggerAction operation, FolderChangeOperationFlags folderChangeOperationFlags, bool copyAfterSave) { bool result = false; if (settings.IsCurrentFolderEnabled(sessionWithBestAccess) || COWCalendarLogging.IsParkedMessagesFolder(settings, sessionWithBestAccess)) { StoreObjectId storeObjectId = item.StoreObjectId; this.PerformCopyOnWrite(sessionWithBestAccess, dumpster, storeObjectId); item.OpenAsReadWrite(); CalendarLoggingHelper.AddMetadata(item, operation, new FolderChangeOperationFlags?(folderChangeOperationFlags)); COWSettings.AddMetadata(settings, item, operation); this.SaveItem(item, sessionWithBestAccess, operation); if (copyAfterSave) { this.PerformCopyOnWrite(sessionWithBestAccess, dumpster, storeObjectId); } result = true; } return(result); }
public void GroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId destinationFolderId, StoreObjectId[] itemIds, GroupOperationResult result, bool onBeforeNotification, CallbackContext callbackContext) { EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation"); EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags"); Util.ThrowOnNullArgument(dumpster, "dumpster"); if (itemIds == null) { return; } if (dumpster.IsDumpsterOverCalendarLoggingQuota(callbackContext.SessionWithBestAccess, settings)) { ExTraceGlobals.CalendarLoggingTracer.Information <string, string>((long)sourceSession.GetHashCode(), "User {0} has exceeded the calendar logging quota of {1}", sourceSession.UserLegacyDN, settings.CalendarLoggingQuota.Value.ToString("A")); StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_COWCalendarLoggingStopped, sourceSession.UserLegacyDN, new object[] { sourceSession.UserLegacyDN }); return; } if (dumpster.IsDumpsterOverWarningQuota(settings)) { ExTraceGlobals.CalendarLoggingTracer.Information <string, string>((long)sourceSession.GetHashCode(), "Disabling calendar logging for user {0}, since it has exceeded the dumpster warning quota of {1}", sourceSession.UserLegacyDN, settings.DumpsterWarningQuota.Value.ToString("A")); dumpster.DisableCalendarLogging(); return; } foreach (StoreObjectId storeObjectId in itemIds) { ICoreItem coreItem = null; StoragePermanentException ex = null; try { if (CalendarLoggingHelper.ShouldBeCopiedOnWrite(storeObjectId)) { if (CalendarLoggingHelper.ShouldLogInitialCheck(storeObjectId, operation)) { try { coreItem = CoreItem.Bind(callbackContext.SessionWithBestAccess, storeObjectId, CalendarLoggingHelper.RequiredOriginalProperties); if (!CalendarLoggingHelper.ShouldLog(coreItem, operation)) { goto IL_25A; } if (coreItem.PropertyBag.GetValueOrDefault <bool>(InternalSchema.HasBeenSubmitted)) { ExTraceGlobals.CalendarLoggingTracer.TraceWarning <ICoreItem, COWTriggerAction>((long)callbackContext.SessionWithBestAccess.GetHashCode(), "Save Item for Calendar Logging skipped as the item.HasBeenSubmitted is true (item {0}, operation {1}.", coreItem, operation); goto IL_25A; } switch (operation) { case COWTriggerAction.Move: case COWTriggerAction.MoveToDeletedItems: case COWTriggerAction.SoftDelete: if (!this.PerformFolderCopyOnWrite(settings, dumpster, coreItem, callbackContext.SessionWithBestAccess, operation, flags, false)) { goto IL_25A; } break; case COWTriggerAction.HardDelete: { StoreObjectId parentIdFromMessageId = IdConverter.GetParentIdFromMessageId(storeObjectId); if (DumpsterFolderHelper.IsAuditFolder(callbackContext.SessionWithBestAccess, parentIdFromMessageId)) { goto IL_25A; } if (DumpsterFolderHelper.IsDumpsterFolder(callbackContext.SessionWithBestAccess, parentIdFromMessageId)) { this.PerformCopyOnWrite(callbackContext.SessionWithBestAccess, dumpster, storeObjectId); goto IL_25A; } if (!this.PerformFolderCopyOnWrite(settings, dumpster, coreItem, callbackContext.SessionWithBestAccess, operation, flags, !settings.HoldEnabled())) { goto IL_25A; } break; } } } catch (ObjectNotFoundException ex2) { ex = ex2; } catch (VirusDetectedException ex3) { ex = ex3; } catch (VirusMessageDeletedException ex4) { ex = ex4; } catch (VirusException ex5) { ex = ex5; } if (ex != null) { ExTraceGlobals.CalendarLoggingTracer.TraceWarning <StoreObjectId, StoragePermanentException, COWTriggerAction>((long)callbackContext.SessionWithBestAccess.GetHashCode(), "Item ({0}) processing for Calendar Logging failure {1} (operation {2}).", storeObjectId, ex, operation); } } } } finally { if (coreItem != null) { coreItem.Dispose(); } } IL_25A :; } }
public CowClientOperationSensitivity SkipGroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId sourceFolderId, StoreObjectId destinationFolderId, ICollection <StoreObjectId> itemIds, bool onBeforeNotification, bool onDumpster, CallbackContext callbackContext) { EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation"); EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags"); Util.ThrowOnNullArgument(settings, "settings"); Util.ThrowOnNullArgument(sourceSession, "sourceSession"); Util.ThrowOnNullArgument(dumpster, "dumpster"); if (onDumpster) { ExTraceGlobals.CalendarLoggingTracer.Information <string>((long)sourceSession.GetHashCode(), "Skipping calendar COW group operation for user {0}, since the operation is on dumpster", sourceSession.UserLegacyDN); return(CowClientOperationSensitivity.Skip); } if (!onBeforeNotification) { ExTraceGlobals.CalendarLoggingTracer.Information <string>((long)sourceSession.GetHashCode(), "Skipping calendar COW group operation for user {0}, since we are only interested in on-before notifications", sourceSession.UserLegacyDN); return(CowClientOperationSensitivity.Skip); } if (!CalendarLoggingHelper.ShouldLog(operation)) { ExTraceGlobals.CalendarLoggingTracer.Information <string, COWTriggerAction>((long)sourceSession.GetHashCode(), "Skipping calendar COW group operation for user {0}, since the trigger action {1} is not interesting", sourceSession.UserLegacyDN, operation); return(CowClientOperationSensitivity.Skip); } if (DumpsterFolderHelper.IsAuditFolder(callbackContext.SessionWithBestAccess, sourceFolderId)) { ExTraceGlobals.CalendarLoggingTracer.Information <string>((long)sourceSession.GetHashCode(), "Skipping calendar COW group operation for user {0}, since the operation is on audit folder", sourceSession.UserLegacyDN); return(CowClientOperationSensitivity.Skip); } if (!settings.IsCalendarLoggingEnabled()) { ExTraceGlobals.CalendarLoggingTracer.Information <string>((long)sourceSession.GetHashCode(), "Skipping calendar COW group operation for user {0}, since calendar logging is disabled for this user", sourceSession.UserLegacyDN); return(CowClientOperationSensitivity.Skip); } if (!DumpsterFolderHelper.IsDumpsterFolder(callbackContext.SessionWithBestAccess, sourceFolderId)) { return(CowClientOperationSensitivity.Capture); } if (operation == COWTriggerAction.HardDelete && !sourceFolderId.Equals(dumpster.CalendarLoggingFolderId)) { return(CowClientOperationSensitivity.Capture); } ExTraceGlobals.CalendarLoggingTracer.Information <string>((long)sourceSession.GetHashCode(), "Skipping calendar COW group operation for user {0}, since we are not interested in hard deletes in calendar logging folder", sourceSession.UserLegacyDN); return(CowClientOperationSensitivity.Skip); }