public void Export(Property property, XElement propertyTag, Dictionary<int, ObjectTypes> dependantNodes) { if (property.Value != null && !string.IsNullOrWhiteSpace(property.Value.ToString())) { var items = new DampModel(property.Value.ToString()); var guidList = new List<Guid>(); if (items.Any) { foreach (var item in items) { var media = Services.MediaService.GetById(item.Id); if (media != null) { guidList.Add(Services.MediaService.GetById(item.Id).Key); if (!dependantNodes.ContainsKey(item.Id)) { dependantNodes.Add(item.Id, ObjectTypes.Media); } } } } propertyTag.Value = string.Join(",", guidList); } }
public void Export(Property property, XElement propertyTag, Dictionary <int, ObjectTypes> dependantNodes) { if (property.Value != null && !string.IsNullOrWhiteSpace(property.Value.ToString())) { var items = new DampModel(property.Value.ToString()); var guidList = new List <Guid>(); if (items.Any) { foreach (var item in items) { var media = Services.MediaService.GetById(item.Id); if (media != null) { guidList.Add(Services.MediaService.GetById(item.Id).Key); if (!dependantNodes.ContainsKey(item.Id)) { dependantNodes.Add(item.Id, ObjectTypes.Media); } } } } propertyTag.Value = string.Join(",", guidList); } }
/// <summary> /// Helper to convert a DAMP model into a standard MediaFile object /// </summary> /// <param name="dampModel">DAMP model</param> /// <returns>MediaFile instance</returns> private static MediaFile GetMediaFile(DampModel dampModel, string rootUrl) { if (dampModel != null && dampModel.Any) { var mediaFile = new MediaFile(); var dampModelItem = dampModel.First; mediaFile.Id = dampModelItem.Id; mediaFile.Name = dampModelItem.Name; mediaFile.Url = dampModelItem.Url; mediaFile.DomainWithUrl = rootUrl + dampModelItem.Url; mediaFile.DocumentTypeAlias = dampModelItem.Type; if (dampModelItem.Type == "Image") { int tempWidth; if (int.TryParse(dampModelItem.GetProperty("umbracoWidth"), out tempWidth)) { mediaFile.Width = tempWidth; } int tempHeight; if (int.TryParse(dampModelItem.GetProperty("umbracoHeight"), out tempHeight)) { mediaFile.Height = tempHeight; } } int tempSize; if (int.TryParse(dampModelItem.GetProperty("umbracoBytes"), out tempSize)) { mediaFile.Size = tempSize; } mediaFile.FileExtension = dampModelItem.GetProperty("umbracoExtension"); mediaFile.AltText = string.IsNullOrWhiteSpace(dampModelItem.GetProperty("altText")) ? dampModelItem.Alt : dampModelItem.GetProperty("altText"); return(mediaFile); } return(null); }
/// <summary> /// Helper to convert a DAMP model into a standard MediaFile object /// </summary> /// <param name="dampModel">DAMP model</param> /// <returns>MediaFile instance</returns> private static MediaFile GetMediaFile(DampModel dampModel, string rootUrl) { if (dampModel != null && dampModel.Any) { var mediaFile = new MediaFile(); var dampModelItem = dampModel.First; mediaFile.Id = dampModelItem.Id; mediaFile.Name = dampModelItem.Name; mediaFile.Url = dampModelItem.Url; mediaFile.DomainWithUrl = rootUrl + dampModelItem.Url; mediaFile.DocumentTypeAlias = dampModelItem.Type; if (dampModelItem.Type == "Image") { int tempWidth; if (int.TryParse(dampModelItem.GetProperty("umbracoWidth"), out tempWidth)) { mediaFile.Width = tempWidth; } int tempHeight; if (int.TryParse(dampModelItem.GetProperty("umbracoHeight"), out tempHeight)) { mediaFile.Height = tempHeight; } } int tempSize; if (int.TryParse(dampModelItem.GetProperty("umbracoBytes"), out tempSize)) { mediaFile.Size = tempSize; } mediaFile.FileExtension = dampModelItem.GetProperty("umbracoExtension"); mediaFile.AltText = string.IsNullOrWhiteSpace(dampModelItem.GetProperty("altText")) ? dampModelItem.Alt : dampModelItem.GetProperty("altText"); return mediaFile; } return null; }