public DicomUID Generate(DicomUID sourceUid = null) {
			lock (GenerateUidLock) {
				DicomUID destinationUid;
				if (sourceUid != null && _uidMap.TryGetValue(sourceUid.UID, out destinationUid))
					return destinationUid;

				long ticks = DateTime.UtcNow.Subtract(Y2K).Ticks;
				while (ticks == LastTicks) {
					Thread.Sleep(1);
					ticks = DateTime.UtcNow.Subtract(Y2K).Ticks;
				}
				LastTicks = ticks;

				string str = ticks.ToString();
				if (str.EndsWith("0000"))
					str = str.Substring(0, str.Length - 4);

				StringBuilder uid = new StringBuilder();
				uid.Append(InstanceRootUID.UID).Append('.').Append(str);

				destinationUid = new DicomUID(uid.ToString(), "SOP Instance UID", DicomUidType.SOPInstance);

				if (sourceUid != null)
					_uidMap.Add(sourceUid.UID, destinationUid);

				return destinationUid;
			}
		}
Ejemplo n.º 2
0
 public void Enumerate_TestKnownUids_TypeAndRetirementShouldMatch(
     DicomUID uid,
     DicomUidType type,
     bool isRetired)
 {
     var found = KnownUids.Single(item => item.UID.Equals(uid.UID));
     Assert.Equal(type, found.Type);
     Assert.Equal(isRetired, found.IsRetired);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Generate a new DICOM UID.
        /// </summary>
        /// <param name="sourceUid">Source UID.</param>
        /// <returns>Generated UID.</returns>
        public DicomUID Generate(DicomUID sourceUid = null)
        {
            lock (GenerateUidLock)
            {
                DicomUID destinationUid;
                if (sourceUid != null && this.uidMap.TryGetValue(sourceUid.UID, out destinationUid)) return destinationUid;

                var ticks = DateTime.UtcNow.Subtract(Y2K).Ticks;
                if (ticks == lastTicks) ++ticks;
                lastTicks = ticks;

                var str = ticks.ToString();
                if (str.EndsWith("0000")) str = str.Substring(0, str.Length - 4);

                var uid = new StringBuilder();
                uid.Append(InstanceRootUID.UID).Append('.').Append(str);

                destinationUid = new DicomUID(uid.ToString(), "SOP Instance UID", DicomUidType.SOPInstance);

                if (sourceUid != null) this.uidMap.Add(sourceUid.UID, destinationUid);

                return destinationUid;
            }
        }
Ejemplo n.º 4
0
 public static DicomTransferSyntax Lookup(DicomUID uid)
 {
     DicomTransferSyntax tx;
     if (Entries.TryGetValue(uid, out tx)) return tx;
     return new DicomTransferSyntax
                {
                    UID = uid,
                    IsExplicitVR = true,
                    IsEncapsulated = true,
                    Endian = Endian.Little
                };
     //throw new DicomDataException("Unknown transfer syntax UID: {0}", uid);
 }
Ejemplo n.º 5
0
		public static DicomUID Append(DicomUID baseUid, long nextSeq) {
			StringBuilder uid = new StringBuilder();
			uid.Append(baseUid.UID).Append('.').Append(nextSeq);
			return new DicomUID(uid.ToString(), "SOP Instance UID", DicomUidType.SOPInstance);
		}
Ejemplo n.º 6
0
 public static DicomTransferSyntax Parse(string uid)
 {
     return(Lookup(DicomUID.Parse(uid)));
 }
Ejemplo n.º 7
0
 public static void Register(DicomUID uid)
 {
     _uids.Add(uid.UID, uid);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Construct new print job using specified SOP instance UID. If passed SOP instance UID is missing, new UID will
        /// be generated
        /// </summary>
        /// <param name="sopInstance">New print job SOP instance uID</param>
        public PrintJob(DicomUID sopInstance, Printer printer, string originator, Dicom.Log.Logger log)
            : base()
        {
            if (printer == null)
            {
                throw new ArgumentNullException("printer");
            }

            Log = log;

            if (sopInstance == null || sopInstance.UID == string.Empty)
            {
                SOPInstanceUID = DicomUID.Generate();
            }
            else
            {
                SOPInstanceUID = sopInstance;
            }

            this.Add(DicomTag.SOPClassUID, SOPClassUID);
            this.Add(DicomTag.SOPInstanceUID, SOPInstanceUID);

            Printer = printer;

            Status = PrintJobStatus.Pending;

            PrinterName = Printer.PrinterAet;

            Originator = originator;

            if (CreationDateTime == DateTime.MinValue)
            {
                CreationDateTime = DateTime.Now;
            }

            PrintJobFolder = SOPInstanceUID.UID;

            var receivingFolder = Environment.CurrentDirectory + @"\PrintJobs";

            FullPrintJobFolder = string.Format(@"{0}\{1}", receivingFolder.TrimEnd('\\'), PrintJobFolder);

            FilmBoxFolderList = new List<string>();
        }