Exemple #1
0
        private void HandleClientUpdatedEvent(ClientUpdatedEvent e)
        {
            ClientState    cs = e.ResultClientState;
            ClientListItem newClientListItem = ClientListItem.GenerateClientListItemFromClientState(cs);

            ClientListUpdateCommand newCLUC = new ClientListUpdateCommand(newClientListItem, e.User, e.ConnectionId);

            _logger.Info($"Updating client list Id:{cs.Id} UserName:{cs.Name}.");
            Persist <ClientListUpdateCommand>(newCLUC, postClientListItemUpdateHandler);
        }
Exemple #2
0
        /// <summary>
        /// This method handles client insert events by updating the Admin's client list to the latest information.
        /// </summary>
        /// <param name="e">ClientInserted event.</param>
        private void HandleClientInsertedEvent(ClientInsertedEvent e)
        {
            if (_ActorState[e.Id] == null)
            {
                ClientState    cs = e.ResultClientState;
                ClientListItem newClientListItem = ClientListItem.GenerateClientListItemFromClientState(cs);

                // It does not matter if the item exists or not we will stomp for that particular client the existing data
                // with the new data - see post insert handler.
                // Persist the event that a new client was added to the client list
                ClientListInsertCommand newCLIC = new ClientListInsertCommand(newClientListItem, e.User, e.ConnectionId);
                _logger.Info($"Inserting new client list item Id:{cs.Id} UserName:{cs.Name}.");
                Persist <ClientListInsertCommand>(newCLIC, postClientListItemInsertHandler);
            }
        }
Exemple #3
0
        public IList <ClientListItem> GetClients(PagingOptions paging)
        {
            ClientEntity   client         = null;
            ClientListItem clientListItem = null;
            var            query          = DataProvider.QueryOver(() => client);
            var            projections    = Projections.ProjectionList();

            projections.Add(Projections.Property(() => client.Id).WithAlias(() => clientListItem.Id));
            projections.Add(Projections.Property(() => client.FirstName).WithAlias(() => clientListItem.FirstName));
            projections.Add(Projections.Property(() => client.LastName).WithAlias(() => clientListItem.LastName));
            projections.Add(Projections.Property(() => client.MiddleName).WithAlias(() => clientListItem.MiddleName));
            projections.Add(Projections.Property(() => client.Version).WithAlias(() => clientListItem.Version));
            AddPaging(query, paging);
            query.Select(projections);
            return(query.TransformUsing(Transformers.AliasToBean <ClientListItem>()).List <ClientListItem>());
        }
Exemple #4
0
        /// <summary>
        /// Removes client(item) from the list.  If an instance of the ClientActor is in memory it unloads it.
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        private void HandleClientUnDeletedEvent(ClientUnDeletedEvent e)
        {
            // Is the item still in the list?
            if (_ActorState[e.Id] == null)
            {
                _logger.Info($"{e.User} tried undeleting from client list id:{e.Id} but was not found.");
            }
            else
            {
                ClientListItem cliNewState = _ActorState[e.Id].Copy();
                cliNewState.IsActive = true;

                // Memorialize that we are recovering the item from the list in the journal
                ClientListUnDeleteCommand clientListUnDeleteCommand = new ClientListUnDeleteCommand(
                    cliNewState,
                    e.User,
                    e.ConnectionId);

                _logger.Info($"Undeleting client list item Id{e.Id} UserName:{e.ResultClientState.Name}.");
                Persist <ClientListUnDeleteCommand>(clientListUnDeleteCommand, PostClientListUnDeleteHandler);
            }
        }
Exemple #5
0
 public ClientListItemDeletedEvent(ClientListItem clientListItem, string user, string connectionId)
     : base(clientListItem.Id, clientListItem.Name, true, ClientListActor.ActorType, MicroServices.CommandType.Delete, MicroServices.Area.Client, "Client deleted from list.", clientListItem, user, connectionId)
 {
 }
Exemple #6
0
 public ClientListDeleteFailedEvent(string reason, ClientListItem originalData, string user, string connectionId)
     : base(originalData.Id, originalData.Name, true, ClientListActor.ActorType, MicroServices.CommandType.Delete, MicroServices.Area.Client, reason, originalData, user, connectionId)
 {
 }
Exemple #7
0
 public ClientListInsertedEvent(ClientListItem clientListItem, string user, string connectionId)
     : base(clientListItem.Id, clientListItem.Name, true, ClientListActor.ActorType, MicroServices.CommandType.Insert, MicroServices.Area.Client, "Client added to list.", clientListItem, user, connectionId)
 {
 }
 private static string ExtractId(ClientListItem data)
 {
     return(data.Id);
 }
 public ClientListUpdateCommand(ClientListItem data, string user, string connectionId)
     : base(ExtractId(data), MicroServices.CommandType.Update, "", data, user, connectionId)
 {
     ActorType = ClientListActor.ActorType;
 }