using System; using DS.ImageCache; // TODO: Change the line below to match the namespace of the imported XMLWrapper proxy stub. // This version is using the generated proxy stub in Reference.cs using DS.WebServices.Calm.XMLWrapper; namespace DS.Examples.XMLWrapper { public class ImageCacheExample { public static int Main(string[] args) { string database = "Catalog"; string fileName = "MyImage.jpg"; string typeId = ImageCacheSettingsManager.DefaultId; int page = 1; string cacheDir = @"c:\ImageCache"; string subCategory = "Images"; ContentService webService = new ContentService(); try { // Get the settings for the supplied type ID. ImageCacheSettings settings = BrokerImageCache.SettingsManager.Get(typeId); if (settings == null) { throw new Exception("Invalid image type " + typeId); } // BrokerImageCache cache = new BrokerImageCache( ".", cacheDir, settings, subCategory, database, webService ); ImageCacheItem item = cache.GetItem(fileName, page); if (item != null) { byte[] data = item.Data; if (data != null) { string mimeType = item.MimeType; // TODO: do something with the image } } else { string msg = String.Format("Failed to get item {0} from cache.", new object[] { fileName }); throw new Exception(msg); } } catch (Exception ex) { string msg = String.Format("Failed to get item {0} from cache. {1}", new object[] { fileName, ex.Message }); throw new Exception(msg); } return 0; } } }