public static List <NBrightInfo> GetProductItemList(ItemListData itemListData, string listkey = "", string entityTypeCode = "PRD", string entityTypeCodeLang = "PRDLANG")
        {
            var strOut    = "";
            var strFilter = "";
            var rtnList   = new List <NBrightInfo>();

            if (itemListData.Exists && itemListData.ItemCount > 0)
            {
                var ModCtrl = new NBrightBuyController();
                if (listkey == "")
                {
                    foreach (var i in itemListData.listnames)
                    {
                        var itemlist = itemListData.GetItemList(i.Key);
                        if (itemlist.Count > 0)
                        {
                            strFilter = " and (";
                            foreach (var i2 in itemlist)
                            {
                                strFilter += " NB1.itemid = '" + i2 + "' or";
                            }
                            strFilter  = strFilter.Substring(0, (strFilter.Length - 3)) + ") ";
                            strFilter += " and (NB3.Visible = 1) ";
                            var l = ModCtrl.GetDataList(PortalSettings.Current.PortalId, -1, entityTypeCode,
                                                        entityTypeCodeLang, Utils.GetCurrentCulture(), strFilter, "", true);
                            foreach (var n in l)
                            {
                                n.SetXmlProperty("genxml/listkey", i.Key);
                                rtnList.Add(n);
                            }
                        }
                    }
                }
                else
                {
                    var itemlist = itemListData.GetItemList(listkey);
                    if (itemlist.Count > 0)
                    {
                        strFilter = " and (";
                        foreach (var i in itemlist)
                        {
                            strFilter += " NB1.itemid = '" + i + "' or";
                        }
                        strFilter  = strFilter.Substring(0, (strFilter.Length - 3)) + ") ";
                        strFilter += " and (NB3.Visible = 1) ";
                        var l = ModCtrl.GetDataList(PortalSettings.Current.PortalId, -1, _entityTypeCode,
                                                    _entityTypeCodeLang, Utils.GetCurrentCulture(), strFilter, "", true);
                        foreach (var n in l)
                        {
                            n.SetXmlProperty("genxml/listkey", listkey);
                            rtnList.Add(n);
                        }
                    }
                }
            }

            return(rtnList);
        }
Beispiel #2
0
 private void FixRecordGroupType(String parentid, String groupType, string editLangCurrent)
 {
     if (Utils.IsNumeric(parentid) && Convert.ToInt32(parentid) > 0)
     {
         EditLangCurrent = editLangCurrent;
         // fix any incorrect sort orders
         var strFilter = " and NB1.ParentItemId = " + parentid + " ";
         var levelList = _objCtrl.GetDataList(PortalSettings.Current.PortalId, -1, "CATEGORY", "CATEGORYLANG", EditLangCurrent, 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, EditLangCurrent);
             if (grouptype != groupType)
             {
                 catData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlgrouptype", groupType);
                 _objCtrl.Update(catData.DataRecord);
             }
             FixRecordGroupType(catData.Info.ItemID.ToString(""), groupType, editLangCurrent);
         }
     }
 }
Beispiel #3
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);
            }
        }
