示例#1
0
        public async Task Check()
        {
            try
            {
                _logger.LogInfo($"Started fetching communication type: {_time.Now}");

                if (!await _internet.CheckForInternetConnectionAsync() || _session.SessionInformation.Offline)
                {
                    _logger.LogInfo($"Can connect to commuincation point: {_time.Now}");
                    return;
                }

                CommunicationType type = await _communication.GetCommunicationType();

                if (type != _communicationTypeService.GetCommunicationType())
                {
                    CommunicationType old = _communicationTypeService.GetCommunicationType();
                    _communicationTypeService.SetCommuncationType(type);
                    _notification.ShowStatusMessage(nameof(CommunicationTypeCheckBehaviour), $"Communication type changed from {old} to {type}");
                }

                _logger.LogInfo($"Finished fetching communication type: {_time.Now} | type is {type}");
            }
            catch (Exception e)
            {
                _logger.LogError(e);
            }
        }
示例#2
0
        public Task<GetTypeQueryResponseDto> Handle(GetTypeQuery request, CancellationToken cancellationToken)
        {
            CommunicationType type = _service.GetCommunicationType();

            return Task.FromResult(new GetTypeQueryResponseDto
            {
                Type = (int)type,
                Name = type.ToString()
            });
        }
示例#3
0
        public ISyncClient GetClient()
        {
            CommunicationType currentType = _typeService.GetCommunicationType();

            switch (currentType)
            {
            case CommunicationType.REST:
                return(new RestSyncClient(_clientFactory.CreateClient(), _options, _tokenService));

            case CommunicationType.SOCKET:
                return(new SignalRClient(_options, _tokenService));

            case CommunicationType.SOAP:
                return(new SoapClient(_tokenService));

            default:
                return(new RestSyncClient(_clientFactory.CreateClient(), _options, _tokenService));
            }
        }
示例#4
0
        public Task <GetAllQueryResponseDto> Handle(GetAllQuery request, CancellationToken cancellationToken)
        {
            var currentCommunication       = _service.GetCommunicationType();
            var possibleCommunicationTypes = new List <CommunicationInstanceType>();

            foreach (CommunicationType enumValue in Enum.GetValues(typeof(CommunicationType)))
            {
                possibleCommunicationTypes.Add(new CommunicationInstanceType
                {
                    Name     = enumValue.ToString(),
                    IsActive = enumValue == currentCommunication,
                    Type     = (int)enumValue
                });
            }

            var dto = new GetAllQueryResponseDto
            {
                Types = possibleCommunicationTypes
            };

            return(Task.FromResult(dto));
        }