public const int FileExpirationTime = 60; // minutes public override string GetResourceUrl(ASPxWebControlBase control, byte[] content, string mimeType, string contentDisposition) { string fileExtension = ""; var a = control.NamingContainer.BindingContainer; if (mimeType.StartsWith("image/")) { fileExtension = "." + mimeType.Substring("image/".Length); } string fileName = control.Attributes["data-key"] + fileExtension; string physicalPath = HttpContext.Current.Server.MapPath(string.Format("~/{0}/", StaticCacheFolderName)) + fileName; if (File.Exists(physicalPath) && DateTime.Now - File.GetCreationTime(physicalPath) > TimeSpan.FromMinutes(FileExpirationTime)) { File.Delete(physicalPath);// an image is refreshed every hour } if (!File.Exists(physicalPath)) { using (FileStream stream = new FileStream(physicalPath, FileMode.OpenOrCreate)) stream.Write(content, 0, content.Length); } return(String.Format("{0}/{1}", StaticCacheFolderName, fileName)); }
/* GetResourceKey * 1) the mime type is saved as a file's extension for further * use within the GetResourceData method. * 2) received key is used to generate the image url for further * use within the StoreResourceData, GetResourceData */ public override string GetResourceKey(ASPxWebControlBase control, byte[] content, string mimeType) { string fileExtension = ""; if (mimeType.StartsWith("image/")) { fileExtension = "." + mimeType.Substring("image/".Length); } return(Guid.NewGuid().ToString() + fileExtension); }
public static void _ResetControlHierarchy(this ASPxWebControlBase source) { ASPxWebControlBaseMembersRepository.ResetControlHierarchy.Invoke(source); }
public override void StoreResourceData(ASPxWebControlBase control, string key, BinaryStorageData data) { ClearFileCacheIfNeeded(GetFolderPath()); using (FileStream stream = new FileStream(GetFilePath(key), FileMode.OpenOrCreate)) stream.Write(data.Content, 0, data.Content.Length); }
public override void StoreResourceData(ASPxWebControlBase control, string key, BinaryStorageData data) { HttpContext.Current.Cache.Add(key, data, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(1), CacheItemPriority.NotRemovable, null); }
public override string GetResourceKey(ASPxWebControlBase control, byte[] content, string mimeType) { int pos = control.ID.LastIndexOf("_"); return control.ID.Substring(pos + 1); }
public override bool CanStoreData(ASPxWebControlBase control) { return HttpContext.Current.Cache != null; }
public override bool CanStoreData(ASPxWebControlBase control) { return(HttpContext.Current.Cache != null); }
public override string GetResourceKey(ASPxWebControlBase control, byte[] content, string mimeType) { int pos = control.ID.LastIndexOf("_"); return(control.ID.Substring(pos + 1)); }