/// <summary> /// Deprecated Method for adding a new object to the DicomElementValue EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToDicomElementValue(DicomElementValue dicomElementValue) { base.AddObject("DicomElementValue", dicomElementValue); }
private bool FilterDicomElementValue(DicomElementValue entity) { return ((entity.GroupNumber == this.GroupNumber) && (entity.ElementNumber == this.ElementNumber)); }
/// <summary> /// Create a new DicomElementValue object. /// </summary> /// <param name="value">Initial value of the Value property.</param> /// <param name="fileId">Initial value of the FileId property.</param> /// <param name="groupNumber">Initial value of the GroupNumber property.</param> /// <param name="elementNumber">Initial value of the ElementNumber property.</param> public static DicomElementValue CreateDicomElementValue(global::System.String value, global::System.Int32 fileId, global::System.Int32 groupNumber, global::System.Int32 elementNumber) { DicomElementValue dicomElementValue = new DicomElementValue(); dicomElementValue.Value = value; dicomElementValue.FileId = fileId; dicomElementValue.GroupNumber = groupNumber; dicomElementValue.ElementNumber = elementNumber; return dicomElementValue; }
private void AttachDicomElementValue(DicomElementValue entity) { entity.DicomElement = this; }
private void DetachDicomElementValue(DicomElementValue entity) { entity.DicomElement = null; }
private bool FilterDicomElementValue(DicomElementValue entity) { return (entity.FileId == this.FileId); }
public void DeleteDicomElementValue(DicomElementValue dicomElementValue) { if ((dicomElementValue.EntityState != EntityState.Detached)) { this.ObjectContext.ObjectStateManager.ChangeObjectState(dicomElementValue, EntityState.Deleted); } else { this.ObjectContext.DicomElementValue.Attach(dicomElementValue); this.ObjectContext.DicomElementValue.DeleteObject(dicomElementValue); } }
public void UpdateDicomElementValue(DicomElementValue currentDicomElementValue) { this.ObjectContext.DicomElementValue.AttachAsModified(currentDicomElementValue, this.ChangeSet.GetOriginal(currentDicomElementValue)); }
public void InsertDicomElementValue(DicomElementValue dicomElementValue) { if ((dicomElementValue.EntityState != EntityState.Detached)) { this.ObjectContext.ObjectStateManager.ChangeObjectState(dicomElementValue, EntityState.Added); } else { this.ObjectContext.DicomElementValue.AddObject(dicomElementValue); } }
public void UploadDicomFile(string guid) { string dirPath = string.Format(@"C:\temp\{0}", guid); string filePath = string.Format(@"{0}\{1}", dirPath, new DirectoryInfo(dirPath).GetFiles().Single().Name); try { using (TransactionScope scope = new TransactionScope()) { DicomDataset dataset = Dicom.DicomFile.Open(filePath).Dataset; // Vlozenie dat do DicomFile FileInfo fileInfo = new FileInfo(filePath); DateTime uploadTime = DateTime.Now; int studyId = int.Parse(dataset.Get<string>(DicomTag.StudyID)); string name = fileInfo.Name; DicomFile dicomFileEntity = new DicomFile { UploadTime = uploadTime, StudyId = studyId, Name = name }; ObjectContext.DicomFile.AddObject(dicomFileEntity); ObjectContext.SaveChanges(); int fileId = (from df in ObjectContext.DicomFile select df.FileId).DefaultIfEmpty().Max(); // Vlozenie dat do DicomElement a DicomElementValue foreach (DicomItem element in dataset) { int groupNumber = element.Tag.Group; int elementNumber = element.Tag.Element; string valueRepresentation = element.ValueRepresentation.ToString(); string valueMultiplicity = element.Tag.DictionaryEntry.ValueMultiplicity.ToString(); string keyword = element.Tag.DictionaryEntry.Keyword; bool elementExists = Convert.ToBoolean(( from de in ObjectContext.DicomElement where de.GroupNumber == groupNumber && de.ElementNumber == elementNumber select de).Count()); if (!elementExists) { DicomElement dicomElementEntity = new DicomElement { GroupNumber = groupNumber, ElementNumber = elementNumber, ValueRepresentation = valueRepresentation, ValueMultiplicity = valueMultiplicity, Keyword = keyword }; ObjectContext.DicomElement.AddObject(dicomElementEntity); ObjectContext.SaveChanges(); } string value = dataset.Get<string>(element.Tag); DicomElementValue dicomElementValueEntity = new DicomElementValue { Value = value, FileId = fileId, GroupNumber = groupNumber, ElementNumber = elementNumber }; ObjectContext.DicomElementValue.AddObject(dicomElementValueEntity); ObjectContext.SaveChanges(); } //Vlozenie dat do DicomFrame DicomImage dicomImage = new DicomImage(filePath); for (int i = 0; i < dicomImage.NumberOfFrames; i++) { Guid frameGuid = Guid.NewGuid(); byte[] frame = dicomImage.PixelData.GetFrame(i).Data;// RangeByteBuffer DicomFrame dicomFrameEntity = new DicomFrame { FileId = fileId, FrameGuid = frameGuid, Frame = frame }; ObjectContext.DicomFrame.AddObject(dicomFrameEntity); ObjectContext.SaveChanges(); } scope.Complete(); } } finally { if (File.Exists(filePath)) File.Delete(filePath); if (Directory.Exists(dirPath)) Directory.Delete(dirPath); } }