Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "liuziyuan"

public class UserAppService : IUserAppService
    {
        public ILogger Logger { get; set; }
        public IEventBus EventBus { get; set; }

        private readonly IUserRepository userRepository;

        public UserAppService(IUserRepository userRepository)
        {
            this.userRepository = userRepository;
            Logger = NullLogger.Instance;
            EventBus = NullEventBus.Instance;
        }
        public UserDto CreateUser(CreateUserInput input)
        {
            Logger.Info("begin CreateUser");
            var user = new User { Name = input.Name, Address = input.Address };
            user = userRepository.Insert(user);
            Logger.Info("end CreateUser");
            EventBus.Trigger<EntityCreatedEventData<User>>(new EntityCreatedEventData<User>(user));
            return Mapper.Map<UserDto>(user);
        }


        public GetUsersOutput GetUsers()
        {
            Logger.Info("begin GetUser");
            var users = userRepository.GetAllList();
            Logger.Info("end GetUser");

            EventBus.Trigger<UserCompletedEventData>(new UserCompletedEventData{ Count = users.Count()});
            return new GetUsersOutput
            {
                Users = Mapper.Map<List<UserDto>>(users)
            };
        }
    }

    public class UserCompletedEventData : EventData
    {
        public int Count { get; set; }
    }

    public class ActivityWriter : IEventHandler<UserCompletedEventData> , IEventHandler<EntityCreatedEventData<User>>,ITransientDependency{
        public ILogger Logger { get; set; }

        public ActivityWriter(){
             Logger = NullLogger.Instance;
        }
        public void HandleEvent(UserCompletedEventData eventData)
        {
 	        Logger.Info("===================================" + eventData.Count);
        }
    
        public void HandleEvent(EntityCreatedEventData<User> eventData)
        {
 	        Logger.Info("+++++++++++++++++++++++++++++++++++" + eventData.Entity.Id);
        }
    }

this is the log file as follow: DEBUG 2016-07-24 17:15:40,273 [1 ] Abp.Logging.LogHelper - Dynamic web api controller is created for type 'GePower.CaseMgmt.Users.IUserAppService' with service name 'app/user'. INFO 2016-07-24 17:15:57,016 [10 ] GePower.CaseMgmt.Users.UserAppService - begin GetUser INFO 2016-07-24 17:15:57,178 [9 ] GePower.CaseMgmt.Users.UserAppService - begin CreateUser INFO 2016-07-24 17:15:59,989 [9 ] GePower.CaseMgmt.Users.UserAppService - end CreateUser INFO 2016-07-24 17:16:05,866 [9 ] GePower.CaseMgmt.Users.ActivityWriter - +++++++++++++++++++++++++++++++++++0 INFO 2016-07-24 17:16:10,097 [9 ] GePower.CaseMgmt.Users.ActivityWriter - +++++++++++++++++++++++++++++++++++5 INFO 2016-07-24 17:16:10,353 [10 ] GePower.CaseMgmt.Users.UserAppService - end GetUser INFO 2016-07-24 17:16:13,151 [10 ] GePower.CaseMgmt.Users.ActivityWriter - ===================================5

You can see ActivityWriter was called twice. actually 5 is the right ,I don't know why?pls help ,thank you

Showing 1 to 1 of 1 entries