Exemple #1
0
        public bool ProcessRequest(HTTPSourcedRequest externalRequest)
        {
            MicroServices.RequestType rType;
            bool ableToParseRequest = MicroServices.ParseRequestType(externalRequest.RequestType, out rType);

            // Handle Command
            if (ableToParseRequest)
            {
                Logger.Debug($"HTTP Client Bridge Converted Request'{externalRequest.RequestType}' to internal value '{rType.ToString()}'.");
                TrackConnection(externalRequest);

                switch (rType)
                {
                case MicroServices.RequestType.GetList:
                {
                    TranslateExternalGetListRequestToAkkaMessage(externalRequest);
                    break;
                }

                default:
                {
                    throw new NotImplementedException($"This request type has not been implemented:{rType.ToString()}");
                }
                }
            }
            else
            {
                Logger.Debug($"HTTP Client Bridge received unknown request value'{externalRequest.RequestType}'.");
                HTTPExternalInterface.HandleFailedStateMessage(new HTTPDestinedRequestStateEvent(MicroServices.ProcessingStatus.Failed, "Unknown request:" + externalRequest.RequestType, externalRequest), true);
            }

            return(ableToParseRequest);
        }
Exemple #2
0
 private bool ExtractStateObject(HTTPSourcedCommand c, out ClientState cs)
 {
     try
     {
         JObject jo = c.Data as JObject;
         cs = ClientState.InstantiateClientState(jo);
         return(true);
     }
     catch (Exception ex)
     {
         cs = null;
         Logger.Error($"During '{c.CommandType}' system was unable to handle client's information. Exception:{ex.ToString()}");
         HTTPExternalInterface.HandleFailedStateMessage(new HTTPDestinedCommandStateEvent(MicroServices.ProcessingStatus.Failed, $"During '{c.CommandType}' system was unable to handle client's information.", c), true);
     }
     return(false);
 }
Exemple #3
0
        public bool ProcessCommand(HTTPSourcedCommand externalCommand)
        {
            MicroServices.CommandType cType;

            bool ableToParseCommand = MicroServices.ParseCommandType(externalCommand.CommandType, out cType);

            // Handle Command
            if (ableToParseCommand)
            {
                Logger.Debug($"{Area}HTTP Bridge Converted Command'{ externalCommand.CommandType}' to internal value{cType.ToString()}.");
                TrackConnection(externalCommand);

                switch (cType)
                {
                //Translate and Send message to client admin actor so that he will forward it to the client actor
                case MicroServices.CommandType.Insert:
                    TranslateExternalInsertCommandToAkkaMessage(externalCommand);
                    break;

                case MicroServices.CommandType.Update:
                    TranslateExternalUpdateCommandToAkkaMessage(externalCommand);
                    break;

                case MicroServices.CommandType.Upsert:
                    TranslateExternalUpsertCommandToAkkaMessage(externalCommand);
                    break;

                case MicroServices.CommandType.Delete:
                    TranslateExternalDeleteCommandToAkkaMessage(externalCommand);
                    break;

                case MicroServices.CommandType.Undelete:
                    TranslateExternalUnDeleteCommandToAkkaMessage(externalCommand);
                    break;
                }
            }
            else
            {
                Logger.Debug($"HTTP Client Bridge received unknown string command value'{externalCommand.CommandType}'.");
                HTTPExternalInterface.HandleFailedStateMessage(new HTTPDestinedCommandStateEvent(MicroServices.ProcessingStatus.Failed, $"Unknown command:{externalCommand.CommandType}", externalCommand), true);
            }
            return(ableToParseCommand);
        }
Exemple #4
0
        public bool TranslateAkkaFailedInsertEventToExternalMessage(CommandEventMessage internalCommandEvent)
        {
            UserFailedInsertEvent e = internalCommandEvent as UserFailedInsertEvent;

            HTTPExternalInterface.HandleFailedStateMessage(
                new HTTPDestinedCommandStateEvent(
                    MicroServices.ProcessingStatus.Failed,
                    e.Message,
                    new HTTPSourcedCommand(
                        e.CommandType.ToString(),
                        e.Area.ToString(),
                        null,
                        e.OriginalUserState,
                        e.User,
                        e.ConnectionId,
                        e.Id
                        )
                    ),
                true //User only?
                );
            return(true);
        }