public WADOResponse Process(WADORequestTypeHandlerContext context) { //Validate(context.HttpContext.Request); ObjectStreamingHandlerFactory factory = new ObjectStreamingHandlerFactory(); IObjectStreamingHandler handler = factory.CreateHandler(context.HttpContext.Request); return handler.Process(context); }
public WADOResponse Process(WADORequestTypeHandlerContext context) { Platform.CheckForNullReference(context, "httpContext"); Platform.CheckForNullReference(context.ServerAE, "context.ServerAE"); Platform.CheckForNullReference(context.HttpContext, "context.HttpContext"); // Cache the query string for performance purpose. Every time Request.QueryString is called, .NET will rebuild the entire dictionary. NameValueCollection query = context.HttpContext.Request.QueryString; ServerPartition partition = ServerPartitionMonitor.Instance.GetPartition(context.ServerAE); if (partition == null) { throw new WADOException(HttpStatusCode.NotFound, String.Format(SR.FaultPartitionNotExists, context.ServerAE)); } if (!partition.Enabled) { throw new WADOException(HttpStatusCode.Forbidden, String.Format(SR.FaultPartitionDisabled, context.ServerAE)); } ImageStreamingContext streamingContext = new ImageStreamingContext(context.HttpContext); streamingContext.ServerAE = context.ServerAE; streamingContext.ContentType = query["ContentType"]; streamingContext.AcceptTypes = context.HttpContext.Request.AcceptTypes; streamingContext.StudyInstanceUid = query["studyuid"]; streamingContext.SeriesInstanceUid = query["seriesuid"]; streamingContext.ObjectUid = query["objectuid"]; string sessionId = context.HttpContext.Request.RemoteEndPoint.Address.ToString(); StudyStorageLoader storageLoader = new StudyStorageLoader(sessionId); storageLoader.CacheEnabled = ImageStreamingServerSettings.Default.EnableCache; storageLoader.CacheRetentionTime = ImageStreamingServerSettings.Default.CacheRetentionWindow; streamingContext.StorageLocation = storageLoader.Find(streamingContext.StudyInstanceUid, partition); // convert the dicom image into the appropriate mime type WADOResponse response = new WADOResponse(); IImageMimeTypeProcessor processor = GetMimeTypeProcessor(streamingContext); MimeTypeProcessorOutput output = processor.Process(streamingContext); response.Output = output.Output; response.ContentType = output.ContentType; response.IsLast = output.IsLast; return(response); }
public WADOResponse Process(WADORequestTypeHandlerContext context) { Platform.CheckForNullReference(context, "httpContext"); Platform.CheckForNullReference(context.ServerAE, "context.ServerAE"); Platform.CheckForNullReference(context.HttpContext, "context.HttpContext"); // Cache the query string for performance purpose. Every time Request.QueryString is called, .NET will rebuild the entire dictionary. NameValueCollection query = context.HttpContext.Request.QueryString; ServerPartition partition = ServerPartitionMonitor.Instance.GetPartition(context.ServerAE); if (partition== null) throw new WADOException(HttpStatusCode.NotFound, String.Format(SR.FaultPartitionNotExists, context.ServerAE)); if (!partition.Enabled) throw new WADOException(HttpStatusCode.Forbidden, String.Format(SR.FaultPartitionDisabled, context.ServerAE)); ImageStreamingContext streamingContext = new ImageStreamingContext(context.HttpContext); streamingContext.ServerAE = context.ServerAE; streamingContext.ContentType = query["ContentType"]; streamingContext.AcceptTypes = context.HttpContext.Request.AcceptTypes; streamingContext.StudyInstanceUid = query["studyuid"]; streamingContext.SeriesInstanceUid = query["seriesuid"]; streamingContext.ObjectUid = query["objectuid"]; string sessionId = context.HttpContext.Request.RemoteEndPoint.Address.ToString(); StudyStorageLoader storageLoader = new StudyStorageLoader(sessionId); storageLoader.CacheEnabled = ImageStreamingServerSettings.Default.EnableCache; storageLoader.CacheRetentionTime = ImageStreamingServerSettings.Default.CacheRetentionWindow; streamingContext.StorageLocation = storageLoader.Find(streamingContext.StudyInstanceUid, partition); // convert the dicom image into the appropriate mime type WADOResponse response = new WADOResponse(); IImageMimeTypeProcessor processor = GetMimeTypeProcessor(streamingContext); MimeTypeProcessorOutput output = processor.Process(streamingContext); response.Output = output.Output; response.ContentType = output.ContentType; response.IsLast = output.IsLast; return response; }
private static void HandleRequest(HttpListenerContext context) { WADORequestProcessorStatistics statistics = new WADORequestProcessorStatistics("Image Streaming"); statistics.TotalProcessTime.Start(); LogRequest(context); try { using (WADORequestTypeHandlerManager handlerManager = new WADORequestTypeHandlerManager()) { string requestType = context.Request.QueryString["requestType"]; IWADORequestTypeHandler typeHandler = handlerManager.GetHandler(requestType); WADORequestTypeHandlerContext ctx = new WADORequestTypeHandlerContext { HttpContext = context, ServerAE = UriHelper.GetServerAE(context) }; using (WADOResponse response = typeHandler.Process(ctx)) { if (response != null) { statistics.TransmissionSpeed.Start(); SendWADOResponse(response, context); statistics.TransmissionSpeed.End(); if (response.Output != null) { statistics.TransmissionSpeed.SetData(response.Output.Length); } } } } } catch(MimeTypeProcessorError error) { SendError(error.HttpError, context); } statistics.TotalProcessTime.End(); StatisticsLogger.Log(LogLevel.Debug, statistics); }
private static void HandleRequest(HttpListenerContext context) { WADORequestProcessorStatistics statistics; if (Platform.IsLogLevelEnabled(LogLevel.Debug)) { statistics = new WADORequestProcessorStatistics("Image Streaming"); statistics.TotalProcessTime.Start(); //Don't hold up this thread for logging. Task.Factory.StartNew(() => LogRequest(context)); } else { statistics = null; } try { using (WADORequestTypeHandlerManager handlerManager = new WADORequestTypeHandlerManager()) { string requestType = context.Request.QueryString["requestType"]; IWADORequestTypeHandler typeHandler = handlerManager.GetHandler(requestType); WADORequestTypeHandlerContext ctx = new WADORequestTypeHandlerContext { HttpContext = context, ServerAE = UriHelper.GetServerAE(context) }; using (WADOResponse response = typeHandler.Process(ctx)) { if (response != null) { if (statistics != null) statistics.TransmissionSpeed.Start(); SendWADOResponse(response, context); if (statistics != null) statistics.TransmissionSpeed.End(); if (statistics != null && response.Output != null) statistics.TransmissionSpeed.SetData(response.Output.Length); } } } } catch(MimeTypeProcessorError error) { SendError(error.HttpError, context); } if (statistics != null) statistics.TotalProcessTime.End(); //Seems like something you'd only want to log if there was a problem. if (Platform.IsLogLevelEnabled(LogLevel.Debug)) { //Don't hold up this thread for logging. Task.Factory.StartNew(() => StatisticsLogger.Log(LogLevel.Debug, statistics)); } }