Exemplo n.º 1
0
        public EmployeeActor(EmployeeStoredInformation storedInformation, IActorRef imageResizer, IActorRef vacationsRegistry)
        {
            this.employeeMetadata = storedInformation.Metadata;
            this.PersistenceId    = $"employee-info-{Uri.EscapeDataString(this.employeeMetadata.EmployeeId)}";

            this.photo = Context.ActorOf(Props.Create(() => new PhotoActor(imageResizer)), "photo");
            this.photo.Tell(new PhotoActor.SetSource(storedInformation.Photo));

            this.employeeFeed = Context.ActorOf(FeedActor.GetProps(), "feed");
            var sendEmailActor = Context.ActorOf(SendEmailSickLeaveActor.GetProps(), "sendEmail");

            sendEmailActor.Tell(new SendEmailSickLeaveActor.SetEmployeesActor(Context.Parent));

            var vacationsActor  = Context.ActorOf(EmployeeVacationsActor.CreateProps(this.employeeMetadata.EmployeeId, this.employeeFeed, vacationsRegistry), "vacations");
            var sickLeavesActor = Context.ActorOf(EmployeeSickLeaveActor.CreateProps(this.employeeMetadata.EmployeeId, sendEmailActor), "sick-leaves");
            var workHoursActor  = Context.ActorOf(EmployeeWorkHoursActor.CreateProps(this.employeeMetadata.EmployeeId), "work-hours");

            Context.Watch(vacationsActor);
            Context.Watch(sickLeavesActor);
            Context.Watch(workHoursActor);

            var calendarActor = Context.ActorOf(EmployeeCalendarActor.CreateProps(this.employeeMetadata.EmployeeId, vacationsActor, workHoursActor, sickLeavesActor), "all-calendar-events");

            this.calendar = new EmployeeCalendarContainer(vacationsActor, workHoursActor, sickLeavesActor, calendarActor);
        }
        public EmployeeActor(
            EmployeeStoredInformation storedInformation,
            IActorRef imageResizer,
            IActorRef vacationsCreditRegistry,
            IEmployeeVacationsRegistryPropsFactory employeeVacationsRegistryPropsFactory,
            IEmployeeSickLeavesRegistryPropsFactory employeeSickLeavesRegistryPropsFactory)
        {
            this.employeeMetadata = storedInformation.Metadata;
            this.PersistenceId    = $"employee-info-{Uri.EscapeDataString(this.employeeMetadata.EmployeeId)}";

            this.photo = Context.ActorOf(Props.Create(() => new PhotoActor(imageResizer)), "photo");
            this.photo.Tell(new PhotoActor.SetSource(storedInformation.Photo));

            this.employeeFeed = Context.ActorOf(FeedActor.GetProps(), "feed");

            var persistenceSupervisorFactory = new PersistenceSupervisorFactory();

            var vacationActorProps = EmployeeVacationsActor.CreateProps(
                this.employeeMetadata.EmployeeId,
                this.employeeFeed,
                vacationsCreditRegistry,
                employeeVacationsRegistryPropsFactory);

            var sickLeaveActorProps = EmployeeSickLeaveActor.CreateProps(
                this.employeeMetadata.EmployeeId,
                employeeSickLeavesRegistryPropsFactory);

            var workHoursActorProps = EmployeeWorkHoursActor.CreateProps(this.employeeMetadata.EmployeeId);

            var vacationsActor = Context.ActorOf(vacationActorProps, "vacations");

            var sickLeavesActor = Context.ActorOf(sickLeaveActorProps, "sick-leaves");

            var workHoursActor = Context.ActorOf(
                persistenceSupervisorFactory.Get(workHoursActorProps),
                "work-hours");

            var calendarActor = Context.ActorOf(
                EmployeeCalendarActor.CreateProps(
                    this.employeeMetadata.EmployeeId,
                    vacationsActor,
                    workHoursActor,
                    sickLeavesActor),
                "all-calendar-events"
                );

            var pendingActionsActor = Context.ActorOf(
                EmployeePendingActionsActor.CreateProps(this.employeeMetadata.EmployeeId),
                "pending-actions"
                );

            this.calendar = new EmployeeCalendarContainer(
                vacationsActor,
                workHoursActor,
                sickLeavesActor,
                calendarActor,
                pendingActionsActor);
        }