예제 #1
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();
             
         }
     }
     
 }
예제 #2
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);
        }
예제 #3
0
		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;
		}
        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;
        }
예제 #5
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();
			}

		}
예제 #6
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;
 }
예제 #7
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);
		}