Пример #1
0
        /*
         * Sets a DicomElement that is either a DicomDateValue or DicomTimeValue
         */

        private void SetTimeDateKeyElement(DicomDataSet ResponseDS, DateTime dt, long tag, bool bTimeValue)
        {
            try
            {
                DicomElement element = ResponseDS.FindFirstElement(null, tag, false);
                if (element != null)
                {
                    if (bTimeValue)
                    {
                        DicomTimeValue[] dtv = new DicomTimeValue[1];
                        dtv[0] = new DicomTimeValue(dt);
                        ResponseDS.SetTimeValue(element, dtv);
                    }
                    else
                    {
                        DicomDateValue[] ddv = new DicomDateValue[1];
                        ddv[0] = new DicomDateValue(dt);
                        ResponseDS.SetDateValue(element, ddv);
                    }
                }
            }
            catch (Exception ex)
            {
                server.mf.Log("Error setting time or date element:\r\n\r\n" + ex.ToString());
                return;
            }
        }
Пример #2
0
 /*
  * Converts a DicomTimeValue object into a string formatted as HH:MM:SS
  */
 private string ConvertDicomTimeToQueryTime(DicomTimeValue dtv)
 {
     try
     {
         // Add 0s to beginning if necessary, e.g. HH-M-SS needs to be HH-MM-SS
         return(dtv.Hours.ToString().PadLeft(2, '0') + ":" +
                dtv.Minutes.ToString().PadLeft(2, '0') + ":" +
                dtv.Seconds.ToString().PadLeft(2, '0'));
     }
     catch (Exception ex)
     {
         server.mf.Log("Error converting time:\r\n\r\n" + ex.ToString());
         return("");
     }
 }