예제 #1
0
        public async Task <string> GetNumberDetailsAsync(string requestBody)
        {
            ValidateHostUrls();
            Response responseResult;

            try
            {
                IncomingCall call = ParseCallParameters(requestBody);
                if (call == null)
                {
                    _logger.LogWarning($"Returning Twilio Disconnect Call response. Incoming call is null.");
                    responseResult = CallResponseService.DisconnectCallResponse();
                }
                else
                {
                    responseResult = await ProcessNumberRoutingAsync(call);
                }

                var resultJson = JsonConvert.SerializeObject(responseResult);
                _logger.LogInformation($"GetNumberDetailsAsync Success");
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"GetNumberDetailsAsync Exception. Details: {ex.Message}");
                responseResult = CallResponseService.DisconnectCallResponse();
            }

            _logger.LogDebug($"{JsonConvert.SerializeObject(responseResult)}");

            var result = TwilioXmlSerializer.XmlSerialize(responseResult);

            _logger.LogInformation($"GetNumberRouteAsync response: {result}");

            return(result);
        }
예제 #2
0
        // POST: api/MessageResponse
        public void Post([FromBody] TwillioMessageResponse message)
        {
            var logger = LogManager.GetLogger("MessageResponseController");

            try
            {
                logger.Info("getting reply from " + message.From);
                var twilioSerializer = new TwilioXmlSerializer();
                var filePath         = Path.Combine(TwilioSettings.TwilioFilePath, DateTime.Now.Ticks + ".xml");
                twilioSerializer.SerializeandSave(filePath, message);
            }
            catch (Exception exception)
            {
                logger.Error("some error occurred");
                logger.Error("Message: " + exception.Message);
                logger.Error("Stack Trace: " + exception.StackTrace);
            }
        }