public void Initialize(SmartObjectContext context) { this._ctx = context; this._sampleImagesPath = CommonHelper.MapPath("~/content/samples/"); this._sampleDownloadsPath = CommonHelper.MapPath("~/content/samples/"); }
/// <remarks> /// Lazy storing... fired on app shut down. Note that items with CacheItemPriority.NotRemovable are not removed when the cache is emptied. /// We're beyond infrastructure and cannot use IOC objects here. It would lead to ComponentNotRegisteredException from autofac. /// </remarks> private static void OnDataRemoved(string key, object value, CacheItemRemovedReason reason) { try { if (key == Key) { var cacheData = value as List<WebApiUserCacheData>; if (cacheData != null) { var dataToStore = cacheData.Where(x => x.LastRequest.HasValue && x.IsValid); if (dataToStore.Count() > 0) { if (DataSettings.Current.IsValid()) { var dbContext = new SmartObjectContext(DataSettings.Current.DataConnectionString); foreach (var user in dataToStore) { try { dbContext.Execute("Update GenericAttribute Set Value = {1} Where Id = {0}", user.GenericAttributeId, user.ToString()); } catch (Exception exc) { exc.Dump(); } } } } } } } catch (Exception exc) { exc.Dump(); } }