コード例 #1
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);
            }
        }
コード例 #2
0
 private bool InsertNewClientCommand(ClientInsertCommand c)
 {
     if (c.ClientStateData.Name == null || c.ClientStateData.Name == "")
     {
         Sender.Tell(new ClientFailedInsertEvent("UserName field cannot be blank(or null).", c.ClientStateData, c.User, c.ConnectionId));
         _logger.Error($"While insert PersistenceId: {PersistenceId} client name is missing.");
     }
     if (c.ClientStateData.Id == null || c.ClientStateData.Id == "")
     {
         _ActorState = new ClientState(PersistenceId, c.ClientStateData);
         AutoSaveSnashot(true);
         _logger.Info($"Inserted {_ActorState.DocumentType} for id:{_ActorState.Id}");
         ClientInsertedEvent message = new ClientInsertedEvent(_ActorState.Clone(), c.User, c.ConnectionId);
         Sender.Tell(message, Self);
         NotifyCommandEventSubscribers(message);
     }
     return(true);
 }
        public bool TranslateAkkaInsertEventToExternalMessage(CommandEventMessage internalCommandEvent)
        {
            ClientInsertedEvent e = internalCommandEvent as ClientInsertedEvent;

            HTTPExternalInterface.HandleEDStateMessage(
                new HTTPDestinedCommandStateEvent(
                    MicroServices.ProcessingStatus.Processed,
                    e.Message,
                    new HTTPSourcedCommand(
                        e.CommandType.ToString(),
                        e.Area.ToString(),
                        null,
                        e.ResultClientState,
                        e.User,
                        e.ConnectionId,
                        e.Id
                        )
                    ),
                false //User only?
                );
            return(true);
        }