public async Task Process(BlobLoaded blob) { var fileId = NewId.NextGuid(); var blobInfo = blob.BlobInfo; Guid userId = blobInfo.UserId.HasValue ? blobInfo.UserId.Value : new Guid(blobInfo.Metadata[nameof(userId)].ToString()); Guid?parentId = blobInfo.Metadata != null?blobInfo.Metadata.ContainsKey(nameof(parentId)) ? (Guid?)new Guid(blobInfo.Metadata[nameof(parentId)].ToString()) : null : null; var file = new RecordsFile.Domain.RecordsFile(fileId, userId, parentId, blobInfo.FileName, FileStatus.Loaded, blobInfo.Bucket, blobInfo.Id, blobInfo.Length, blobInfo.MD5); await _session.Add(file); await _session.Commit(); await _bus.Publish <ProcessChemicalFile>(new { Id = fileId, Bucket = blobInfo.Bucket, BlobId = blobInfo.Id, UserId = userId }); }
public static void NodeShouldBeEquivalentTo(this GenericDictionaryAssertions <string, object> assertions, RecordsFile.Domain.RecordsFile file) { var expected = new Dictionary <string, object>() { { "_id", file.Id }, { "Type", "File" }, { "SubType", FileType.Records.ToString() }, { "Blob", new Dictionary <string, object>() { { "_id", file.BlobId }, { "Bucket", file.Bucket }, { "Length", file.Length }, { "Md5", file.Md5 } } }, { "OwnedBy", file.OwnedBy }, { "CreatedBy", file.CreatedBy }, { "CreatedDateTime", file.CreatedDateTime.UtcDateTime }, { "UpdatedBy", file.UpdatedBy }, { "UpdatedDateTime", file.UpdatedDateTime.UtcDateTime }, { "Name", file.FileName }, { "Status", file.Status.ToString() }, { "ParentId", file.ParentId }, { "Version", file.Version } }; //if (file.Status != FileStatus.Failed) if (assertions.Subject.ContainsKey("TotalRecords")) { expected.Add("TotalRecords", file.TotalRecords); } if (file.Images.Any()) { expected.Add("Images", file.Images.Select(i => new Dictionary <string, object> { { "_id", i.Id }, { "Bucket", file.Bucket }, { "Height", i.Height }, { "Width", i.Height }, { "MimeType", i.MimeType }, { "Scale", i.GetScale() } })); } assertions.Subject.ShouldAllBeEquivalentTo(expected); }