Exemple #1
0
        private void UndeleteIfCmd(UndeleteIf cmd)
        {
            // aggregator
            var agg = Context.ActorOf(Props.Create(() => new AggregateActor()), AggregateActor.GetUniqueName());

            // active ids
            agg.Tell(new AggregateActor.GetIf(Sender, cmd, State.IdsDeletedActive.Count, typeof(UndeleteIf_ItemSuccess), typeof(UndeleteIf_ItemNoMatch), 10, false));
            foreach (var activeId in State.IdsDeletedActive)
            {
                var child = Context.Child(activeId);
                if (child != ActorRefs.Nobody)
                {
                    agg.Tell(new AggregateActor.GetIfAdd(child, cmd));
                }
                else
                {
                    agg.Tell(new AggregateActor.ReduceTargetCount());
                }
            }
            // inactive ids
            agg.Tell(new AggregateActor.GetIf(Sender, cmd, State.IdsDeletedInactive.Count, typeof(UndeleteIf_ItemSuccess), typeof(UndeleteIf_ItemNoMatch), 10, false));
            foreach (var inactiveId in State.IdsDeletedInactive)
            {
                var child = Context.Child(inactiveId);
                if (child == ActorRefs.Nobody)
                {
                    child = CreateEntity(inactiveId);
                }

                // get inactive data and deactivate child once it replies
                agg.Tell(new AggregateActor.GetIfAdd(child, new EntityActor.DeactivateAfter <UndeleteIf>(cmd)));
            }
        }
Exemple #2
0
        private void DeleteAllCmd(DeleteAll cmd)
        {
            // aggregator
            var agg = Context.ActorOf(Props.Create(() => new AggregateActor()), AggregateActor.GetUniqueName());

            // active ids
            agg.Tell(new AggregateActor.GetAll(Sender, cmd, State.IdsActive.Count, typeof(DeleteById_Success), 10, false));
            foreach (var activeId in State.IdsActive)
            {
                var child = Context.Child(activeId);
                if (child != ActorRefs.Nobody)
                {
                    agg.Tell(new AggregateActor.GetAllAdd(child, new DeleteById(activeId)));
                }
                else
                {
                    agg.Tell(new AggregateActor.ReduceTargetCount());
                }
            }
            // inactive ids
            agg.Tell(new AggregateActor.GetAll(Sender, cmd, State.IdsInactive.Count, typeof(DeleteById_Success), 10, false));
            foreach (var inactiveId in State.IdsInactive)
            {
                var child = Context.Child(inactiveId);
                if (child == ActorRefs.Nobody)
                {
                    child = CreateEntity(inactiveId);
                }

                // get inactive data and deactivate child once it replies
                agg.Tell(new AggregateActor.GetAllAdd(child, new EntityActor.DeactivateAfter <DeleteById>(new DeleteById(inactiveId))));
            }
        }