internal static StoreObjectId CreateVersion(StoreSession session, StoreObjectId itemId, StoreObjectId versionFolderId)
        {
            StoreObjectId result;

            using (CoreCalendarItemVersion coreCalendarItemVersion = new CoreCalendarItemVersion(session))
            {
                using (MapiProp mapiProp = session.GetMapiProp(itemId, OpenEntryFlags.DeferredErrors | OpenEntryFlags.ShowSoftDeletes))
                {
                    coreCalendarItemVersion.underlyingMessage = Folder.InternalCreateMapiMessage(session, versionFolderId, CreateMessageType.Normal);
                    coreCalendarItemVersion.CopyRequiredData((MapiMessage)mapiProp);
                    object thisObject = null;
                    bool   flag       = false;
                    try
                    {
                        if (session != null)
                        {
                            session.BeginMapiCall();
                            session.BeginServerHealthCall();
                            flag = true;
                        }
                        if (StorageGlobals.MapiTestHookBeforeCall != null)
                        {
                            StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                        }
                        coreCalendarItemVersion.underlyingMessage.SetReadFlag(SetReadFlags.ClearRnPending | SetReadFlags.CleanNrnPending);
                    }
                    catch (MapiPermanentException ex)
                    {
                        throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetReadFlags, ex, session, thisObject, "{0}. MapiException = {1}.", new object[]
                        {
                            string.Format("CoreCalendarItemVersion::CreateVersion. Failed to set read flag of underlying message.", new object[0]),
                            ex
                        });
                    }
                    catch (MapiRetryableException ex2)
                    {
                        throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetReadFlags, ex2, session, thisObject, "{0}. MapiException = {1}.", new object[]
                        {
                            string.Format("CoreCalendarItemVersion::CreateVersion. Failed to set read flag of underlying message.", new object[0]),
                            ex2
                        });
                    }
                    finally
                    {
                        try
                        {
                            if (session != null)
                            {
                                session.EndMapiCall();
                                if (flag)
                                {
                                    session.EndServerHealthCall();
                                }
                            }
                        }
                        finally
                        {
                            if (StorageGlobals.MapiTestHookAfterCall != null)
                            {
                                StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                            }
                        }
                    }
                }
                coreCalendarItemVersion.Save();
                StoreObjectId storeObjectId = StoreObjectId.FromProviderSpecificId(coreCalendarItemVersion.underlyingMessage.GetProp(PropTag.EntryId).GetBytes(), itemId.ObjectType);
                CoreCalendarItemVersion.perfCounters.DumpsterCalendarLogsRate.Increment();
                result = storeObjectId;
            }
            return(result);
        }
Exemple #2
0
 private StoreObjectId PerformCopyOnWrite(MailboxSession sessionWithBestAccess, IDumpsterItemOperations dumpster, StoreObjectId storeObjectId)
 {
     return(CoreCalendarItemVersion.CreateVersion(sessionWithBestAccess, storeObjectId, dumpster.CalendarLoggingFolderId));
 }