Beispiel #4
0
        private String GetData(HttpContext context, bool clearCache = false)
        {
            var objCtrl = new NBrightBuyController();
            var strOut  = "";
            //get uploaded params
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);

            var itemid         = ajaxInfo.GetXmlProperty("genxml/hidden/itemid");
            var typeCode       = ajaxInfo.GetXmlProperty("genxml/hidden/typecode");
            var newitem        = ajaxInfo.GetXmlProperty("genxml/hidden/newitem");
            var selecteditemid = ajaxInfo.GetXmlProperty("genxml/hidden/selecteditemid");
            var moduleid       = ajaxInfo.GetXmlProperty("genxml/hidden/moduleid");
            var editlang       = ajaxInfo.GetXmlProperty("genxml/hidden/editlang");

            if (editlang == "")
            {
                editlang = Utils.GetCurrentCulture();
            }

            var rundisplay = ajaxInfo.GetXmlPropertyBool("genxml/hidden/rundisplay");

            if (!Utils.IsNumeric(moduleid))
            {
                moduleid = "-2";                             // use moduleid -2 for razor
            }
            if (clearCache)
            {
                NBrightBuyUtils.RemoveModCache(Convert.ToInt32(moduleid));
            }

            if (newitem == "new")
            {
                selecteditemid = AddNew(moduleid, typeCode);
            }

            var templateControl = "/DesktopModules/NBright/OS_Reports";

            if (Utils.IsNumeric(selecteditemid))
            {
                // do edit field data if a itemid has been selected
                var obj = objCtrl.Get(Convert.ToInt32(selecteditemid), "", editlang);
                if (rundisplay)
                {
                    strOut = NBrightBuyUtils.RazorTemplRender("run.cshtml", Convert.ToInt32(moduleid), itemid + editlang + selecteditemid, obj, templateControl, "config", editlang, StoreSettings.Current.Settings());
                }
                else
                {
                    strOut = NBrightBuyUtils.RazorTemplRender("datafields.cshtml", Convert.ToInt32(moduleid), itemid + editlang + selecteditemid, obj, templateControl, "config", editlang, StoreSettings.Current.Settings());
                }
            }
            else
            {
                var pagenumber = ajaxInfo.GetXmlPropertyInt("genxml/hidden/pagenumber");
                var pagesize   = ajaxInfo.GetXmlPropertyInt("genxml/hidden/pagesize");

                if (pagenumber == 0)
                {
                    pagenumber = 1;
                }
                if (pagesize == 0)
                {
                    pagesize = 20;
                }

                var filter     = "";
                var searchText = ajaxInfo.GetXmlProperty("genxml/hidden/searchtext");
                if (searchText != "")
                {
                    filter += " and ( ";
                    filter += " (([xmldata].value('(genxml/textbox/ref)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))";
                    filter += " or (([xmldata].value('(genxml/lang/genxml/textbox/ref2)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))";
                    filter += " ) ";
                }

                // get only entity type required
                var recordcount = objCtrl.GetListCount(PortalSettings.Current.PortalId, -1, typeCode, filter);


                // Return list of items
                var l = objCtrl.GetDataList(PortalSettings.Current.PortalId, Convert.ToInt32(moduleid), typeCode, typeCode + "LANG", editlang, filter, " order by [XMLData].value('(genxml/textbox/ref)[1]','nvarchar(50)')", true, "", 0, pagenumber, pagesize, recordcount);
                strOut = NBrightBuyUtils.RazorTemplRenderList("datalist.cshtml", Convert.ToInt32(moduleid), "", l, templateControl, "config", editlang, StoreSettings.Current.Settings());

                if (recordcount > pagesize)
                {
                    var pg = new NBrightCore.controls.PagingCtrl();
                    strOut += pg.RenderPager(recordcount, pagesize, pagenumber);
                }
            }

            return(strOut);
        }
        private String GetData(HttpContext context, bool clearCache = false)

        {
            var objCtrl = new NBrightBuyController();
            var strOut  = "";
            //get uploaded params
            var ajaxInfo       = NBrightBuyUtils.GetAjaxFields(context);
            var itemid         = ajaxInfo.GetXmlProperty("genxml/hidden/itemid");
            var typeCode       = ajaxInfo.GetXmlProperty("genxml/hidden/typecode");
            var newitem        = ajaxInfo.GetXmlProperty("genxml/hidden/newitem");
            var selecteditemid = ajaxInfo.GetXmlProperty("genxml/hidden/selecteditemid");
            var moduleid       = ajaxInfo.GetXmlProperty("genxml/hidden/moduleid");
            var editlang       = ajaxInfo.GetXmlProperty("genxml/hidden/editlang");
            var selectlang     = ajaxInfo.GetXmlProperty("genxml/hidden/selectlang");
            var rundisplay     = ajaxInfo.GetXmlPropertyBool("genxml/hidden/rundisplay");

            if (selectlang != "")
            {
                editlang = selectlang;
            }

            if (itemid == "")
            {
                itemid = selecteditemid;
            }

            if (editlang == "")
            {
                editlang = _lang;
            }

            if (!Utils.IsNumeric(moduleid))
            {
                moduleid = "-2";                             // use moduleid -2 for razor
            }
            if (clearCache)
            {
                NBrightBuyUtils.RemoveModCache(Convert.ToInt32(moduleid));
            }

            if (newitem == "new")
            {
                itemid = AddNew(moduleid, typeCode);
            }

            var templateControl = "/DesktopModules/NBright/NBrightBuyReport";

            if (Utils.IsNumeric(itemid))
            {
                // do edit field data if a itemid has been selected
                var obj = objCtrl.Get(Convert.ToInt32(itemid), "", editlang);
                if (rundisplay)
                {
                    strOut = NBrightBuyUtils.RazorTemplRender(typeCode.ToLower() + "run.cshtml", Convert.ToInt32(moduleid), _lang + itemid + editlang, obj, templateControl, "config", _lang, StoreSettings.Current.Settings());
                }
                else
                {
                    strOut = NBrightBuyUtils.RazorTemplRender(typeCode.ToLower() + "fields.cshtml", Convert.ToInt32(moduleid), _lang + itemid + editlang, obj, templateControl, "config", _lang, StoreSettings.Current.Settings());
                }
            }
            else
            {
                // Return list of items
                var l = objCtrl.GetDataList(PortalSettings.Current.PortalId, Convert.ToInt32(moduleid), typeCode, typeCode + "LANG", Utils.GetCurrentCulture(), "", " order by ModifiedDate desc", false, "", 100, 0, 0, 0);
                strOut = NBrightBuyUtils.RazorTemplRenderList(typeCode.ToLower() + "list.cshtml", Convert.ToInt32(moduleid), _lang + editlang, l, templateControl, "config", _lang, StoreSettings.Current.Settings());
            }
            return(strOut);
        }
