コード例 #1
0
        public void ItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, CoreFolder folder, bool onBeforeNotification, OperationResult result, CallbackContext callbackContext)
        {
            Util.ThrowOnNullArgument(dumpster, "dumpster");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <OperationResult>(result, "result");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            MailboxSession sessionWithBestAccess = callbackContext.SessionWithBestAccess;

            if (onBeforeNotification)
            {
                if (CalendarLoggingHelper.ShouldLog(item, operation))
                {
                    StoreObjectId storeObjectId = ((ICoreObject)item).StoreObjectId;
                    CalendarLoggingHelper.AddMetadata(item, operation, null);
                    if (operation == COWTriggerAction.Update && state == COWTriggerActionState.Save && CalendarLoggingHelper.ShouldBeCopiedOnWrite(storeObjectId))
                    {
                        if (settings.HoldEnabled() && item.IsLegallyDirty)
                        {
                            return;
                        }
                        if (!settings.IsCurrentFolderItemEnabled(sessionWithBestAccess, item) && !COWCalendarLogging.IsParkedMessagesFolder(settings, sessionWithBestAccess))
                        {
                            return;
                        }
                        if (dumpster.IsDumpsterOverCalendarLoggingQuota(sessionWithBestAccess, settings))
                        {
                            ExTraceGlobals.CalendarLoggingTracer.Information <string, string>((long)session.GetHashCode(), "User {0} has exceeded the calendar logging quota of {1}", session.UserLegacyDN, settings.CalendarLoggingQuota.Value.ToString("A"));
                            StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_COWCalendarLoggingStopped, session.UserLegacyDN, new object[]
                            {
                                session.UserLegacyDN
                            });
                        }
                        else if (dumpster.IsDumpsterOverWarningQuota(settings))
                        {
                            ExTraceGlobals.CalendarLoggingTracer.Information <string, string>((long)session.GetHashCode(), "Disabling calendar logging for user {0}, since it has exceeded the dumpster warning quota of {1}", session.UserLegacyDN, settings.DumpsterWarningQuota.Value.ToString("A"));
                            dumpster.DisableCalendarLogging();
                        }
                        else
                        {
                            StoreObjectId calendarLogGeneratedId = this.PerformCopyOnWrite(sessionWithBestAccess, dumpster, storeObjectId);
                            dumpster.Results.CalendarLogGeneratedId = calendarLogGeneratedId;
                        }
                    }
                    COWSettings.AddMetadata(settings, item, operation);
                    return;
                }
            }
            else if (operation == COWTriggerAction.Update && state == COWTriggerActionState.Save && result == OperationResult.Failed)
            {
                dumpster.RollbackItemVersion(sessionWithBestAccess, item, dumpster.Results.CalendarLogGeneratedId);
                dumpster.Results.CalendarLogGeneratedId = null;
            }
        }
コード例 #2
0
        public void ItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, CoreFolder folder, bool onBeforeNotification, OperationResult result, CallbackContext callbackContext)
        {
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <OperationResult>(result, "result");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            StoreObjectId storeObjectId = ((ICoreObject)item).StoreObjectId;

            if (storeObjectId is OccurrenceStoreObjectId)
            {
                return;
            }
            if (onBeforeNotification)
            {
                List <string> legallyDirtyProperties = item.GetLegallyDirtyProperties();
                if (legallyDirtyProperties != null && legallyDirtyProperties.Count > 0)
                {
                    COWSettings.AddMetadata(settings, item, operation);
                    if (state == COWTriggerActionState.Save)
                    {
                        StoreObjectId destinationFolderId;
                        if (settings.IsOnlyInPlaceHoldEnabled())
                        {
                            settings.Session.CowSession.CheckAndCreateDiscoveryHoldsFolder(callbackContext.SessionWithBestAccess);
                            destinationFolderId = dumpster.RecoverableItemsDiscoveryHoldsFolderId;
                        }
                        else
                        {
                            destinationFolderId = dumpster.RecoverableItemsVersionsFolderId;
                        }
                        StoreObjectId copyOnWriteGeneratedId = dumpster.CopyItemToDumpster(callbackContext.SessionWithBestAccess, destinationFolderId, item);
                        dumpster.Results.CopyOnWriteGeneratedId = copyOnWriteGeneratedId;
                        return;
                    }
                }
            }
            else if (operation == COWTriggerAction.Update && state == COWTriggerActionState.Save && result == OperationResult.Failed)
            {
                dumpster.RollbackItemVersion(callbackContext.SessionWithBestAccess, item, dumpster.Results.CopyOnWriteGeneratedId);
                dumpster.Results.CopyOnWriteGeneratedId = null;
            }
        }