예제 #1
0
        internal override async Task GetSeriesImageImpAsync(GetSeriesImageRequest request, CancellationToken ct)
        {
            var createImage = new ActionBlock <Series>(async ser =>
            {
                var fsSeries = ser as FileSysSeriesImp;
                if (fsSeries == null)
                {
                    _logger.Warning("{service} got unexpected type of series object {@Series}", GetType(), ser);
                    return;
                }

                var image = await CreateFromSeriesDirAsync(fsSeries.SeriesDir, (dicomFile) => { return(dicomFile.CreateImage()); });
                if (image != null)
                {
                    if (ser.Orientation == FDCSeriesOrientation.eFDC_NO_ORIENTATION &&
                        image.Orientation != FDCSeriesOrientation.eFDC_NO_ORIENTATION)
                    {
                        ser.Orientation = image.Orientation;
                    }

                    request.RaiseImageGot(image);
                }
            }, new ExecutionDataflowBlockOptions {
                CancellationToken = ct, MaxDegreeOfParallelism = 1
            });


            foreach (var ser in request.Series)
            {
                await createImage.SendAsync(ser, ct);
            }

            createImage.Complete();
            await createImage.Completion;
        }
예제 #2
0
        public async Task LoadSeriesImages(ISearchService searchService, CancellationToken ct)
        {
            if (ct.IsCancellationRequested)
            {
                return;
            }

            var request = new GetSeriesImageRequest {
                Series = Series.Select(s => s.Series)
            };

            request.ImageGot += (s, e) =>
            {
                if (ct.IsCancellationRequested)
                {
                    return;
                }

                var series = Series.FirstOrDefault(ser => ser.SeriesInstanceUid == e.SeriesInstanceUid);
                if (series == null)
                {
                    return;
                }

                _dispatcher.InvokeAsync(() =>
                {
                    series.SetImage(e);
                });
            };

            await searchService.GetSeriesImageAsync(request, ct).ConfigureAwait(false);
        }
예제 #3
0
        public async Task GetSeriesImageAsync(GetSeriesImageRequest request, CancellationToken ct)
        {
            foreach (var series in request.Series)
            {
                Validator.ValidateObject(series, new ValidationContext(series), true);
            }

            await GetSeriesImageImpAsync(request, ct);
        }
예제 #4
0
        internal override async Task GetSeriesImageImpAsync(GetSeriesImageRequest request, CancellationToken ct)
        {
            await _getSeriesImageSemaphore.WaitAsync(ct);

            try
            {
                if (ct.IsCancellationRequested)
                {
                    return;
                }

                await DicomSeriesImageService.GetSeriesImageAsync(request, _settings, ct);
            }
            finally
            {
                _getSeriesImageSemaphore.Release();
            }
        }
예제 #5
0
 public static async Task GetSeriesImageAsync(GetSeriesImageRequest request, DicomSearchServiceSettings settings, CancellationToken ct)
 {
     var service = new DicomSeriesImageService(request.RaiseImageGot, settings, ct);
     await service.Go(request.Series, ct);
 }
예제 #6
0
 internal abstract Task GetSeriesImageImpAsync(GetSeriesImageRequest request, CancellationToken ct);