static String stampa(DCXOBJ currObj, int elementNumber) { try { currElem = currObj.getElementByTag(elementNumber); } catch (Exception e) { Console.WriteLine(e.Message); } //Tag Not Found return(elementName(elementNumber) + ": " + currElem.Value + " | "); }
private string TryGetString(DCXOBJ obj, DICOM_TAGS_ENUM tag) { try { DCXELM e = obj.getElementByTag((int)tag); if (e != null && e.Value != null) { return(obj.getElementByTag((int)tag).Value.ToString()); } else { return("N/A"); } } catch (COMException) { return("N/A"); } }
public static String extractValue(DCXOBJ currObj, int dicomTagNumber) { string ret = ""; DCXELM currElem = new DCXELM(); try { currElem = currObj.getElementByTag(dicomTagNumber); ret = currElem.Value; } catch (Exception) { errorMessage("Nel risultato della query non è contenuto il tag DICOM '" + dicomTagName(dicomTagNumber) + "'"); } return(ret); }
// evento: arrivato il file (lo controllo e rispondo se è ok) private void OnStoreDoneEventHandler(string filename, bool status, ref bool accept) { // if status, file saved! if (!status) { errorCount++; errorMessage("errore nel salvataggio del file!"); } // check if file already exists string sop_instance_uid = null; DCXOBJ o = new DCXOBJ(); o.openFile(filename); DCXELM e = o.getElementByTag((int)DICOM_TAGS_ENUM.sopInstanceUID); if (e != null) { sop_instance_uid = e.Value.ToString(); } ReleaseComObject(e); ReleaseComObject(o); if (sop_instance_uid != null) { String destinationFilename = storageDirectory + sop_instance_uid + ".dcm"; if (!File.Exists(destinationFilename)) { File.Move(filename, destinationFilename); } else { errorMessage("file gia esiste"); File.Delete(filename); } } accept = true; }
public static String find(Association ass, Selector sel) { DCXOBJ obj = fillData(sel); String ret = ""; // Create the requester object DCXREQ req = new DCXREQ(); // send the query DCXOBJIterator it = req.Query(ass.myAET, ass.TargetAET, ass.TargetIp, ass.TargetPort, "1.2.840.10008.5.1.4.1.2.1.1", obj); DCXOBJ currObj = null; try { int index = 1; // Iterate over the query results for (; !it.AtEnd(); it.Next()) { currObj = it.Get(); string message = ""; message += stampa(currObj, (int)DICOM_TAGS_ENUM.patientName); if (level == "STUDY" || level == "SERIES" || level == "IMAGE") { message += stampa(currObj, (int)DICOM_TAGS_ENUM.StudyDescription); } if (level == "SERIES" || level == "IMAGE") { message += stampa(currObj, (int)DICOM_TAGS_ENUM.SeriesDescription); } if (level == "IMAGE") { message += stampa(currObj, (int)DICOM_TAGS_ENUM.sopClassUid); message += stampa(currObj, (int)DICOM_TAGS_ENUM.sopInstanceUID); } if (level == "STUDY") { message += stampa(currObj, (int)DICOM_TAGS_ENUM.studyInstanceUID); } if (level == "SERIES") { message += stampa(currObj, (int)DICOM_TAGS_ENUM.seriesInstanceUID); if (index == 1) // l'UID della serie è il primo dello studio // non uso la funzione stampa, se no mi aggiunge altro testo oltre all'id { try { currElem = currObj.getElementByTag((int)DICOM_TAGS_ENUM.seriesInstanceUID); } catch (Exception e) { Console.WriteLine(e.Message); } //Tag Not Found ret = currElem.Value; Console.WriteLine(ret); } } index++; Console.WriteLine(message); } } catch (Exception ex) { MessageBox.Show(ex.Message); } return(ret); }