Ejemplo n.º 1
0
        private void CreateFilmSession()
        {
            DcmDataset fimSessionDataset = new DcmDataset(DicomTransferSyntax.ImplicitVRLittleEndian);

            _filmSession = new DcmFilmSession(DcmFilmSession.SOPClassUID,
                                              DicomUID.Generate(), fimSessionDataset.Clone());
            _filmSession.FilmDestination  = _filmDestination;
            _filmSession.FilmSessionLabel = _filmSessionLabel;
            _filmSession.MediumType       = _mediumType;
            _filmSession.NumberOfCopies   = _numberOfCopies;
            _filmSession.OwnerID          = _ownerID;
            _filmSession.PrintPriority    = _printPriority;

            byte pcid = Associate.FindAbstractSyntax(DicomUID.BasicGrayscalePrintManagementMetaSOPClass);

            SendNCreateRequest(pcid, NextMessageID(), DcmFilmSession.SOPClassUID, _filmSession.SOPInstanceUID, _filmSession.Dataset);
        }
Ejemplo n.º 2
0
        protected override void OnReceiveNCreateResponse(byte presentationID, ushort messageIdRespondedTo, DicomUID affectedClass, DicomUID affectedInstance,
                                                         DcmDataset dataset, DcmStatus status)
        {
            if (_filmSession != null)
            {
                // ReSharper disable PossibleUnintendedReferenceComparison
                if (affectedClass == DicomUID.BasicFilmSessionSOPClass)
                // ReSharper restore PossibleUnintendedReferenceComparison
                {
                    if (status == DcmStatus.Success)
                    {
                        int filmBoxesCount = CalculateRequiredImageBoxes();
                        if (filmBoxesCount == 0)
                        {
                            SendReleaseRequest();
                            return;
                        }

                        for (int i = 0; i < filmBoxesCount; i++)
                        {
                            var uid            = DicomUID.Generate();
                            var filmBoxDataset = new DcmDataset(DicomTransferSyntax.ImplicitVRLittleEndian);
                            var filmBox        = _filmSession.CreateFilmBox(uid, filmBoxDataset.Clone());

                            filmBox.AnnotationDisplayFormatID = _annotationDisplayFormatID;
                            filmBox.BorderDensity             = _borderDensity;
                            filmBox.ConfigurationInformation  = _configurationInformation;
                            filmBox.EmptyImageDensity         = _emptyImageDensity;
                            filmBox.FilmOrientation           = _filmOrientation;
                            filmBox.FilmSizeID            = _filmSizeID;
                            filmBox.Illumination          = _illumination;
                            filmBox.ImageDisplayFormat    = _imageDisplayFormat;
                            filmBox.MagnificationType     = _magnificationType;
                            filmBox.MaxDensity            = _maxDensity;
                            filmBox.MinDensity            = _minDensity;
                            filmBox.ReflectedAmbientLight = _reflectedAmbientLight;
                            filmBox.RequestedResolutionID = _requestedResolutionID;
                            filmBox.SmoothingType         = _smoothingType;
                            filmBox.Trim = _trim;

                            byte pcid = Associate.FindAbstractSyntax(DicomUID.BasicGrayscalePrintManagementMetaSOPClass);
                            SendNCreateRequest(pcid, NextMessageID(), DicomUID.BasicFilmBoxSOPClass, filmBox.SOPInstanceUID, filmBox.Dataset);
                        }
                        return;
                    }
                }

                // ReSharper disable PossibleUnintendedReferenceComparison
                if (affectedClass == DicomUID.BasicFilmBoxSOPClass)
                // ReSharper restore PossibleUnintendedReferenceComparison
                {
                    if (status == DcmStatus.Success)
                    {
                        var filmBox      = _filmSession.FindFilmBox(affectedInstance);
                        var filmBoxIndex = _filmSession.BasicFilmBoxes.IndexOf(filmBox);
                        if (filmBox != null)
                        {
                            var referencedImageBoxSequenceList = dataset.GetSQ(DicomTags.ReferencedImageBoxSequence);
                            if (referencedImageBoxSequenceList != null)
                            {
                                foreach (var item in referencedImageBoxSequenceList.SequenceItems)
                                {
                                    var referencedSOPInstanceUID = item.Dataset.GetUID(DicomTags.ReferencedSOPInstanceUID);
                                    if (referencedSOPInstanceUID != null)
                                    {
                                        var imageBox = new DcmImageBox(filmBox, DcmImageBox.GraySOPClassUID, referencedSOPInstanceUID);
                                        filmBox.BasicImageBoxes.Add(imageBox);
                                    }
                                }
                            }

                            _pendingImageBoxResponses.Clear();
                            if (filmBox.BasicImageBoxes.Count > 0)
                            {
                                var imageBoxIndex    = 0;
                                var imagesPerFilmbox = CalculateImagesPreFilmBox();
                                foreach (var imageBox in filmBox.BasicImageBoxes)
                                {
                                    if (imagesPerFilmbox * filmBoxIndex + imageBoxIndex < _files.Count)
                                    {
                                        UpdateImageBox(imageBox, _files[imagesPerFilmbox * filmBoxIndex + imageBoxIndex], imageBoxIndex);
                                    }
                                    _pendingImageBoxResponses.Add(imageBox);
                                    imageBoxIndex++;

                                    byte pcid = Associate.FindAbstractSyntax(DicomUID.PrinterSOPClass);
                                    SendNSetRequest(pcid, NextMessageID(), imageBox.SOPClassUID, imageBox.SOPInstanceUID, imageBox.Dataset);
                                }
                            }
                            return;
                        }
                    }
                }
            }

            SendAbort(DcmAbortSource.ServiceUser, DcmAbortReason.NotSpecified);
        }