Beispiel #6
0
        public string ProductAdminList(HttpContext context)
        {
            try
            {
                if (NBrightBuyUtils.CheckRights())
                {
                    var ajaxInfo = NBrightBuyUtils.GetAjaxInfo(context);

                    if (UserController.Instance.GetCurrentUserInfo().UserID <= 0)
                    {
                        return(null);
                    }

                    var editlang = ajaxInfo.GetXmlProperty("genxml/hidden/editlang");
                    if (editlang == "")
                    {
                        editlang = Utils.GetCurrentCulture();
                    }

                    NBrightBuyUtils.RemoveModCache(-2);

                    ajaxInfo.SetXmlProperty("genxml/hidden/razortemplate", "datalist.cshtml");

                    var strOut = "";

                    // select a specific entity data type for the product (used by plugins)
                    var entitytypecodelang = "PRDLANG";
                    var entitytypecode     = "PRD";

                    var filter      = ajaxInfo.GetXmlProperty("genxml/hidden/filter");
                    var orderby     = ajaxInfo.GetXmlProperty("genxml/hidden/orderby");
                    var returnLimit = ajaxInfo.GetXmlPropertyInt("genxml/hidden/returnlimit");
                    var pageNumber  = ajaxInfo.GetXmlPropertyInt("genxml/hidden/pagenumber");
                    var pageSize    = ajaxInfo.GetXmlPropertyInt("genxml/hidden/pagesize");
                    var cascade     = ajaxInfo.GetXmlPropertyBool("genxml/hidden/cascade");
                    var portalId    = PortalSettings.Current.PortalId;
                    if (ajaxInfo.GetXmlProperty("genxml/hidden/portalid") != "")
                    {
                        portalId = ajaxInfo.GetXmlPropertyInt("genxml/hidden/portalid");
                    }

                    var searchText     = ajaxInfo.GetXmlProperty("genxml/hidden/searchtext");
                    var searchCategory = ajaxInfo.GetXmlProperty("genxml/hidden/searchcategory");

                    if (searchText != "")
                    {
                        filter += " and (NB3.[ProductName] like '%" + searchText + "%' or NB3.[ProductRef] like '%" + searchText + "%' or NB3.[Summary] like '%" + searchText + "%' ) ";
                    }

                    if (Utils.IsNumeric(searchCategory))
                    {
                        if (orderby == "{bycategoryproduct}")
                        {
                            orderby += searchCategory;
                        }
                        var objQual = DotNetNuke.Data.DataProvider.Instance().ObjectQualifier;
                        var dbOwner = DotNetNuke.Data.DataProvider.Instance().DatabaseOwner;
                        if (!cascade)
                        {
                            filter += " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where typecode = 'CATXREF' and XrefItemId = " + searchCategory + ") ";
                        }
                        else
                        {
                            filter += " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where (typecode = 'CATXREF' and XrefItemId = " + searchCategory + ") or (typecode = 'CATCASCADE' and XrefItemId = " + searchCategory + ")) ";
                        }
                    }
                    else
                    {
                        if (orderby == "{bycategoryproduct}")
                        {
                            orderby = " order by NB3.productname ";
                        }
                    }

                    // logic for client list of products
                    if (NBrightBuyUtils.IsClientOnly())
                    {
                        filter += " and NB1.ItemId in (select ParentItemId from dbo.[NBrightBuy] as NBclient where NBclient.TypeCode = 'USERPRDXREF' and NBclient.UserId = " + UserController.Instance.GetCurrentUserInfo().UserID.ToString("") + ") ";
                    }

                    var recordCount = 0;
                    var objCtrl     = new NBrightBuyController();

                    if (pageNumber == 0)
                    {
                        pageNumber = 1;
                    }
                    if (pageSize == 0)
                    {
                        pageSize = 20;
                    }

                    // get only entity type required.  Do NOT use typecode, that is set by the filter.
                    recordCount = objCtrl.GetListCount(PortalSettings.Current.PortalId, -1, "PRD", filter, "", editlang);

                    // get selected entitytypecode.
                    var list = objCtrl.GetDataList(PortalSettings.Current.PortalId, -1, "PRD", "PRDLANG", editlang, filter, orderby, StoreSettings.Current.DebugMode, "", returnLimit, pageNumber, pageSize, recordCount);

                    return(RenderProductAdminList(list, ajaxInfo, recordCount));
                }
            }
            catch (Exception ex)
            {
                Logging.LogException(ex);
                return(ex.ToString());
            }
            return("");
        }
