예제 #1
0
 private bool bulkBuyOn(ProductData prodData, NBrightInfo qtypromo)
 {
     if (qtypromo != null && prodData != null)
     {
         if (!qtypromo.GetXmlPropertyBool("genxml/checkbox/disabled"))
         {
             var typeselect  = qtypromo.GetXmlProperty("genxml/radiobuttonlist/typeselect");
             var catgroupid  = qtypromo.GetXmlProperty("genxml/dropdownlist/catgroupid");
             var propgroupid = qtypromo.GetXmlProperty("genxml/dropdownlist/propgroupid");
             var groupid     = catgroupid;
             if (typeselect == "prop")
             {
                 groupid = propgroupid;
             }
             var gCat = CategoryUtils.GetCategoryData(groupid, Utils.GetCurrentCulture());
             if (gCat != null)
             {
                 if (prodData.HasProperty(gCat.CategoryRef) || prodData.IsInCategory(gCat.CategoryRef))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
예제 #2
0
        public static string RemoveGroupProductPromo(int portalId, int promoid)
        {
            var objCtrl = new NBrightBuyController();
            var p       = objCtrl.GetData(promoid);

            var typeselect  = p.GetXmlProperty("genxml/radiobuttonlist/typeselect");
            var catgroupid  = p.GetXmlProperty("genxml/dropdownlist/catgroupid");
            var propgroupid = p.GetXmlProperty("genxml/dropdownlist/propgroupid");

            CategoryData gCat;
            var          groupid = catgroupid;

            if (typeselect != "cat")
            {
                groupid = propgroupid;
            }

            gCat = CategoryUtils.GetCategoryData(groupid, Utils.GetCurrentCulture());
            if (gCat.Exists)
            {
                var prdList = gCat.GetAllArticles();

                foreach (var prd in prdList)
                {
                    // END Promo
                    RemoveProductPromoData(portalId, prd.ParentItemId, p.ItemID);
                    ProductUtils.RemoveProductDataCache(prd.PortalId, prd.ParentItemId);
                }
            }
            return("OK");
        }
예제 #3
0
        public string CategoryHidden(HttpContext context)
        {
            try
            {
                var ajaxInfo     = NBrightBuyUtils.GetAjaxInfo(context);
                var parentitemid = ajaxInfo.GetXmlPropertyInt("genxml/hidden/selectedcatid");
                if (parentitemid > 0)
                {
                    var catData = CategoryUtils.GetCategoryData(parentitemid, EditLangCurrent);

                    if (catData.DataRecord.GetXmlPropertyBool("genxml/checkbox/chkishidden"))
                    {
                        catData.DataRecord.SetXmlProperty("genxml/checkbox/chkishidden", "False");
                    }
                    else
                    {
                        catData.DataRecord.SetXmlProperty("genxml/checkbox/chkishidden", "True");
                    }
                    catData.Save();
                    // remove save GetData cache
                    NBrightBuyUtils.RemoveModCachePortalWide(PortalSettings.Current.PortalId);
                    return("");
                }
                return("Invalid parentitemid");
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
예제 #4
0
파일: parser.cs 프로젝트: zlxy/Genesis-3D
        private Category ParseUnicodeCategory()
        {
            if (pattern[ptr++] != '{')
            {
                throw NewParseException("Incomplete \\p{X} character escape.");
            }

            string name = ParseName(pattern, ref ptr);

            if (name == null)
            {
                throw NewParseException("Incomplete \\p{X} character escape.");
            }

            Category cat = CategoryUtils.CategoryFromName(name);

            if (cat == Category.None)
            {
                throw NewParseException("Unknown property '" + name + "'.");
            }

            if (pattern[ptr++] != '}')
            {
                throw NewParseException("Incomplete \\p{X} character escape.");
            }

            return(cat);
        }
예제 #5
0
        public String DeleteCategory(HttpContext context, string editType = "")
        {
            var ajaxInfo      = NBrightBuyUtils.GetAjaxInfo(context);
            var selectedcatid = ajaxInfo.GetXmlPropertyInt("genxml/hidden/selectedcatid");
            var categoryData  = CategoryUtils.GetCategoryData(selectedcatid, EditLangCurrent);

            categoryData.Delete();
            NBrightBuyUtils.RemoveModCachePortalWide(PortalSettings.Current.PortalId);
            return(CategoryAdminList(context, editType, EditLangCurrent));
        }
예제 #6
0
        private void MoveRecord(int itemId)
        {
            var selecteditemid = GenXmlFunctions.GetField(rpDataH, "selecteditemid");

            if (Utils.IsNumeric(selecteditemid))
            {
                var movData          = CategoryUtils.GetCategoryData(itemId, StoreSettings.Current.EditLanguage);
                var selData          = CategoryUtils.GetCategoryData(Convert.ToInt32(selecteditemid), StoreSettings.Current.EditLanguage);
                var fromParentItemid = selData.DataRecord.ParentItemId;
                var toParentItemid   = movData.DataRecord.ParentItemId;
                var reindex          = toParentItemid != fromParentItemid;

                var objGrpCtrl = new GrpCatController(StoreSettings.Current.EditLanguage);
                var movGrp     = objGrpCtrl.GetGrpCategory(movData.Info.ItemID);
                if (!movGrp.Parents.Contains(selData.Info.ItemID)) // cannot move a category into itself (i.e. move parent into sub-category)
                {
                    selData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlparentcatid", toParentItemid.ToString(""));
                    selData.DataRecord.ParentItemId = toParentItemid;
                    selData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlgrouptype", movData.DataRecord.GetXmlProperty("genxml/dropdownlist/ddlgrouptype"));
                    var strneworder = movData.DataRecord.GetXmlProperty("genxml/hidden/recordsortorder");
                    var selorder    = selData.DataRecord.GetXmlProperty("genxml/hidden/recordsortorder");
                    if (!Utils.IsNumeric(strneworder))
                    {
                        strneworder = "1";
                    }
                    if (!Utils.IsNumeric(selorder))
                    {
                        selorder = "1";
                    }
                    var neworder = Convert.ToDouble(strneworder, CultureInfo.GetCultureInfo("en-US"));
                    if (Convert.ToDouble(strneworder, CultureInfo.GetCultureInfo("en-US")) < Convert.ToDouble(selorder, CultureInfo.GetCultureInfo("en-US")))
                    {
                        neworder = neworder - 0.5;
                    }
                    else
                    {
                        neworder = neworder + 0.5;
                    }
                    selData.DataRecord.SetXmlProperty("genxml/hidden/recordsortorder", neworder.ToString(""), TypeCode.Double);
                    ModCtrl.Update(selData.DataRecord);

                    FixRecordSortOrder(toParentItemid.ToString("")); //reindex all siblings (this is so we get a int on the recordsortorder)
                    FixRecordGroupType(selData.Info.ItemID.ToString(""), selData.DataRecord.GetXmlProperty("genxml/dropdownlist/ddlgrouptype"));

                    if (reindex)
                    {
                        objGrpCtrl.ReIndexCascade(fromParentItemid);    // reindex from parent and parents.
                        objGrpCtrl.ReIndexCascade(selData.Info.ItemID); // reindex select and parents
                    }
                    NBrightBuyUtils.RemoveModCachePortalWide(PortalId); //clear any cache
                }
            }
        }
예제 #7
0
        private void PageLoad()
        {
            #region "Data Repeater"

            if (UserId > 0) // only logged in users can see data on this module.
            {
                if (Utils.IsNumeric(_entryid) && _entryid != "0")
                {
                    var categoryData = CategoryUtils.GetCategoryData(Convert.ToInt32(_entryid), EditLanguage);
                    base.DoDetail(rpData, categoryData.Info);
                }
                else
                {
                    var navigationData = new NavigationData(PortalId, "CategoryAdmin");

                    // get search data
                    var sInfo = new NBrightInfo();
                    sInfo.XMLData = navigationData.XmlData;

                    // display search
                    base.DoDetail(rpSearch, sInfo);

                    var grpCats = new List <NBrightInfo>();
                    if (!String.IsNullOrEmpty(Edittype) && Edittype.ToLower() == "group")
                    {
                        var selgroup = GenXmlFunctions.GetGenXmlValue(navigationData.XmlData, "genxml/dropdownlist/groupsel");
                        if (selgroup == "")
                        {
                            selgroup = GenXmlFunctions.GetField(rpSearch, "groupsel");
                        }
                        grpCats = NBrightBuyUtils.GetCatList(_openid, selgroup, EditLanguage);
                    }
                    else
                    {
                        grpCats = NBrightBuyUtils.GetCatList(_openid, "cat", EditLanguage);
                    }

                    rpData.DataSource = grpCats;
                    rpData.DataBind();
                }
            }

            #endregion

            // display header (Do header after the data return so the productcount works)
            base.DoDetail(rpDataH);

            // display footer
            base.DoDetail(rpDataF);
        }
예제 #8
0
        public static string RemoveMultiBuyProductPromo(int portalId, int promoid)
        {
            var objCtrl = new NBrightBuyController();
            var p       = objCtrl.GetData(promoid);

            var propgroupid      = p.GetXmlPropertyInt("genxml/dropdownlist/propbuy");
            var propapplygroupid = p.GetXmlPropertyInt("genxml/dropdownlist/propapply");

            var portalsettings = NBrightDNN.DnnUtils.GetPortalSettings(p.PortalId);
            var lang           = portalsettings.DefaultLanguage;


            var gCat = CategoryUtils.GetCategoryData(propgroupid, lang);

            if (gCat.Exists)
            {
                var prdList = gCat.GetAllArticles();

                foreach (var prd in prdList)
                {
                    // END Promo
                    RemoveProductPromoData(portalId, prd.ParentItemId, promoid);
                    ProductUtils.RemoveProductDataCache(prd.PortalId, prd.ParentItemId);
                    var productData = ProductUtils.GetProductData(prd.ParentItemId, lang);
                    productData.Save(); // recalc any new prices.
                }
            }

            if (propapplygroupid != propgroupid && propapplygroupid > 0)
            {
                gCat = CategoryUtils.GetCategoryData(propapplygroupid, lang);
                if (gCat.Exists)
                {
                    var prdList2 = gCat.GetAllArticles();

                    foreach (var prd in prdList2)
                    {
                        // END Promo
                        RemoveProductPromoData(p.PortalId, prd.ParentItemId, p.ItemID);
                        ProductUtils.RemoveProductDataCache(p.PortalId, prd.ParentItemId);
                        var productData = ProductUtils.GetProductData(prd.ParentItemId, lang);
                        productData.Save(); // recalc any new prices.
                    }
                }
            }

            return("OK");
        }
예제 #9
0
        public static string RemoveGroupProductPromo(int portalId, int promoid)
        {
            var objCtrl = new NBrightBuyController();
            var p       = objCtrl.GetData(promoid);

            var typeselect  = p.GetXmlProperty("genxml/radiobuttonlist/typeselect");
            var catgroupid  = p.GetXmlProperty("genxml/dropdownlist/catgroupid");
            var propgroupid = p.GetXmlProperty("genxml/dropdownlist/propgroupid");

            var portalsettings = NBrightDNN.DnnUtils.GetPortalSettings(p.PortalId);
            var lang           = portalsettings.DefaultLanguage;

            var prdList = new List <NBrightInfo>();

            if (typeselect == "all")
            {
                prdList = objCtrl.GetList(p.PortalId, -1, "PRD");
            }
            else
            {
                CategoryData gCat;
                var          groupid = catgroupid;
                if (typeselect != "cat")
                {
                    groupid = propgroupid;
                }
                gCat = CategoryUtils.GetCategoryData(groupid, lang);
                if (gCat != null)
                {
                    prdList = gCat.GetAllArticles();
                }
            }
            foreach (var prd in prdList)
            {
                var productid = prd.ParentItemId;
                if (typeselect == "all")
                {
                    productid = prd.ItemID;
                }

                // END Promo
                RemoveProductPromoData(portalId, productid, p.ItemID);
                ProductUtils.RemoveProductDataCache(prd.PortalId, productid);
                var productData = ProductUtils.GetProductData(productid, lang);
                productData.Save(); // recalc any new prices.
            }
            return("OK");
        }
예제 #10
0
 private Boolean IsParentInChildren(CategoryData catData, int parentItemId)
 {
     foreach (var ch in catData.GetDirectChildren())
     {
         if (ch.ItemID == parentItemId)
         {
             return(true);
         }
         var catChildData = CategoryUtils.GetCategoryData(ch.ItemID, EditLangCurrent);
         if (IsParentInChildren(catChildData, parentItemId))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #11
0
        private void MoveRecord(int movetocatid, int movecatid)
        {
            if (movecatid > 0)
            {
                var movData = CategoryUtils.GetCategoryData(movetocatid, EditLangCurrent);
                var selData = CategoryUtils.GetCategoryData(movecatid, EditLangCurrent);
                if (movData.Exists && selData.Exists)
                {
                    var fromParentItemid = selData.DataRecord.ParentItemId;
                    var toParentItemid   = movData.DataRecord.ParentItemId;
                    var reindex          = toParentItemid != fromParentItemid;
                    var objGrpCtrl       = new GrpCatController(EditLangCurrent);
                    var movGrp           = objGrpCtrl.GetGrpCategory(movData.Info.ItemID);
                    if (!movGrp.Parents.Contains(selData.Info.ItemID)) // cannot move a category into itself (i.e. move parent into sub-category)
                    {
                        selData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlparentcatid", toParentItemid.ToString(""));
                        selData.DataRecord.ParentItemId = toParentItemid;
                        selData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlgrouptype", movData.DataRecord.GetXmlProperty("genxml/dropdownlist/ddlgrouptype"));
                        var strneworder = movData.DataRecord.GetXmlPropertyDouble("genxml/hidden/recordsortorder");
                        var selorder    = selData.DataRecord.GetXmlPropertyDouble("genxml/hidden/recordsortorder");
                        var neworder    = Convert.ToDouble(strneworder, CultureInfo.GetCultureInfo("en-US"));
                        if (strneworder < selorder)
                        {
                            neworder = neworder - 0.5;
                        }
                        else
                        {
                            neworder = neworder + 0.5;
                        }
                        selData.DataRecord.SetXmlProperty("genxml/hidden/recordsortorder", neworder.ToString(""), TypeCode.Double);
                        var objCtrl = new NBrightBuyController();
                        objCtrl.Update(selData.DataRecord);

                        FixRecordSortOrder(toParentItemid.ToString(""), EditLangCurrent); //reindex all siblings (this is so we get a int on the recordsortorder)
                        FixRecordGroupType(selData.Info.ItemID.ToString(""), selData.DataRecord.GetXmlProperty("genxml/dropdownlist/ddlgrouptype"), EditLangCurrent);

                        if (reindex)
                        {
                            objGrpCtrl.ReIndexCascade(fromParentItemid);    // reindex from parent and parents.
                            objGrpCtrl.ReIndexCascade(selData.Info.ItemID); // reindex select and parents
                        }
                        NBrightBuyUtils.RemoveModCachePortalWide(PortalSettings.Current.PortalId);
                    }
                }
            }
        }
예제 #12
0
        public String CategoryAdminAddNew(HttpContext context, string editType = "")
        {
            var ajaxInfo     = NBrightBuyUtils.GetAjaxInfo(context);
            var categoryData = CategoryUtils.GetCategoryData(-1, EditLangCurrent);
            var selgroup     = ajaxInfo.GetXmlProperty("genxml/hidden/selectedgroup");

            if (selgroup == "")
            {
                selgroup = "cat";
            }
            categoryData.GroupType = selgroup;
            categoryData.DataRecord.SetXmlProperty("genxml/checkbox/chkishidden", "True");
            categoryData.DataRecord.ParentItemId = ajaxInfo.GetXmlPropertyInt("genxml/hidden/selectedcatid");
            categoryData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlparentcatid", categoryData.DataRecord.ParentItemId.ToString());
            categoryData.Save();
            NBrightBuyUtils.RemoveModCachePortalWide(PortalSettings.Current.PortalId);
            return(CategoryAdminList(context, editType, EditLangCurrent));
        }
예제 #13
0
        private void FixRecordSortOrder()
        {
            // fix any incorrect sort orders
            Double lp        = 1;
            var    levelList = NBrightBuyUtils.GetCategoryGroups(EditLanguage, true);

            foreach (NBrightInfo catinfo in levelList)
            {
                var recordsortorder = catinfo.GetXmlPropertyDouble("genxml/hidden/recordsortorder");
                if (recordsortorder != lp)
                {
                    var catData = CategoryUtils.GetCategoryData(catinfo.ItemID, StoreSettings.Current.EditLanguage);
                    catData.DataRecord.SetXmlPropertyDouble("genxml/hidden/recordsortorder", lp);
                    ModCtrl.Update(catData.DataRecord);
                }
                lp += 1;
            }
        }
예제 #14
0
 private void FixRecordGroupType(String parentid, String groupType)
 {
     if (Utils.IsNumeric(parentid) && Convert.ToInt32(parentid) > 0)
     {
         // fix any incorrect sort orders
         var strFilter = " and NB1.ParentItemId = " + parentid + " ";
         var levelList = ModCtrl.GetDataList(PortalSettings.Current.PortalId, -1, "CATEGORY", "CATEGORYLANG", EditLanguage, strFilter, " order by [XMLData].value('(genxml/hidden/recordsortorder)[1]','decimal(10,2)') ", true);
         foreach (NBrightInfo catinfo in levelList)
         {
             var grouptype = catinfo.GetXmlProperty("genxml/dropdownlist/ddlgrouptype");
             var catData   = CategoryUtils.GetCategoryData(catinfo.ItemID, StoreSettings.Current.EditLanguage);
             if (grouptype != groupType)
             {
                 catData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlgrouptype", groupType);
                 ModCtrl.Update(catData.DataRecord);
             }
             FixRecordGroupType(catData.Info.ItemID.ToString(""), groupType);
         }
     }
 }
예제 #15
0
        public static string RemoveMultiBuyProductPromo(int portalId, int promoid)
        {
            var objCtrl = new NBrightBuyController();
            var p       = objCtrl.GetData(promoid);

            var propgroupid      = p.GetXmlPropertyInt("genxml/dropdownlist/propbuy");
            var propapplygroupid = p.GetXmlPropertyInt("genxml/dropdownlist/propapply");

            var gCat = CategoryUtils.GetCategoryData(propgroupid, Utils.GetCurrentCulture());

            if (gCat.Exists)
            {
                var prdList = gCat.GetAllArticles();

                foreach (var prd in prdList)
                {
                    // END Promo
                    RemoveProductPromoData(portalId, prd.ParentItemId, promoid);
                    ProductUtils.RemoveProductDataCache(prd.PortalId, prd.ParentItemId);
                }
            }

            if (propapplygroupid != propgroupid && propapplygroupid > 0)
            {
                gCat = CategoryUtils.GetCategoryData(propapplygroupid, Utils.GetCurrentCulture());
                if (gCat.Exists)
                {
                    var prdList2 = gCat.GetAllArticles();

                    foreach (var prd in prdList2)
                    {
                        // END Promo
                        RemoveProductPromoData(p.PortalId, prd.ParentItemId, p.ItemID);
                        ProductUtils.RemoveProductDataCache(p.PortalId, prd.ParentItemId);
                    }
                }
            }

            return("OK");
        }
예제 #16
0
        public String CategoryAdminSaveList(HttpContext context)
        {
            var ajaxInfoList   = NBrightBuyUtils.GetAjaxInfoList(context);
            var strOut         = "";
            var regex          = new Regex(@"^[a-z0-9]+$");
            var isPropertyList = (context.Request.QueryString.Get("cmd") == "property_admin_savelist");

            foreach (var nbi in ajaxInfoList)
            {
                // validate property refs
                if (isPropertyList)
                {
                    var propertyRef = nbi.GetXmlProperty("genxml/textbox/propertyref");
                    if (propertyRef != "" && !regex.IsMatch(propertyRef))
                    {
                        strOut = "Error: Invalid Ref. Only use lower case alpha numeric values. No spaces. " + propertyRef;
                        break;
                    }
                    ;
                }

                if (nbi.GetXmlPropertyBool("genxml/hidden/isdirty"))
                {
                    var categoryData = CategoryUtils.GetCategoryData(nbi.GetXmlPropertyInt("genxml/hidden/itemid"), nbi.GetXmlProperty("genxml/hidden/categorylang"));
                    if (categoryData.Exists)
                    {
                        categoryData.Name = nbi.GetXmlProperty("genxml/textbox/txtcategoryname");
                        if (categoryData.DataRecord.GetXmlProperty("genxml/textbox/propertyref") == "")
                        {
                            categoryData.DataRecord.SetXmlProperty("genxml/textbox/propertyref", nbi.GetXmlProperty("genxml/textbox/propertyref"));
                        }
                        categoryData.Save();
                    }
                }
            }
            DataCache.ClearCache();
            NBrightBuyUtils.RemoveModCachePortalWide(PortalSettings.Current.PortalId);
            return(strOut);
        }
예제 #17
0
        private void FixRecordSortOrder(String parentid)
        {
            if (!Utils.IsNumeric(parentid))
            {
                parentid = "0";
            }
            // fix any incorrect sort orders
            Double lp        = 1;
            var    strFilter = " and NB1.ParentItemId = " + parentid + " ";
            var    levelList = ModCtrl.GetDataList(PortalSettings.Current.PortalId, -1, "CATEGORY", "CATEGORYLANG", EditLanguage, strFilter, " order by [XMLData].value('(genxml/hidden/recordsortorder)[1]','decimal(10,2)') ", true);

            foreach (NBrightInfo catinfo in levelList)
            {
                var recordsortorder = catinfo.GetXmlProperty("genxml/hidden/recordsortorder");
                if (!Utils.IsNumeric(recordsortorder) || Convert.ToDouble(recordsortorder, CultureInfo.GetCultureInfo("en-US")) != lp)
                {
                    var catData = CategoryUtils.GetCategoryData(catinfo.ItemID, StoreSettings.Current.EditLanguage);
                    catData.DataRecord.SetXmlProperty("genxml/hidden/recordsortorder", lp.ToString(""));
                    ModCtrl.Update(catData.DataRecord);
                }
                lp += 1;
            }
        }
예제 #18
0
        private void MoveRecord(int itemId)
        {
            var selecteditemid = GenXmlFunctions.GetField(rpDataH, "selecteditemid");

            if (Utils.IsNumeric(selecteditemid))
            {
                var movData  = CategoryUtils.GetCategoryData(itemId, StoreSettings.Current.EditLanguage);
                var selData  = CategoryUtils.GetCategoryData(Convert.ToInt32(selecteditemid), StoreSettings.Current.EditLanguage);
                var neworder = movData.DataRecord.GetXmlPropertyDouble("genxml/hidden/recordsortorder");
                var selorder = selData.DataRecord.GetXmlPropertyDouble("genxml/hidden/recordsortorder");
                if (neworder < selorder)
                {
                    neworder = neworder - 0.5;
                }
                else
                {
                    neworder = neworder + 0.5;
                }
                selData.DataRecord.SetXmlPropertyDouble("genxml/hidden/recordsortorder", neworder);
                ModCtrl.Update(selData.DataRecord);
                FixRecordSortOrder();
            }
        }
예제 #19
0
        public String CategoryAdminSaveList(HttpContext context)
        {
            var ajaxInfoList = NBrightBuyUtils.GetAjaxInfoList(context);

            foreach (var nbi in ajaxInfoList)
            {
                if (nbi.GetXmlPropertyBool("genxml/hidden/isdirty"))
                {
                    var categoryData = CategoryUtils.GetCategoryData(nbi.GetXmlPropertyInt("genxml/hidden/itemid"), nbi.GetXmlProperty("genxml/hidden/categorylang"));
                    if (categoryData.Exists)
                    {
                        categoryData.Name = nbi.GetXmlProperty("genxml/textbox/txtcategoryname");
                        if (categoryData.DataRecord.GetXmlProperty("genxml/textbox/propertyref") == "")
                        {
                            categoryData.DataRecord.SetXmlProperty("genxml/textbox/propertyref", nbi.GetXmlProperty("genxml/textbox/propertyref"));
                        }
                        categoryData.Save();
                    }
                }
            }
            NBrightBuyUtils.RemoveModCachePortalWide(PortalSettings.Current.PortalId);
            return("");
        }
예제 #20
0
        private void ResetLanguage()
        {
            var pass = GenXmlFunctions.GetField(rpData, "txtclearpass");

            if (pass == StoreSettings.Current.Get("adminpin") && pass != "")
            {
                var languagetoreset = GenXmlFunctions.GetField(rpData, "languagetoreset");
                var languageresetto = GenXmlFunctions.GetField(rpData, "languageresetto");
                if (languagetoreset != "" && languageresetto != languagetoreset)
                {
                    var objCtrl = new NBrightBuyController();

                    var l = objCtrl.GetDataList(PortalId, -1, "PRD", "", Utils.GetCurrentCulture(), "", "");
                    foreach (var i in l)
                    {
                        var prdData = ProductUtils.GetProductData(i.ItemID, languagetoreset);
                        prdData.ResetLanguage(languageresetto);
                    }

                    l = objCtrl.GetDataList(PortalId, -1, "CATEGORY", "", Utils.GetCurrentCulture(), "", "");
                    foreach (var i in l)
                    {
                        var catData = CategoryUtils.GetCategoryData(i.ItemID, languagetoreset);
                        catData.ResetLanguage(languageresetto);
                    }

                    DataCache.ClearCache();

                    NBrightBuyUtils.SetNotfiyMessage(ModuleId, "completed", NotifyCode.ok);
                }
            }
            else
            {
                NBrightBuyUtils.SetNotfiyMessage(ModuleId, "nopin", NotifyCode.fail);
            }
        }
예제 #21
0
        public static string CalcMultiBuyPromoItem(NBrightInfo p)
        {
            var objCtrl        = new NBrightBuyController();
            var propgroupid    = p.GetXmlPropertyInt("genxml/dropdownlist/propbuy");
            var promoname      = p.GetXmlProperty("genxml/textbox/name");
            var validfrom      = p.GetXmlProperty("genxml/textbox/validfrom");
            var validuntil     = p.GetXmlProperty("genxml/textbox/validuntil");
            var disabled       = p.GetXmlPropertyBool("genxml/checkbox/disabled");
            var lastcalculated = p.GetXmlProperty("genxml/hidden/lastcalculated");

            if (!disabled)
            {
                var portalsettings = NBrightDNN.DnnUtils.GetPortalSettings(p.PortalId);
                var lang           = portalsettings.DefaultLanguage;

                var runcalc = true;
                if (Utils.IsDate(lastcalculated))
                {
                    if (Convert.ToDateTime(lastcalculated) >= p.ModifiedDate)
                    {
                        runcalc = false;                                                        // only run if changed
                    }
                    if (DateTime.Now.Date > Convert.ToDateTime(lastcalculated).Date.AddDays(1))
                    {
                        runcalc = true;                                                                         // every day just after midnight. (for site performace)
                    }
                }
                if (Utils.IsDate(validuntil))
                {
                    if (DateTime.Now.Date > Convert.ToDateTime(validuntil))
                    {
                        runcalc = true;                                                     // need to disable the promo if passed date
                    }
                }
                if ((runcalc) && Utils.IsDate(validfrom) && Utils.IsDate(validuntil))
                {
                    var          dteF = Convert.ToDateTime(validfrom).Date;
                    var          dteU = Convert.ToDateTime(validuntil).Date;
                    CategoryData gCat;

                    gCat = CategoryUtils.GetCategoryData(propgroupid, lang);
                    var prdList = gCat.GetAllArticles();

                    foreach (var prd in prdList)
                    {
                        if (DateTime.Now.Date >= dteF && DateTime.Now.Date <= dteU)
                        {
                            // CALC Promo
                            FlagProductMultiBuy(p.PortalId, prd.ParentItemId, promoname, p.ItemID, "PROMOMULTIBUY", dteF, dteU);
                        }
                        if (DateTime.Now.Date > dteU)
                        {
                            // END Promo
                            RemoveProductPromoData(p.PortalId, prd.ParentItemId, p.ItemID);
                            p.SetXmlProperty("genxml/checkbox/disabled", "True");
                            objCtrl.Update(p);
                        }
                        ProductUtils.RemoveProductDataCache(p.PortalId, prd.ParentItemId);
                        var productData = ProductUtils.GetProductData(prd.ParentItemId, lang);
                        productData.Save(); // recalc any new prices.
                    }

                    p.SetXmlProperty("genxml/hidden/lastcalculated", DateTime.Now.AddSeconds(10).ToString("O")); // Add 10 sec to time so we don't get exact clash with update time.
                    objCtrl.Update(p);
                }
            }
            return("OK");
        }
예제 #22
0
        private bool EvalChar(Mode mode, ref int ptr, ref int pc, bool multi)
        {
            bool flag = false;
            char c    = '\0';
            bool flag3;

            do
            {
                ushort  num     = program[pc];
                OpCode  opCode  = (OpCode)(num & 0xFF);
                OpFlags opFlags = (OpFlags)(num & 0xFF00);
                pc++;
                bool flag2 = (opFlags & OpFlags.IgnoreCase) != OpFlags.None;
                if (!flag)
                {
                    if ((opFlags & OpFlags.RightToLeft) != 0)
                    {
                        if (ptr <= 0)
                        {
                            return(false);
                        }
                        c = text[--ptr];
                    }
                    else
                    {
                        if (ptr >= text_end)
                        {
                            return(false);
                        }
                        c = text[ptr++];
                    }
                    if (flag2)
                    {
                        c = char.ToLower(c);
                    }
                    flag = true;
                }
                flag3 = ((opFlags & OpFlags.Negate) != OpFlags.None);
                switch (opCode)
                {
                case OpCode.True:
                    return(true);

                case OpCode.False:
                    return(false);

                case OpCode.Character:
                    if (c == program[pc++])
                    {
                        return(!flag3);
                    }
                    break;

                case OpCode.Category:
                    if (CategoryUtils.IsCategory((Category)program[pc++], c))
                    {
                        return(!flag3);
                    }
                    break;

                case OpCode.NotCategory:
                    if (!CategoryUtils.IsCategory((Category)program[pc++], c))
                    {
                        return(!flag3);
                    }
                    break;

                case OpCode.Range:
                {
                    int num6 = program[pc++];
                    int num7 = program[pc++];
                    if (num6 <= c && c <= num7)
                    {
                        return(!flag3);
                    }
                    break;
                }

                case OpCode.Set:
                {
                    int num2 = program[pc++];
                    int num3 = program[pc++];
                    int num4 = pc;
                    pc += num3;
                    int num5 = c - num2;
                    if (num5 < 0 || num5 >= num3 << 4 || (program[num4 + (num5 >> 4)] & (1 << (num5 & 0xF))) == 0)
                    {
                        break;
                    }
                    return(!flag3);
                }
                }
            }while (multi);
            return(flag3);
        }
예제 #23
0
 private bool IsWordChar(char c)
 {
     return(CategoryUtils.IsCategory(Category.Word, c));
 }
예제 #24
0
        public String CategorySave(HttpContext context, string editLangCurrent)
        {
            if (NBrightBuyUtils.CheckManagerRights())
            {
                EditLangCurrent = editLangCurrent;
                var ajaxInfo     = NBrightBuyUtils.GetAjaxFields(context);
                var parentitemid = ajaxInfo.GetXmlPropertyInt("genxml/dropdownlist/ddlparentcatid");
                var catid        = ajaxInfo.GetXmlPropertyInt("genxml/hidden/itemid");
                if (catid > 0)
                {
                    if (parentitemid != catid)
                    {
                        var catData = new CategoryData(catid, EditLangCurrent);

                        // check we've not put a category under it's child
                        if (!IsParentInChildren(catData, parentitemid))
                        {
                            var catDirectList   = catData.GetDirectArticles();
                            var oldparentitemId = catData.ParentItemId;
                            if (parentitemid != oldparentitemId)
                            {
                                // remove articles for category, so we realign the cascade records.
                                foreach (var p in catDirectList)
                                {
                                    var prdData = new ProductData(p.ParentItemId, p.PortalId, p.Lang);
                                    prdData.RemoveCategory(catData.CategoryId);
                                }
                            }

                            catData.Update(ajaxInfo);

                            // the base category ref cannot have language dependant refs, we therefore just use a unique key
                            var catref = catData.DataRecord.GetXmlProperty("genxml/textbox/txtcategoryref");
                            if (catref == "")
                            {
                                if (catData.DataRecord.GUIDKey == "")
                                {
                                    catref = Utils.GetUniqueKey().ToLower();
                                    catData.DataRecord.SetXmlProperty("genxml/textbox/txtcategoryref", catref);
                                    catData.DataRecord.GUIDKey = catref;
                                }
                                else
                                {
                                    catData.DataRecord.SetXmlProperty("genxml/textbox/txtcategoryref", catData.DataRecord.GUIDKey);
                                }
                            }
                            catData.Save();
                            CategoryUtils.ValidateLangaugeRef(PortalSettings.Current.PortalId, catid); // do validate so we update all refs and children refs
                            NBrightBuyUtils.RemoveModCachePortalWide(PortalSettings.Current.PortalId);

                            if (parentitemid != oldparentitemId)
                            {
                                // all all articles for category. so we realign the cascade records.
                                foreach (var p in catDirectList)
                                {
                                    var prdData = new ProductData(p.ParentItemId, p.PortalId, p.Lang);
                                    prdData.AddCategory(catData.CategoryId);
                                }
                            }
                        }
                    }
                }
                DataCache.ClearCache();
                NBrightBuyUtils.RemoveModCachePortalWide(PortalSettings.Current.PortalId);
            }
            return("");
        }
예제 #25
0
        public TestFixtureClass(string name, System.Type type, object[] parameters) : base(name)
        {
            if (type.BaseType == null || type.BaseType.GetConstructor(new System.Type[0]) == null)
            {
                baseClass = null;
            }
            else
            {
                baseClass = new TestFixtureClass(name, type.BaseType, null);
            }
            this.parameters = parameters;

            fullName             = type.FullName;
            HasExplicitAttribute = Reflection.HasAttribute(type, typeof(NUnit.Framework.ExplicitAttribute), false);
            var ignoreAttribute = Reflection.GetAttribute(type, typeof(NUnit.Framework.IgnoreAttribute), false);

            HasIgnoreAttribute = ignoreAttribute != null;
            if (HasIgnoreAttribute)
            {
                IgnoreMessage = Reflection.GetProperty(ignoreAttribute, "Reason") as string;
            }
            Tests      = new System.Collections.Generic.List <Test>();
            Categories = CategoryUtils.GetCategories(type);

            ctorInfo = type.GetConstructor(MethodHelper.GetArgumentTypes(parameters));
            if (ctorInfo == null)
            {
                throw new System.Exception("No default constructor");
            }

            var methods = type.GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.DeclaredOnly);

            System.Array.Sort(methods, CompareMethodInfoByName);
            foreach (var methodInfo in methods)
            {
                var hasTestAttribute             = Reflection.HasAttribute(methodInfo, typeof(NUnit.Framework.TestAttribute), false);
                var hasTestCaseAttribute         = Reflection.HasAttribute(methodInfo, typeof(NUnit.Framework.TestCaseAttribute), false);
                var hasTestCaseSourceAttribute   = Reflection.HasAttribute(methodInfo, typeof(NUnit.Framework.TestCaseSourceAttribute), false);
                var hasTestFixtureSetUpAttribute =
                    Reflection.HasAttribute(methodInfo, typeof(NUnit.Framework.TestFixtureSetUpAttribute), false) ||
                    Reflection.HasAttribute(methodInfo, typeof(NUnit.Framework.OneTimeSetUpAttribute), false);
                var hasSetUpAttribute               = Reflection.HasAttribute(methodInfo, typeof(NUnit.Framework.SetUpAttribute), false);
                var hasTearDownAttribute            = Reflection.HasAttribute(methodInfo, typeof(NUnit.Framework.TearDownAttribute), false);
                var hasTestFixtureTearDownAttribute =
                    Reflection.HasAttribute(methodInfo, typeof(NUnit.Framework.TestFixtureTearDownAttribute), false) ||
                    Reflection.HasAttribute(methodInfo, typeof(NUnit.Framework.OneTimeTearDownAttribute), false);
                var hasNUnitAttribute = hasTestAttribute || hasTestFixtureSetUpAttribute || hasSetUpAttribute || hasTearDownAttribute || hasTestFixtureTearDownAttribute;

                if (hasTestAttribute ||
                    hasTestCaseAttribute ||
                    hasTestCaseSourceAttribute ||
                    !hasNUnitAttribute && methodInfo.Name.Substring(0, 4).ToLower() == "test" && methodInfo.GetParameters().Length == 0)
                {
                    Tests.Add(new Test(methodInfo));
                }

                if (hasTestFixtureSetUpAttribute)
                {
                    testFixtureSetUp.Add(methodInfo);
                }

                if (hasSetUpAttribute)
                {
                    setUp.Add(methodInfo);
                }

                if (hasTearDownAttribute)
                {
                    tearDown.Add(methodInfo);
                }

                if (hasTestFixtureTearDownAttribute)
                {
                    testFixtureTearDown.Add(methodInfo);
                }
            }
        }
예제 #26
0
        public static string CalcGroupPromoItem(NBrightInfo p)
        {
            var objCtrl        = new NBrightBuyController();
            var typeselect     = p.GetXmlProperty("genxml/radiobuttonlist/typeselect");
            var catgroupid     = p.GetXmlProperty("genxml/dropdownlist/catgroupid");
            var propgroupid    = p.GetXmlProperty("genxml/dropdownlist/propgroupid");
            var promoname      = p.GetXmlProperty("genxml/textbox/name");
            var amounttype     = p.GetXmlProperty("genxml/radiobuttonlist/amounttype");
            var amount         = p.GetXmlPropertyDouble("genxml/textbox/amount");
            var validfrom      = p.GetXmlProperty("genxml/textbox/validfrom");
            var validuntil     = p.GetXmlProperty("genxml/textbox/validuntil");
            var overwrite      = p.GetXmlPropertyBool("genxml/checkbox/overwrite");
            var disabled       = p.GetXmlPropertyBool("genxml/checkbox/disabled");
            var lastcalculated = p.GetXmlProperty("genxml/hidden/lastcalculated");

            if (!disabled)
            {
                var runcalc = true;
                if (Utils.IsDate(lastcalculated))
                {
                    if (Convert.ToDateTime(lastcalculated) >= p.ModifiedDate)
                    {
                        runcalc = false;                                                           // only run if changed
                    }
                    if (DateTime.Now.Date > Convert.ToDateTime(lastcalculated).Date.AddDays(1))
                    {
                        runcalc = true;                                                                             // every day just after midnight. (for site performace)
                    }
                }
                if (Utils.IsDate(validuntil))
                {
                    if (DateTime.Now.Date > Convert.ToDateTime(validuntil))
                    {
                        runcalc = true;                                                         // need to disable the promo if passed date
                    }
                }
                if ((runcalc) && Utils.IsDate(validfrom) && Utils.IsDate(validuntil))
                {
                    var          dteF = Convert.ToDateTime(validfrom).Date;
                    var          dteU = Convert.ToDateTime(validuntil).Date;
                    CategoryData gCat;
                    var          groupid = catgroupid;
                    if (typeselect != "cat")
                    {
                        groupid = propgroupid;
                    }

                    gCat = CategoryUtils.GetCategoryData(groupid, Utils.GetCurrentCulture());
                    var prdList = gCat.GetAllArticles();

                    foreach (var prd in prdList)
                    {
                        if (DateTime.Now.Date >= dteF && DateTime.Now.Date <= dteU)
                        {
                            // CALC Promo
                            CalcProductSalePrice(p.PortalId, prd.ParentItemId, amounttype, amount, promoname, p.ItemID, overwrite, dteF, dteU);
                        }
                        if (DateTime.Now.Date > dteU)
                        {
                            // END Promo
                            RemoveProductPromoData(p.PortalId, prd.ParentItemId, p.ItemID);
                            p.SetXmlProperty("genxml/checkbox/disabled", "True");
                            objCtrl.Update(p);
                        }
                        ProductUtils.RemoveProductDataCache(p.PortalId, prd.ParentItemId);
                    }

                    p.SetXmlProperty("genxml/hidden/lastcalculated", DateTime.Now.AddSeconds(10).ToString("O"));     // Add 10 sec to time so we don't get exact clash with update time.
                    objCtrl.Update(p);
                }
            }
            return("OK");
        }
예제 #27
0
        public static string CalcGroupPromoItem(NBrightInfo p)
        {
            var objCtrl        = new NBrightBuyController();
            var typeselect     = p.GetXmlProperty("genxml/radiobuttonlist/typeselect");
            var catgroupid     = p.GetXmlProperty("genxml/dropdownlist/catgroupid");
            var propgroupid    = p.GetXmlProperty("genxml/dropdownlist/propgroupid");
            var promoname      = p.GetXmlProperty("genxml/textbox/name");
            var amounttype     = p.GetXmlProperty("genxml/radiobuttonlist/amounttype");
            var amount         = p.GetXmlPropertyDouble("genxml/textbox/amount");
            var validfrom      = p.GetXmlProperty("genxml/textbox/validfrom");
            var validuntil     = p.GetXmlProperty("genxml/textbox/validuntil");
            var overwrite      = p.GetXmlPropertyBool("genxml/checkbox/overwrite");
            var disabled       = p.GetXmlPropertyBool("genxml/checkbox/disabled");
            var lastcalculated = p.GetXmlProperty("genxml/hidden/lastcalculated");
            var whichprice     = p.GetXmlPropertyInt("genxml/radiobuttonlist/whichprice");
            var runfreq        = p.GetXmlPropertyInt("genxml/radiobuttonlist/runfreq");

            if (!disabled)
            {
                var portalsettings = NBrightDNN.DnnUtils.GetPortalSettings(p.PortalId);
                var lang           = portalsettings.DefaultLanguage;

                var prdList = new List <NBrightInfo>();
                if (typeselect == "all")
                {
                    prdList = objCtrl.GetList(p.PortalId, -1, "PRD");
                }
                else
                {
                    CategoryData gCat;
                    var          groupid = catgroupid;
                    if (typeselect != "cat")
                    {
                        groupid = propgroupid;
                    }
                    gCat = CategoryUtils.GetCategoryData(groupid, lang);
                    if (gCat != null)
                    {
                        prdList = gCat.GetAllArticles();
                    }
                }

                var runcalc = true;
                if (runfreq == 1 || runfreq == 3) // run freq is date range
                {
                    if (runfreq == 3)
                    {
                        // run constantly, set end date to +100 year
                        validfrom  = DateTime.Now.AddYears(-1).ToString("s");
                        validuntil = DateTime.Now.AddYears(100).ToString("s");
                    }
                    // run date range
                    if (Utils.IsDate(lastcalculated))
                    {
                        if (Convert.ToDateTime(lastcalculated) >= p.ModifiedDate)
                        {
                            runcalc = false;                                                       // only run if changed
                        }
                        if (DateTime.Now.Date > Convert.ToDateTime(lastcalculated).Date.AddDays(1))
                        {
                            runcalc = true;                                                                         // every day just after midnight. (for site performace)
                        }
                    }
                    if (Utils.IsDate(validuntil))
                    {
                        if (DateTime.Now.Date > Convert.ToDateTime(validuntil))
                        {
                            runcalc = true;                                                     // need to disable the promo if passed date
                        }
                    }
                    if ((runcalc) && Utils.IsDate(validfrom) && Utils.IsDate(validuntil))
                    {
                        var dteF = Convert.ToDateTime(validfrom).Date;
                        var dteU = Convert.ToDateTime(validuntil).Date;

                        foreach (var prd in prdList)
                        {
                            var productid = prd.ParentItemId;
                            if (typeselect == "all")
                            {
                                productid = prd.ItemID;
                            }

                            if (DateTime.Now.Date >= dteF && DateTime.Now.Date <= dteU)
                            {
                                // CALC Promo
                                CalcProductSalePrice(p.PortalId, productid, amounttype, amount, p.ItemID, whichprice, overwrite);
                            }
                            if (DateTime.Now.Date > dteU)
                            {
                                // END Promo
                                RemoveProductPromoData(p.PortalId, productid, p.ItemID);
                            }
                            ProductUtils.RemoveProductDataCache(p.PortalId, productid);
                            var productData = ProductUtils.GetProductData(productid, lang);
                            productData.Save(); // recalc any new prices.
                        }
                        if (DateTime.Now.Date > dteU)
                        {
                            // END Promo
                            p.SetXmlProperty("genxml/checkbox/disabled", "True");
                        }
                    }
                }
                if (runfreq == 2) // run Once, do update and disable promo.
                {
                    foreach (var prd in prdList)
                    {
                        var productid = prd.ParentItemId;
                        if (typeselect == "all")
                        {
                            productid = prd.ItemID;
                        }
                        // CALC Promo
                        CalcProductSalePrice(p.PortalId, productid, amounttype, amount, p.ItemID, whichprice, overwrite);
                        ProductUtils.RemoveProductDataCache(p.PortalId, productid);
                        var productData = ProductUtils.GetProductData(productid, lang);
                        productData.Save(); // recalc any new prices.
                    }
                    p.SetXmlProperty("genxml/checkbox/disabled", "True");
                }
                if (runfreq == 4) // remove
                {
                    foreach (var prd in prdList)
                    {
                        var productid = prd.ParentItemId;
                        if (typeselect == "all")
                        {
                            productid = prd.ItemID;
                        }
                        RemoveProductPromoData(p.PortalId, productid, p.ItemID);
                        ProductUtils.RemoveProductDataCache(p.PortalId, productid);
                        var productData = ProductUtils.GetProductData(productid, lang);
                        productData.Save(); // recalc any new prices.
                    }

                    p.SetXmlProperty("genxml/checkbox/disabled", "True");
                }
                p.SetXmlProperty("genxml/hidden/lastcalculated", DateTime.Now.AddSeconds(10).ToString("O")); // Add 10 sec to time so we don't get exact clash with update time.
                objCtrl.Update(p);
            }
            return("OK");
        }
예제 #28
0
        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
                                        if (prodxref.TypeCode == "CATCASCADE")     // just check we have correct record. (stop nasty surprises)
                                        {
                                            ModCtrl.Delete(prodxref.ItemID);
                                        }
                                    }
                                }
                            }

                            foreach (var dc in delCatData.GetDirectArticles())
                            {
                                // delete CATXREF record
                                if (dc.TypeCode == "CATXREF")     // just check we have correct record. (stop nasty surprises)
                                {
                                    ModCtrl.Delete(dc.ItemID);
                                }
                            }
                            // 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;
            }
        }
예제 #29
0
        private void SaveAll()
        {
            foreach (RepeaterItem rtnItem in rpData.Items)
            {
                var isdirty = GenXmlFunctions.GetField(rtnItem, "isdirty");
                var itemid  = GenXmlFunctions.GetField(rtnItem, "itemid");
                if (isdirty == "true" && Utils.IsNumeric(itemid))
                {
                    var catData = CategoryUtils.GetCategoryData(Convert.ToInt32(itemid), StoreSettings.Current.EditLanguage);
                    if (catData.Exists)
                    {
                        var chkishidden = GenXmlFunctions.GetField(rtnItem, "chkishidden");
                        var catname     = GenXmlFunctions.GetField(rtnItem, "txtcategoryname");
                        catData.DataRecord.SetXmlProperty("genxml/checkbox/chkishidden", chkishidden);

                        if (!String.IsNullOrEmpty(Edittype) && Edittype.ToLower() == "group")
                        {
                            var propertyref = GenXmlFunctions.GetField(rtnItem, "propertyref");
                            if (propertyref != "")
                            {
                                catData.DataRecord.SetXmlProperty("genxml/textbox/propertyref", propertyref);
                                catData.DataRecord.SetXmlProperty("genxml/textbox/txtcategoryref", propertyref);
                            }
                            var grptype = catData.DataRecord.GetXmlProperty("genxml/dropdownlist/ddlgrouptype");
                            var grp     = ModCtrl.GetByGuidKey(PortalSettings.PortalId, -1, "GROUP", grptype);
                            if (grp != null)
                            {
                                catData.ParentItemId = grp.ItemID;
                                ModCtrl.Update(catData.DataRecord);
                            }
                        }
                        else
                        {
                            // the base category ref cannot have language dependant refs, we therefore just use a unique key
                            var catref = catData.DataRecord.GetXmlProperty("genxml/textbox/txtcategoryref");
                            if (catref == "")
                            {
                                catref = Utils.GetUniqueKey().ToLower();
                                catData.DataRecord.SetXmlProperty("genxml/textbox/txtcategoryref", catref);
                                catData.DataRecord.GUIDKey = catref;
                            }
                            ModCtrl.Update(catData.DataRecord);
                        }

                        catData.DataLangRecord.SetXmlProperty("genxml/textbox/txtcategoryname", catname);
                        ModCtrl.Update(catData.DataLangRecord);
                        if (catname != "")
                        {
                            // update all language records that have no name
                            foreach (var lang in DnnUtils.GetCultureCodeList(PortalSettings.Current.PortalId))
                            {
                                var catLangUpd = CategoryUtils.GetCategoryData(Convert.ToInt32(itemid), lang);
                                if (catLangUpd.DataLangRecord != null && catLangUpd.Info.GetXmlProperty("genxml/lang/genxml/textbox/txtcategoryname") == "")
                                {
                                    catLangUpd.DataLangRecord.SetXmlProperty("genxml/textbox/txtcategoryname", catname);
                                    ModCtrl.Update(catLangUpd.DataLangRecord);
                                }
                            }
                        }

                        catData.Save();
                        NBrightBuyUtils.RemoveModCachePortalWide(PortalId);                   // clear cache before validate lang, so we pickup new changes to name.
                        CategoryUtils.ValidateLangaugeRef(PortalId, Convert.ToInt32(itemid)); // do validate so we update all refs and children refs
                    }
                }
            }
        }
예제 #30
0
        private void UpdateRecord()
        {
            var xmlData = GenXmlFunctions.GetGenXml(rpData, "", StoreSettings.Current.FolderImagesMapPath);
            var objInfo = new NBrightInfo();

            objInfo.ItemID   = -1;
            objInfo.TypeCode = "POSTDATA";
            objInfo.XMLData  = xmlData;
            var settings = objInfo.ToDictionary(); // put the fieds into a dictionary, so we can get them easy.

            // check we don't have an invalid parentitemid
            var parentitemid = objInfo.GetXmlPropertyInt("genxml/dropdownlist/ddlparentcatid");
            var strOut       = "No Category ID ('itemid' hidden fields needed on input form)";

            if (settings.ContainsKey("itemid"))
            {
                if (parentitemid != Convert.ToInt32(settings["itemid"]))
                {
                    var catData = CategoryUtils.GetCategoryData(Convert.ToInt32(settings["itemid"]), StoreSettings.Current.EditLanguage);

                    // check we've not put a category under it's child
                    if (IsParentInChildren(catData, parentitemid))
                    {
                        NBrightBuyUtils.SetNotfiyMessage(ModuleId, "categoryactionsave", NotifyCode.fail);
                    }
                    else
                    {
                        var catDirectList   = catData.GetDirectArticles();
                        var oldparentitemId = catData.ParentItemId;
                        if (parentitemid != oldparentitemId)
                        {
                            // remove articles for category, so we realign the cascade records.
                            foreach (var p in catDirectList)
                            {
                                var prdData = new ProductData(p.ParentItemId, p.PortalId, p.Lang);
                                prdData.RemoveCategory(catData.CategoryId);
                            }
                        }

                        catData.Update(objInfo);

                        if (!String.IsNullOrEmpty(Edittype) && Edittype.ToLower() == "group")
                        {
                            var grptype = objInfo.GetXmlProperty("genxml/dropdownlist/ddlparentcatid");
                            var grp     = ModCtrl.GetByGuidKey(PortalSettings.PortalId, -1, "GROUP", grptype);
                            if (grp != null)
                            {
                                var newGuidKey = objInfo.GetXmlProperty("genxml/textbox/propertyref");
                                if (newGuidKey != "")
                                {
                                    newGuidKey = GetUniqueGuidKey(catData.CategoryId, Utils.UrlFriendly(newGuidKey));
                                }
                                catData.DataRecord.GUIDKey = newGuidKey;
                                catData.DataRecord.SetXmlProperty("genxml/textbox/txtcategoryref", newGuidKey);
                                catData.DataRecord.ParentItemId = grp.ItemID;
                                // list done using ddlgrouptype, in  GetCatList
                                catData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlgrouptype", grptype);
                                catData.Save();
                                NBrightBuyUtils.RemoveModCachePortalWide(PortalId);
                            }
                        }
                        else
                        {
                            // the base category ref cannot have language dependant refs, we therefore just use a unique key
                            var catref = catData.DataRecord.GetXmlProperty("genxml/textbox/txtcategoryref");
                            if (catref == "")
                            {
                                if (catData.DataRecord.GUIDKey == "")
                                {
                                    catref = Utils.GetUniqueKey().ToLower();
                                    catData.DataRecord.SetXmlProperty("genxml/textbox/txtcategoryref", catref);
                                    catData.DataRecord.GUIDKey = catref;
                                }
                                else
                                {
                                    catData.DataRecord.SetXmlProperty("genxml/textbox/txtcategoryref", catData.DataRecord.GUIDKey);
                                }
                            }
                            catData.Save();
                            CategoryUtils.ValidateLangaugeRef(PortalId, Convert.ToInt32(settings["itemid"])); // do validate so we update all refs and children refs
                            NBrightBuyUtils.RemoveModCachePortalWide(PortalId);
                        }

                        if (parentitemid != oldparentitemId)
                        {
                            // all all articles for category. so we realign the cascade records.
                            foreach (var p in catDirectList)
                            {
                                var prdData = new ProductData(p.ParentItemId, p.PortalId, p.Lang);
                                prdData.AddCategory(catData.CategoryId);
                            }
                        }

                        NBrightBuyUtils.SetNotfiyMessage(ModuleId, "categoryactionsave", NotifyCode.ok);
                    }
                }
                else
                {
                    NBrightBuyUtils.SetNotfiyMessage(ModuleId, "categoryactionsave", NotifyCode.fail);
                }
            }
            NBrightBuyUtils.RemoveModCachePortalWide(PortalId); //clear any cache
        }