private void Export(string path) { try { using (StreamWriter writer = new StreamWriter(path)) { // header writer.Write("\"Filename\""); foreach (String text in mapping) { string[] strings = text.Split(":".ToCharArray()); writer.Write(",\"" + ((strings.Length > 1) ? strings[1] : Dictionary.Instance[strings[0]].Description) + "\""); } writer.WriteLine(); // rows foreach (FileInfo file in files) { EK.Capture.Dicom.DicomToolKit.DataSet dicom = new EK.Capture.Dicom.DicomToolKit.DataSet(); dicom.Read(file.FullName, 0x7F00); writer.Write("\"" + file.FullName + "\""); foreach (String text in mapping) { string[] strings = text.Split(":".ToCharArray()); string value = String.Empty; try { value = (dicom.ValueExists(strings[0])) ? ToString(dicom[strings[0]]) : String.Empty; } catch (Exception ex) { Logging.Log(LogLevel.Error, String.Format("Export Value: {0}", ex.Message)); } writer.Write(",\"" + value + "\""); } writer.WriteLine(); } } } catch (Exception ex) { Logging.Log(LogLevel.Error, String.Format("Export: {0}", ex.Message)); } }
private string ReadDicom(FileInfo file) { string error = "\uFFFD"; StringBuilder line = new StringBuilder(); try { EK.Capture.Dicom.DicomToolKit.DataSet dicom = new EK.Capture.Dicom.DicomToolKit.DataSet(); dicom.Read(file.FullName, 0x5000); for (int n = 0; n < mapping.Count; n++) { String text = mapping[n]; string[] strings = text.Split(":".ToCharArray()); string value = String.Empty; try { value = (dicom.ValueExists(strings[0])) ? ToString(dicom[strings[0]]) : String.Empty; } catch (Exception ex) { value = error; Logging.Log(LogLevel.Error, String.Format("ReadDicom Value: {0}", ex.Message)); } if (n > 0) { line.Append("|"); } line.Append(value); } } catch (Exception ex) { line = new StringBuilder(""); for (int n = 0; n < mapping.Count; n++) { if (n > 0) { line.Append("|"); } line.Append(error); } Logging.Log(LogLevel.Error, String.Format("ReadDicom: {0}", ex.Message)); } return(line.ToString()); }