public void On(DocumentDescriptorCreated e) { _streamReadModelCollection.Insert(e, new StreamReadModel() { Id = GetNewId(), Handle = e.HandleInfo.Handle, EventType = HandleStreamEventTypes.DocumentCreated, }); //Now doc is not duplicated anymore, we should generate format added to document events. var doc = _documentDescriptorReadModel .AllUnsorted .Where(r => r.Id == e.AggregateId) .SingleOrDefault(); if (doc.Documents == null || !doc.Documents.Any()) { return; //no handle in this document descriptor } var allHandles = doc.Documents; var descriptor = _blobStore.GetDescriptor(e.BlobId); foreach (var handle in allHandles) { var handleReadMode = _documentWriter.FindOneById(handle); foreach (var format in doc.Formats) { _streamReadModelCollection.Insert(e, new StreamReadModel() { Id = GetNewId(), Handle = handle, Filename = descriptor.FileNameWithExtension, DocumentDescriptorId = (DocumentDescriptorId)e.AggregateId, FormatInfo = new FormatInfo() { BlobId = e.BlobId, DocumentFormat = format.Key, PipelineId = format.Value.PipelineId != PipelineId.Null ? format.Value.PipelineId : new PipelineId("original"), }, EventType = HandleStreamEventTypes.DocumentHasNewFormat, DocumentCustomData = handleReadMode.CustomData, }); } } }
public void On(InsertEvent e) { _collection.Insert(e, new MyReadModel() { Id = e.AggregateId, Text = e.Text }); }
public void On(SampleAggregateCreated e) { _collection.Insert(e, new SampleReadModel() { Id = e.AggregateId, IsInRebuild = base.IsRebuilding, Timestamp = DateTime.Now.Ticks }); }
public void On(DocumentDescriptorInitialized e) { var longCheckpoint = e.CheckpointToken; var document = new DocumentDescriptorReadModel(longCheckpoint, (DocumentDescriptorId)e.AggregateId, e.BlobId) { Hash = e.Hash }; _documents.Insert(e, document); }
public void InsertMethodTest() { TestEntity dummy = new TestEntity(); _fakeCollection.Insert(dummy).Returns(new BsonValue(1)); _fakeDbWrapper.Execute <TestEntity>(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <Func <ICollectionWrapper <TestEntity>, int> >()) .Returns(x => ((Func <ICollectionWrapper <TestEntity>, int>)x[2]).Invoke(_fakeCollection)); int result = _sut.Insert(dummy); Assert.AreEqual(result, 1); }
public void On(DocumentDeleted e) { _writer.Delete(e.Handle, e.CheckpointToken); _documentDeletedWrapper.Insert(e, new DocumentDeletedReadModel() { Id = e.Handle + "+" + e.DocumentDescriptorId + "+" + e.CheckpointToken, DeletionDate = e.CommitStamp, Handle = e.Handle, DocumentDescriptorId = e.DocumentDescriptorId }, false); }
public void On(SampleAggregateCreated e) { Console.WriteLine("Projected in thread {0} - {1}", Thread.CurrentThread.ManagedThreadId, Thread.CurrentThread.Name); Thread.Sleep(0); _collection.Insert(e, new SampleReadModel3() { Id = e.AggregateId, IsInRebuild = base.IsRebuilding, Timestamp = DateTime.Now.Ticks }); }