Beispiel #7
0
        public static String ProductAdminList(Dictionary <string, string> settings, bool paging = true)
        {
            try
            {
                if (NBrightBuyUtils.CheckManagerRights())
                {
                    if (UserController.Instance.GetCurrentUserInfo().UserID <= 0)
                    {
                        return("");
                    }

                    var strOut = "";

                    if (!settings.ContainsKey("themefolder"))
                    {
                        settings.Add("themefolder", "");
                    }
                    if (!settings.ContainsKey("razortemplate"))
                    {
                        settings.Add("razortemplate", "");
                    }
                    if (!settings.ContainsKey("header"))
                    {
                        settings.Add("header", "");
                    }
                    if (!settings.ContainsKey("body"))
                    {
                        settings.Add("body", "");
                    }
                    if (!settings.ContainsKey("footer"))
                    {
                        settings.Add("footer", "");
                    }
                    if (!settings.ContainsKey("filter"))
                    {
                        settings.Add("filter", "");
                    }
                    if (!settings.ContainsKey("orderby"))
                    {
                        settings.Add("orderby", "");
                    }
                    if (!settings.ContainsKey("returnlimit"))
                    {
                        settings.Add("returnlimit", "0");
                    }
                    if (!settings.ContainsKey("pagenumber"))
                    {
                        settings.Add("pagenumber", "0");
                    }
                    if (!settings.ContainsKey("pagesize"))
                    {
                        settings.Add("pagesize", "0");
                    }
                    if (!settings.ContainsKey("searchtext"))
                    {
                        settings.Add("searchtext", "");
                    }
                    if (!settings.ContainsKey("searchcategory"))
                    {
                        settings.Add("searchcategory", "");
                    }
                    if (!settings.ContainsKey("cascade"))
                    {
                        settings.Add("cascade", "False");
                    }

                    if (!settings.ContainsKey("portalid"))
                    {
                        settings.Add("portalid", PortalSettings.Current.PortalId.ToString(""));                                    // aways make sure we have portalid in settings
                    }
                    // select a specific entity data type for the product (used by plugins)
                    if (!settings.ContainsKey("entitytypecode"))
                    {
                        settings.Add("entitytypecode", "PRD");
                    }
                    if (!settings.ContainsKey("entitytypecodelang"))
                    {
                        settings.Add("entitytypecodelang", "PRDLANG");
                    }
                    var entitytypecodelang = settings["entitytypecodelang"];
                    var entitytypecode     = settings["entitytypecode"];

                    var themeFolder   = settings["themefolder"];
                    var header        = settings["header"];
                    var body          = settings["body"];
                    var footer        = settings["footer"];
                    var filter        = settings["filter"];
                    var orderby       = settings["orderby"];
                    var returnLimit   = Convert.ToInt32(settings["returnlimit"]);
                    var pageNumber    = Convert.ToInt32(settings["pagenumber"]);
                    var pageSize      = Convert.ToInt32(settings["pagesize"]);
                    var cascade       = Convert.ToBoolean(settings["cascade"]);
                    var razortemplate = settings["razortemplate"];
                    var portalId      = Convert.ToInt32(settings["portalid"]);

                    var searchText     = settings["searchtext"];
                    var searchCategory = settings["searchcategory"];

                    if (searchText != "")
                    {
                        filter += " and (NB3.[ProductName] like '%" + searchText + "%' or NB3.[ProductRef] like '%" + searchText + "%' or NB3.[Summary] like '%" + searchText + "%' ) ";
                    }

                    if (Utils.IsNumeric(searchCategory))
                    {
                        if (orderby == "{bycategoryproduct}")
                        {
                            orderby += searchCategory;
                        }
                        var objQual = DotNetNuke.Data.DataProvider.Instance().ObjectQualifier;
                        var dbOwner = DotNetNuke.Data.DataProvider.Instance().DatabaseOwner;
                        if (!cascade)
                        {
                            filter += " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where typecode = 'CATXREF' and XrefItemId = " + searchCategory + ") ";
                        }
                        else
                        {
                            filter += " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where (typecode = 'CATXREF' and XrefItemId = " + searchCategory + ") or (typecode = 'CATCASCADE' and XrefItemId = " + searchCategory + ")) ";
                        }
                    }
                    else
                    {
                        if (orderby == "{bycategoryproduct}")
                        {
                            orderby = " order by NB3.productname ";
                        }
                    }

                    // logic for client list of products
                    if (NBrightBuyUtils.IsClientOnly())
                    {
                        filter += " and NB1.ItemId in (select ParentItemId from dbo.[NBrightBuy] as NBclient where NBclient.TypeCode = 'USERPRDXREF' and NBclient.UserId = " + UserController.Instance.GetCurrentUserInfo().UserID.ToString("") + ") ";
                    }

                    var recordCount = 0;

                    if (themeFolder == "")
                    {
                        themeFolder = StoreSettings.Current.ThemeFolder;
                        if (settings.ContainsKey("themefolder"))
                        {
                            themeFolder = settings["themefolder"];
                        }
                    }


                    var objCtrl = new NBrightBuyController();

                    if (paging) // get record count for paging
                    {
                        if (pageNumber == 0)
                        {
                            pageNumber = 1;
                        }
                        if (pageSize == 0)
                        {
                            pageSize = 20;
                        }

                        // get only entity type required
                        recordCount = objCtrl.GetListCount(PortalSettings.Current.PortalId, -1, entitytypecode, filter, entitytypecodelang, Utils.GetCurrentCulture());
                    }

                    // get selected entitytypecode.
                    var list = objCtrl.GetDataList(PortalSettings.Current.PortalId, -1, entitytypecode, entitytypecodelang, Utils.GetCurrentCulture(), filter, orderby, StoreSettings.Current.DebugMode, "", returnLimit, pageNumber, pageSize, recordCount);

                    var passSettings = settings;
                    foreach (var s in StoreSettings.Current.Settings()) // copy store setting, otherwise we get a byRef assignement
                    {
                        if (passSettings.ContainsKey(s.Key))
                        {
                            passSettings[s.Key] = s.Value;
                        }
                        else
                        {
                            passSettings.Add(s.Key, s.Value);
                        }
                    }

                    strOut = NBrightBuyUtils.RazorTemplRenderList(razortemplate, 0, "", list, "/DesktopModules/NBright/NBrightBuy", themeFolder, Utils.GetCurrentCulture(), passSettings);

                    // add paging if needed
                    if (paging && (recordCount > pageSize))
                    {
                        var pg = new NBrightCore.controls.PagingCtrl();
                        strOut += pg.RenderPager(recordCount, pageSize, pageNumber);
                    }

                    return(strOut);
                }
                return("");
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }