Exemplo n.º 1
0
        public void TranslateExternalUpsertCommandToAkkaMessage(HTTPSourcedCommand cmdExternal)
        {
            ClientState cs;

            if (ExtractStateObject(cmdExternal, out cs))
            {
                ClientUpsertCommand upsertCmd = new ClientUpsertCommand(cs, cmdExternal.User, cmdExternal.ConnectionId);
                SendTo.Tell(upsertCmd, ReplyTo);
            }
        }
Exemplo n.º 2
0
        private void PostUpsertHandler(ClientUpsertCommand c)
        {
            ClientState cs = c.ClientStateData;

            _ActorState = cs;
            AutoSaveSnashot(false);
            _logger.Info($"Updated/Inserted {cs.DocumentType} for id:{_ActorState.Id}");
            ClientUpsertedEvent message = new ClientUpsertedEvent(_ActorState.Clone(), c.User, c.ConnectionId);

            Sender.Tell(message, Self);
            NotifyCommandEventSubscribers(message);
        }
Exemplo n.º 3
0
        private bool UpsertClientCommand(ClientUpsertCommand c)
        {
            if (_ActorState.isActive == false && c.ClientStateData.isActive == true)
            {
                _logger.Error($"Reactivating client with Id: {PersistenceId}");
                return(true);
            }
            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.");
                return(true);
            }
            if (c.ClientStateData.Id == null || c.ClientStateData.Id == "")
            {
                Sender.Tell(new ClientFailedInsertEvent("Client Id cannot be empty.", c.ClientStateData, c.User, c.ConnectionId));
                _logger.Error($"While insert PersistenceId: {PersistenceId} client id is missing.");
                return(true);
            }

            Persist <ClientUpsertCommand>(c, PostUpsertHandler);
            return(true);
        }
Exemplo n.º 4
0
 private void UpsertNewClientRecoveryCommand(ClientUpsertCommand c)
 {
     // When recovering set the state of the actor
     _ActorState = c.ClientStateData;
 }