コード例 #1
0
ファイル: LogHistory.cs プロジェクト: bangush/server-1
        private StudyHistoryUpdateColumns CreateStudyHistoryRecord(StudyEditedEventArgs context)
        {
            Platform.CheckForNullReference(context.OriginalStudyStorageLocation, "context.OriginalStudyStorageLocation");
            Platform.CheckForNullReference(context.NewStudyStorageLocation, "context.NewStudyStorageLocation");

            _studyInfo  = StudyInformation.CreateFrom(context.OriginalStudy);
            _changeDesc = new WebEditStudyHistoryChangeDescription
            {
                UpdateCommands = context.EditCommands,
                TimeStamp      = Platform.Time,
                UserId         = context.UserId,
                Reason         = context.Reason,
                EditType       = context.EditType
            };

            var columns = new StudyHistoryUpdateColumns
            {
                InsertTime           = Platform.Time,
                StudyStorageKey      = context.OriginalStudyStorageLocation.GetKey(),
                DestStudyStorageKey  = context.NewStudyStorageLocation.GetKey(),
                StudyData            = XmlUtils.SerializeAsXmlDoc(_studyInfo),
                StudyHistoryTypeEnum =
                    context.EditType == EditType.WebEdit
                                                        ? StudyHistoryTypeEnum.WebEdited
                                                        : StudyHistoryTypeEnum.ExternalEdit
            };

            XmlDocument doc = XmlUtils.SerializeAsXmlDoc(_changeDesc);

            columns.ChangeDescription = doc;
            return(columns);
        }
