public void SetBlobData(Guid docId, Guid attrDefId, byte[] data, string fileName) { var blobData = GetBlobData(null, docId, attrDefId); if (blobData != null) { blobData.NewData = data; blobData.NewFileName = fileName; if (!BlobDatas.Contains(blobData)) { BlobDatas.Add(blobData); } } else { blobData = new StateBlobData(docId, attrDefId, null, String.Empty) { NewData = data, NewFileName = fileName }; BlobDatas.Add(blobData); } var process = Previous as RunProcess; if (process != null && process.ProcessContext != null) { var processBlobData = process.ProcessContext.BlobDatas != null ? process.ProcessContext.BlobDatas.FirstOrDefault( bd => bd.DocumentId == docId && bd.AttributeDefId == attrDefId) : null; if (processBlobData != null) { processBlobData.Data = data; processBlobData.FileName = fileName; } else { processBlobData = new BlobData { DocumentId = docId, AttributeDefId = attrDefId, Data = data, FileName = fileName }; if (process.ProcessContext.BlobDatas == null) { process.ProcessContext.BlobDatas = new List <BlobData>(); } process.ProcessContext.BlobDatas.Add(processBlobData); } } }
public StateBlobData GetImageData(IContext context, Guid docId, Guid attrDefId, int height, int width) { var data = BlobDatas.FirstOrDefault(d => d.DocumentId == docId && d.AttributeDefId == attrDefId); // TODO: Сделать ResizeImage! if (data != null) { return(data); } var parent = Previous; while (parent != null) { var formState = parent as BaseForm; if (formState != null) { data = formState.BlobDatas.FirstOrDefault(d => d.DocumentId == docId && d.AttributeDefId == attrDefId); if (data != null) { return(data); } } else if (parent is RunProcess && ((RunProcess)parent).ProcessContext.BlobDatas != null) { var blobData = ((RunProcess)parent).ProcessContext.BlobDatas.FirstOrDefault(bd => bd.DocumentId == docId && bd.AttributeDefId == attrDefId); if (blobData != null) { data = new StateBlobData(docId, attrDefId, blobData.Data, blobData.FileName); return(data); } } parent = parent.Previous; } if (context != null) { var dm = context.GetDocumentProxy(); var docBlob = dm.Proxy.GetDocBlob(docId, attrDefId); if (docBlob != null) { data = new StateBlobData(docId, attrDefId, docBlob.Data, docBlob.FileName); BlobDatas.Add(data); return(data); } } return(null); }
public void AddFile(string fileName, byte[] data) { var uploadedFile = new StateBlobData(Guid.Empty, Guid.Empty, data, fileName); UploadedFiles.Add(uploadedFile); }