public bool DownloadImage(TaxonomyInfo taxonomy, Attribute attribute = null, ListOfValue lov = null) { bool success = false; if (!(String.IsNullOrEmpty(RemoteImageGuid) || String.IsNullOrEmpty(LocalDirectory)) && Directory.Exists(LocalDirectory)) { // get fully formed name string localName = GetLocalName(taxonomy, attribute, lov); LocalImageName = LocalDirectory + "\\" + localName; // download file success = FetchImage(HttpDir + _projectId + "/" + RemoteImageGuid + OriginalImageExtension, LocalImageName); } else { LocalImageName = ""; } return(success); }
private string GetLocalName(TaxonomyInfo taxonomy, Attribute attribute, ListOfValue lov) { // this is only a sketch var localName = new StringBuilder(); localName.Append(CleanName(taxonomy.TaxonomyData.NodeName)); if (attribute != null) { localName.Append("(" + CleanName(attribute.AttributeName) + ")"); } if (lov != null) { localName.Append("[" + CleanName(lov.Value) + "]"); } localName.Append(OriginalImageExtension); return(localName.ToString()); }
public bool UploadImage(string localName) { bool success = false; if (File.Exists(localName)) { RemoteImageGuid = Guid.NewGuid().ToString(); var newSku = new Sku { ID = new Guid(RemoteImageGuid), ItemID = RemoteImageGuid, ProjectID = NatalieTools.Instance.InstanceData.CurrentProject.ID, SkuType = Framework.Data.NatalieDb.Sku.ItemType.EnrichmentImage.ToString() }; newSku.EntityInfos.Add(new EntityInfo { EntityDatas = { new EntityData { Attribute = Attribute.GetAttributeFromName("Image FileName", true), Value = localName } } }); newSku.EntityInfos.Add(new EntityInfo { EntityDatas = { new EntityData { Attribute = Attribute.GetAttributeFromName("Image FileExtension", true), Value = Path.GetExtension(localName) } } }); ImageSku = newSku; StoreImage(localName); success = true; } return(success); }