コード例 #2
0
 public void OnCompleted(WebDeleteProcessorContext context, IList <Series> series)
 {
     if (series.Count > 0)
     {
         Platform.Log(LogLevel.Info, "Logging history..");
         DateTime now = Platform.Time;
         using (IUpdateContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
         {
             IStudyHistoryEntityBroker broker  = ctx.GetBroker <IStudyHistoryEntityBroker>();
             StudyHistoryUpdateColumns columns = new StudyHistoryUpdateColumns();
             columns.InsertTime           = Platform.Time;
             columns.StudyHistoryTypeEnum = StudyHistoryTypeEnum.SeriesDeleted;
             columns.StudyStorageKey      = context.StorageLocation.Key;
             columns.DestStudyStorageKey  = context.StorageLocation.Key;
             columns.StudyData            = XmlUtils.SerializeAsXmlDoc(_studyInfo);
             SeriesDeletionChangeLog changeLog = new SeriesDeletionChangeLog();
             changeLog.TimeStamp = now;
             changeLog.Reason    = context.Reason;
             changeLog.UserId    = context.UserId;
             changeLog.UserName  = context.UserName;
             changeLog.Series    = CollectionUtils.Map(series,
                                                       delegate(Series ser)
             {
                 ServerEntityAttributeProvider seriesWrapper = new ServerEntityAttributeProvider(ser);
                 return(new SeriesInformation(seriesWrapper));
             });
             columns.ChangeDescription = XmlUtils.SerializeAsXmlDoc(changeLog);
             StudyHistory history = broker.Insert(columns);
             if (history != null)
             {
                 ctx.Commit();
             }
         }
     }
 }
コード例 #3
0
        static public StudyHistory Insert(IUpdateContext update, StudyHistory entity)
        {
            var broker        = update.GetBroker <IStudyHistoryEntityBroker>();
            var updateColumns = new StudyHistoryUpdateColumns();

            updateColumns.InsertTime           = entity.InsertTime;
            updateColumns.StudyStorageKey      = entity.StudyStorageKey;
            updateColumns.StudyHistoryTypeEnum = entity.StudyHistoryTypeEnum;
            updateColumns.StudyData            = entity.StudyData;
            updateColumns.ChangeDescription    = entity.ChangeDescription;
            updateColumns.DestStudyStorageKey  = entity.DestStudyStorageKey;
            StudyHistory newEntity = broker.Insert(updateColumns);

            return(newEntity);
        }
コード例 #4
0
ファイル: LogHistory.cs プロジェクト: yjsyyyjszf/CC13.2
		public void EventHandler(object sender, StudyEditedEventArgs e)
		{
			IPersistentStore store = PersistentStoreRegistry.GetDefaultStore();
			using (IUpdateContext ctx = store.OpenUpdateContext(UpdateContextSyncMode.Flush))
			{
				Platform.Log(LogLevel.Info, "Logging study history record...");
				IStudyHistoryEntityBroker broker = ctx.GetBroker<IStudyHistoryEntityBroker>();
				StudyHistoryUpdateColumns recordColumns = CreateStudyHistoryRecord(e);
				StudyHistory entry = broker.Insert(recordColumns);
				if (entry != null)
					ctx.Commit();
				else
					throw new ApplicationException("Unable to log study history record");
			}
		}
コード例 #5
0
        protected override void OnExecute(CommandProcessor theProcessor, IUpdateContext updateContext)
        {
            IStudyHistoryEntityBroker historyUpdateBroker = updateContext.GetBroker <IStudyHistoryEntityBroker>();
            StudyHistoryUpdateColumns parms = new StudyHistoryUpdateColumns {
                DestStudyStorageKey = _destStudy.Key
            };

            if (_map != null)
            {
                // replace the mapping in the history
                StudyReconcileDescriptor changeLog = XmlUtils.Deserialize <StudyReconcileDescriptor>(_studyHistory.ChangeDescription);
                changeLog.SeriesMappings = new System.Collections.Generic.List <SeriesMapping>(_map.GetSeriesMappings());
                parms.ChangeDescription  = XmlUtils.SerializeAsXmlDoc(changeLog);
            }

            historyUpdateBroker.Update(_studyHistory.Key, parms);
        }
コード例 #6
0
        public static StudyHistory CreateStudyHistoryRecord(IUpdateContext updateContext,
                                                            StudyStorageLocation primaryStudyLocation, StudyStorageLocation secondaryStudyLocation,
                                                            StudyHistoryTypeEnum type, object entryInfo, object changeLog)
        {
            StudyHistoryUpdateColumns columns = new StudyHistoryUpdateColumns
            {
                InsertTime           = Platform.Time,
                StudyHistoryTypeEnum = type,
                StudyStorageKey      = primaryStudyLocation.GetKey(),
                DestStudyStorageKey  =
                    secondaryStudyLocation != null
                                                                                        ? secondaryStudyLocation.GetKey()
                                                                                        : primaryStudyLocation.GetKey(),
                StudyData         = XmlUtils.SerializeAsXmlDoc(entryInfo) ?? new XmlDocument(),
                ChangeDescription = XmlUtils.SerializeAsXmlDoc(changeLog) ?? new XmlDocument()
            };

            IStudyHistoryEntityBroker broker = updateContext.GetBroker <IStudyHistoryEntityBroker>();

            return(broker.Insert(columns));
        }
コード例 #7
0
        private void LogHistory(ImageSetDetails details)
        {
            IPersistentStore store = PersistentStoreRegistry.GetDefaultStore();

            using (IUpdateContext ctx = store.OpenUpdateContext(UpdateContextSyncMode.Flush))
            {
                Platform.Log(LogLevel.Info, "Logging study history record...");
                IStudyHistoryEntityBroker broker        = ctx.GetBroker <IStudyHistoryEntityBroker>();
                StudyHistoryUpdateColumns recordColumns = CreateStudyHistoryRecord(details);
                StudyHistory entry = broker.Insert(recordColumns);
                if (entry != null)
                {
                    ctx.Commit();
                }
                else
                {
                    throw new ApplicationException("Unable to log study history record");
                }
            }

            HistoryLogged = true;
        }
コード例 #8
0
ファイル: LogHistory.cs プロジェクト: hksonngan/Xian
        private StudyHistoryUpdateColumns CreateStudyHistoryRecord(WebEditStudyContext context)
        {
            Platform.CheckForNullReference(context.OriginalStudyStorageLocation, "context.OriginalStudyStorageLocation");
            Platform.CheckForNullReference(context.NewStudystorageLocation, "context.NewStudystorageLocation");

            var columns = new StudyHistoryUpdateColumns
            {
                InsertTime           = Platform.Time,
                StudyStorageKey      = context.OriginalStudyStorageLocation.GetKey(),
                DestStudyStorageKey  = context.NewStudystorageLocation.GetKey(),
                StudyData            = XmlUtils.SerializeAsXmlDoc(_studyInfo),
                StudyHistoryTypeEnum =
                    context.EditType == EditType.WebEdit
                                                  ? StudyHistoryTypeEnum.WebEdited
                                                  : StudyHistoryTypeEnum.ExternalEdit
            };


            XmlDocument doc = XmlUtils.SerializeAsXmlDoc(_changeDesc);

            columns.ChangeDescription = doc;
            return(columns);
        }
コード例 #9
0
        private StudyHistoryUpdateColumns CreateStudyHistoryRecord(ImageSetDetails details)
        {
            var columns = new StudyHistoryUpdateColumns
            {
                InsertTime           = Platform.Time,
                StudyHistoryTypeEnum = StudyHistoryTypeEnum.Duplicate,
                StudyStorageKey      = StorageLocation.GetKey(),
                DestStudyStorageKey  = StorageLocation.GetKey(),
                StudyData            = XmlUtils.SerializeAsXmlDoc(_currentStudyInfo)
            };

            var changeLog = new ProcessDuplicateChangeLog
            {
                Action              = _processDuplicateEntry.QueueData.Action,
                DuplicateDetails    = details,
                StudySnapShot       = _currentStudyInfo,
                StudyUpdateCommands = _studyUpdateCommands,
                UserName            = _processDuplicateEntry.QueueData.UserName
            };
            XmlDocument doc = XmlUtils.SerializeAsXmlDoc(changeLog);

            columns.ChangeDescription = doc;
            return(columns);
        }
コード例 #10
0
        private static void ReconcileStudy(string command, StudyIntegrityQueue item)
        {
            //Ignore the reconcile command if the item is null.
            if (item == null)
            {
                return;
            }

            // Preload the change description so its not done during the DB transaction
            XmlDocument changeDescription = new XmlDocument();

            changeDescription.LoadXml(command);

            // The Xml in the SIQ item was generated when the images were received and put into the SIQ.
            // We now add the user info to it so that it will be logged in the history
            ReconcileStudyWorkQueueData queueData = XmlUtils.Deserialize <ReconcileStudyWorkQueueData>(item.Details);

            queueData.TimeStamp = Platform.Time;
            queueData.UserId    = ServerHelper.CurrentUserName;

            using (IUpdateContext context = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
            {
                LockStudyParameters lockParms = new LockStudyParameters
                {
                    QueueStudyStateEnum = QueueStudyStateEnum.ReconcileScheduled,
                    StudyStorageKey     = item.StudyStorageKey
                };
                ILockStudy broker = context.GetBroker <ILockStudy>();
                broker.Execute(lockParms);
                if (!lockParms.Successful)
                {
                    throw new ApplicationException(lockParms.FailureReason);
                }


                //Add to Study History
                StudyHistoryeAdaptor      historyAdaptor = new StudyHistoryeAdaptor();
                StudyHistoryUpdateColumns parameters     = new StudyHistoryUpdateColumns
                {
                    StudyData            = item.StudyData,
                    ChangeDescription    = changeDescription,
                    StudyStorageKey      = item.StudyStorageKey,
                    StudyHistoryTypeEnum = StudyHistoryTypeEnum.StudyReconciled
                };

                StudyHistory history = historyAdaptor.Add(context, parameters);

                //Create WorkQueue Entry
                WorkQueueAdaptor       workQueueAdaptor = new WorkQueueAdaptor();
                WorkQueueUpdateColumns row = new WorkQueueUpdateColumns
                {
                    Data = XmlUtils.SerializeAsXmlDoc(queueData),
                    ServerPartitionKey  = item.ServerPartitionKey,
                    StudyStorageKey     = item.StudyStorageKey,
                    StudyHistoryKey     = history.GetKey(),
                    WorkQueueTypeEnum   = WorkQueueTypeEnum.ReconcileStudy,
                    WorkQueueStatusEnum = WorkQueueStatusEnum.Pending,
                    ScheduledTime       = Platform.Time,
                    ExpirationTime      = Platform.Time.AddHours(1),
                    GroupID             = item.GroupID
                };
                WorkQueue newWorkQueueItem = workQueueAdaptor.Add(context, row);

                StudyIntegrityQueueUidAdaptor        studyIntegrityQueueUidAdaptor = new StudyIntegrityQueueUidAdaptor();
                StudyIntegrityQueueUidSelectCriteria crit = new StudyIntegrityQueueUidSelectCriteria();
                crit.StudyIntegrityQueueKey.EqualTo(item.GetKey());
                IList <StudyIntegrityQueueUid> uidList = studyIntegrityQueueUidAdaptor.Get(context, crit);

                WorkQueueUidAdaptor       workQueueUidAdaptor = new WorkQueueUidAdaptor();
                WorkQueueUidUpdateColumns update = new WorkQueueUidUpdateColumns();
                foreach (StudyIntegrityQueueUid uid in uidList)
                {
                    update.WorkQueueKey      = newWorkQueueItem.GetKey();
                    update.SeriesInstanceUid = uid.SeriesInstanceUid;
                    update.SopInstanceUid    = uid.SopInstanceUid;
                    update.RelativePath      = uid.RelativePath;
                    workQueueUidAdaptor.Add(context, update);
                }

                //DeleteStudyIntegrityQueue Item
                StudyIntegrityQueueUidSelectCriteria criteria = new StudyIntegrityQueueUidSelectCriteria();
                criteria.StudyIntegrityQueueKey.EqualTo(item.GetKey());
                studyIntegrityQueueUidAdaptor.Delete(context, criteria);

                StudyIntegrityQueueAdaptor studyIntegrityQueueAdaptor = new StudyIntegrityQueueAdaptor();
                studyIntegrityQueueAdaptor.Delete(context, item.GetKey());

                context.Commit();
            }
        }