Exemplo n.º 1
0
        private void LoadFullHeader()
        {
            if (_fullHeader != null)
            {
                return;                 //We've already got it without the pixel data.
            }
            var args = new LoadDicomFileArgs(this.StudyInstanceUid, this.SeriesInstanceUid, this.SopInstanceUid, true, false);

            _fullHeader = _dicomFileLoader.LoadDicomFile(args);
            _metaInfo   = null;
        }
        private DicomFile TryClientRetrieveImageHeader(out Exception lastRetrieveException)
        {
            // retry parameters
            const int retryTimeout = 1500;
            int       retryDelay   = 50;
            int       retryCounter = 0;

            CodeClock timeoutClock = new CodeClock();

            timeoutClock.Start();

            lastRetrieveException = null;

            while (true)
            {
                try
                {
                    if (retryCounter > 0)
                    {
                        Platform.Log(LogLevel.Info, "Retrying retrieve headers for Sop '{0}' (Attempt #{1})", this.SopInstanceUid, retryCounter);
                    }

                    return(_loader.LoadDicomFile(new LoadDicomFileArgs(this.StudyInstanceUid, this.SeriesInstanceUid, this.SopInstanceUid, true, false)));
                }
                catch (Exception ex)
                {
                    lastRetrieveException = ex;

                    timeoutClock.Stop();
                    if (timeoutClock.Seconds * 1000 >= retryTimeout)
                    {
                        // log an alert that we are aborting (exception trace at debug level only)
                        int elapsed = (int)(1000 * timeoutClock.Seconds);
                        Platform.Log(LogLevel.Warn, "Failed to retrieve headers for Sop '{0}'; Aborting after {1} attempts in {2} ms", this.SopInstanceUid, retryCounter, elapsed);
                        Platform.Log(LogLevel.Debug, ex, "[GetHeaders Fail-Abort] Sop: {0}, Retry Attempts: {1}, Elapsed: {2} ms", this.SopInstanceUid, retryCounter, elapsed);
                        break;
                    }
                    timeoutClock.Start();

                    retryCounter++;

                    // log the retry (exception trace at debug level only)
                    Platform.Log(LogLevel.Warn, "Failed to retrieve headers for Sop '{0}'; Retrying in {1} ms", this.SopInstanceUid, retryDelay);
                    Platform.Log(LogLevel.Debug, ex, "[GetHeaders Fail-Retry] Sop: {0}, Retry in: {1} ms", this.SopInstanceUid, retryDelay);

                    MemoryManager.Collect(retryDelay);
                    retryDelay *= 2;
                }
            }

            return(null);
        }
 private ISopDicomFileLoader ConvertLoader(IDicomFileLoader loader)
 {
     return(new SopDicomFileLoader(loader.CanLoadCompleteHeader, loader.CanLoadPixelData, loader.CanLoadFramePixelData,
                                   args => loader.LoadDicomFile(new LoadDicomFileArgs(StudyInstanceUid, SeriesInstanceUid, SopInstanceUid, args.ForceCompleteHeader, args.IncludePixelData)),
                                   args => loader.LoadFramePixelData(new LoadFramePixelDataArgs(StudyInstanceUid, SeriesInstanceUid, SopInstanceUid, args.FrameNumber))));
 }
		private ISopDicomFileLoader ConvertLoader(IDicomFileLoader loader)
		{
			return new SopDicomFileLoader(loader.CanLoadCompleteHeader, loader.CanLoadPixelData, loader.CanLoadFramePixelData,
				args => loader.LoadDicomFile(new LoadDicomFileArgs(StudyInstanceUid, SeriesInstanceUid, SopInstanceUid, args.ForceCompleteHeader, args.IncludePixelData)),
				args => loader.LoadFramePixelData(new LoadFramePixelDataArgs(StudyInstanceUid, SeriesInstanceUid, SopInstanceUid, args.FrameNumber)));
		}