コード例 #1
0
        internal void Enqueue(ReplayAction action)
        {
            MrsTracer.Provider.Function("ReplayActionsQueue.Enqueue", new object[0]);
            byte[] itemId = action.ItemId;
            List <ReplayAction> list;

            if (!this.optimizeMap.TryGetValue(itemId, out list))
            {
                this.optimizeMap.Add(itemId, new List <ReplayAction>
                {
                    action
                });
            }
            else
            {
                foreach (ReplayAction replayAction in list)
                {
                    ActionUpdateGroup actionUpdateGroup;
                    ActionUpdateGroup actionUpdateGroup2;
                    if (!replayAction.Ignored && ReplayActionsQueue.IsActionUpdate(replayAction, out actionUpdateGroup) && ReplayActionsQueue.IsActionUpdate(action, out actionUpdateGroup2) && actionUpdateGroup == actionUpdateGroup2)
                    {
                        MrsTracer.Service.Debug("Action {0} already existed in the batch. Replacing with action: {1}", new object[]
                        {
                            replayAction,
                            action
                        });
                        replayAction.Ignored = true;
                    }
                }
                list.Add(action);
            }
            this.queue.Enqueue(action);
        }
コード例 #2
0
        IEnumerable <ReplayAction> IActionsSource.ReadActions(IActionWatermark watermark)
        {
            MrsTracer.Provider.Function("StorageActionsSource.ReadActions", new object[0]);
            IActivityLog        activityLog = ActivityLogFactory.Current.Bind(this.mailboxSession);
            List <ReplayAction> actionsIndescendingOrder = new List <ReplayAction>(100);

            foreach (Activity activity in activityLog.Query())
            {
                if (activity.ClientId.LoggedViaServerSideInstrumentation)
                {
                    IActionWatermark actionWatermark = new StorageActionWatermark(activity);
                    if (watermark != null && watermark.CompareTo(actionWatermark) >= 0)
                    {
                        break;
                    }
                    ReplayAction replayAction = this.TryConvertToAction(activity, actionWatermark);
                    if (replayAction != null)
                    {
                        actionsIndescendingOrder.Add(replayAction);
                    }
                }
            }
            for (int index = actionsIndescendingOrder.Count - 1; index >= 0; index--)
            {
                yield return(actionsIndescendingOrder[index]);
            }
            yield break;
        }
コード例 #3
0
 internal bool TryQueue(out ReplayAction action)
 {
     if (this.queue.Count > 0)
     {
         action = this.queue.Dequeue();
         return(true);
     }
     action = null;
     return(false);
 }
コード例 #4
0
        private static bool IsActionUpdate(ReplayAction action, out ActionUpdateGroup updateGroup)
        {
            updateGroup = ActionUpdateGroup.None;
            switch (action.Id)
            {
            case ActionId.MarkAsRead:
            case ActionId.MarkAsUnRead:
                updateGroup = ActionUpdateGroup.Read;
                return(true);

            case ActionId.Flag:
            case ActionId.FlagClear:
            case ActionId.FlagComplete:
                updateGroup = ActionUpdateGroup.Flag;
                return(true);

            case ActionId.UpdateCalendarEvent:
                updateGroup = ActionUpdateGroup.CalendarEvent;
                return(true);
            }
            return(false);
        }
コード例 #5
0
        private void PostReplay(ReplayAction action, ReplayActionResult result)
        {
            byte[]   originalFolderId = action.OriginalFolderId;
            byte[]   originalItemId   = action.OriginalItemId;
            ActionId id = action.Id;

            switch (id)
            {
            case ActionId.Move:
            {
                MoveActionResult moveActionResult = (MoveActionResult)result;
                MrsTracer.Service.Debug("Result of move action: {0}", new object[]
                    {
                        moveActionResult
                    });
                if (ArrayComparer <byte> .EqualityComparer.Equals(moveActionResult.ItemId, moveActionResult.PreviousItemId))
                {
                    return;
                }
                if (moveActionResult.MoveAsDelete)
                {
                    MrsTracer.Service.Debug("Move action {0} resulted in deletion of an item in source. removing from target as well.", new object[]
                        {
                            action
                        });
                    this.DeleteItem(originalFolderId, originalItemId);
                    return;
                }
                MrsTracer.Service.Debug("Stamping new source message id after move action: {0}", new object[]
                    {
                        action
                    });
                this.UpdateSourceId(originalFolderId, originalItemId, moveActionResult.ItemId);
                return;
            }

            case ActionId.Send:
                MrsTracer.Service.Debug("Deleting the message after send action: {0}", new object[]
                {
                    action
                });
                try
                {
                    this.DeleteItem(originalFolderId, originalItemId);
                    return;
                }
                finally
                {
                    this.ReplaySyncState.ProviderState = action.Watermark;
                    this.SaveReplaySyncState();
                }
                break;

            default:
                if (id != ActionId.CreateCalendarEvent)
                {
                    return;
                }
                break;
            }
            CreateCalendarEventActionResult createCalendarEventActionResult = (CreateCalendarEventActionResult)result;

            MrsTracer.Service.Debug("Result of create calendar event: {0}", new object[]
            {
                createCalendarEventActionResult
            });
            MrsTracer.Service.Debug("Stamping source message id after create calendar event action: {0}", new object[]
            {
                action
            });
            this.UpdateSourceId(originalFolderId, originalItemId, createCalendarEventActionResult.SourceItemId);
        }