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 int AddStaticPage(StaticPage page) { var id = SQLDataAccess.ExecuteScalar <int>(@"INSERT INTO [CMS].[StaticPage] ([PageName],[PageText],[SortOrder],[AddDate],[ModifyDate],[IndexAtSiteMap],[ParentID],[Enabled],[UrlPath]) VALUES " + " (@PageName,@PageText,@SortOrder,GETDATE(),GETDATE(),@IndexAtSiteMap,@ParentID,@Enabled, @UrlPath); SELECT scope_identity();", CommandType.Text, new[] { new SqlParameter("@PageName", page.PageName ?? ""), new SqlParameter("@PageText", page.PageText ?? ""), new SqlParameter("@SortOrder", page.SortOrder), new SqlParameter("@IndexAtSiteMap", page.IndexAtSiteMap), new SqlParameter("@Enabled", page.Enabled), page.ParentId == 0 ? new SqlParameter("@ParentID", DBNull.Value) : new SqlParameter("@ParentID", page.ParentId), new SqlParameter("@UrlPath", page.UrlPath) } ); // ---- Meta if (page.Meta != null) { if (!page.Meta.Title.IsNullOrEmpty() || !page.Meta.MetaKeywords.IsNullOrEmpty() || !page.Meta.MetaDescription.IsNullOrEmpty()) { page.Meta.ObjId = id; MetaInfoService.SetMeta(page.Meta); } } return(id); }
/// <summary> /// add category /// </summary> /// <param name="category"></param> /// <param name="updateCache"></param> /// <param name="setHierarchicallyEnabled"></param> /// <returns></returns> public static int AddCategory(Category category, bool updateCache, bool setHierarchicallyEnabled = true) { int id; using (var db = new SQLDataAccess()) { id = AddCategory(category, updateCache, db); if (id == -1) { return(-1); } // ---- Meta if (setHierarchicallyEnabled) { SetCategoryHierarchicallyEnabled(id); } if (category.Meta != null) { if (!category.Meta.Title.IsNullOrEmpty() || !category.Meta.MetaKeywords.IsNullOrEmpty() || !category.Meta.MetaDescription.IsNullOrEmpty() || !category.Meta.H1.IsNullOrEmpty()) { category.Meta.ObjId = id; MetaInfoService.SetMeta(category.Meta); } } } return(id); }
public static void UpdateStaticPage(StaticPage page) { SQLDataAccess.ExecuteNonQuery( @"UPDATE [CMS].[StaticPage] SET [PageName] = @PageName, [PageText] = @PageText, [SortOrder] = @SortOrder, [ModifyDate] = GETDATE(), [IndexAtSiteMap] = @IndexAtSiteMap, [ParentID] = @ParentID, [Enabled] = @Enabled, UrlPath=@UrlPath WHERE [StaticPageID] = @StaticPageID", CommandType.Text, new[] { new SqlParameter("@PageName", page.PageName), new SqlParameter("@PageText", page.PageText), new SqlParameter("@SortOrder", page.SortOrder), new SqlParameter("@IndexAtSiteMap", page.IndexAtSiteMap), new SqlParameter("@ParentID", page.ParentId == 0 ? DBNull.Value : (object)page.ParentId), new SqlParameter("@StaticPageID", page.StaticPageId), new SqlParameter("@Enabled", page.Enabled), new SqlParameter("@UrlPath", page.UrlPath) }); // ---- Meta if (page.Meta != null) { if (page.Meta.Title.IsNullOrEmpty() && page.Meta.MetaKeywords.IsNullOrEmpty() && page.Meta.MetaDescription.IsNullOrEmpty()) { if (MetaInfoService.IsMetaExist(page.ID, MetaType.StaticPage)) { MetaInfoService.DeleteMetaInfo(page.ID, MetaType.StaticPage); } } else { MetaInfoService.SetMeta(page.Meta); } } }
public static int AddBrand(Brand brand) { brand.BrandId = Convert.ToInt32(SQLDataAccess.ExecuteScalar( "[Catalog].[sp_AddBrand]", CommandType.StoredProcedure, new SqlParameter("@BrandName", brand.Name), new SqlParameter("@BrandDescription", brand.Description ?? (object)DBNull.Value), new SqlParameter("@BrandBriefDescription", brand.BriefDescription ?? (object)DBNull.Value), new SqlParameter("@Enabled", brand.Enabled), new SqlParameter("@SortOrder", brand.SortOrder), new SqlParameter("@CountryID", brand.CountryId == 0 ? (object)DBNull.Value : brand.CountryId), new SqlParameter("@UrlPath", brand.UrlPath), new SqlParameter("@BrandSiteUrl", brand.BrandSiteUrl.IsNotEmpty() ? brand.BrandSiteUrl : (object)DBNull.Value) )); if (brand.BrandId == 0) return 0; // ---- Meta if (brand.Meta != null) { brand.Meta.ObjId = brand.BrandId; MetaInfoService.SetMeta(brand.Meta); } return brand.BrandId; }
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); }
protected void LoadStaticPage() { var page = StaticPageService.GetStaticPage(StaticPageId); if (page == null) { spAuxFoundNotification.InnerHtml = Resource.Client_AuxView_AuxNotFound; return; } lblHead.Text = page.PageName; txtPageName.Text = page.PageName; chkEnabled.Checked = page.Enabled; chkIndexAtSitemap.Checked = page.IndexAtSiteMap; txtSynonym.Text = page.UrlPath; txtSortOrder.Text = page.SortOrder.ToString(); if (page.Parent != null) { lblParentName.Text = page.Parent.PageName; } hfParentId.Value = page.ParentId.ToString(); //meta //hfMetaId.Value = page.MetaId.ToString(); page.Meta = MetaInfoService.GetMetaInfo(StaticPageId, MetaType.StaticPage) ?? new MetaInfo(0, 0, MetaType.StaticPage, string.Empty, string.Empty, string.Empty); txtPageTitle.Text = page.Meta.Title; txtMetaKeywords.Text = page.Meta.MetaKeywords; txtMetaDescription.Text = page.Meta.MetaDescription; //ddlParentPage.SelectedValue = page.ParentPageId.ToString(); fckPageText.Text = page.PageText; popTree.ExceptId = StaticPageId; //popTree.UpdateTree(); }
/// <summary> /// update product /// </summary> /// <param name="product"></param> /// <param name="sentToLuceneIndex"></param> /// <param name="db"></param> /// <returns></returns> public static bool UpdateProduct(Product product, bool sentToLuceneIndex, SQLDataAccess db) { db.cmd.CommandText = "[Catalog].[sp_UpdateProductById]"; db.cmd.CommandType = CommandType.StoredProcedure; db.cmd.Parameters.Clear(); db.cmd.Parameters.AddWithValue("@ArtNo", product.ArtNo); db.cmd.Parameters.AddWithValue("@Name", product.Name); db.cmd.Parameters.AddWithValue("@ProductID", product.ProductId); db.cmd.Parameters.AddWithValue("@Ratio", product.Ratio); db.cmd.Parameters.AddWithValue("@Discount", product.Discount); db.cmd.Parameters.AddWithValue("@Weight", product.Weight); db.cmd.Parameters.AddWithValue("@Size", (product.Size ?? ((object)DBNull.Value))); db.cmd.Parameters.AddWithValue("@IsFreeShipping", product.IsFreeShipping); db.cmd.Parameters.AddWithValue("@ItemsSold", product.ItemsSold); db.cmd.Parameters.AddWithValue("@BriefDescription", (product.BriefDescription ?? ((object)DBNull.Value))); db.cmd.Parameters.AddWithValue("@Description", (product.Description ?? ((object)DBNull.Value))); db.cmd.Parameters.AddWithValue("@Enabled", product.Enabled); db.cmd.Parameters.AddWithValue("@OrderByRequest", product.OrderByRequest); db.cmd.Parameters.AddWithValue("@Recomended", product.Recomended); db.cmd.Parameters.AddWithValue("@New", product.New); db.cmd.Parameters.AddWithValue("@BestSeller", product.BestSeller); db.cmd.Parameters.AddWithValue("@OnSale", product.OnSale); db.cmd.Parameters.AddWithValue("@BrandID", product.BrandId == 0 ? ((object)DBNull.Value) : product.BrandId); db.cmd.Parameters.AddWithValue("@UrlPath", product.UrlPath); db.cmd.ExecuteNonQuery(); SetProductHierarchicallyEnabled(product.ProductId); if (product.Offers != null && product.Offers.Count > 0) { OfferService.UpdateOffersByProductId(product.ProductId, product.Offers); } if (product.Meta != null) { if (product.Meta.Title.IsNullOrEmpty() && product.Meta.MetaKeywords.IsNullOrEmpty() && product.Meta.MetaDescription.IsNullOrEmpty()) { if (MetaInfoService.IsMetaExist(product.ProductId, MetaType.Product)) { MetaInfoService.DeleteMetaInfo(product.ProductId, MetaType.Product); } } else { MetaInfoService.SetMeta(product.Meta); } } if (sentToLuceneIndex) { LuceneSearch.AddUpdateLuceneIndex(new SampleData(product.ProductId, product.ArtNo, product.Name)); } return(true); }
/// <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); }
/// <summary> /// for elbuz import /// </summary> /// <param name="strCategory"></param> /// <returns></returns> public static int SubParseAndCreateCategory(string strCategory) { int categoryId = -1; // // strCategory "[Техника >> Игровые приставки >> PlayStation]-10;[....]" (10 - порядок сортировки товара в категории(* необязательно)) // foreach (string strT in strCategory.Split(new[] { ';' })) { var st = strT; st = st.Replace("[", ""); st = st.Replace("]", ""); int parentId = 0; string[] temp = st.Split(new[] { ">>" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i <= temp.Length - 1; i++) { string name = temp[i].Trim(); if (!String.IsNullOrEmpty(name)) { var cat = GetChildCategoryIdByName(parentId, name); if (cat.HasValue) { parentId = cat.Value; categoryId = cat.Value; } else { parentId = AddCategory(new Category { Name = name, ParentCategoryId = parentId, //Picture = string.Empty, SortOrder = 0, Enabled = true, DisplayChildProducts = false, UrlPath = UrlService.GetAvailableValidUrl(0, ParamType.Category, name), DisplayStyle = DisplayStyle.List.ToString(), Meta = MetaInfoService.GetDefaultMetaInfo(MetaType.Category, name) }, false); } } if (i == temp.Length - 1) { categoryId = parentId; } } } return(categoryId); }
protected MetaInfo SetMeta(MetaInfo meta, string name = null, string categoryName = null, string brandName = null, string price = null, int page = 0) { var newMeta = meta != null ? (MetaInfo)meta.Clone() : MetaInfoService.GetDefaultMetaInfo(); // Creating new object to modify - keeping original Meta for cache if (page > 1) { newMeta.Title += Resource.Client_Catalog_PageIs + page; newMeta.H1 += Resource.Client_Catalog_PageIs + page; newMeta.MetaDescription += Resource.Client_Catalog_PageIs + page; } SetMetaTags(MetaInfoService.GetFormatedMetaInfo(newMeta, name, categoryName, brandName, price)); return(newMeta); }
public string UpdateProductMeta(int productID, MetaInfo meta) { if (!AuthorizeService.CheckAdminCookies()) { return(MsgAuthFailed); } Product p = ProductService.GetProduct(productID); if (p == null) { return(string.Format(MsgNotFound, productID)); } p.Meta = meta; MetaInfoService.SetMeta(p.Meta); return(string.Format(MsgUpdateSuccess, productID)); }
public static int InsertNewsCategory(NewsCategory newsCategory) { var id = SQLDataAccess.ExecuteScalar <int>("Insert into [Settings].[NewsCategory] ([Name],[SortOrder],[UrlPath]) values (@Name,@SortOrder,@UrlPath); Select SCOPE_IDENTITY ();", CommandType.Text, new SqlParameter("@Name", newsCategory.Name), new SqlParameter("@UrlPath", newsCategory.UrlPath), new SqlParameter("@SortOrder", newsCategory.SortOrder)); if (newsCategory.Meta != null) { if (!newsCategory.Meta.Title.IsNullOrEmpty() || !newsCategory.Meta.MetaKeywords.IsNullOrEmpty() || !newsCategory.Meta.MetaDescription.IsNullOrEmpty() || !newsCategory.Meta.H1.IsNullOrEmpty()) { newsCategory.Meta.ObjId = id; MetaInfoService.SetMeta(newsCategory.Meta); } } return(id); }
public static void UpdateBrand(Brand brand) { SQLDataAccess.ExecuteNonQuery( "[Catalog].[sp_UpdateBrandById]", CommandType.StoredProcedure, new SqlParameter("@BrandID", brand.BrandId), new SqlParameter("@BrandName", brand.Name), new SqlParameter("@BrandDescription", brand.Description ?? (object)DBNull.Value), new SqlParameter("@BrandBriefDescription", brand.BriefDescription ?? (object)DBNull.Value), new SqlParameter("@Enabled", brand.Enabled), new SqlParameter("@SortOrder", brand.SortOrder), new SqlParameter("@CountryID", brand.CountryId == 0 ? (object)DBNull.Value : brand.CountryId), new SqlParameter("@UrlPath", brand.UrlPath), new SqlParameter("@BrandSiteUrl", brand.BrandSiteUrl.IsNotEmpty() ? brand.BrandSiteUrl : (object)DBNull.Value) ); MetaInfoService.SetMeta(brand.Meta); }
private void LoadNewsById(int newsId) { NewsItem news = NewsService.GetNewsById(newsId); if (news == null) { MsgErr("News with this ID not exist"); return; } txtStringID.Text = news.UrlPath; txtDate.Text = news.AddingDate.ToShortDateString(); txtTime.Text = news.AddingDate.ToString("HH:mm"); txtTitle.Text = news.Title; if (news.Picture != null) { lblImage.Text = news.Picture.PhotoName; pnlImage.Visible = true; Image1.ImageUrl = FoldersHelper.GetPath(FolderType.News, news.Picture.PhotoName, true); Image1.ToolTip = news.Picture.PhotoName; } else { lblImage.Text = @"No picture"; pnlImage.Visible = false; } FCKTextToPublication.Text = news.TextToPublication; CKEditorControlAnnatation.Text = news.TextAnnotation; chkOnMainPage.Checked = news.ShowOnMainPage; //FCKTextToEmail.Text = news.TextToEmail; //hfMetaId.Text = news.MetaId.ToString(); news.Meta = MetaInfoService.GetMetaInfo(newsId, MetaType.News) ?? new MetaInfo(0, 0, MetaType.News, string.Empty, string.Empty, string.Empty, string.Empty); txtHeadTitle.Text = news.Meta.Title; txtH1.Text = news.Meta.H1; txtMetaKeys.Text = news.Meta.MetaKeywords; txtMetaDescription.Text = news.Meta.MetaDescription; dboNewsCategory.DataBind(); dboNewsCategory.SelectedValue = news.NewsCategoryID.ToString(CultureInfo.InvariantCulture); }
public static void UpdateNewsCategory(NewsCategory newsCategory) { SQLDataAccess.ExecuteNonQuery("Update [Settings].[NewsCategory] set [Name]=@name,[UrlPath] = @UrlPath , [SortOrder] = @SortOrder where NewsCategoryID = @NewsCategoryID", CommandType.Text, new SqlParameter("@NewsCategoryID", newsCategory.NewsCategoryID), new SqlParameter("@Name", newsCategory.Name), new SqlParameter("@UrlPath", newsCategory.UrlPath), new SqlParameter("@SortOrder", newsCategory.SortOrder)); if (newsCategory.Meta != null) { if (newsCategory.Meta.Title.IsNullOrEmpty() && newsCategory.Meta.MetaKeywords.IsNullOrEmpty() && newsCategory.Meta.MetaDescription.IsNullOrEmpty() && newsCategory.Meta.H1.IsNullOrEmpty()) { if (MetaInfoService.IsMetaExist(newsCategory.NewsCategoryID, MetaType.NewsCategory)) { MetaInfoService.DeleteMetaInfo(newsCategory.NewsCategoryID, MetaType.NewsCategory); } } else { MetaInfoService.SetMeta(newsCategory.Meta); } } }
public static void Update(string name, MetaInfo metaInfo) { var query = string.Empty; switch (metaInfo.Type) { case MetaType.Brand: query = "UPDATE Catalog.Brand SET BrandName=@name Where BrandID=@objId"; break; case MetaType.Category: query = "UPDATE [Catalog].[Category] SET [Name] = @name WHERE CategoryID = @objId"; break; case MetaType.News: query = "UPDATE [Settings].[News] SET [Title] = @name WHERE NewsID = @objId"; break; case MetaType.Product: query = "UPDATE [Catalog].[Product] SET [Name] = @name WHERE [ProductID] = @objId"; break; case MetaType.StaticPage: query = "UPDATE [CMS].[StaticPage] SET [PageName] = @name WHERE [StaticPageID] = @objId"; break; } SQLDataAccess.ExecuteNonQuery(query, CommandType.Text, new SqlParameter("@name", name), new SqlParameter("@objId", metaInfo.ObjId)); if (MetaType.Category == metaInfo.Type) { CategoryService.ClearCategoryCache(); } MetaInfoService.SetMeta(metaInfo); }
protected void SetMeta(MetaInfo meta, string name) { MetaInfo newMeta = meta != null?meta.DeepClone() : MetaInfoService.GetDefaultMetaInfo(); // Creating new object to modify - keeping original Meta for cache SetMetaTags(MetaInfoService.GetFormatedMetaInfo(newMeta, name)); }
private void LoadProduct(Product product) { SetMeta(GetPageTitle()); lProductName.Text = product.Name; lbIsProductActive.ForeColor = _product.Enabled ? System.Drawing.Color.FromArgb(2, 125, 194) : System.Drawing.Color.Red; lbIsProductActive.Visible = !AddingNewProduct; lbIsProductActive.Text = _product.Enabled ? Resource.Admin_m_Product_Active : Resource.Admin_Catalog_ProductDisabled; //btnAdd.Visible = !AddingNewProduct; if (product.ProductId != 0) { //btnAdd.OnClientClick = string.Format("window.location=\'Product.aspx?CategoryID={0}\';return false;", CategoryID > 0 ? CategoryID : 0); lblProductId.Text = product.ProductId.ToString(); txtStockNumber.Text = product.ArtNo; txtName.Text = product.Name; txtSynonym.Text = product.UrlPath; chkEnabled.Checked = product.Enabled; chkAllowPreOrder.Checked = product.AllowPreOrder; txtWeight.Text = product.Weight.ToString(); txtPopularityManually.Text = product.PopularityManually.ToString(); var temp = product.Size.Split('|'); if (temp.Length == 3) { txtSizeLength.Text = temp[0]; txtSizeWidth.Text = temp[1]; txtSizeHeight.Text = temp[2]; } else { txtSizeLength.Text = string.IsNullOrEmpty(product.Size) ? "0" : product.Size; } popUpBrand.SelectBrandId = product.BrandId; lBrand.Text = product.BrandId == 0 ? Resource.Admin_Product_NotSelected : product.Brand.Name; chkBestseller.Checked = product.BestSeller; chkRecommended.Checked = product.Recomended; chkNew.Checked = product.New; chkOnSale.Checked = product.OnSale; var flagEnabled = ProductService.GetCountOfCategoriesByProductId(product.ProductId) > 0; chkBestseller.Enabled = flagEnabled; chkRecommended.Enabled = flagEnabled; chkNew.Enabled = flagEnabled; chkOnSale.Enabled = flagEnabled; lblMarkersDisabled.Visible = !flagEnabled; txtShippingPrice.Text = product.ShippingPrice.ToString("#0.00") ?? "0"; txtUnit.Text = product.Unit; txtMaxAmount.Text = product.MaxAmount.ToString(); txtMinAmount.Text = product.MinAmount.ToString(); txtMultiplicity.Text = product.Multiplicity.ToString(); txtSalesNote.Text = product.SalesNote; txtGtin.Text = product.Gtin; txtGoogleProductCategory.Text = product.GoogleProductCategory; chbAdult.Checked = product.Adult; chbManufacturerWarranty.Checked = product.ManufacturerWarranty; txtDiscount.Text = product.Discount.ToString(); fckDescription.Text = product.Description; fckBriefDescription.Text = product.BriefDescription; productOffers.Offers = product.Offers; productOffers.HasMultiOffer = product.HasMultiOffer; productOffers.ProductID = ProductId; productOffers.ArtNo = product.ArtNo; var meta = MetaInfoService.GetMetaInfo(product.ProductId, MetaType.Product); if (meta == null) { _product.Meta = new MetaInfo(0, 0, MetaType.Product, string.Empty, string.Empty, string.Empty, string.Empty); chbDefaultMeta.Checked = true; } else { chbDefaultMeta.Checked = false; _product.Meta = meta; txtTitle.Text = _product.Meta.Title; txtMetaKeywords.Text = _product.Meta.MetaKeywords; txtMetaDescription.Text = _product.Meta.MetaDescription; txtH1.Text = _product.Meta.H1; } LoadCategoryTree(); } else { productOffers.HasMultiOffer = false; productOffers.ProductID = 0; } }
/// <summary> /// add product /// </summary> /// <param name="product"></param> /// <param name="sentToLuceneIndex"></param> /// <returns></returns> public static int AddProduct(Product product, bool sentToLuceneIndex) { if (SaasDataService.IsSaasEnabled && GetProductCountByOffer(6) >= SaasDataService.CurrentSaasData.ProductsCount) { return(0); } product.ProductId = Convert.ToInt32(SQLDataAccess.ExecuteScalar("[Catalog].[sp_AddProduct]", CommandType.StoredProcedure, new SqlParameter("@ArtNo", product.ArtNo), new SqlParameter("@Name", product.Name), new SqlParameter("@Ratio", product.Ratio), new SqlParameter("@Discount", product.Discount), new SqlParameter("@Weight", product.Weight), new SqlParameter("@Size", (product.Size ?? ((object)DBNull.Value))), new SqlParameter("@IsFreeShipping", product.IsFreeShipping), new SqlParameter("@ItemsSold", product.ItemsSold), new SqlParameter("@BriefDescription", (product.BriefDescription ?? ((object)DBNull.Value))), new SqlParameter("@Description", (product.Description ?? ((object)DBNull.Value))), new SqlParameter("@Enabled", product.Enabled), new SqlParameter("@Recomended", product.Recomended), new SqlParameter("@New", product.New), new SqlParameter("@BestSeller", product.BestSeller), new SqlParameter("@OnSale", product.OnSale), new SqlParameter("@OrderByRequest", product.OrderByRequest), new SqlParameter("@BrandID", (product.BrandId != 0 ? product.BrandId : (object)DBNull.Value)), new SqlParameter("@UrlPath", product.UrlPath) )); if (product.ProductId == 0) { return(0); } //by default in bd set ID if artNo is Null if (string.IsNullOrEmpty(product.ArtNo)) { product.ArtNo = product.ProductId.ToString(CultureInfo.InvariantCulture); } SetProductHierarchicallyEnabled(product.ProductId); // ---- Offers if (product.Offers != null && product.Offers.Count != 0) { OfferService.AddOffersToProduct(product.ProductId, product.Offers.Where(o => o.OfferId == 0)); } // ---- Meta if (product.Meta != null) { if (!product.Meta.Title.IsNullOrEmpty() || !product.Meta.MetaKeywords.IsNullOrEmpty() || !product.Meta.MetaDescription.IsNullOrEmpty()) { product.Meta.ObjId = product.ProductId; MetaInfoService.SetMeta(product.Meta); } } if (sentToLuceneIndex) { LuceneSearch.AddUpdateLuceneIndex(new SampleData(product.ProductId, product.ArtNo, product.Name)); } return(product.ProductId); }
private void WriteItem(ICsvWriter writer, Product product) { var meta = MetaInfoService.GetMetaInfo(product.ID, MetaType.Product) ?? new MetaInfo(0, 0, MetaType.Product, string.Empty, string.Empty, string.Empty, string.Empty); foreach (var item in _fieldMapping) { if (item == ProductFields.Sku) { writer.WriteField(product.ArtNo); } if (item == ProductFields.Name) { writer.WriteField(product.Name); } if (item == ProductFields.ParamSynonym) { writer.WriteField(product.UrlPath); } if (item == ProductFields.Category) { writer.WriteField((CategoryService.GetCategoryStringByProductId(product.ProductId, _columSeparator))); } if (item == ProductFields.Sorting) { writer.WriteField((CategoryService.GetCategoryStringByProductId(product.ProductId, _columSeparator, true))); } if (item == ProductFields.Enabled) { writer.WriteField(product.Enabled ? "+" : "-"); } if (!product.HasMultiOffer) { var offer = product.Offers.FirstOrDefault() ?? new Offer(); if (item == ProductFields.Price) { writer.WriteField(offer.Price.ToString("F2")); } if (item == ProductFields.PurchasePrice) { writer.WriteField(offer.SupplyPrice.ToString("F2")); } if (item == ProductFields.Amount) { writer.WriteField(offer.Amount.ToString(CultureInfo.InvariantCulture)); } if (item == ProductFields.MultiOffer) { writer.WriteField(string.Empty); } } else { if (item == ProductFields.Price) { writer.WriteField(string.Empty); } if (item == ProductFields.PurchasePrice) { writer.WriteField(string.Empty); } if (item == ProductFields.Amount) { writer.WriteField(string.Empty); } if (item == ProductFields.MultiOffer) { writer.WriteField(OfferService.OffersToString(product.Offers, _columSeparator, _propertySeparator)); } } if (item == ProductFields.Unit) { writer.WriteField(product.Unit); } if (item == ProductFields.ShippingPrice) { writer.WriteField(product.ShippingPrice.ToString("F2")); } if (item == ProductFields.Discount) { writer.WriteField(product.Discount.ToString("F2")); } if (item == ProductFields.Weight) { writer.WriteField(product.Weight.ToString("F2")); } if (item == ProductFields.Size) { writer.WriteField(product.Size.Replace("|", " x ")); } if (item == ProductFields.BriefDescription) { writer.WriteField(product.BriefDescription); } if (item == ProductFields.Description) { writer.WriteField(product.Description); } if (item == ProductFields.Title) { writer.WriteField(meta.Title); } if (item == ProductFields.H1) { writer.WriteField(meta.H1); } if (item == ProductFields.MetaKeywords) { writer.WriteField(meta.MetaKeywords); } if (item == ProductFields.MetaDescription) { writer.WriteField(meta.MetaDescription); } if (item == ProductFields.Markers) { writer.WriteField(ProductService.MarkersToString(product, _columSeparator)); } if (item == ProductFields.Photos) { writer.WriteField(PhotoService.PhotoToString(product.ProductPhotos, _columSeparator, _propertySeparator)); } if (item == ProductFields.Videos) { writer.WriteField(ProductVideoService.VideoToString(product.ProductVideos, _columSeparator)); } if (item == ProductFields.Properties) { writer.WriteField(PropertyService.PropertiesToString(product.ProductPropertyValues, _columSeparator, _propertySeparator)); } if (item == ProductFields.Producer) { writer.WriteField(BrandService.BrandToString(product.BrandId)); } if (item == ProductFields.OrderByRequest) { writer.WriteField(product.AllowPreOrder ? "+" : "-"); } if (item == ProductFields.SalesNotes) { writer.WriteField(product.SalesNote); } if (item == ProductFields.Related) { writer.WriteField(ProductService.LinkedProductToString(product.ProductId, RelatedType.Related, _columSeparator)); } if (item == ProductFields.Alternative) { writer.WriteField(ProductService.LinkedProductToString(product.ProductId, RelatedType.Alternative, _columSeparator)); } if (item == ProductFields.CustomOption) { writer.WriteField(CustomOptionsService.CustomOptionsToString(CustomOptionsService.GetCustomOptionsByProductId(product.ProductId))); } if (item == ProductFields.Gtin) { writer.WriteField(product.Gtin); } if (item == ProductFields.GoogleProductCategory) { writer.WriteField(product.GoogleProductCategory); } if (item == ProductFields.Adult) { writer.WriteField(product.Adult ? "+" : "-"); } if (item == ProductFields.ManufacturerWarranty) { writer.WriteField(product.ManufacturerWarranty ? "+" : "-"); } } writer.NextRecord(); }
private void LoadProduct(Product product) { lProductName.Text = product.Name; lbIsProductActive.ForeColor = _product.Enabled ? System.Drawing.Color.FromArgb(2, 125, 194) : System.Drawing.Color.Red; lbIsProductActive.Visible = !AddingNewProduct; lbIsProductActive.Text = _product.Enabled ? Resource.Admin_m_Product_Active : Resource.Admin_Catalog_ProductDisabled; btnSave.Text = AddingNewProduct ? Resource.Admin_Product_AddProduct : Resource.Admin_Product_Save; btnAdd.Visible = !AddingNewProduct; if (product.ProductId != 0) { btnAdd.OnClientClick = string.Format("window.location=\'Product.aspx?CategoryID={0}\';return false;", CategoryID > 0 ? CategoryID : 0); lblProductId.Text = product.ProductId.ToString(); txtStockNumber.Text = product.ArtNo; txtName.Text = product.Name; txtSynonym.Text = product.UrlPath; chkEnabled.Checked = product.Enabled; chkOrderByRequest.Checked = product.OrderByRequest; txtWeight.Text = product.Weight.ToString(); var temp = product.Size.Split('|'); if (temp.Length == 3) { txtSizeLength.Text = temp[0]; txtSizeWidth.Text = temp[1]; txtSizeHeight.Text = temp[2]; } else { txtSizeLength.Text = string.IsNullOrEmpty(product.Size) ? "0" : product.Size; } popUpBrand.SelectBrandId = product.BrandId; lBrand.Text = product.BrandId == 0 ? Resource.Admin_Product_NotSelected : product.Brand.Name; chkBestseller.Checked = product.BestSeller; chkRecommended.Checked = product.Recomended; chkNew.Checked = product.New; chkOnSale.Checked = product.OnSale; var flagEnabled = ProductService.GetCountOfCategoriesByProductId(product.ProductId) > 0; chkBestseller.Enabled = flagEnabled; chkRecommended.Enabled = flagEnabled; chkNew.Enabled = flagEnabled; chkOnSale.Enabled = flagEnabled; lblMarkersDisabled.Visible = !flagEnabled; txtSupplyPrice.Text = product.Offers.First().SupplyPrice.ToString("#0.00") ?? "0"; txtPrice.Text = product.Offers.First().Price.ToString("#0.00") ?? "0"; txtShippingPrice.Text = product.Offers.First().ShippingPrice.ToString("#0.00") ?? "0"; txtAmount.Text = product.Offers.First().Amount.ToString(); txtUnit.Text = product.Offers.First().Unit; txtMaxAmount.Text = product.Offers.First().MaxAmount.ToString(); txtMinAmount.Text = product.Offers.First().MinAmount.ToString(); txtMultiplicity.Text = product.Offers.First().Multiplicity.ToString(); txtDiscount.Text = product.Discount.ToString(); fckDescription.Text = product.Description; fckBriefDescription.Text = product.BriefDescription; var meta = MetaInfoService.GetMetaInfo(product.ProductId, MetaType.Product); if (meta == null) { _product.Meta = new MetaInfo(0, 0, MetaType.Product, string.Empty, string.Empty, string.Empty); chbDefaultMeta.Checked = true; } else { chbDefaultMeta.Checked = false; _product.Meta = meta; txtTitle.Text = _product.Meta.Title; txtMetaKeywords.Text = _product.Meta.MetaKeywords; txtMetaDescription.Text = _product.Meta.MetaDescription; } LoadCategoryTree(); } }
protected void LoadCategory(int catId) { try { Category category = CategoryService.GetCategory(catId); txtName.Text = category.Name; if (category.Picture != null && File.Exists(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Big, category.Picture.PhotoName))) { Label10.Text = category.Picture.PhotoName; pnlImage.Visible = true; Image1.ImageUrl = FoldersHelper.GetImageCategoryPath(CategoryImageType.Big, category.Picture.PhotoName, true); Image1.ToolTip = category.Picture.PhotoName; } else { Label10.Text = @"No picture"; pnlImage.Visible = false; } if (category.MiniPicture != null && File.Exists(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Small, category.MiniPicture.PhotoName))) { lblMiniPictureFileName.Text = category.MiniPicture.PhotoName; pnlMiniImage.Visible = true; imgMiniPicture.ImageUrl = FoldersHelper.GetImageCategoryPath(CategoryImageType.Small, category.MiniPicture.PhotoName, true); imgMiniPicture.ToolTip = category.MiniPicture.PhotoName; } else { lblMiniPictureFileName.Text = @"No picture"; pnlMiniImage.Visible = false; } if (category.Icon != null && File.Exists(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Icon, category.Icon.PhotoName))) { lblIconFileName.Text = category.Icon.PhotoName; pnlIcon.Visible = true; imgIcon.ImageUrl = FoldersHelper.GetImageCategoryPath(CategoryImageType.Icon, category.Icon.PhotoName, true); imgIcon.ToolTip = category.Icon.PhotoName; } else { lblIconFileName.Text = @"No picture"; pnlIcon.Visible = false; } SubCategoryDisplayStyle.SelectedValue = category.DisplayStyle; //ChkDisplayChildProducts.Checked = category.DisplayChildProducts; ChkDisplayBrands.Checked = category.DisplayBrandsInMenu; ChkDisplaySubCategories.Checked = category.DisplaySubCategoriesInMenu; fckDescription.Text = category.Description; fckBriefDescription.Text = category.BriefDescription; txtSortIndex.Text = category.SortOrder.ToString(); ChkEnableCategory.Checked = category.Enabled; txtSynonym.Text = category.UrlPath; ddlSorting.SelectedValue = ((int)category.Sorting).ToString(); var meta = MetaInfoService.GetMetaInfo(catId, MetaType.Category); if (meta == null) { category.Meta = new MetaInfo(0, 0, MetaType.Product, string.Empty, string.Empty, string.Empty, string.Empty); chbDefaultMeta.Checked = true; } else { chbDefaultMeta.Checked = false; category.Meta = meta; txtTitle.Text = category.Meta.Title; txtMetaKeywords.Text = category.Meta.MetaKeywords; txtMetaDescription.Text = category.Meta.MetaDescription; txtH1.Text = category.Meta.H1; } } catch (Exception ex) { MsgErr(ex.Message + " at LoadCategory"); Debug.LogError(ex, "at LoadCategory"); } }
public static void SaveProductsToCsv(string path, Encodings.EncodingsEnum encodeType, Separators.SeparatorsEnum delimetr, List <ProductFields.Fields> fieldMapping) { using (var writer = new CsvHelper.CsvWriter(new StreamWriter(path, false, Encodings.GetEncoding(encodeType)))) { writer.Configuration.Delimiter = Separators.GetCharSeparator(delimetr); //var fields = new List<string> { "SKU", "Name*", "ParamSynonym", "Category", "Enabled*", "Price*", "PurchasePrice*", "Amount*", "Unit", "Discount", "ShippingPrice", "Weight", "Size", "BriefDescription", "Description" }; //foreach (var item in fields) // writer.WriteField(item); foreach (var item in fieldMapping) { writer.WriteField(ProductFields.GetStringNameByEnum(item)); } writer.NextRecord(); var items = ProductService.GetProducts(); if (items == null) { return; } var regex = new Regex("^[0-9]+$"); for (int j = 0; j < items.Count; j++) { var product = items[j]; if (!ExportStatistic.IsRun) { return; } var offer = product.Offers.FirstOrDefault() ?? new Offer { Amount = 0, Price = 0, SupplyPrice = 0, Unit = "", ShippingPrice = 0 }; var meta = MetaInfoService.GetMetaInfo(product.ID, MetaType.Product) ?? new MetaInfo(0, 0, MetaType.Product, string.Empty, string.Empty, string.Empty); for (int i = 0; i < fieldMapping.Count; i++) { var item = fieldMapping[i]; //Changed by Evgeni to insert dotes if (item == ProductFields.Fields.Sku) { string art = product.ArtNo; //if (art.Contains("-") == false && art.Length > 7) // { // art = art.Insert(7, ".").Insert(4, ".").Insert(1, "."); // } // writer.WriteField(art); // writer.WriteField(product.ArtNo); } // if (item == ProductFields.Fields.Name) { writer.WriteField(product.Name); } if (item == ProductFields.Fields.ParamSynonym) { if (regex.IsMatch(product.UrlPath)) { writer.WriteField("IPD" + product.UrlPath); } else { writer.WriteField(product.UrlPath); } } if (item == ProductFields.Fields.Category) { writer.WriteField((GetCategoryStringByProductID(product.ProductId))); } if (item == ProductFields.Fields.Enabled) { writer.WriteField(product.Enabled ? "+" : "-"); } if (item == ProductFields.Fields.Price) { writer.WriteField(offer.Price.ToString("F2")); } if (item == ProductFields.Fields.PurchasePrice) { writer.WriteField(offer.SupplyPrice.ToString("F2")); } if (item == ProductFields.Fields.Amount) { writer.WriteField(offer.Amount.ToString()); } if (item == ProductFields.Fields.Unit) { writer.WriteField(offer.Unit); } if (item == ProductFields.Fields.ShippingPrice) { writer.WriteField(offer.ShippingPrice.ToString("F2")); } if (item == ProductFields.Fields.Discount) { writer.WriteField(product.Discount.ToString("F2")); } if (item == ProductFields.Fields.Weight) { writer.WriteField(product.Weight.ToString("F2")); } if (item == ProductFields.Fields.Size) { writer.WriteField(product.Size.Replace("|", " x ")); } if (item == ProductFields.Fields.BriefDescription) { writer.WriteField(product.BriefDescription); } if (item == ProductFields.Fields.Description) { writer.WriteField(product.Description); } if (item == ProductFields.Fields.Title) { writer.WriteField(meta.Title); } if (item == ProductFields.Fields.MetaKeywords) { writer.WriteField(meta.MetaKeywords); } if (item == ProductFields.Fields.MetaDescription) { writer.WriteField(meta.MetaDescription); } if (item == ProductFields.Fields.Markers) { writer.WriteField(MarkersToString(product)); } if (item == ProductFields.Fields.Photos) { writer.WriteField(PhotoToString(product.ProductPhotos)); } if (item == ProductFields.Fields.Properties) { writer.WriteField(PropertiesToString(product.ProductPropertyValues)); } //Changed by Evgeni if (item == ProductFields.Fields.EAN) { writer.WriteField(product.EAN); } if (item == ProductFields.Fields.SubBrandId) { writer.WriteField(product.SubBrandId); } // if (item == ProductFields.Fields.Producer) { var brand = BrandService.GetBrandById(product.BrandId); writer.WriteField(brand != null ? brand.Name : string.Empty); } if (item == ProductFields.Fields.OrderByRequest) { writer.WriteField(product.OrderByRequest ? "+" : "-"); } } writer.NextRecord(); ExportStatistic.RowPosition++; } } }