public ProviderQueryPortTypeClient Build(WcfConfiguration configuration = null)
        {
            var client = new ProviderQueryPortTypeClient();

            client.Endpoint.Address = new EndpointAddress(Endpoint);
            return(client);
        }
        public List <ProviderRecordStructure> GetAllProviders(List <string> ukprnList)
        {
            string[] statusesToFetch =
            {
                "A",     // Active
                //"V", // Verified. Omitted, we suspect this may be a subset of Active providers
                //"PD1", // Deactivation in process
                //"PD2" // Deactivation complete
            };

            List <ProviderRecordStructure> results = new List <ProviderRecordStructure>();

            int chunkSize  = 300;
            var noOfChunks = Math.Ceiling((double)ukprnList.Count / chunkSize);

            // Get UKRLP data in chunks at a time as API does not support large requests.
            for (int i = 0; i < noOfChunks; i++)
            {
                foreach (String status in statusesToFetch)
                {
                    var request = BuildRequest(ukprnList.Skip(i * chunkSize).Take(chunkSize).ToArray());
                    request.SelectionCriteria.ProviderStatus = status;
                    request.QueryId = GetNextQueryId();

                    var providerClient = new ProviderQueryPortTypeClient();
                    providerClient.InnerChannel.OperationTimeout = new TimeSpan(0, 10, 0);
                    Task <response> x = providerClient.retrieveAllProvidersAsync(request);
                    x.Wait();

                    results.AddRange(x.Result?.ProviderQueryResponse?.MatchingProviderRecords ?? new ProviderRecordStructure[] { });
                }
            }

            return(results.ToList());
        }
示例#3
0
        public ProviderQueryPortTypeClient Build(WcfConfiguration configuration = null)
        {
            var client = new ProviderQueryPortTypeClient();

            Configure(configuration, client);
            return(client);
        }
        public List <ProviderRecordStructure> SynchroniseProviders(DateTime dtLastUpdate, ILogger log)
        {
            string[] statusesToFetch =
            {
                "A",     // Active
                //"V", // Verified                      // Omitted, we suspect this may be a subset of Active providers
                "PD1",   // Deactivation in process
                "PD2"    // Deactivation complete
            };

            List <ProviderRecordStructure> results = new List <ProviderRecordStructure>();
            var request = Request(dtLastUpdate);

            foreach (String status in statusesToFetch)
            {
                log.LogInformation($"Downloading providers from UKRLP service with status {status}");

                request.SelectionCriteria.ProviderStatus = status;
                request.QueryId = GetNextQueryId();

                var pqp = new ProviderQueryParam {
                    ProviderQueryRequest = request
                };
                var             retrieveall = new ProviderQueryPortTypeClient();
                Task <response> x           = retrieveall.retrieveAllProvidersAsync(request);
                x.Wait();

                log.LogInformation($"UKRLP service returned {x.Result?.ProviderQueryResponse?.MatchingProviderRecords?.LongLength ?? 0} providers with status {status}");
                results.AddRange(x.Result?.ProviderQueryResponse?.MatchingProviderRecords ?? new ProviderRecordStructure[] { });
            }
            return(results);
        }
        private static void Configure(WcfConfiguration configuration, ProviderQueryPortTypeClient client)
        {
            if (configuration == null)
            {
                return;
            }

            client.ChannelFactory.Endpoint.Binding.SendTimeout    = configuration.SendTimeout;
            client.ChannelFactory.Endpoint.Binding.ReceiveTimeout = configuration.ReceiveTimeout;
        }
        private static void RegisterApiClient(IServiceCollection services)
        {
            services.AddHttpClient <IGoogleMapApiClient, GoogleMapApiClient>();
            services.AddHttpClient <ILocationApiClient, LocationApiClient>();
            services.AddHttpClient <ICalendarApiClient, CalendarApiClient>();

            services.AddTransient <IProviderQueryPortTypeClient>(svcProvider =>
            {
                var client = new ProviderQueryPortTypeClient();

                var fiveMinuteTimeSpan = new TimeSpan(0, 5, 0);

                client.Endpoint.Binding.SendTimeout    = fiveMinuteTimeSpan;
                client.Endpoint.Binding.ReceiveTimeout = fiveMinuteTimeSpan;

                return(client);
            });

            services.AddTransient <IProviderReferenceDataClient, ProviderReferenceDataClient>();
        }