/// <summary> /// Copies the specified folder element. /// </summary> /// <param name="folderElement">The folder element.</param> /// <param name="newParentId">The parent id.</param> public static void Copy(FolderElement folderElement, int parentId) { FolderElement newElement = null; BlobInfo blobInfo = folderElement.GetBlobInfo(); BlobInfo blobInfoNew = (BlobInfo)blobInfo.Clone(); blobInfoNew.Uid = Guid.NewGuid(); BlobStorageProvider provider = BlobStorage.Providers[folderElement.BlobStorageProvider]; using (Stream srcStream = provider.ReadStream(blobInfo)) { using (Stream dstStream = provider.CreateStream(blobInfoNew)) { BlobStreamHelper.WriteToStream(dstStream, srcStream, 0, srcStream.Length); provider.CommitStream(blobInfoNew); } } newElement = (FolderElement)folderElement.Clone(); newElement.BlobUid = blobInfoNew.Uid; newElement.Save(); Move(newElement, parentId); }
/// <summary> /// Processes the specified element. /// </summary> /// <param name="element">The element.</param> public void Process(FolderElement element) { element.Card = cardName; BlobInfo blobInfo = element.GetBlobInfo(); if (blobInfo != null) { BlobStorageProvider provider = BlobStorage.Providers[blobInfo.Provider]; if (provider != null) { using (Stream stream = provider.ReadStream(blobInfo)) { try { Image img = Image.FromStream(stream); element.Properties["Width"].Value = img.Width; element.Properties["Height"].Value = img.Height; } catch (ArgumentException) { } } } } }