private static void RemoveStudyStorage(StudyStorageLocation location)
		{
			// NOTE:  This was an IUpdateContext, however, it was modified to be an IReadContext
			// after having problems w/ locks on asystem with a fair amount of load.  The 
			// updates are just automatically committed within the stored procedure when it
			// runs...
			using (IReadContext updateContext = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
			{
				// Setup the delete parameters
				DeleteStudyStorageParameters parms = new DeleteStudyStorageParameters
				                                     	{
				                                     		ServerPartitionKey = location.ServerPartitionKey,
				                                     		StudyStorageKey = location.Key
				                                     	};

				// Get the Insert Instance broker and do the insert
				IDeleteStudyStorage delete = updateContext.GetBroker<IDeleteStudyStorage>();

				if (false == delete.Execute(parms))
				{
					Platform.Log(LogLevel.Error, "Unexpected error when trying to delete study: {0}",
								 location.StudyInstanceUid);
				}
			}
		}
示例#2
0
        /// <summary>
        /// Deletes the <see cref="StudyStorage"/> record
        /// </summary>
        /// <param name="item"></param>
        private void DeleteStudyStorage(Model.WorkQueue item)
        {
            using (IUpdateContext context = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
            {
                var study = context.GetBroker<IStudyEntityBroker>();
                var criteria = new StudySelectCriteria();

                criteria.StudyInstanceUid.EqualTo(StorageLocation.StudyInstanceUid);
                criteria.ServerPartitionKey.EqualTo(item.ServerPartitionKey);

                int count = study.Count(criteria);
                if (count == 0)
                {
                    Platform.Log(LogLevel.Debug, "StudyProcess Cleanup: removing study storage record...");
                    var delete = context.GetBroker<IDeleteStudyStorage>();

                    var parms = new DeleteStudyStorageParameters
                    {
                        ServerPartitionKey = item.ServerPartitionKey,
                        StudyStorageKey = item.StudyStorageKey
                    };

                    delete.Execute(parms);

                    context.Commit();
                }

            }
        }