protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e) { var cArg = e.CommandArgument.ToString(); var param = new string[3]; var navigationData = new NavigationData(PortalId, "CategoryAdmin"); switch (e.CommandName.ToLower()) { case "entrydetail": SaveAll(); param[1] = "eid=" + cArg; param[2] = "catid=" + _openid; Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "return": param[1] = ""; param[2] = "catid=" + _openid; Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "search": var strXml = GenXmlFunctions.GetGenXml(rpSearch, "", ""); navigationData.XmlData = strXml; if (StoreSettings.Current.DebugModeFileOut) { strXml = "<root><sql><![CDATA[" + navigationData.Criteria + "]]></sql>" + strXml + "</root>"; var xmlDoc = new System.Xml.XmlDocument(); xmlDoc.LoadXml(strXml); xmlDoc.Save(PortalSettings.HomeDirectoryMapPath + "debug_search.xml"); } navigationData.Save(); Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "resetsearch": // clear cookie info navigationData.Delete(); param[2] = "catid=0"; Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "addnew": var strXml2 = GenXmlFunctions.GetGenXml(rpSearch, "", ""); navigationData.XmlData = strXml2; navigationData.Save(); var categoryData = CategoryUtils.GetCategoryData(-1, EditLanguage); if (!String.IsNullOrEmpty(Edittype) && Edittype.ToLower() == "group") { categoryData.GroupType = GenXmlFunctions.GetGenXmlValue(navigationData.XmlData, "genxml/dropdownlist/groupsel"); if (categoryData.GroupType == "") categoryData.GroupType = "cat"; var grpCtrl = new GrpCatController(Utils.GetCurrentCulture()); var grp = grpCtrl.GetGrpCategoryByRef(categoryData.GroupType); if (grp != null) categoryData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlparentcatid", grp.categoryid.ToString("")); categoryData.DataRecord.SetXmlProperty("genxml/checkbox/chkishidden", "False"); // don't hide property groups by default } categoryData.ParentItemId = _openid; categoryData.Save(); NBrightBuyUtils.RemoveModCachePortalWide(PortalId); param[2] = "catid=" + _openid; Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "delete": if (Utils.IsNumeric(cArg)) { ModCtrl.Delete(Convert.ToInt32(cArg)); } param[2] = "catid=" + _openid; Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "saveall": SaveAll(); NBrightBuyUtils.RemoveModCachePortalWide(PortalId); //clear any cache param[2] = "catid=" + _openid; Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "move": SaveAll(); if (Utils.IsNumeric(cArg)) { MoveRecord(Convert.ToInt32(cArg)); } param[2] = "catid=" + _openid; Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "open": param[1] = "catid=" + cArg; Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "close": var catData = CategoryUtils.GetCategoryData(_openid, EditLanguage); if (catData.DataRecord == null) param[1] = "catid=0"; else param[1] = "catid=" + catData.DataRecord.ParentItemId.ToString(""); Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "save": UpdateRecord(); param[1] = "eid=" + cArg; param[2] = "catid=" + _openid; Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "saveexit": UpdateRecord(); param[2] = "catid=" + _openid; Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; } }
private Dictionary<int, string> GetPropertyList(XmlNode xmlNod) { var displaylevels = 20; var parentref = ""; var prefix = ".."; var showhidden = "False"; var showarchived = "False"; var showempty = "True"; var showHidden = false; var showArchived = false; var catreflist = ""; var parentid = 0; var displaycount = "False"; var displayCount = false; var showEmpty = true; var groupref = ""; var filtermode = ""; List<int> validCatList = null; var modulekey = ""; var redirecttabid = ""; var tabid = ""; var lang = Utils.GetCurrentCulture(); if (xmlNod.Attributes != null) { if (xmlNod.Attributes["displaylevels"] != null) { if (Utils.IsNumeric(xmlNod.Attributes["displaylevels"].Value)) displaylevels = Convert.ToInt32(xmlNod.Attributes["displaylevels"].Value); } if (xmlNod.Attributes["parentref"] != null) parentref = xmlNod.Attributes["parentref"].Value; if (xmlNod.Attributes["showhidden"] != null) showhidden = xmlNod.Attributes["showhidden"].Value; if (xmlNod.Attributes["showarchived"] != null) showarchived = xmlNod.Attributes["showarchived"].Value; if (xmlNod.Attributes["showempty"] != null) showempty = xmlNod.Attributes["showempty"].Value; if (xmlNod.Attributes["displaycount"] != null) displaycount = xmlNod.Attributes["displaycount"].Value; if (xmlNod.Attributes["prefix"] != null) prefix = xmlNod.Attributes["prefix"].Value; if (xmlNod.Attributes["groupref"] != null) groupref = xmlNod.Attributes["groupref"].Value; if (xmlNod.Attributes["filtermode"] != null) filtermode = xmlNod.Attributes["filtermode"].Value; if (xmlNod.Attributes["modulekey"] != null) modulekey = xmlNod.Attributes["modulekey"].Value; if (xmlNod.Attributes["lang"] != null) lang = xmlNod.Attributes["lang"].Value; if (showhidden.ToLower() == "true") showHidden = true; if (showarchived.ToLower() == "true") showArchived = true; if (showempty.ToLower() == "false") showEmpty = false; if (displaycount.ToLower() == "true") displayCount = true; if (xmlNod.Attributes["catreflist"] != null) catreflist = xmlNod.Attributes["catreflist"].Value; var grpCatCtrl = new GrpCatController(lang); if (parentref != "") { var p = grpCatCtrl.GetGrpCategoryByRef(parentref); if (p != null) parentid = p.categoryid; } var catid = ""; if (filtermode != "") { var navigationData = new NavigationData(PortalSettings.Current.PortalId, modulekey); catid = Utils.RequestQueryStringParam(HttpContext.Current.Request, "catid"); if (String.IsNullOrEmpty(catid)) catid = navigationData.CategoryId; if (Utils.IsNumeric(catid)) { validCatList = GetCateoriesInProductList(Convert.ToInt32(catid)); } } } var rtnList = BuildPropertyList(displaylevels, showHidden, showArchived, parentid, catreflist, prefix, displayCount, showEmpty, groupref, ">", lang); if (validCatList != null) { var nonValid = new List<int>(); // we have a filter on the list, so remove any categories not in valid list. foreach (var k in rtnList) { if (!validCatList.Contains(k.Key)) nonValid.Add(k.Key); } foreach (var k in nonValid) { rtnList.Remove(k); } } return rtnList; }
protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e) { var cArg = e.CommandArgument.ToString(); var param = new string[3]; var navigationData = new NavigationData(PortalId, "CategoryAdmin"); switch (e.CommandName.ToLower()) { case "entrydetail": SaveAll(); param[1] = "eid=" + cArg; param[2] = "catid=" + _openid; Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "return": param[1] = ""; param[2] = "catid=" + _openid; Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "search": var strXml = GenXmlFunctions.GetGenXml(rpSearch, "", ""); navigationData.XmlData = strXml; if (StoreSettings.Current.DebugModeFileOut) { strXml = "<root><sql><![CDATA[" + navigationData.Criteria + "]]></sql>" + strXml + "</root>"; var xmlDoc = new System.Xml.XmlDocument(); xmlDoc.LoadXml(strXml); xmlDoc.Save(PortalSettings.HomeDirectoryMapPath + "debug_search.xml"); } navigationData.Save(); Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "resetsearch": // clear cookie info navigationData.Delete(); param[2] = "catid=0"; Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "addnew": var strXml2 = GenXmlFunctions.GetGenXml(rpSearch, "", ""); navigationData.XmlData = strXml2; navigationData.Save(); var categoryData = CategoryUtils.GetCategoryData(-1, EditLanguage); if (!String.IsNullOrEmpty(Edittype) && Edittype.ToLower() == "group") { categoryData.GroupType = GenXmlFunctions.GetGenXmlValue(navigationData.XmlData, "genxml/dropdownlist/groupsel"); if (categoryData.GroupType == "") categoryData.GroupType = "cat"; var grpCtrl = new GrpCatController(Utils.GetCurrentCulture()); var grp = grpCtrl.GetGrpCategoryByRef(categoryData.GroupType); if (grp != null) categoryData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlparentcatid", grp.categoryid.ToString("")); categoryData.DataRecord.SetXmlProperty("genxml/checkbox/chkishidden", "False"); // don't hide property groups by default } categoryData.ParentItemId = _openid; categoryData.Save(); NBrightBuyUtils.RemoveModCachePortalWide(PortalId); param[2] = "catid=" + _openid; Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "delete": if (Utils.IsNumeric(cArg)) { var catid = Convert.ToInt32(cArg); if (catid > 0) { var delCatData = CategoryUtils.GetCategoryData(catid, EditLanguage); if (delCatData.Exists && delCatData.GetDirectChildren().Count == 0) // only delete end leaf { var productidlist = new ArrayList(); foreach (var dc in delCatData.GetDirectArticles()) { productidlist.Add(dc.ParentItemId); } var parentCatList = new List<CategoryData>(); var loopCat = CategoryUtils.GetCategoryData(catid, EditLanguage); while (loopCat.Exists && loopCat.ParentItemId > 0) { loopCat = CategoryUtils.GetCategoryData(loopCat.ParentItemId, EditLanguage); parentCatList.Add(loopCat); } foreach (var pCat in parentCatList) { foreach (var prodxref in pCat.GetCascadeArticles()) { if (productidlist.Contains(prodxref.ParentItemId)) { // delete CATCASCADE record ModCtrl.Delete(prodxref.ItemID); } } } foreach (var dc in delCatData.GetDirectArticles()) { // delete CATXREF record ModCtrl.Delete(dc.ParentItemId); } // delete CATEGORY record (constrants remove LANG records.) ModCtrl.Delete(catid); } else { NBrightBuyUtils.SetNotfiyMessage(ModuleId, "onlyleafcat", NotifyCode.fail); } } } param[2] = "catid=" + _openid; Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "saveall": SaveAll(); NBrightBuyUtils.RemoveModCachePortalWide(PortalId); //clear any cache param[2] = "catid=" + _openid; Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "move": SaveAll(); if (Utils.IsNumeric(cArg)) { MoveRecord(Convert.ToInt32(cArg)); } param[2] = "catid=" + _openid; Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "open": param[1] = "catid=" + cArg; Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "close": var catData = CategoryUtils.GetCategoryData(_openid, EditLanguage); if (catData.DataRecord == null) param[1] = "catid=0"; else param[1] = "catid=" + catData.DataRecord.ParentItemId.ToString(""); Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "save": UpdateRecord(); param[1] = "eid=" + cArg; param[2] = "catid=" + _openid; Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; case "saveexit": UpdateRecord(); param[2] = "catid=" + _openid; Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true); break; } }