Пример #1
0
        private int GetIntTagValue(MElementList elmlist, tag_t tag)
        {
            var nValue = 0;

            try
            {
                using (MElementRef eref = elmlist.get_Element(tag))
                {
                    if (eref != null && eref.value_count != 0 && eref.value_count != -1)
                    {
                        nValue = eref.get_sint(0);
                    }
                    return(nValue);
                }
            }
            catch (Exception e)
            {
                _logger.Error("DCMHeader.GetIntTagValue(): " + "get int for tag " + tag.ToString() + " pop up an exception--" + e.Message + ".");
                return(nValue);
            }
        }
Пример #2
0
 private void GetDateTimeTagValue(ref string strValue, MElementList elmlist, tag_t tag)
 {
     try
     {
         using (MElementRef eref = elmlist.get_Element(tag))
         {
             if (eref != null && eref.value_count != 0 && eref.value_count != -1)
             {
                 strValue = eref.get_string(0);
             }
             else
             {
                 strValue = " ";
             }
         }
     }
     catch (Exception e)
     {
         strValue = " ";
         _logger.Error("DCMHeader.GetDateTimeTagValue(): " + "get datetime for tag " + tag.ToString() + " pop up an exception--" + e.Message + ".");
     }
 }
Пример #3
0
 /// <summary>
 /// For some tag with local language, e.g PatientName
 /// ISO_IR 192: use UTF8 encoding local string
 /// ISO_IR 100: use GB2312 encoding local string
 /// </summary>
 /// <param name="strValue"></param>
 /// <param name="elmlist"></param>
 /// <param name="tag"></param>
 private void GetLocalStringTagValue(ref string strValue, MElementList elmlist, tag_t tag)
 {
     try
     {
         String str_speccharacter = "";
         using (MElementRef intereref = elmlist.get_Element(tag_t.kSpecificCharacterSet))
         {
             if (intereref != null && intereref.value_count != 0 && intereref.value_count != -1)
             {
                 str_speccharacter = intereref.get_string(0);
             }
             else
             {
                 str_speccharacter = "";
             }
         }
         using (MElementRef eref = elmlist.get_Element(tag))
         {
             Byte[] byte_patName = null;
             if (str_speccharacter.Trim() == "ISO_IR 192")
             {
                 if (eref != null && eref.value_count != 0 && eref.value_count != -1)
                 {
                     byte_patName = eref.get_blob(0);
                 }
                 strValue = Encoding.UTF8.GetString(byte_patName);
             }
             else if (str_speccharacter.Trim() == "ISO_IR 100")
             {
                 if (eref != null && eref.value_count != 0 && eref.value_count != -1)
                 {
                     byte_patName = eref.get_blob(0);
                 }
                 strValue = Encoding.GetEncoding("GB2312").GetString(byte_patName);
             }
             else
             {
                 if (eref != null && eref.value_count != 0 && eref.value_count != -1)
                 {
                     strValue = eref.get_string(0);
                 }
                 else
                 {
                     strValue = " ";
                 }
             }
         }
     }
     catch (Exception e)
     {
         strValue = " ";
         _logger.Error("DCMHeader.GetStringTagValue(): " + "get string for tag " + tag.ToString() + " pop up an exception--" + e.Message + ".");
     }
 }
Пример #4
0
        private string GetStringTagValue(MElementList elmlist, tag_t tag)
        {
            var strValue = string.Empty;

            try
            {
                using (MElementRef eref = elmlist.get_Element(tag))
                {
                    if (eref != null && eref.value_count != 0 && eref.value_count != -1)
                    {
                        strValue = eref.get_string(0);
                    }
                    else
                    {
                        strValue = "";
                    }
                    return(strValue);
                }
            }
            catch (Exception e)
            {
                _logger.Error("DicomHeader.GetStringTagValue(): " + "get string for tag " + tag.ToString() + " pop up an exception--" + e.Message + ".");
                return(strValue);
            }
        }
Пример #5
0
        private string GetDateTimeTagValue(MElementList elmlist, tag_t tag)
        {
            var strValue = string.Empty;
            var strRet   = string.Empty;

            try
            {
                using (MElementRef eref = elmlist.get_Element(tag))
                {
                    if (eref != null && eref.value_count != 0 && eref.value_count != -1)
                    {
                        strValue = eref.get_string(0);
                    }
                    if (!string.IsNullOrEmpty((strValue)))
                    {
                        strRet = System.DateTime.ParseExact(strValue, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture).ToString("yyyy-MM-dd");
                    }
                    return(strRet);
                }
            }
            catch (Exception e)
            {
                _logger.Error("DCMHeader.GetDateTimeTagValue(): " + "get datetime for tag " + tag.ToString() + " pop up an exception--" + e.Message + ".");
                strRet = System.DateTime.ParseExact(strValue, "yyyy.MM.dd", System.Globalization.CultureInfo.CurrentCulture).ToString("yyyy-MM-dd");
                return(strRet);
            }
        }