Exemple #1
0
        private ReplayAction TryConvertToAction(Activity activity, IActionWatermark watermark)
        {
            ActivityId id = activity.Id;

            switch (id)
            {
            case ActivityId.Move:
                if (IdConverter.IsMessageId(activity.ItemId))
                {
                    byte[] array;
                    byte[] itemAndFolderId = StorageActionsSource.GetItemAndFolderId(activity.ItemId, out array);
                    byte[] prevFolderId;
                    StorageActionsSource.GetItemAndFolderId(activity.PreviousItemId, out prevFolderId);
                    DefaultFolderType defaultFolderType = this.mailboxSession.IsDefaultFolderType(StoreObjectId.FromProviderSpecificId(array, StoreObjectType.Folder));
                    if (defaultFolderType == DefaultFolderType.RecoverableItemsDeletions || defaultFolderType == DefaultFolderType.RecoverableItemsPurges)
                    {
                        return(new DeleteAction(itemAndFolderId, array, prevFolderId, watermark.SerializeToString()));
                    }
                    return(new MoveAction(itemAndFolderId, array, prevFolderId, watermark.SerializeToString()));
                }
                break;

            case ActivityId.Flag:
            {
                byte[] array;
                byte[] itemAndFolderId = StorageActionsSource.GetItemAndFolderId(activity.ItemId, out array);
                return(new FlagAction(itemAndFolderId, array, watermark.SerializeToString()));
            }

            case ActivityId.FlagComplete:
            {
                byte[] array;
                byte[] itemAndFolderId = StorageActionsSource.GetItemAndFolderId(activity.ItemId, out array);
                return(new FlagCompleteAction(itemAndFolderId, array, watermark.SerializeToString()));
            }

            case ActivityId.FlagCleared:
            {
                byte[] array;
                byte[] itemAndFolderId = StorageActionsSource.GetItemAndFolderId(activity.ItemId, out array);
                return(new FlagClearAction(itemAndFolderId, array, watermark.SerializeToString()));
            }

            case ActivityId.Categorize:
            case ActivityId.InspectorDisplayStart:
            case ActivityId.InspectorDisplayEnd:
                break;

            case ActivityId.MarkAsRead:
            {
                byte[] array;
                byte[] itemAndFolderId = StorageActionsSource.GetItemAndFolderId(activity.ItemId, out array);
                return(new MarkAsReadAction(itemAndFolderId, array, watermark.SerializeToString()));
            }

            case ActivityId.MarkAsUnread:
            {
                byte[] array;
                byte[] itemAndFolderId = StorageActionsSource.GetItemAndFolderId(activity.ItemId, out array);
                return(new MarkAsUnReadAction(itemAndFolderId, array, watermark.SerializeToString()));
            }

            default:
                switch (id)
                {
                case ActivityId.RemoteSend:
                {
                    string[] recipients;
                    byte[]   mimeData = this.GetMimeData(activity.ItemId, out recipients);
                    byte[]   array;
                    byte[]   itemAndFolderId = StorageActionsSource.GetItemAndFolderId(activity.ItemId, out array);
                    return(new SendAction(itemAndFolderId, array, watermark.SerializeToString())
                        {
                            Data = mimeData,
                            Recipients = recipients
                        });
                }

                case ActivityId.CreateCalendarEvent:
                {
                    byte[]         array;
                    byte[]         itemAndFolderId = StorageActionsSource.GetItemAndFolderId(activity.ItemId, out array);
                    IList <Event>  exceptionalOccurrences;
                    IList <string> deletedOccurrences;
                    Event          calendarEventData = this.GetCalendarEventData(activity, out exceptionalOccurrences, out deletedOccurrences);
                    if (calendarEventData == null)
                    {
                        return(null);
                    }
                    return(new CreateCalendarEventAction(itemAndFolderId, array, watermark.SerializeToString(), calendarEventData, exceptionalOccurrences, deletedOccurrences));
                }

                case ActivityId.UpdateCalendarEvent:
                {
                    byte[]         array;
                    byte[]         itemAndFolderId = StorageActionsSource.GetItemAndFolderId(activity.ItemId, out array);
                    IList <Event>  exceptionalOccurrences2;
                    IList <string> deletedOccurrences2;
                    Event          calendarEventData2 = this.GetCalendarEventData(activity, out exceptionalOccurrences2, out deletedOccurrences2);
                    if (calendarEventData2 == null)
                    {
                        return(null);
                    }
                    return(new UpdateCalendarEventAction(itemAndFolderId, array, watermark.SerializeToString(), calendarEventData2, exceptionalOccurrences2, deletedOccurrences2));
                }
                }
                break;
            }
            return(null);
        }