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); } }
public Task<GetTypeQueryResponseDto> Handle(GetTypeQuery request, CancellationToken cancellationToken) { CommunicationType type = _service.GetCommunicationType(); return Task.FromResult(new GetTypeQueryResponseDto { Type = (int)type, Name = type.ToString() }); }
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)); } }
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)); }