示例#1
0
        /// <summary>
        /// Gets due messages as of now, given the approximate due time that they were stored with when <see cref="ITimeoutManager.Defer"/> was called
        /// </summary>
        public async Task <DueMessagesResult> GetDueMessages()
        {
            var now = _rebusTime.Now.UtcDateTime;

            var session = _documentStore.OpenSession();

            var timeouts = session.Query <Timeout>()
                           .Customize(x => x.WaitForNonStaleResults(TimeSpan.FromSeconds(10)))
                           .Where(x => x.DueTimeUtc <= now)
                           .ToList();

            var dueMessages = timeouts
                              .Select(timeout => new DueMessage(timeout.Headers, timeout.Body, async() =>
            {
                var command = new DeleteCommandData(timeout.Id, session.Advanced.GetChangeVectorFor(timeout));

                session.Advanced.Defer(command);
            }));

            return(new DueMessagesResult(dueMessages, async() =>
            {
                try
                {
                    session.SaveChanges();
                }
                finally
                {
                    session.Dispose();
                }
            }));
        }
示例#2
0
        //TODO: update this to return a type showing what objects got deleted e.g. IObjectId[]
        //the "reuest" dataset is assumed to have the Object ID values. However,
        //an extended implementation might send a query dataset and this method will query the DB and generate multiple Object IDs
        //Example: the request dataset has a date range, wild-card or SOP Class UID...
        public DCloudCommandResult Delete
        (
            fo.DicomDataset request,
            ObjectQueryLevel level
        )
        {
            DCloudCommandResult deleteResult  = null;
            IDeleteCommand      deleteCommand = CommandFactory.CreateDeleteCommand( );
            DeleteCommandData   deleteData    = new DeleteCommandData( )
            {
                Instances = new List <ObjectId> ( )
                {
                    new ObjectId(request)
                },
                DeleteLevel = level
            };

            return(deleteResult = deleteCommand.Execute(deleteData));
        }
示例#3
0
        Action CreateCleanUpProcedure(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return () => { }
            }
            ;

            return(() =>
            {
                using (var session = _documentStore.OpenSession())
                {
                    var deleteCommands = new DeleteCommandData {
                        Key = id
                    };
                    session.Advanced.Defer(deleteCommands);
                    session.SaveChanges();
                }
            });
        }
    }