コード例 #1
0
        /// <summary>
        /// Validates the license key using the InnerEye segmentation client.
        /// </summary>
        /// <param name="gatewayProcessorConfigProvider">Gateway processor config provider.</param>
        /// <param name="licenseKey">The license key to validate.</param>
        /// <param name="inferenceUri">Inference Uri to validate.</param>
        /// <returns>If valid and text to display with the validation result.</returns>
        internal static async Task <(bool Result, string ValidationText)> ValidateLicenseKeyAsync(GatewayProcessorConfigProvider gatewayProcessorConfigProvider, string licenseKey, Uri inferenceUri)
        {
            var validationText       = string.Empty;
            var processorSettings    = gatewayProcessorConfigProvider.ProcessorSettings();
            var existingInferenceUri = processorSettings.InferenceUri;
            var existingLicenseKey   = processorSettings.LicenseKey;

            try
            {
                // Update the settings for the Gateway.
                gatewayProcessorConfigProvider.SetProcessorSettings(inferenceUri, licenseKey);

                using (var segmentationClient = gatewayProcessorConfigProvider.CreateInnerEyeSegmentationClient()())
                {
                    await segmentationClient.PingAsync();
                }

                return(true, validationText);
            }
            catch (AuthenticationException)
            {
                validationText = "Invalid product key";
            }
            catch (Exception)
            {
                validationText = "Unable to connect to inference service uri";
            }

            // Restore the previous config
            gatewayProcessorConfigProvider.SetProcessorSettings(existingInferenceUri, existingLicenseKey);

            return(false, validationText);
        }
コード例 #2
0
 protected IEnumerable <DicomTagAnonymisation> SegmentationAnonymisationProtocol()
 {
     using (var segmentationClient = TestGatewayProcessorConfigProvider.CreateInnerEyeSegmentationClient().Invoke())
     {
         return(segmentationClient.SegmentationAnonymisationProtocol);
     }
 }
コード例 #3
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        public static void Main()
        {
            // Create the loggerFactory as Console + Log4Net.
            using (var loggerFactory = LoggerFactory.Create(builder =>
            {
                builder.AddConsole();
                builder.SetMinimumLevel(LogLevel.Trace);
                builder.AddLog4Net();
            }))
            {
                var relativePaths = new[] {
                    "../Config",
                    "../../../../../SampleConfigurations"
                };

                var configurationsPathRoot = ConfigurationService.FindRelativeDirectory(relativePaths, loggerFactory.CreateLogger("Main"));

                using (var aetConfigurationProvider = new AETConfigProvider(
                           loggerFactory.CreateLogger("ModelSettings"),
                           configurationsPathRoot))
                    using (var gatewayProcessorConfigProvider = new GatewayProcessorConfigProvider(
                               loggerFactory.CreateLogger("ProcessorSettings"),
                               configurationsPathRoot))
                    {
                        var segmentationClientLogger = loggerFactory.CreateLogger("SegmentationClient");

                        // The ProjectInstaller.cs uses the service name to install the service.
                        // If you change it please update the ProjectInstaller.cs
                        ServiceHelpers.RunServices(
                            ServiceName,
                            gatewayProcessorConfigProvider.ServiceSettings(),
                            new ConfigurationService(
                                gatewayProcessorConfigProvider.CreateInnerEyeSegmentationClient(segmentationClientLogger),
                                gatewayProcessorConfigProvider.ConfigurationServiceConfig,
                                loggerFactory.CreateLogger("ConfigurationService"),
                                new UploadService(
                                    gatewayProcessorConfigProvider.CreateInnerEyeSegmentationClient(segmentationClientLogger),
                                    aetConfigurationProvider.AETConfigModels,
                                    GatewayMessageQueue.UploadQueuePath,
                                    GatewayMessageQueue.DownloadQueuePath,
                                    GatewayMessageQueue.DeleteQueuePath,
                                    gatewayProcessorConfigProvider.DequeueServiceConfig,
                                    loggerFactory.CreateLogger("UploadService"),
                                    instances: 2),
                                new DownloadService(
                                    gatewayProcessorConfigProvider.CreateInnerEyeSegmentationClient(segmentationClientLogger),
                                    GatewayMessageQueue.DownloadQueuePath,
                                    GatewayMessageQueue.PushQueuePath,
                                    GatewayMessageQueue.DeleteQueuePath,
                                    gatewayProcessorConfigProvider.DownloadServiceConfig,
                                    gatewayProcessorConfigProvider.DequeueServiceConfig,
                                    loggerFactory.CreateLogger("DownloadService"),
                                    instances: 1),
                                new PushService(
                                    aetConfigurationProvider.AETConfigModels,
                                    new DicomDataSender(),
                                    GatewayMessageQueue.PushQueuePath,
                                    GatewayMessageQueue.DeleteQueuePath,
                                    gatewayProcessorConfigProvider.DequeueServiceConfig,
                                    loggerFactory.CreateLogger("PushService"),
                                    instances: 1),
                                new DeleteService(
                                    GatewayMessageQueue.DeleteQueuePath,
                                    gatewayProcessorConfigProvider.DequeueServiceConfig,
                                    loggerFactory.CreateLogger("DeleteService"))));
                    }
            }
        }