public DicomFile LoadDicomFile(LoadDicomFileArgs args)
		{
			try
			{
				var client = new StreamingClient(_wadoUri);
				var file = new DicomFile();
				using (var stream = client.RetrieveImageHeader(_aeTitle, args.StudyInstanceUid, args.SeriesInstanceUid, args.SopInstanceUid))
				{
					file.Load(stream);
				}

				return file;
			}
			catch (Exception e)
			{
				throw TranslateStreamingException(e);
			}
		}
		public DicomFile LoadDicomFile(LoadDicomFileArgs args)
		{
			try
			{
				Uri uri = new Uri(string.Format(StreamingSettings.Default.FormatWadoUriPrefix, _hostName, _wadoServicePort));
				var client = new StreamingClient(uri);
				var file = new DicomFile();
				using (var stream = client.RetrieveImageHeader(_aeTitle, args.StudyInstanceUid, args.SeriesInstanceUid, args.SopInstanceUid))
				{
					file.Load(stream);
				}

				return file;
			}
			catch (Exception e)
			{
				throw TranslateStreamingException(e);
			}
		}
Пример #3
0
		private DicomFile TryClientRetrieveImageHeader(out Exception lastRetrieveException)
		{
			// retry parameters
			const int retryTimeout = 1500;
			int retryDelay = 50;
			int retryCounter = 0;

			Uri uri = new Uri(string.Format(StreamingSettings.Default.FormatWadoUriPrefix, _host, _wadoServicePort));
			StreamingClient client = new StreamingClient(uri);
			DicomFile result = null;
			lastRetrieveException = null;

			CodeClock timeoutClock = new CodeClock();
			timeoutClock.Start();

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

					using (Stream imageHeaderStream = client.RetrieveImageHeader(_aeTitle, this.StudyInstanceUid, this.SeriesInstanceUid, this.SopInstanceUid))
					{
						DicomFile imageHeader = new DicomFile();
						imageHeader.Load(imageHeaderStream);
						result = imageHeader;
					}

					break;
				}
				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 result;
		}