public static bool UpdatePagePart(StaticBlock part) { StaticBlock sb = GetPagePart(part.StaticBlockId); var cacheName = CacheNames.GetStaticBlockCacheObjectName(sb.Key); if (CacheManager.Contains(cacheName)) { CacheManager.Remove(cacheName); } SQLDataAccess.ExecuteNonQuery( "UPDATE [CMS].[StaticBlock] SET [Key] = @Key, [InnerName] = @InnerName, [Content] = @Content, [Modified] = GETDATE(), Enabled =@Enabled WHERE [StaticBlockID] = @StaticBlockID", CommandType.Text, new[] { new SqlParameter("@StaticBlockID", part.StaticBlockId), new SqlParameter("@Key", part.Key), new SqlParameter("@InnerName", part.InnerName), new SqlParameter("@Content", part.Content), new SqlParameter("@Enabled", part.Enabled) } ); cacheName = CacheNames.GetStaticBlockCacheObjectName(part.Key); CacheManager.Insert(cacheName, part); return(true); }
protected void grid_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "DeleteDiscount") { DeleteOrderPriceDiscount(SQLDataHelper.GetInt(e.CommandArgument)); } if (e.CommandName == "AddRange") { SQLDataAccess.ExecuteNonQuery("INSERT INTO [Order].[OrderPriceDiscount] (PriceRange, PercentDiscount) VALUES (@Range, @Discount)", CommandType.Text, new SqlParameter("@Range", ((TextBox)grid.FooterRow.FindControl("txtNewPriceRange")).Text.TryParseDecimal()), new SqlParameter("@Discount", ((TextBox)grid.FooterRow.FindControl("txtNewPercentDiscount")).Text.TryParseDecimal()) ); grid.ShowFooter = false; grid.DataBind(); } if (e.CommandName == "CancelAdd") { grid.ShowFooter = false; } CacheManager.Remove(CacheNames.GetOrderPriceDiscountCacheObjectName()); } catch (Exception ex) { Debug.LogError(ex); } }
/// <summary> /// delete relationship between product and category /// </summary> /// <param name="productId"></param> /// <param name="catId"></param> /// <returns></returns> public static int DeleteProductLink(int productId, int catId) { SQLDataAccess.ExecuteNonQuery("[Catalog].[sp_RemoveProductFromCategory]", CommandType.StoredProcedure, new SqlParameter("@ProductID", productId), new SqlParameter("@CategoryID", catId)); CacheManager.Remove(CacheNames.GetCategoryCacheObjectName(catId)); return(0); }
private int CreateMenuItem() { ValidateData(); var mItem = new AdvMenuItem { MenuItemName = txtName.Text, MenuItemParentID = string.IsNullOrEmpty(hParent.Value) ? 0 : Convert.ToInt32(hParent.Value), MenuItemUrlPath = txtUrl.Text, Enabled = ckbEnabled.Checked, Blank = ckbBlank.Checked, SortOrder = Convert.ToInt32(txtSortOrder.Text), MenuItemUrlType = (EMenuItemUrlType)Convert.ToInt32(rblLinkType.SelectedValue), ShowMode = (EMenuItemShowMode)Convert.ToInt32(ddlShowMode.SelectedValue) }; if (_type == MenuService.EMenuType.Top) { CacheManager.RemoveByPattern(CacheNames.GetMainMenuCacheObjectName()); CacheManager.RemoveByPattern(CacheNames.GetMainMenuAuthCacheObjectName()); } else if (_type == MenuService.EMenuType.Bottom) { var cacheName = CacheNames.GetBottomMenuCacheObjectName(); if (CacheManager.Contains(cacheName)) { CacheManager.Remove(cacheName); } var cacheAuthName = CacheNames.GetBottomMenuAuthCacheObjectName(); if (CacheManager.Contains(cacheAuthName)) { CacheManager.Remove(cacheAuthName); } } mItem.MenuItemID = MenuService.AddMenuItem(mItem, _type); _menuItemId = mItem.MenuItemID; if (IconFileUpload.HasFile) { using (IconFileUpload.FileContent) { var tempName = PhotoService.AddPhoto(new Photo(0, _menuItemId, PhotoType.MenuIcon) { OriginName = IconFileUpload.FileName }); if (!string.IsNullOrWhiteSpace(tempName)) { IconFileUpload.SaveAs(FoldersHelper.GetPathAbsolut(FolderType.MenuIcons, tempName)); } } } else { mItem.MenuItemIcon = string.Empty; } MenuService.UpdateMenuItem(mItem, _type); return(mItem.MenuItemID); }
protected string GetHtml() { if (!AdvantShop.Customers.CustomerSession.CurrentCustomer.RegistredUser && CacheManager.Contains(CacheNames.GetMainMenuCacheObjectName())) { return(CacheManager.Get <string>(CacheNames.GetMainMenuCacheObjectName())); } if (AdvantShop.Customers.CustomerSession.CurrentCustomer.RegistredUser && CacheManager.Contains(CacheNames.GetMainMenuAuthCacheObjectName())) { return(CacheManager.Get <string>(CacheNames.GetMainMenuAuthCacheObjectName())); } string result = string.Empty; foreach (var mItem in MenuService.GetEnabledChildMenuItemsByParentId(0, MenuService.EMenuType.Top, AdvantShop.Customers.CustomerSession.CurrentCustomer.RegistredUser ? EMenuItemShowMode.Authorized : EMenuItemShowMode.NotAuthorized)) { result += string.Format("<a href=\"{0}\"{1}>{2}</a>\n", //mItem.MenuItemUrlType != EMenuItemUrlType.Custom // ? UrlService.GetLinkDB((ParamType)mItem.MenuItemUrlType, Convert.ToInt32(mItem.MenuItemUrlPath)) // : mItem.MenuItemUrlPath, mItem.MenuItemUrlPath, mItem.Blank ? " target=\"_blank\"" : string.Empty, mItem.MenuItemName); } if (!AdvantShop.Customers.CustomerSession.CurrentCustomer.RegistredUser) { CacheManager.Insert(CacheNames.GetMainMenuCacheObjectName(), result); } else if (AdvantShop.Customers.CustomerSession.CurrentCustomer.RegistredUser) { CacheManager.Insert(CacheNames.GetMainMenuAuthCacheObjectName(), result); } return(result); }
public static int InsertNews(NewsItem news) { CacheManager.Remove(CacheNames.GetNewsForMainPage()); var id = SQLDataAccess.ExecuteScalar <int>("[Settings].[sp_AddNews]", CommandType.StoredProcedure, new[] { new SqlParameter("@NewsCategoryID", news.NewsCategoryID), new SqlParameter("@AddingDate", news.AddingDate), new SqlParameter("@Title", news.Title), //new SqlParameter("@Picture", news.Picture), new SqlParameter("@TextToPublication", news.TextToPublication), new SqlParameter("@TextToEmail", news.TextToEmail), new SqlParameter("@TextAnnotation", news.TextAnnotation), new SqlParameter("@ShowOnMainPage", news.ShowOnMainPage), new SqlParameter("@UrlPath", news.UrlPath) }); // ---- Meta if (news.Meta != null) { if (!news.Meta.Title.IsNullOrEmpty() || !news.Meta.MetaKeywords.IsNullOrEmpty() || !news.Meta.MetaDescription.IsNullOrEmpty() || !news.Meta.H1.IsNullOrEmpty()) { news.Meta.ObjId = id; MetaInfoService.SetMeta(news.Meta); } } return(id); }
public static bool UpdateNews(NewsItem news) { CacheManager.Remove(CacheNames.GetNewsForMainPage()); SQLDataAccess.ExecuteNonQuery("[Settings].[sp_UpdateNews]", CommandType.StoredProcedure, new[] { new SqlParameter("@NewsID", news.NewsID), new SqlParameter("@NewsCategoryID", news.NewsCategoryID), new SqlParameter("@AddingDate", news.AddingDate), new SqlParameter("@Title", news.Title), //new SqlParameter("@Picture", news.Picture), new SqlParameter("@TextToPublication", news.TextToPublication), new SqlParameter("@TextToEmail", news.TextToEmail), new SqlParameter("@TextAnnotation", news.TextAnnotation), new SqlParameter("@ShowOnMainPage", news.ShowOnMainPage), new SqlParameter("@UrlPath", news.UrlPath) } ); if (news.Meta != null) { if (news.Meta.Title.IsNullOrEmpty() && news.Meta.MetaKeywords.IsNullOrEmpty() && news.Meta.MetaDescription.IsNullOrEmpty() && news.Meta.H1.IsNullOrEmpty()) { if (MetaInfoService.IsMetaExist(news.ID, MetaType.News)) { MetaInfoService.DeleteMetaInfo(news.ID, MetaType.News); } } else { MetaInfoService.SetMeta(news.Meta); } } return(true); }
public static List <Currency> GetAllCurrencies(bool fromCache) { if (fromCache) { string strCacheName = CacheNames.GetCurrenciesCacheObjectName(); List <Currency> res; if (CacheManager.Contains(strCacheName)) { res = CacheManager.Get <List <Currency> >(strCacheName); if (res != null) { return(res); } } res = GetAllCurrencies(); if (res != null) { CacheManager.Insert(strCacheName, res); } else { CacheManager.Remove(strCacheName); } return(res); } return(GetAllCurrencies()); }
private void DeleteOrderPriceDiscount(int id) { SQLDataAccess.ExecuteNonQuery("DELETE FROM [Order].[OrderPriceDiscount] WHERE (OrderPriceDiscountID = @OrderPriceDiscountID)", CommandType.Text, new SqlParameter("@OrderPriceDiscountID", id)); CacheManager.Remove(CacheNames.GetOrderPriceDiscountCacheObjectName()); }
protected void tree_TreeNodeCommand(object sender, CommandEventArgs e) { try { if (e.CommandName.StartsWith("DeleteMenuItem")) { int menuId = 0; if (!String.IsNullOrEmpty(tree.SelectedValue)) { menuId = Convert.ToInt32(tree.SelectedValue); } if (e.CommandName.Contains("#")) { menuId = Convert.ToInt32(e.CommandName.Substring(e.CommandName.IndexOf("#") + 1)); } if (menuId != 0) { foreach (var id in MenuService.GetAllChildIdByParent(menuId, MenuService.EMenuType.Top)) { MenuService.DeleteMenuItemById(id, MenuService.EMenuType.Top); } CacheManager.RemoveByPattern(CacheNames.GetMainMenuCacheObjectName()); } } } catch (Exception ex) { Debug.LogError(ex); } }
protected void Page_Load(object sender, EventArgs e) { if (!CustomerSession.CurrentCustomer.RegistredUser) { var cacheName = CacheNames.GetBottomMenuCacheObjectName(); if (CacheManager.Contains(cacheName)) { ltbottomMenu.Text = CacheManager.Get <string>(cacheName); } else { ltbottomMenu.Text = GetHtml(); CacheManager.Insert <string>(cacheName, ltbottomMenu.Text); } } else { var cacheName = CacheNames.GetBottomMenuAuthCacheObjectName(); if (CacheManager.Contains(cacheName)) { ltbottomMenu.Text = CacheManager.Get <string>(cacheName); } else { ltbottomMenu.Text = GetHtml(); CacheManager.Insert <string>(cacheName, ltbottomMenu.Text); } } }
/// <summary> /// get category by categoryId from cache or db if cache null /// </summary> /// <param name="categoryId"></param> /// <returns></returns> public static Category GetCategory(int categoryId) { Category res; string strCacheName = CacheNames.GetCategoryCacheObjectName(categoryId); if (CacheManager.Contains(strCacheName)) { res = CacheManager.Get <Category>(strCacheName); if (res != null) { return(res); } } // Return from db res = GetCategoryFromDbByCategoryId(categoryId); // Insert to cahce if (res != null) { CacheManager.Insert(strCacheName, res); } else { CacheManager.Remove(strCacheName); } return(res); }
public static void DeleteNews(int newsId) { CacheManager.Remove(CacheNames.GetNewsForMainPage()); DeleteNewsImage(newsId); SQLDataAccess.ExecuteNonQuery("DELETE FROM [Settings].[News] WHERE NewsID=@ID", CommandType.Text, new SqlParameter { ParameterName = "@ID", Value = newsId }); }
private void LoadData() { CacheManager.RemoveByPattern(CacheNames.GetDesignCacheObjectName("")); _currentDesigns = DesignService.GetDesigns(DesignType); _onLineDesigns = DesignService.GetAvaliableDesignsOnLine(DesignType); DataListDesigns.DataSource = (_onLineDesigns ?? new List <Theme>()).Union(_currentDesigns ?? new List <Theme>()).OrderBy(design => design.Name); DataListDesigns.DataBind(); }
public static void SetSqlSettingValue(string strName, string strValue, SQLDataAccess db) { SetSqlSettingValueFromDB(strName, strValue, db); // Add into cahce string strCacheName = CacheNames.GetCommonSettingsCacheObjectName(strName); CacheManager.Insert(strCacheName, strValue); }
private static List <RoleAction> GetCustomerRoleActionsByCustomerIdFromDB(Guid customerId) { List <RoleAction> actions = SQLDataAccess.ExecuteReadList <RoleAction>("Select RoleActionKey, Enabled From Customers.CustomerRoleAction Where CustomerID = @CustomerID", CommandType.Text, GetCustomerRoleActionFromReader, new SqlParameter("@CustomerID", customerId)); CacheManager.Insert(CacheNames.GetRoleActionsCacheObjectName(customerId.ToString()), actions); return(actions); }
public static bool RemoveSqlSetting(string strKey) { SQLDataAccess.ExecuteNonQuery("DELETE FROM [Settings].[Settings] WHERE [Name]=@Name", CommandType.Text, new SqlParameter("@Name", strKey)); // Clear cache object string strCacheName = CacheNames.GetCommonSettingsCacheObjectName(strKey); CacheManager.Remove(strCacheName); return(true); }
/// <summary> /// clear all categories in cache /// </summary> public static void ClearCategoryCache() { foreach (DictionaryEntry e in CacheManager.CacheObject) { if (SQLDataHelper.GetString(e.Key).StartsWith(CacheNames.GetCategoryCacheObjectPrefix())) { CacheManager.Remove(SQLDataHelper.GetString(e.Key)); } } }
public static bool RemoveSqlSetting(string strKey, string moduleName) { SQLDataAccess.ExecuteNonQuery( "DELETE FROM [Settings].[ModuleSettings] WHERE [Name] = @Name AND [ModuleName] = @ModuleName", CommandType.Text, new SqlParameter("@Name", strKey), new SqlParameter("@ModuleName", moduleName)); CacheManager.Remove(CacheNames.GetModuleSettingsCacheObjectName()); return(true); }
/// <summary> /// Save settings into DB /// </summary> /// <param name="strName"></param> /// <param name="strValue"></param> /// <remarks></remarks> public static bool SetSqlSettingValue(string strName, string strValue) { bool boolReult = SetSqlSettingValueFromDB(strName, strValue); // Add into cahce string strCacheName = CacheNames.GetCommonSettingsCacheObjectName(strName); CacheManager.Insert(strCacheName, strValue); return(boolReult); }
/// <summary> /// update category /// </summary> /// <param name="category"></param> /// <param name="updateCache">refresh cache</param> /// <returns></returns> public static bool UpdateCategory(Category category, bool updateCache) { SQLDataAccess.ExecuteNonQuery("[Catalog].[sp_UpdateCategory]", CommandType.StoredProcedure, new SqlParameter("@CategoryID", category.CategoryId), new SqlParameter("@Name", category.Name), new SqlParameter("@ParentCategory", category.ParentCategoryId), new SqlParameter("@Description", category.Description), new SqlParameter("@BriefDescription", category.BriefDescription), new SqlParameter("@Enabled", category.Enabled), new SqlParameter("@DisplayStyle", category.DisplayStyle), new SqlParameter("@displayChildProducts", category.DisplayChildProducts), new SqlParameter("@DisplayBrandsInMenu", category.DisplayBrandsInMenu), new SqlParameter("@DisplaySubCategoriesInMenu", category.DisplaySubCategoriesInMenu), new SqlParameter("@SortOrder", category.SortOrder), //new SqlParameter("@Picture", !string.IsNullOrEmpty(category.Picture) ? category.Picture : ((object)DBNull.Value)), //new SqlParameter("@MiniPicture", !string.IsNullOrEmpty(category.MiniPicture) ? category.MiniPicture : ((object)DBNull.Value)), new SqlParameter("@UrlPath", category.UrlPath), new SqlParameter("@Sorting", category.Sorting) ); if (category.Meta != null) { if (category.Meta.Title.IsNullOrEmpty() && category.Meta.MetaKeywords.IsNullOrEmpty() && category.Meta.MetaDescription.IsNullOrEmpty() && category.Meta.H1.IsNullOrEmpty()) { if (MetaInfoService.IsMetaExist(category.CategoryId, MetaType.Category)) { MetaInfoService.DeleteMetaInfo(category.CategoryId, MetaType.Category); } } else { MetaInfoService.SetMeta(category.Meta); } } SetCategoryHierarchicallyEnabled(category.CategoryId); // Work with cache if (updateCache) { CacheManager.Remove(CacheNames.GetCategoryCacheObjectName(category.CategoryId)); CacheManager.RemoveByPattern("MenuCatalog"); if (category.ParentCategoryId == 0) { var cacheName = CacheNames.GetBottomMenuCacheObjectName(); if (CacheManager.Contains(cacheName)) { CacheManager.Remove(cacheName); } } } return(true); }
public static void DeleteCustomerRoleActions(Guid customerId) { SQLDataAccess.ExecuteNonQuery("Delete From Customers.CustomerRoleAction Where CustomerID = @CustomerID", CommandType.Text, new SqlParameter("@CustomerID", customerId)); var cacheName = CacheNames.GetRoleActionsCacheObjectName(customerId.ToString()); if (CacheManager.Contains(cacheName)) { CacheManager.Remove(cacheName); } }
public static bool SetSettingValue(string strName, string strValue) { var boolReult = SetTemplateSetting(strName, strValue); // Add into cahce if (boolReult) { string strCacheName = CacheNames.GetTemplateSettingsCacheObjectName(SettingsDesign.Template, strName); CacheManager.Insert(strCacheName, strValue); } return(boolReult); }
protected void Page_PreRender(object sender, EventArgs e) { if (grid.UpdatedRow != null) { var discount = grid.UpdatedRow["PercentDiscount"].TryParseDecimal(); if (grid.UpdatedRow["PriceRange"].IsDecimal() && discount >= 0 && discount < 100) { SQLDataAccess.ExecuteNonQuery("UPDATE [Order].[OrderPriceDiscount] SET PriceRange = @PriceRange, PercentDiscount = @PercentDiscount WHERE (OrderPriceDiscountID = @OrderPriceDiscountID)", CommandType.Text, new SqlParameter("@PriceRange", grid.UpdatedRow["PriceRange"].TryParseDecimal()), new SqlParameter("@PercentDiscount", grid.UpdatedRow["PercentDiscount"].TryParseDecimal()), new SqlParameter("@OrderPriceDiscountID", grid.UpdatedRow["ID"])); } CacheManager.Remove(CacheNames.GetOrderPriceDiscountCacheObjectName()); } DataTable data = _paging.PageItems; while (data.Rows.Count < 1 & _paging.CurrentPageIndex > 1) { _paging.CurrentPageIndex -= 1; data = _paging.PageItems; } var clmn = new DataColumn("IsSelected", typeof(bool)) { DefaultValue = _inverseSelection }; data.Columns.Add(clmn); if (_selectionFilter != null && _selectionFilter.Values != null) { for (int i = 0; i <= data.Rows.Count - 1; i++) { Int32 intIndex = i; if (Array.Exists <string>(_selectionFilter.Values, (string c) => c == data.Rows[intIndex]["ID"].ToString())) { data.Rows[i]["IsSelected"] = !_inverseSelection; } } } if (data.Rows.Count < 1) { goToPage.Visible = false; } grid.DataSource = data; grid.DataBind(); pageNumberer.PageCount = _paging.PageCount; lblFound.Text = _paging.TotalRowsCount.ToString(); }
public bool SaveData() { if (!ValidateData()) { return(false); } SettingsNews.NewsPerPage = SQLDataHelper.GetInt(txtNewsPerPage.Text); SettingsNews.NewsMainPageCount = SQLDataHelper.GetInt(txtNewsMainPageCount.Text); CacheManager.Remove(CacheNames.GetNewsForMainPage()); LoadData(); return(true); }
public static List <Theme> GetDesigns(eDesign design) { string strCacheName = CacheNames.GetDesignCacheObjectName(design.ToString()); if (CacheManager.Contains(strCacheName)) { return(CacheManager.Get <List <Theme> >(strCacheName)); } var list = GetDesignsFromConfig(design); CacheManager.Insert(strCacheName, list); return(list); }
/// <summary> /// ƒействи¤ доступные данному пользователю /// </summary> /// <returns></returns> public static List <RoleAction> GetCustomerRoleActionsByCustomerId(Guid customerId) { var cacheName = CacheNames.GetRoleActionsCacheObjectName(customerId.ToString()); if (CacheManager.Contains(cacheName)) { var actions = CacheManager.Get <List <RoleAction> >(cacheName); if (actions != null) { return(actions); } } return(GetCustomerRoleActionsByCustomerIdFromDB(customerId)); }
/// <summary> /// 删除数据结构信息 /// </summary> /// <param name="cacheName">缓存名称标识</param> /// <param name="identity"></param> private void removeDataStructure(HashString cacheName, ref IndexIdentity identity) { ClientDataStructure dataStructure; Monitor.Enter(cacheNameLock); try { if (CacheNames.TryGetValue(cacheName, out dataStructure) && dataStructure.Identity.Equals(ref identity) == 0) { CacheNames.Remove(cacheName); } } finally { Monitor.Exit(cacheNameLock); } }
// get from cache by name of function if it in cache or from db public static List <NewsItem> GetNewsForMainPage() { List <NewsItem> list; if (CacheManager.Contains(CacheNames.GetNewsForMainPage())) { list = CacheManager.Get <List <NewsItem> >(CacheNames.GetNewsForMainPage()); } else { list = GetNewsForMainPageFromDb(); CacheManager.Insert(CacheNames.GetNewsForMainPage(), list); } return(list); }
/// <summary> /// delete category and photo of category /// </summary> /// <param name="categoryId"></param> public static void DeleteCategoryAndPhotos(int categoryId) { foreach (var id in DeleteCategory(categoryId, true)) { PhotoService.DeletePhotos(id, PhotoType.CategoryBig); PhotoService.DeletePhotos(id, PhotoType.CategorySmall); } var cacheName = CacheNames.GetBottomMenuCacheObjectName(); if (CacheManager.Contains(cacheName)) { CacheManager.Remove(cacheName); } }