Beispiel #1
0
        public static async Task StartAsync(int port)
        {
            IPAddress localAddr = await EndpointUtils.GetIPAsync();

            IExpiryProvider expiryProvider = new StorageExpiryProvider();
            IStorage        storage        = new InMemoryStorage(expiryProvider);

            IRequestProcessor requestProcessor = new RequestProcessor(storage);
            IProcessor        processor        = new SocketProcessor();
            IListener         server           = new Listener(localAddr, port, processor, requestProcessor);

            server.Start();

            var reset = new ManualResetEventSlim();

            Console.CancelKeyPress += (sender, e) =>
            {
                reset.Set();
            };

            reset.Wait();

            // dispose components
            storage.Dispose();
            server.Dispose();
        }
Beispiel #2
0
        private ChangedOpenApiBO Compare()
        {
            PreProcess(OldSpecOpenApi);
            PreProcess(NewSpecOpenApi);
            var paths =
                PathsDiff.Diff(PathsDiff.ValOrEmpty(OldSpecOpenApi.Paths), PathsDiff.ValOrEmpty(NewSpecOpenApi.Paths));

            NewEndpoints      = new List <EndpointBO>();
            MissingEndpoints  = new List <EndpointBO>();
            ChangedOperations = new List <ChangedOperationBO>();

            if (paths != null)
            {
                NewEndpoints     = EndpointUtils.ConvertToEndpointList <EndpointBO>(paths.Increased);
                MissingEndpoints = EndpointUtils.ConvertToEndpointList <EndpointBO>(paths.Missing);
                foreach (var(key, value) in paths.Changed)
                {
                    NewEndpoints.AddRange(EndpointUtils.ConvertToEndpoints <EndpointBO>(key, value.Increased));
                    MissingEndpoints.AddRange(EndpointUtils.ConvertToEndpoints <EndpointBO>(key, value.Missing));
                    ChangedOperations.AddRange(value.Changed);
                }
            }

            var diff = ExtensionsDiff
                       .Diff(OldSpecOpenApi.Extensions, NewSpecOpenApi.Extensions);

            if (diff != null)
            {
                ChangedExtensions = diff;
            }
            return(GetChangedOpenApi());
        }
Beispiel #3
0
 public void GetPatientToDosTest()
 {
     EndpointUtils utils = new EndpointUtils();
     var           todos = utils.GetPatientToDos("5325da35d6a4850adcbba58e", "1234",
                                                 new AppDomainRequest {
         Version = 1.0, ContractNumber = "InHealth001", UserId = "1234"
     });
 }
Beispiel #4
0
        public void GetScheduleToDoByIdTest()
        {
            EndpointUtils utils = new EndpointUtils();

            utils.GetScheduleToDoById("53ff6b92d4332314bcab46e0", "5325c821072ef705080d3488", new GetToDosRequest {
                Version = 1.0, ContractNumber = "InHealth001", UserId = "1234"
            });
        }
Beispiel #5
0
        public async Task GetIPAsync_ReturnsIpAddress(string hostName)
        {
            // Act
            IPAddress address = await EndpointUtils.GetIPAsync();

            // Assert
            Assert.NotNull(address);
            Assert.Equal(address.AddressFamily, AddressFamily.InterNetwork);
        }
            public void OnMessage(IMessage message, IModel channel)
            {
                var retryDisabled = _adapter.RetryTemplate == null;

                try
                {
                    if (retryDisabled)
                    {
                        CreateAndSend(message, channel);
                    }
                    else
                    {
                        var toSend = CreateMessage(message, channel);
                        _adapter.RetryTemplate.Execute(
                            context =>
                        {
                            try
                            {
                                _logger?.LogTrace($"RabbitInboundChannelAdapter::OnMessage Context: {context}");
                                var deliveryAttempts = message.Headers.Get <AtomicInteger>(IntegrationMessageHeaderAccessor.DELIVERY_ATTEMPT);
                                deliveryAttempts?.IncrementAndGet();
                                _adapter.SetAttributesIfNecessary(message, toSend);
                                _adapter.SendMessage(message);
                            }
                            catch (Exception ex)
                            {
                                _logger?.LogError(ex, ex.Message, context);
                                throw;
                            }
                        }, _adapter.RecoveryCallback);
                    }
                }
                catch (MessageConversionException e)
                {
                    if (_adapter.ErrorChannel != null)
                    {
                        _adapter.SetAttributesIfNecessary(message, null);
                        var errorMessage = _adapter.BuildErrorMessage(null, EndpointUtils.CreateErrorMessagePayload(message, channel, IsManualAck, e));
                        _adapter.MessagingTemplate.Send(_adapter.ErrorChannel, errorMessage);
                    }
                    else
                    {
                        throw;
                    }
                }
                finally
                {
                    if (retryDisabled)
                    {
                        _attributesHolder.Value = null;
                    }
                }
            }
