public Task <List <Navigation> > GetStoreActiveNavigationsAsync(int storeId) { SetCache(); string url = string.Format("http://{0}/api/{1}/GetStoreActiveNavigationsAsync?storeId={2}", WebServiceAddress, ApiControllerName, storeId); HttpRequestHelper.CacheMinute = ProjectAppSettings.GetWebConfigInt("RequestHelperCacheLongMinute", 600); return(HttpRequestHelper.GetUrlResultsAsync <Navigation>(url)); }
public static EmailAccount GetAdminEmailAccount() { var emailAccount = new EmailAccount(); emailAccount.Username = ProjectAppSettings.GetWebConfigString("AdminEmailAccount_Username"); emailAccount.Email = ProjectAppSettings.GetWebConfigString("AdminEmailAccount_Email"); emailAccount.DisplayName = ProjectAppSettings.GetWebConfigString("AdminEmailAccount_DisplayName"); emailAccount.Password = ProjectAppSettings.GetWebConfigString("AdminEmailAccount_Password"); emailAccount.Host = ProjectAppSettings.GetWebConfigString("AdminEmailAccount_Host"); emailAccount.Port = ProjectAppSettings.GetWebConfigInt("AdminEmailAccount_Port"); emailAccount.EnableSsl = ProjectAppSettings.GetWebConfigBool("AdminEmailAccount_EnableSsl"); emailAccount.UseDefaultCredentials = ProjectAppSettings.GetWebConfigBool("AdminEmailAccount_UseDefaultCredentials"); return(emailAccount); }
protected List<Setting> GetStoreSettings() { String key = String.Format("GetStoreSettingsFromCacheAsync-{0}", StoreId); _settingStoreCache.IsCacheEnable = true; List<Setting> items = null; _settingStoreCache.TryGet(key, out items); if (items == null) { var itemsAsyn = SettingService.GetStoreSettingsFromCache(StoreId); items = itemsAsyn; _settingStoreCache.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("Setting_CacheAbsoluteExpiration_Minute", 10))); } return items; }
public List <Setting> GetStoreSettingsFromCache(int storeid) { String key = String.Format("GetStoreSettingsFromCache-{0}", storeid); _settingStoreCache.IsCacheEnable = this.IsCacheEnable; List <Setting> items = null; _settingStoreCache.TryGet(key, out items); if (items == null) { items = GetStoreSettings(storeid).Where(r => r.State).OrderBy(r => r.Ordering).ToList(); _settingStoreCache.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("Setting_CacheAbsoluteExpiration_Minute", 10))); } return(items); }
public ActionResult AdminSearch(String adminsearchkey, int page = 1) { if (String.IsNullOrEmpty(adminsearchkey)) { return(View(new PagedList <BaseEntity>(new List <BaseEntity>(), page - 1, 20, 0))); } ViewBag.SearchKey = adminsearchkey; adminsearchkey = adminsearchkey.Trim().ToLower(); int storeId = this.LoginStore.Id; String key = String.Format("SearchEntireStore-{0}-{1}", storeId, adminsearchkey); List <BaseEntity> resultList = null; StoreSearchCache.TryGet(key, out resultList); if (resultList == null) { resultList = SearchEntireStoreAsync(adminsearchkey, storeId).Result; StoreSearchCache.Set(key, resultList, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("SearchEntireStore_Minute", 10))); } var returnSearchModel = new PagedList <BaseEntity>(resultList, page - 1, 20, resultList.Count); return(View(returnSearchModel)); }
public StoreUser GetStoreUserByUserId(int userId) { String key = String.Format("GetStoreUserByUserId-{0}", userId); StoreUser item = null; StoreUserCache.TryGet(key, out item); if (item == null) { item = this.FindBy(r => r.UserId == userId).FirstOrDefault(); // item = this.GetSingleIncluding(userId, r => r.UserProfile); //var res = from s in this.StoreDbContext.StoreUsers // join u in this.StoreDbContext.UserProfiles on s.UserId equals u.UserId // where s.UserId == userId // select s; // item = res.FirstOrDefault(); StoreUserCache.Set(key, item, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("MainMenuNavigation_CacheAbsoluteExpiration_Minute", 10))); } return(item); }
public StorePagedList <FileManager> GetImagesByStoreId(int storeId, int page, int pageSize) { String key = String.Format("StoreFileManager-{0}", storeId); StorePagedList <FileManager> items = null; StorePagedListFileManagerCache.TryGet(key, out items); if (items == null) { var images = FindBy(r => r.StoreId == storeId).ToList(); items = new StorePagedList <FileManager>(images.Skip((page - 1) * pageSize).Take(pageSize).ToList(), page, pageSize, images.Count()); StorePagedListFileManagerCache.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("FileManager_CacheAbsoluteExpiration_Minute", 10))); } return(items); }
public StorePagedList <ProductCategory> GetProductCategoryWithContents(int categoryId, int page, int pageSize = 25) { String key = String.Format("GetProductCategoryWithContents-{0}-{1}", categoryId, page); StorePagedList <ProductCategory> items = null; PagingProductCategoryCache.TryGet(key, out items); if (items == null) { IQueryable <ProductCategory> cats = StoreDbContext.ProductCategories.Where(r => r.Id == categoryId && r.Products.Any()) .Include( r => r.Products.Select( r1 => r1.ProductFiles.Select(m => m.FileManager))) .OrderByDescending(r => r.Ordering); var c = cats.ToList(); items = new StorePagedList <ProductCategory>(c.Skip((page - 1) * pageSize).Take(pageSize).ToList(), page, c.Count()); PagingProductCategoryCache.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("ProductCategories_CacheAbsoluteExpiration_Minute", 10))); } return(items); }
public List <ProductCategory> GetProductCategoriesByStoreIdFromCache(int storeId, string type) { String key = String.Format("GetProductCategoriesByStoreIdFromCache-{0}-{1}", storeId, type); List <ProductCategory> items = null; ProductCategoryCache.TryGet(key, out items); if (items == null) { var cats = this.FindBy(r => r.StoreId == storeId && r.CategoryType.Equals(type, StringComparison.InvariantCultureIgnoreCase)) .OrderBy(r => r.Ordering) .Include(r => r.Products.Select(r1 => r1.ProductFiles.Select(m => m.FileManager))); items = cats.ToList(); foreach (var category in items) { foreach (var ccc in category.Products) { ccc.Description = ""; // GeneralHelper.GetDescription(ccc.Description, 200); } } ProductCategoryCache.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("ProductCategories_CacheAbsoluteExpiration_Minute", 10))); } return(items); }
public List <FileManager> GetFilesByStoreIdFromCache(int storeId) { String key = String.Format("StoreFileManager-{0}", storeId); List <FileManager> items = null; StoreFileManagerCache.TryGet(key, out items); if (items == null) { items = GetFilesByStoreId(storeId); StoreFileManagerCache.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("FileManager_CacheAbsoluteExpiration_Minute", 10))); } return(items); }
public Store GetStore(String domainName) { String key = String.Format("GetStoreDomain-{0}", domainName); Store site = null; StoreCache.TryGet(key, out site); if (site == null) { site = this.GetStoreByDomain(domainName); if (site != null) { string layout = String.Format("~/Views/Shared/Layouts/{0}.cshtml", !String.IsNullOrEmpty((String)site.Layout) ? (String)site.Layout : "_Layout1"); var isFileExist = File.Exists(System.Web.HttpContext.Current.Server.MapPath(layout)); _defaultlayout = String.Format(_defaultlayout, ProjectAppSettings.GetWebConfigString("DefaultLayout", "_Layout1")); if (!isFileExist) { Logger.Info(String.Format("Layout is not found.Default Layout {0} is used.Site Domain is {1} ", _defaultlayout, site.Domain)); } String selectedLayout = isFileExist ? layout : _defaultlayout; site.Layout = selectedLayout; StoreCache.Set(key, site, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("TooMuchTime_CacheAbsoluteExpiration_Minute", 100000))); } } return(site); }
public List <Store> GetAllStores() { String key = String.Format("GetAllStores"); List <Store> sites = null; AllStoreCache.TryGet(key, out sites); if (sites == null) { sites = GetAll().ToList(); StoreCache.Set(key, sites, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("TooMuchTime_CacheAbsoluteExpiration_Minute", 100000))); } return(sites); }
public Store GetStore(int id) { String key = String.Format("GetStore-{0}", id); Store site = null; StoreCache.TryGet(key, out site); if (site == null) { site = GetSingle(id); if (site != null) { StoreCache.Set(key, site, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("TooMuchTime_CacheAbsoluteExpiration_Minute", 100000))); } } return(site); }
public List <Product> GetProductByTypeAndCategoryIdFromCache(int storeId, string typeName, int categoryId) { String key = String.Format("GetProductByTypeAndCategoryIdFromCache-{0}-{1}-{2}", storeId, typeName, categoryId); List <Product> items = null; ProductCache.TryGet(key, out items); if (items == null) { items = GetProductByTypeAndCategoryId(storeId, typeName, categoryId); ProductCache.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("Products_CacheAbsoluteExpiration_Minute", 10))); } return(items); }
public StorePagedList <Product> GetProductsCategoryId(int storeId, int?categoryId, string typeName, bool?isActive, int page, int pageSize) { String key = String.Format("GetContentsCategoryId-{0}-{1}-{2}-{3}-{4}-{5}", storeId, typeName, categoryId, isActive.HasValue ? isActive.Value.ToStr() : "", page, pageSize); StorePagedList <Product> items = null; ProductCacheStorePagedList.TryGet(key, out items); if (items == null) { var returnList = this.GetAllIncluding(r => r.ProductFiles.Select(r1 => r1.FileManager)).Where(r2 => r2.StoreId == storeId && r2.Type.Equals(typeName, StringComparison.InvariantCultureIgnoreCase)); if (categoryId.HasValue) { returnList = returnList.Where(r => r.ProductCategoryId == categoryId.Value); } if (isActive.HasValue) { returnList = returnList.Where(r => r.State == isActive); } var cat = returnList.OrderByDescending(r => r.Id).ToList(); items = new StorePagedList <Product>(cat.Skip((page - 1) * pageSize).Take(pageSize).ToList(), page, pageSize, cat.Count()); // items = new PagedList<Content>(cat, page, cat.Count()); // items = (PagedList<Content>) cat.ToPagedList(page, pageSize); ProductCacheStorePagedList.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("Products_CacheAbsoluteExpiration_Minute", 10))); } return(items); }
public List <Navigation> GetStoreActiveNavigations(int storeId) { String key = String.Format("Navigation-{0}", storeId); List <Navigation> items = null; NavigationsCache.TryGet(key, out items); if (items == null) { items = GetStoreNavigations(storeId).Where(r => r.State).ToList(); NavigationsCache.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("MainMenuNavigation_CacheAbsoluteExpiration_Minute", 10))); } return(items); }