public void GenerateMpr(MprGenerationRequestV1 request)
        {
            var responseContext =
                OperationContext.Current.IncomingMessageHeaders.GetHeader<ResponseContext>(
                    "ResponseContext", "ServiceModelEx");
            System.Diagnostics.Trace.Assert(responseContext.MethodId.CompareTo(Guid.Empty.ToString()) != 0);

            LocalImageResourceManagerClient lirm =
                new LocalImageResourceManagerClient();
            lirm.Open();

            UniformImageVolumeDataContract ivdc = null;
            ivdc = lirm.GetImageVolume(request.ImageVolumeId);

            int[] size = CalculateSize(ivdc, request.Orientation);

            ImageDataContract idc = null;
            _cacheResultImages.TryGetValue(responseContext.MethodId, out idc);
            if (idc == null
                || idc.Width != size[0]
                || idc.Height != size[1])
            {
                idc = new ImageDataContract();
                idc.Width = size[0];
                idc.Height = size[1];
                idc = lirm.AddImage(idc);
                _cacheResultImages.TryAdd(responseContext.MethodId, idc);
            }

            lirm.Close();

            UpdatePixelsFromVolumeResampled(ivdc,
                request.Orientation, request.SlicePosition,
                request.WindowCenter, request.WindowWidth,
                idc);

            MessageHeader<ResponseContext> responseHeader = new MessageHeader<ResponseContext>(responseContext);
            NetMsmqBinding binding = new NetMsmqBinding("NoMsmqSecurity");
            MprGenerationResponseProxy proxy = new MprGenerationResponseProxy(binding,
                new EndpointAddress(responseContext.ResponseAddress));

            using (OperationContextScope scope = new OperationContextScope(proxy.InnerChannel))
            {
                OperationContext.Current.OutgoingMessageHeaders.Add(
                    responseHeader.GetUntypedHeader("ResponseContext", "ServiceModelEx"));

                proxy.OnMprDone(idc, request.RequestTime);
            }

            proxy.Close();
        }
예제 #2
0
        /// <summary>
        /// queues the request to update the MPR
        /// </summary>
        void QueueRequest()
        {
            if (_ivdc == null)
                return;

            MprGenerationEngineServiceClient mges =
                new MprGenerationEngineServiceClient();
            MprGenerationRequestV1 request =
                new MprGenerationRequestV1();
            request.RequestTime = DateTime.Now;
            request.ImageVolumeId = _ivdc.Identity.Guid;
            request.SlicePosition = this.SlicePosition;
            request.Orientation = this.Orientation;
            request.WindowCenter = this.WindowCenter;
            request.WindowWidth = this.WindowWidth;

            OperationContextScope contextScope = new OperationContextScope(mges.InnerChannel);
            {
                Guid methodId = Guid.NewGuid();
                this._queueWaiting.TryAdd(methodId, request);

                ImageRenderManagerHelper.SetupResponseHeader(methodId);
                mges.GenerateMpr(request);
            }

            mges.Close();
        }