Beispiel #7
0
        private IPEndPoint CreateIpEndPoint()
        {
            IPAddress address;

            if (!string.IsNullOrEmpty(Domain))
            {
                address = EndpointUtils.GetIpAsync(Domain).Result;
                Ip      = address.ToString();
            }
            else
            {
                address = IPAddress.Parse(Ip);
            }

            return(new IPEndPoint(address, Port));
        }
Beispiel #8
0
        public void GetGoalByIdTest()
        {
            Mapper.CreateMap <GoalData, Goal>()
            .ForMember(d => d.CustomAttributes,
                       opt => opt.MapFrom(src => src.CustomAttributes.ConvertAll(
                                              c => new CustomAttribute {
                Id = c.Id, Values = c.Values
            })));

            EndpointUtils utils = new EndpointUtils();
            var           goal  = utils.GetGoalById("545a91a1fe7a59218cef2d6d", "5325c821072ef705080d3488",
                                                    new GetToDosRequest {
                Version = 1.0, ContractNumber = "InHealth001", UserId = "1234"
            });

            Assert.IsNotNull(goal);
        }
Beispiel #9
0
        public void GetPatientGoalByTemplateId_Null()
        {
            #region
            Mapper.CreateMap <PatientGoalData, PatientGoal>()
            .ForMember(d => d.CustomAttributes,
                       opt => opt.MapFrom(src => src.CustomAttributes.ConvertAll(
                                              c => new CustomAttribute {
                Id = c.Id, Values = c.Values
            })))
            .ForMember(d => d.Barriers,
                       opt => opt.MapFrom(src => src.BarriersData.ConvertAll(
                                              c =>
                                              new PatientBarrier
            {
                Id            = c.Id,
                CategoryId    = c.CategoryId,
                DeleteFlag    = c.DeleteFlag,
                Name          = c.Name,
                PatientGoalId = c.PatientGoalId,
                StatusDate    = c.StatusDate,
                StatusId      = c.StatusId,
                Details       = c.Details
            })))
            .ForMember(d => d.Tasks,
                       opt => opt.MapFrom(src => src.TasksData.ConvertAll(
                                              c =>
                                              new PatientTask
            {
                Id               = c.Id,
                BarrierIds       = c.BarrierIds,
                ClosedDate       = c.ClosedDate,
                CreatedById      = c.CreatedById,
                CustomAttributes =
                    c.CustomAttributes.ConvertAll(
                        ca =>
                        new CustomAttribute
                {
                    ControlType = ca.ControlType,
                    Id          = ca.Id,
                    Name        = ca.Name,
                    Order       = ca.Order,
                    Required    = ca.Required,
                    Type        = ca.Type,
                    Values      = ca.Values,
                    Options     = NGUtils.FormatOptions(ca.Options)
                }),
                DeleteFlag    = c.DeleteFlag,
                Description   = c.Description,
                GoalName      = c.GoalName,
                PatientGoalId = c.PatientGoalId,
                StartDate     = c.StartDate,
                StatusDate    = c.StatusDate,
                StatusId      = c.StatusId,
                TargetDate    = c.TargetDate,
                TargetValue   = c.TargetValue,
                Details       = c.Details
            })))
            .ForMember(d => d.Interventions,
                       opt => opt.MapFrom(src => src.InterventionsData.ConvertAll(
                                              c =>
                                              new PatientIntervention
            {
                AssignedToId  = c.AssignedToId,
                BarrierIds    = c.BarrierIds,
                CategoryId    = c.CategoryId,
                ClosedDate    = c.ClosedDate,
                CreatedById   = c.CreatedById,
                DeleteFlag    = c.DeleteFlag,
                Description   = c.Description,
                GoalName      = c.GoalName,
                Id            = c.Id,
                PatientGoalId = c.PatientGoalId,
                PatientId     = c.PatientId,
                StartDate     = c.StartDate,
                DueDate       = c.DueDate,
                StatusDate    = c.StatusDate,
                StatusId      = c.StatusId,
                Details       = c.Details
            })));
            #endregion

            EndpointUtils utils       = new EndpointUtils();
            var           patientGoal = utils.GetOpenNotMetPatientGoalByTemplateId("123491a1fe7a59218cef2d6d", "5325db9cd6a4850adcbba9ca", "1234",
                                                                                   new AppDomainRequest {
                Version = 1.0, ContractNumber = "InHealth001", UserId = "1234"
            });

            Assert.IsNull(patientGoal);
        }