private void HandleNewClientRegistration(MessageEventArgs messageEvent) { try { var processRegistration = new ProcessRegistration(); var registrationDto = processRegistration.Get(messageEvent.PatientId); var registrationEntity = _jsonEntityMapper.PatientRegistration(registrationDto, messageEvent); string registrationJson = new JavaScriptSerializer().Serialize(registrationEntity); //save var apiOutbox = new ApiOutbox() { DateSent = DateTime.Now, Message = registrationJson, RecepientId = 1 }; _apiOutboxManager.AddApiOutbox(apiOutbox); //Send SendData(registrationJson, "").ConfigureAwait(false); } catch (Exception e) { string message = new JavaScriptSerializer().Serialize(messageEvent); //error var apiOutbox = new ApiOutbox() { DateSent = DateTime.Now, Message = message, LogMessage = e.Message + "\n" + e.StackTrace }; _apiOutboxManager.AddApiOutbox(apiOutbox); } }
public int AddApiOutbox(ApiOutbox apiOutbox) { ApiOutbox outbox = new ApiOutbox() { DateSent = apiOutbox.DateSent, RecepientId = apiOutbox.RecepientId, AttemptCount = 0, Message = apiOutbox.Message, LogMessage = apiOutbox.LogMessage }; return(_apiOutboxmanager.AddApiOutbox(outbox)); }