private void HandleUpdatedClientInformation(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 }; _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 async Task <int> OnExecuteAsync(CommandLineApplication app, IConsole console) { System.Threading.CancellationToken cancellationToken = console.GetCtrlCToken(); EndPoint endPoint; if (ProcessId is int pid) { ProcessRegistration reg = await ProcessLocator.GetRegistrationAsync(pid); endPoint = new IPEndPoint(IPAddress.Loopback, reg.DiagnosticsPort); } else { if (string.IsNullOrEmpty(Target)) { console.Error.WriteLine("Missing required option: --server"); return(1); } if (!EndPointParser.TryParseEndpoint(Target, out endPoint)) { console.Error.WriteLine($"Invalid server value: {Target}"); return(1); } } if (Providers.Count == 0) { console.Error.WriteLine("No providers were listed"); return(1); } var client = new DiagnosticsClient(endPoint); console.WriteLine("Connecting to application..."); client.OnEventWritten += (evt) => { var formattedMessage = string.Format(evt.Message, evt.Payload.ToArray()); console.WriteLine($"{evt.ProviderName}/{evt.EventName}({evt.EventId}): {formattedMessage}"); }; await client.ConnectAsync(); await client.EnableEventsAsync(Providers.Select(p => new EnableEventsRequest(p, EventLevel.Verbose, EventKeywords.All))); console.WriteLine("Connected, press Ctrl-C to terminate..."); await cancellationToken.WaitForCancellationAsync(); return(0); }
private void HandleNewClientRegistration(ApiInbox incomingMessage) { //save to inbox int Id = _apiInboxmanager.AddApiInbox(incomingMessage); incomingMessage.Id = Id; try { PatientRegistrationEntity entity = new JavaScriptSerializer().Deserialize <PatientRegistrationEntity>(incomingMessage.Message); Mapper.Initialize(cfg => { cfg.CreateMap <PatientRegistrationDTO, PatientRegistrationEntity>().ReverseMap(); cfg.CreateMap <DTO.CommonEntities.MESSAGEHEADER, MappingEntities.MESSAGEHEADER>().ReverseMap(); cfg.CreateMap <DTO.CommonEntities.PATIENTIDENTIFICATION, MappingEntities.PATIENTIDENTIFICATION>().ReverseMap(); cfg.CreateMap <DTO.CommonEntities.NEXTOFKIN, MappingEntities.NEXTOFKIN>().ReverseMap(); cfg.CreateMap <DTO.CommonEntities.VISIT, MappingEntities.VISIT>().ReverseMap(); cfg.CreateMap <DTO.CommonEntities.EXTERNALPATIENTID, MappingEntities.EXTERNALPATIENTID>().ReverseMap(); cfg.CreateMap <DTO.CommonEntities.INTERNALPATIENTID, MappingEntities.INTERNALPATIENTID>().ReverseMap(); cfg.CreateMap <DTO.CommonEntities.PATIENTNAME, MappingEntities.PATIENTNAME>().ReverseMap(); cfg.CreateMap <DTO.CommonEntities.PATIENTADDRESS, MappingEntities.PATIENTADDRESS>().ReverseMap(); cfg.CreateMap <DTO.CommonEntities.PHYSICAL_ADDRESS, MappingEntities.PHYSICALADDRESS>().ReverseMap(); cfg.CreateMap <DTO.CommonEntities.NOKNAME, MappingEntities.NOKNAME>().ReverseMap(); }); var register = Mapper.Map <PatientRegistrationDTO>(entity); var processRegistration = new ProcessRegistration(); processRegistration.Save(register); //update message set processed=1, erromsq=null incomingMessage.DateProcessed = DateTime.Now; incomingMessage.Processed = true; incomingMessage.IsSuccess = true; _apiInboxmanager.EditApiInbox(incomingMessage); } catch (Exception e) { //update message set processed=1, erromsq incomingMessage.LogMessage = e.Message; incomingMessage.Processed = true; incomingMessage.IsSuccess = false; _apiInboxmanager.EditApiInbox(incomingMessage); } }