Beispiel #1
0
        public void OnData(MessageType control, Message message)
        {
            // TODO put a lock on the pdu array
            // TODO interpret the commands

            Logging.Log("CMoveServiceSCU({0}).OnData", Reflection.GetName(typeof(SOPClass), this.SOPClassUId));

            DataSet dicom = message.Dicom;

            if (MessageControl.IsCommand(control))
            {
                ushort status = (ushort)dicom[t.Status].Value;
                bool   last   = !(status == 0xFF00);

                DataSetType present = (DataSetType)dicom[t.CommandDataSetType].Value;

                Logging.Log("<< {0} {1},{2}", Enum.Parse(typeof(CommandType), dicom[t.CommandField].Value.ToString()), (last) ? "LAST FRAGMENT" : "NOT-LAST FRAGMENT", present.ToString());
                //dicom.Dump();

                string text = String.Empty;
                if (dicom.Contains(t.NumberofRemainingSuboperations))
                {
                    text += String.Format("remaining={0} ", dicom[t.NumberofRemainingSuboperations].Value);
                    results.Set(t.NumberofRemainingSuboperations, dicom[t.NumberofRemainingSuboperations].Value);
                }
                if (dicom.Contains(t.NumberofCompletedSuboperations))
                {
                    text += String.Format("completed={0} ", dicom[t.NumberofCompletedSuboperations].Value);
                    results.Set(t.NumberofCompletedSuboperations, dicom[t.NumberofCompletedSuboperations].Value);
                }
                if (dicom.Contains(t.NumberofFailedSuboperations))
                {
                    text += String.Format("failed={0} ", dicom[t.NumberofFailedSuboperations].Value);
                    results.Set(t.NumberofFailedSuboperations, dicom[t.NumberofFailedSuboperations].Value);
                }
                if (dicom.Contains(t.NumberofWarningSuboperations))
                {
                    text += String.Format("warning={0} ", dicom[t.NumberofWarningSuboperations].Value);
                    results.Set(t.NumberofWarningSuboperations, dicom[t.NumberofWarningSuboperations].Value);
                }

                if (this.ImageMoved != null)
                {
                    ImageMoved(this, new CMoveEventArgs(dicom));
                }

                Logging.Log(text);

                if (last)
                {
                    dicom.Remove(t.NumberofRemainingSuboperations);
                    // TODO do we reset the state to Open here
                    completeEvent.Set();
                }
            }
            else
            {
                Logging.Log("<< P-DATA-TF");
            }
        }
        private bool SendStorageCommit(string path, ApplicationEntity host, int status)
        {
            bool result = true;

            try
            {
                StorageCommitServiceSCU commit = new StorageCommitServiceSCU();
                commit.Syntaxes.Add(Syntax.ImplicitVrLittleEndian);
                commit.Role = Role.Scp;

                Association association = new Association();
                association.AddService(commit);

                if (association.Open(host))
                {
                    if (commit.Active)
                    {
                        try
                        {
                            EK.Capture.Dicom.DicomToolKit.DataSet dicom = new EK.Capture.Dicom.DicomToolKit.DataSet();
                            dicom.Read(path);

                            if (status != 0)
                            {
                                dicom.Add(t.RetrieveAETitle, host.Title);
                                // add the FailedSOPSequence
                                Sequence sequence = new Sequence(t.FailedSOPSequence);
                                dicom.Add(sequence);
                                Elements item = sequence.NewItem();
                                item.Add(dicom[t.ReferencedSOPSequence + t.ReferencedSOPClassUID]);
                                item.Add(dicom[t.ReferencedSOPSequence + t.ReferencedSOPInstanceUID]);
                                item.Add(t.FailureReason, 274);
                                // remove the ReferencedSOPSequence
                                dicom.Remove(t.ReferencedSOPSequence);
                            }

                            result = commit.Report(dicom);
                            Debug.WriteLine("commit done!");
                        }
                        catch (Exception ex)
                        {
                            result = false;
                            Debug.WriteLine(ex.Message);
                        }
                    }
                }
                else
                {
                    result = false;
                    Debug.WriteLine("\ncan't Open.");
                }
                association.Close();
            }
            catch
            {
            }
            RefreshControls();
            return(result);
        }
Beispiel #3
0
        private void DeleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode node = this.TreeView.SelectedNode;

            if (node != null)
            {
                Tag head = EK.Capture.Dicom.DicomToolKit.Tag.Head(node.Name.Substring(0, node.Name.IndexOf(' ')));
                dicom.Remove(head.ToString());
                node.Parent.Nodes.Remove(node);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Perform an N-EVENT-REPORT Storage Commitment report over an established association with the ScpScuRole of Scp.
        /// </summary>
        /// <returns></returns>
        public bool Report(DataSet dicom)
        {
            PresentationDataPdu   pdu = new PresentationDataPdu(Syntaxes[0]);
            PresentationDataValue pdv = new PresentationDataValue(PresentationContextId, Syntaxes[0], MessageType.LastCommand);

            // for storage commit, ScpScuRoleSelectionItem is mandatory and N_EVENT_REPORT_RQ generator is the SCP
            // perhaps move Report to StorageCommitServiceSCU, and move responses in here
            Role = Role.Scp;

            DataSet command = new DataSet();

            command.Add(t.GroupLength(0), (uint)0);
            command.Add(t.AffectedSOPClassUID, SOPClass.StorageCommitmentPushModelSOPClass);
            command.Add(t.CommandField, (ushort)CommandType.N_EVENT_REPORT_RQ);
            command.Add(t.MessageId, (ushort)1);
            command.Add(t.CommandDataSetType, (ushort)DataSetType.DataSetPresent);
            command.Add(t.AffectedSOPInstanceUID, SOPClass.StorageCommitmentPushModelSOPInstance);
            command.Add(t.ActionTypeID, "1");

            pdv.Dicom = command;
            pdu.Values.Add(pdv);

            SendPdu("N_EVENT_REPORT_RQ", pdu);

            if (dicom.Contains(t.SOPClassUID))
            {
                dicom.Remove(t.SOPClassUID);
            }
            if (dicom.Contains(t.SOPInstanceUID))
            {
                dicom.Remove(t.SOPInstanceUID);
            }

            SendDataPdu("N_EVENT_REPORT_RQ DATA", dicom);

            ProcessResponse("N_EVENT_REPORT_RQ (Storage Commit)", 8000, null, null);
            return(true);
        }