Exemplo n.º 1
0
        public ReplayActionsQueue GetAndTranslateActions(string replaySyncState, int maxNumberOfActions, MergeSyncContext syncContext, out string retrieveSyncState, out bool moreActions)
        {
            MrsTracer.Service.Function("MailboxMerger.GetAndTranslateActions", new object[0]);
            List <ReplayAction> actions = base.DestMailbox.GetActions(replaySyncState, maxNumberOfActions);

            moreActions       = (actions.Count == maxNumberOfActions);
            retrieveSyncState = ((actions.Count == 0) ? replaySyncState : actions[actions.Count - 1].Watermark);
            ReplayActionsQueue replayActionsQueue = new ReplayActionsQueue(actions.Count);

            foreach (ReplayAction action in actions)
            {
                replayActionsQueue.Enqueue(action);
            }
            EntryIdMap <List <byte[]> > entryIdMap = new EntryIdMap <List <byte[]> >();

            foreach (ReplayAction replayAction in actions)
            {
                if (!replayAction.Ignored)
                {
                    foreach (KeyValuePair <byte[], byte[]> keyValuePair in replayAction.GetMessageEntryIdsToTranslate())
                    {
                        byte[]        key   = keyValuePair.Key;
                        byte[]        value = keyValuePair.Value;
                        List <byte[]> list;
                        if (!entryIdMap.TryGetValue(key, out list))
                        {
                            list = new List <byte[]>();
                            entryIdMap.Add(key, list);
                        }
                        list.Add(value);
                    }
                }
            }
            syncContext.PrefetchSourceMessageIdsFromTargetMessageIds(entryIdMap);
            foreach (ReplayAction replayAction2 in actions)
            {
                if (!replayAction2.Ignored)
                {
                    replayAction2.TranslateEntryIds(syncContext);
                }
            }
            return(replayActionsQueue);
        }