public static Bitmap GetEmployeePhoto(Guid employeeId) { byte[] photoData = null; // Attempt to retrieve from cache ICacheManager cache = EnterpriseLibraryContainer.Current.GetInstance <ICacheManager>(); photoData = (byte[])cache[employeeId.ToString()]; // Retrieve from dataProvider if not in Cache and Online if (photoData == null && ConnectionManager.IsOnline) { EmployeeDataProvider dataProvider = new EmployeeDataProvider(); photoData = dataProvider.GetEmployeePhotoData(employeeId); cache.Add(employeeId.ToString(), photoData); } // No data found. if (photoData == null) { return(null); } // Convert bytes to Bitmap using (MemoryStream ms = new MemoryStream(photoData)) { return(new Bitmap(ms)); } }
public static EmployeesDataSet GetContactDetails() { EmployeesDataSet dsEmployees = null; // Attempt to retrieve from cache ICacheManager cache = EnterpriseLibraryContainer.Current.GetInstance <ICacheManager>(); dsEmployees = (EmployeesDataSet)cache[CACHE_KEY]; // Retrieve from dataProvider if not in Cache and Online if (dsEmployees == null && ConnectionManager.IsOnline) { EmployeeDataProvider dataProvider = new EmployeeDataProvider(); dsEmployees = dataProvider.GetEmployees(); // Expire in 2 days AbsoluteTime expiry = new AbsoluteTime(new TimeSpan(2, 0, 0, 0)); cache.Add( CACHE_KEY, dsEmployees, CacheItemPriority.High, null, new ICacheItemExpiration[] { expiry }); } return(dsEmployees); }
public static Bitmap GetEmployeePhoto(Guid employeeId) { byte[] photoData = null; // TODO: Add Caching of Photo //EmployeeDataProvider dataProvider = new EmployeeDataProvider(); //photoData = dataProvider.GetEmployeePhotoData(employeeId); ICacheManager cache = EnterpriseLibraryContainer.Current.GetInstance <ICacheManager>(); photoData = (byte[])cache[employeeId.ToString()]; // No data found. if (photoData == null) { EmployeeDataProvider dataProvider = new EmployeeDataProvider(); photoData = dataProvider.GetEmployeePhotoData(employeeId); cache.Add(employeeId.ToString(), photoData); } // Convert bytes to Bitmap using (MemoryStream ms = new MemoryStream(photoData)) { return(new Bitmap(ms)); } }
public static EmployeesDataSet GetContactDetails() { EmployeesDataSet dsEmployees = null; EmployeeDataProvider dataProvider = new EmployeeDataProvider(); dsEmployees = dataProvider.GetEmployees(); return(dsEmployees); }
public static EmployeesDataSet GetContactDetails() { EmployeesDataSet dsEmployees = null; // TODO: Add persistent caching with time-out EmployeeDataProvider dataProvider = new EmployeeDataProvider(); dsEmployees = dataProvider.GetEmployees(); return(dsEmployees); }
public static Bitmap GetEmployeePhoto(Guid employeeId) { byte[] photoData = null; // TODO: Add Caching of Photo EmployeeDataProvider dataProvider = new EmployeeDataProvider(); photoData = dataProvider.GetEmployeePhotoData(employeeId); // No data found. if (photoData == null) { return(null); } // Convert bytes to Bitmap using (MemoryStream ms = new MemoryStream(photoData)) { return(new Bitmap(ms)); } }
// TODO: PopulateCache & BeginBackgroundLoad private static void PopulateCache() { byte[] photoData = null; EmployeesDataSet dsEmployees = GetContactDetails(); if (dsEmployees == null) { return; } ICacheManager cache = EnterpriseLibraryContainer.Current.GetInstance <ICacheManager>(); foreach (EmployeesDataSet.EmployeesRow employee in dsEmployees.Employees) { if (!cache.Contains(employee.EmployeeID.ToString())) { EmployeeDataProvider dataProvider = new EmployeeDataProvider(); photoData = dataProvider.GetEmployeePhotoData(employee.EmployeeID); cache.Add(employee.EmployeeID.ToString(), photoData); } } }