Beispiel #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);
 }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IEnumerable <Tally> GetTallyManList(int orderId)
        {
            NBrightBuyController nBrightBuy = new NBrightBuyController();
            List <Tally>         tallies    = new List <Tally>();
            OrderData            orderData  = new OrderData(orderId);

            var info = orderData.PurchaseInfo.XMLDoc.SelectNodes("genxml/tally/*");

            foreach (XmlNode xml in info)
            {
                var newInfo = new NBrightInfo
                {
                    XMLData = xml.OuterXml
                };
                tallies.Add(new Tally
                {
                    OrderId        = newInfo.ItemID,
                    IsTally        = newInfo.GetXmlPropertyBool("genxml/istally"),
                    ManId          = newInfo.GetXmlPropertyInt("genxml/manid"),
                    TallyMan       = newInfo.GetXmlProperty("genxml/tallyman"),
                    TallyStartDate = newInfo.GetXmlProperty("genxml/tallystartdate"),
                    TallyEndDate   = newInfo.GetXmlProperty("genxml/tallyenddate")
                });
            }
            return(tallies);
        }
Beispiel #3
0
        public override bool IsValid(NBrightInfo cartInfo)
        {
            // check if this provider is valid for the counrty in the checkout
            var shipoption = cartInfo.GetXmlProperty("genxml/extrainfo/genxml/radiobuttonlist/rblshippingoptions");
            var countrycode = "";
            switch (shipoption)
            {
                case "1":
                    countrycode = cartInfo.GetXmlProperty("genxml/billaddress/genxml/dropdownlist/country");
                    break;
                case "2":
                    countrycode = cartInfo.GetXmlProperty("genxml/shipaddress/genxml/dropdownlist/country");
                    break;
            }

            var isValid = true;
            var shipData = new ShippingData(Shippingkey);
            var validlist = "," + shipData.Info.GetXmlProperty("genxml/textbox/validcountrycodes") + ",";
            var notvalidlist = "," + shipData.Info.GetXmlProperty("genxml/textbox/notvalidcountrycodes") + ",";
            if (validlist.Trim(',') != "")
            {
                isValid = false;
                if (validlist.Contains("," + countrycode + ",")) isValid = true;
            }
            if (notvalidlist.Trim(',') != "" && notvalidlist.Contains("," + countrycode + ",")) isValid = false;

            return isValid;
        }
Beispiel #4
0
        public IEnumerable <Items> GetItemList(int orderId)
        {
            List <Items> items     = new List <Items>();
            OrderData    orderData = new OrderData(orderId);

            var info = orderData.PurchaseInfo.XMLDoc.SelectNodes("genxml/items/*");

            foreach (XmlNode xml in info)
            {
                var newInfo = new NBrightInfo
                {
                    XMLData = xml.OuterXml
                };

                items.Add(new Items
                {
                    ProductName  = newInfo.GetXmlProperty("genxml/productname"),
                    Qty          = newInfo.GetXmlPropertyInt("genxml/qty"),
                    Model        = newInfo.GetXmlProperty("genxml/taxratecode"),
                    ProductPrice = Convert.ToDecimal(newInfo.GetXmlPropertyDouble("genxml/appliedcost")),
                    ProductTotal = Convert.ToDecimal(newInfo.GetXmlPropertyDouble("genxml/appliedtotalcost"))
                });
            }
            return(items);
        }
Beispiel #5
0
        private List <NBrightInfo> CalcPluginList(NBrightInfo info)
        {
            var rtnList     = new List <NBrightInfo>();
            var xmlNodeList = info.XMLDoc.SelectNodes("genxml/plugin/*");

            if (xmlNodeList != null)
            {
                foreach (XmlNode carNod in xmlNodeList)
                {
                    var newInfo = new NBrightInfo {
                        XMLData = carNod.OuterXml
                    };
                    newInfo.ItemID = rtnList.Count;
                    newInfo.SetXmlProperty("genxml/hidden/index", rtnList.Count.ToString(""));
                    newInfo.GUIDKey = newInfo.GetXmlProperty("genxml/textbox/ctrl");
                    rtnList.Add(newInfo);
                }
            }

            // get the systemlevel, incase this is an update and we have new system level provider that needs to be added
            // Some systems create their own portal specific menu we assume they don't require new updates from NBS core, so take that if we have one.
            var menupluginsys = _templCtrl.GetTemplateData("menuplugin" + _portalId + ".xml", Utils.GetCurrentCulture(), true, true, false, _storeSettings.Settings());

            // if no portal specific menus exist, take the default
            if (menupluginsys == "")
            {
                menupluginsys = _templCtrl.GetTemplateData("menuplugin.xml", Utils.GetCurrentCulture(), true, true, false, _storeSettings.Settings());
            }
            var infosys = new NBrightInfo();

            infosys.XMLData = menupluginsys;
            if (infosys.XMLDoc != null)
            {
                var xmlNodeList2 = infosys.XMLDoc.SelectNodes("genxml/plugin/*");
                if (xmlNodeList2 != null)
                {
                    foreach (XmlNode carNod in xmlNodeList2)
                    {
                        var newInfo = new NBrightInfo {
                            XMLData = carNod.OuterXml
                        };
                        newInfo.GUIDKey = newInfo.GetXmlProperty("genxml/textbox/ctrl");
                        var resultsys = rtnList.Where(p => p.GUIDKey == newInfo.GUIDKey);
                        if (!resultsys.Any())
                        {
                            // add the missing plugin to the active list
                            newInfo.ItemID = rtnList.Count;
                            newInfo.SetXmlProperty("genxml/hidden/index", rtnList.Count.ToString(""));
                            newInfo.GUIDKey = newInfo.GetXmlProperty("genxml/textbox/ctrl");
                            rtnList.Add(newInfo);
                        }
                    }
                }
            }

            return(rtnList);
        }
        public static String RenderPluginAdminList(List <NBrightInfo> list, NBrightInfo ajaxInfo, int recordCount)
        {
            try
            {
                if (NBrightBuyUtils.CheckRights())
                {
                    if (list == null)
                    {
                        return("");
                    }
                    var strOut = "";

                    // select a specific entity data type for the product (used by plugins)
                    var themeFolder = ajaxInfo.GetXmlProperty("genxml/hidden/themefolder");
                    if (themeFolder == "")
                    {
                        themeFolder = "config";
                    }
                    var razortemplate = ajaxInfo.GetXmlProperty("genxml/hidden/razortemplate");
                    if (razortemplate == "")
                    {
                        razortemplate = "Admin_pluginsList.cshtml";
                    }

                    var passSettings = new Dictionary <string, string>();
                    foreach (var s in ajaxInfo.ToDictionary())
                    {
                        if (!passSettings.ContainsKey(s.Key))
                        {
                            passSettings.Add(s.Key, s.Value);
                        }
                    }
                    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, TemplateRelPath, themeFolder, Utils.GetCurrentCulture(), passSettings);

                    return(strOut);
                }
                return("");
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Beispiel #7
0
        public void Update(NBrightInfo info)
        {
            var localfields = info.GetXmlProperty("genxml/hidden/localizedfields").Split(',');

            foreach (var f in localfields)
            {
                if (f == "genxml/edt/message")
                {
                    // special processing for editor, to place code in standard place.
                    if (DataLangRecord.XMLDoc.SelectSingleNode("genxml/edt") == null)
                    {
                        DataLangRecord.AddSingleNode("edt", "", "genxml");
                    }
                    if (info.GetXmlProperty("genxml/textbox/message") == "")
                    {
                        DataLangRecord.SetXmlProperty(f, info.GetXmlProperty("genxml/edt/message"));
                    }
                    else
                    {
                        DataLangRecord.SetXmlProperty(f, info.GetXmlProperty("genxml/textbox/message")); // ajax on ckeditor (Ajax diesn't work for telrik)
                    }
                }
                else
                {
                    DataLangRecord.SetXmlProperty(f, info.GetXmlProperty(f));
                }

                DataRecord.RemoveXmlNode(f);
            }
            var fields = info.GetXmlProperty("genxml/hidden/fields").Split(',');

            foreach (var f in fields)
            {
                DataRecord.SetXmlProperty(f, info.GetXmlProperty(f));
                // if we have a image field then we need to create the imageurl field
                if (info.GetXmlProperty(f.Replace("textbox/", "hidden/hidinfo")) == "Img=True")
                {
                    DataRecord.SetXmlProperty(f.Replace("textbox/", "hidden/") + "url", StoreSettings.Current.FolderImages + "/" + info.GetXmlProperty(f.Replace("textbox/", "hidden/hid")));
                    DataRecord.SetXmlProperty(f.Replace("textbox/", "hidden/") + "path", StoreSettings.Current.FolderImagesMapPath + "\\" + info.GetXmlProperty(f.Replace("textbox/", "hidden/hid")));
                }
                if (f == "genxml/dropdownlist/ddlparentcatid")
                {
                    var parentitemid = info.GetXmlProperty(f);
                    if (!Utils.IsNumeric(parentitemid))
                    {
                        parentitemid = "0";
                    }
                    if (DataRecord.ParentItemId != Convert.ToInt32(parentitemid))
                    {
                        _oldcatcascadeid        = DataRecord.ParentItemId;
                        _doCascadeIndex         = true;
                        DataRecord.ParentItemId = Convert.ToInt32(parentitemid);
                    }
                }
                DataLangRecord.RemoveXmlNode(f);
            }
        }
Beispiel #8
0
        private void PopulateData(String userId)
        {
            DocList      = new Dictionary <string, NBrightInfo>();
            _fileKeyXref = new Dictionary <string, string>();

            Exists = false;
            if (Utils.IsNumeric(userId))
            {
                _userInfo = UserController.GetUserById(PortalSettings.Current.PortalId, Convert.ToInt32(userId));
            }
            else
            {
                _userInfo = UserController.Instance.GetCurrentUserInfo();
            }

            if (_userInfo != null && _userInfo.UserID != -1) // only create userdata if we have a user logged in.
            {
                var modCtrl = new NBrightBuyController();
                Info = modCtrl.GetByType(_userInfo.PortalID, -1, "USERDATA", _userInfo.UserID.ToString(""));
                if (Info == null && _userInfo.UserID != -1)
                {
                    Info          = new NBrightInfo();
                    Info.ItemID   = -1;
                    Info.UserId   = _userInfo.UserID;
                    Info.PortalId = _userInfo.PortalID;
                    Info.ModuleId = -1;
                    Info.TypeCode = "USERDATA";
                    Info.XMLData  = "<genxml></genxml>";
                    Save();
                }
                else
                {
                    Exists = true;
                }

                var nodlist = Info.XMLDoc.SelectNodes("genxml/docs/*");
                if (nodlist != null)
                {
                    foreach (XmlNode nod in nodlist)
                    {
                        if (nod.SelectSingleNode("filename") != null && !_fileKeyXref.ContainsKey(nod.SelectSingleNode("filename").InnerXml))
                        {
                            var nbi = new NBrightInfo();
                            nbi.XMLData = nod.OuterXml;
                            nbi.GUIDKey = nbi.GetXmlProperty("genxml/key");
                            DocList.Add(nbi.GetXmlProperty("genxml/key"), nbi);
                            _fileKeyXref.Add(nbi.GetXmlProperty("genxml/filename"), nbi.GUIDKey);
                        }
                    }
                }
            }
        }
Beispiel #9
0
 /// <summary>
 /// Add Adddress
 /// </summary>
 /// <param name="rpData"></param>
 /// <param name="debugMode"></param>
 public String AddAddress(Repeater rpData, Boolean debugMode = false)
 {
     var strXml = GenXmlFunctions.GetGenXml(rpData, "", "");
     // load into NBrigthInfo class, so it's easier to get at xml values.
     var objInfoIn = new NBrightInfo();
     objInfoIn.XMLData = strXml;
     var addIndex = objInfoIn.GetXmlProperty("genxml/hidden/index"); // addresses updated from manager should have a index hidden field.
     if (addIndex == "") addIndex = objInfoIn.GetXmlProperty("genxml/dropdownlist/selectaddress"); // updated from cart should have a selected address
     if (!Utils.IsNumeric(addIndex)) addIndex = "-1"; // assume new address.
     var addressIndex = Convert.ToInt32(addIndex);
     AddAddress(objInfoIn,addressIndex);
     return ""; // if everything is OK, don't send a message back.
 }
        public IEncodedString RegionSelect(NBrightInfo info, String xpath, String countryCode, String attributes = "", Boolean allowEmpty = true)
        {
            if (countryCode == "")
            {
                // get the countrycode if already updated
                countryCode = info.GetXmlProperty(xpath.Replace("region", "country"));
            }

            var rtnList = NBrightBuyUtils.GetRegionList(countryCode);

            if (rtnList != null && rtnList.Count > 0)
            {
                // we have a list, so do a dropdownlist
                if (attributes.StartsWith("ResourceKey:"))
                {
                    attributes = ResourceKey(attributes.Replace("ResourceKey:", "")).ToString();
                }

                var strOut = "";

                var upd = getUpdateAttr(xpath, attributes);
                var id  = getIdFromXpath(xpath);
                strOut = "<select id='" + id + "' " + upd + " " + attributes + ">";
                var s = "";
                if (allowEmpty)
                {
                    strOut += "    <option value=''></option>";
                }
                foreach (var tItem in rtnList)
                {
                    if (info.GetXmlProperty(xpath) == tItem.Key.ToString())
                    {
                        s = "selected";
                    }
                    else
                    {
                        s = "";
                    }
                    strOut += "    <option value='" + tItem.Key.ToString() + "' " + s + ">" + tItem.Value + "</option>";
                }
                strOut += "</select>";
                return(new RawString(strOut));
            }
            else
            {
                // no list so output textbox
                xpath = xpath.Replace("dropdownlist", "textbox");
                return(NBrightTextBox(info, xpath, attributes, ""));
            }
        }
Beispiel #11
0
        /// <summary>
        /// Get the cookie data from the client.
        /// </summary>
        /// <returns></returns>
        public NavigationData Get(string tempfilename = "")
        {
            ClearData();

            if (tempfilename == "")
            {
                if (_storageType == DataStorageType.SessionMemory)
                {
                    if (HttpContext.Current.Session[_cookieName + "tempname"] != null)
                    {
                        tempfilename = (String)HttpContext.Current.Session[_cookieName + "tempname"];
                    }
                }
                else
                {
                    tempfilename = Cookie.GetCookieValue(_portalId, _cookieName, "tempname", "");
                }
            }

            XmlData = "";

            if (tempfilename != "")
            {
                var filePath = StoreSettings.Current.FolderTempMapPath + "\\" + tempfilename;
                if (File.Exists(filePath))
                {
                    XmlData = Utils.ReadFile(filePath);
                }
                var nbi = new NBrightInfo();
                nbi.XMLData = XmlData;

                _criteria      = nbi.GetXmlProperty("genxml/Criteria");
                PageModuleId   = nbi.GetXmlProperty("genxml/PageModuleId");
                PageNumber     = nbi.GetXmlProperty("genxml/PageNumber");
                PageName       = nbi.GetXmlProperty("genxml/PageName");
                PageSize       = nbi.GetXmlProperty("genxml/PageSize");
                OrderBy        = nbi.GetXmlProperty("genxml/OrderBy");
                CategoryId     = Convert.ToInt32(nbi.GetXmlPropertyDouble("genxml/CategoryId"));
                RecordCount    = nbi.GetXmlProperty("genxml/RecordCount");
                Mode           = nbi.GetXmlProperty("genxml/Mode");
                OrderByIdx     = nbi.GetXmlProperty("genxml/OrderByIdx");
                SearchFormData = nbi.GetXmlNode("genxml/SearchFormData").ToString();
            }

            if (_criteria == "" && XmlData == "") // "Exist" property not used for paging data
            {
                Exists = false;
            }
            else
            {
                Exists = true;
            }

            return(this);
        }
Beispiel #12
0
        public override NBrightInfo CalculateShipping(NBrightInfo cartInfo)
        {
            var    shipData   = new ShippingData(Shippingkey);
            var    shipoption = cartInfo.GetXmlProperty("genxml/extrainfo/genxml/radiobuttonlist/rblshippingoptions");
            Double rangeValue = 0;

            if (shipData.CalculationUnit == "1")
            {
                rangeValue = cartInfo.GetXmlPropertyDouble("genxml/totalweight");
            }
            else
            {
                rangeValue = cartInfo.GetXmlPropertyDouble("genxml/appliedsubtotal");
            }
            var countrycode = "";
            var regioncode  = "";
            var regionkey   = "";
            var total       = cartInfo.GetXmlPropertyDouble("genxml/appliedsubtotal");

            switch (shipoption)
            {
            case "1":
                countrycode = cartInfo.GetXmlProperty("genxml/billaddress/genxml/dropdownlist/country");
                regionkey   = cartInfo.GetXmlProperty("genxml/billaddress/genxml/dropdownlist/region");
                break;

            case "2":
                countrycode = cartInfo.GetXmlProperty("genxml/shipaddress/genxml/dropdownlist/country");
                regionkey   = cartInfo.GetXmlProperty("genxml/shipaddress/genxml/dropdownlist/region");
                break;
            }

            if (regionkey != "")
            {
                var rl = regionkey.Split(':');
                if (rl.Count() == 2)
                {
                    regioncode = rl[1];
                }
            }

            var shippingcost       = shipData.CalculateShipping(countrycode, regioncode, rangeValue, total);
            var shippingdealercost = shippingcost;

            cartInfo.SetXmlPropertyDouble("genxml/shippingcost", shippingcost);
            cartInfo.SetXmlPropertyDouble("genxml/shippingdealercost", shippingdealercost);

            return(cartInfo);
        }
Beispiel #13
0
 public String getChecked(NBrightInfo info, String xpath, Boolean defaultValue)
 {
     if (info.GetXmlProperty(xpath) == "True")
     {
         return("checked='True'");
     }
     if (info.GetXmlProperty(xpath) == "")
     {
         if (defaultValue)
         {
             return("checked='True'");
         }
     }
     return("");
 }
        public IEncodedString AddressSelectList(NBrightInfo info, String xpath, String formselector, String datafields, String attributes = "", Boolean allowEmpty = true)
        {
            var usr         = UserController.Instance.GetCurrentUserInfo();
            var addressData = new AddressData(usr.UserID.ToString(""));

            var rtnList = addressData.GetAddressList();

            if (attributes.StartsWith("ResourceKey:"))
            {
                attributes = ResourceKey(attributes.Replace("ResourceKey:", "")).ToString();
            }

            var fieldList = datafields.Split(',');

            var strOut = "";
            var upd    = getUpdateAttr(xpath, attributes);
            var id     = getIdFromXpath(xpath);

            strOut = "<select id='" + id + "' " + upd + " " + attributes + " formselector='" + formselector + "' >";
            var s = "";

            if (allowEmpty)
            {
                strOut += "    <option value=''></option>";
            }
            foreach (var tItem in rtnList)
            {
                var fields     = tItem.ToDictionary();
                var datavalues = "";
                foreach (var xp in fieldList)
                {
                    if (xp != "" && fields.ContainsKey(xp))
                    {
                        datavalues += "," + fields[xp].Replace(",", " ");
                    }
                    else
                    {
                        datavalues += ",";
                    }
                }

                var itemtext = tItem.GetXmlProperty("genxml/textbox/firstname") + "," + tItem.GetXmlProperty("genxml/textbox/lastname") + "," + tItem.GetXmlProperty("genxml/textbox/unit") + "," + tItem.GetXmlProperty("genxml/textbox/street") + "," + tItem.GetXmlProperty("genxml/textbox/city");
                var idx      = tItem.GetXmlProperty("genxml/hidden/index");
                if (idx != "")
                {
                    if (info.GetXmlProperty(xpath) == idx)
                    {
                        s = "selected";
                    }
                    else
                    {
                        s = "";
                    }
                    strOut += "    <option value='" + idx + "' " + s + " datafields = '" + datafields + "' datavalues = '" + datavalues.TrimStart(',') + "' > " + itemtext.TrimStart(',') + "</option>";
                }
            }
            strOut += "</select>";

            return(new RawString(strOut));
        }
Beispiel #15
0
        public String AddPlugin(NBrightInfo pluginInfo, int index = -1)
        {
            // look to see if we already have the plugin
            var ctrl = pluginInfo.GetXmlProperty("genxml/textbox/ctrl");

            if (ctrl != "")
            {
                var ctrllist     = from i in _pluginList where i.GetXmlProperty("genxml/textbox/ctrl") == ctrl select i;
                var nBrightInfos = ctrllist as IList <NBrightInfo> ?? ctrllist.ToList();
                if (nBrightInfos.Any())
                {
                    index = nBrightInfos.First().GetXmlPropertyInt("genxml/hidden/index");
                }
            }

            if (index == -1)
            {
                _pluginList.Add(pluginInfo);
            }
            else
            {
                UpdatePlugin(pluginInfo.XMLData, index);
            }

            return(""); // if everything is OK, don't send a message back.
        }
Beispiel #16
0
        public IEncodedString CheckBoxListOf(NBrightInfo info, String xpath, String datavalue, String datatext, String attributes = "")
        {
            if (datavalue.StartsWith("ResourceKey:"))
            {
                datavalue = ResourceKey(datavalue.Replace("ResourceKey:", "")).ToString();
            }
            if (datatext.StartsWith("ResourceKey:"))
            {
                datatext = ResourceKey(datatext.Replace("ResourceKey:", "")).ToString();
            }
            if (attributes.StartsWith("ResourceKey:"))
            {
                attributes = ResourceKey(attributes.Replace("ResourceKey:", "")).ToString();
            }

            var strOut = "";
            var datav  = datavalue.Split(',');
            var datat  = datatext.Split(',');

            if (datav.Count() == datat.Count())
            {
                strOut = "<ul " + attributes + ">";
                var c = 0;
                foreach (var v in datav)
                {
                    if (info.GetXmlProperty(xpath + "/chk[@data='" + v + "']/@value") == "True")
                    {
                        strOut += "    <li>" + datat[c] + "</li>";
                    }
                    c += 1;
                }
                strOut += "</ul>";
            }
            return(new RawString(strOut.ToString()));
        }
Beispiel #17
0
        public IEncodedString EmailOf(NBrightInfo info, String xpath)
        {
            var strOut = info.GetXmlProperty(xpath);

            strOut = Utils.FormatAsMailTo(strOut);
            return(new RawString(strOut));
        }
Beispiel #18
0
        public IEncodedString HtmlOf(NBrightInfo info, String xpath)
        {
            var strOut = info.GetXmlProperty(xpath);

            strOut = System.Web.HttpUtility.HtmlDecode(strOut);
            return(new RawString(strOut));
        }
Beispiel #19
0
        public IEncodedString TextBox(NBrightInfo info, String xpath, String attributes = "", String defaultValue = "")
        {
            if (attributes.StartsWith("ResourceKey:"))
            {
                attributes = ResourceKey(attributes.Replace("ResourceKey:", "")).ToString();
            }
            if (defaultValue.StartsWith("ResourceKey:"))
            {
                defaultValue = ResourceKey(defaultValue.Replace("ResourceKey:", "")).ToString();
            }

            var upd   = getUpdateAttr(xpath, attributes);
            var id    = getIdFromXpath(xpath);
            var value = info.GetXmlProperty(xpath);

            if (value == "")
            {
                value = defaultValue;
            }

            var typeattr = "type='text'";

            if (attributes.ToLower().Contains(" type="))
            {
                typeattr = "";
            }

            var strOut = "<input value='" + value.Replace("'", "&#39;") + "' id='" + id + "' " + attributes + " " + upd + " " + typeattr + " />";

            return(new RawString(strOut));
        }
 public override NBrightInfo UpdatePercentUsage(int portalId, int userId, NBrightInfo purchaseInfo)
 {
     if (userId <= 0) return purchaseInfo;
     var discountcode = purchaseInfo.GetXmlProperty("genxml/extrainfo/genxml/textbox/promocode");
     if (!purchaseInfo.GetXmlPropertyBool("genxml/discountprocessed"))
     {
         if (discountcode == "") return purchaseInfo;
         var clientData = new ClientData(portalId, userId);
         if (clientData.DiscountCodes.Count == 0) return purchaseInfo;
         var list = clientData.DiscountCodes;
         foreach (var d in list)
         {
             if (d.GetXmlProperty("genxml/textbox/coderef").ToLower() == discountcode.ToLower())
             {
                 var usageleft = d.GetXmlPropertyDouble("genxml/textbox/usageleft");
                 var used = d.GetXmlPropertyDouble("genxml/textbox/used");
                 d.SetXmlPropertyDouble("genxml/textbox/usageleft", (usageleft - 1));
                 d.SetXmlPropertyDouble("genxml/textbox/used", (used + 1));
             }
         }
         clientData.UpdateDiscountCodeList(list);
         clientData.Save();
         purchaseInfo.SetXmlProperty("genxml/discountprocessed", "True");
     }
     return purchaseInfo;
 }
Beispiel #21
0
        private Boolean CheckSecurity(NBrightInfo pluginData)
        {
            if (pluginData.GetXmlPropertyBool("genxml/checkbox/hidden"))
            {
                return(false);
            }

            var roles = pluginData.GetXmlProperty("genxml/textbox/roles");

            if (roles.Trim() == "")
            {
                roles = StoreSettings.ManagerRole + "," + StoreSettings.EditorRole;
            }
            if (UserInfo.IsSuperUser)
            {
                return(true);
            }
            if (UserInfo.IsInRole("Administrators"))
            {
                return(true);
            }
            var rlist = roles.Split(',');

            foreach (var r in rlist)
            {
                if (UserInfo.IsInRole(r))
                {
                    return(true);
                }
            }
            return(false);
        }
        public Double CalculateDiscount(String discountCode)
        {
            // calc if we have free shipping limit
            var freeShipAmt  = Info.GetXmlPropertyDouble("genxml/textbox/freeshiplimit");
            var freeShipRefs = Info.GetXmlProperty("genxml/textbox/freeshipcountrycodes");

            return(0);
        }
Beispiel #23
0
        /// <summary>
        /// Search filesystem for any new plugins that have been added. Removed any deleted ones.
        /// </summary>
        public void UpdateSystemPlugins()
        {
            if (!_portallevel) // only want to edit system level file
            {
                // Add new plugins
                var updated             = false;
                var pluginfoldermappath = System.Web.Hosting.HostingEnvironment.MapPath(StoreSettings.NBrightBuyPath() + "/Plugins");
                if (pluginfoldermappath != null && Directory.Exists(pluginfoldermappath))
                {
                    var ctrlList = new Dictionary <String, int>();
                    var flist    = Directory.GetFiles(pluginfoldermappath);
                    foreach (var f in flist)
                    {
                        if (f.EndsWith(".xml"))
                        {
                            var datain = File.ReadAllText(f);
                            try
                            {
                                var nbi = new NBrightInfo();
                                nbi.XMLData = datain;
                                // check if we are injecting multiple
                                var nodlist = nbi.XMLDoc.SelectNodes("root/genxml");
                                if (nodlist != null && nodlist.Count == 0)
                                {
                                    AddPlugin(nbi);
                                }
                                else
                                {
                                    foreach (XmlNode nod in nodlist)
                                    {
                                        var nbi2 = new NBrightInfo();
                                        nbi2.XMLData = nod.OuterXml;
                                        AddPlugin(nbi2);
                                    }
                                }


                                ctrlList.Add(nbi.GetXmlProperty("genxml/textbox/ctrl"), nbi.GetXmlPropertyInt("genxml/hidden/index"));

                                updated = true;
                                File.Delete(f);
                            }
                            catch (Exception)
                            {
                                // data might not be XML complient (ignore)
                            }
                        }
                    }

                    if (updated)
                    {
                        Save(false); // only update system level
                    }
                }
            }
        }
Beispiel #24
0
        public IEncodedString BreakOf(NBrightInfo info, String xpath)
        {
            var strOut = info.GetXmlProperty(xpath);

            strOut = System.Web.HttpUtility.HtmlEncode(strOut);
            strOut = strOut.Replace(Environment.NewLine, "<br/>");
            strOut = strOut.Replace("\t", "&nbsp;&nbsp;&nbsp;");
            strOut = strOut.Replace("'", "&apos;");
            return(new RawString(strOut));
        }
Beispiel #25
0
        private void DoImportDocs(NBrightInfo nbi)
        {
            var fname = StoreSettings.Current.FolderUploadsMapPath + "\\" + nbi.GetXmlProperty("genxml/hidden/hiddocsfile");

            if (System.IO.File.Exists(fname))
            {
                DnnUtils.UnZip(fname, StoreSettings.Current.FolderDocumentsMapPath);
            }
            Utils.DeleteSysFile(fname);
        }
Beispiel #26
0
        public override Double CalculateItemTax(NBrightInfo cartItemInfo)
        {
            var info    = ProviderUtils.GetProviderSettings("tax");
            var taxtype = info.GetXmlProperty("genxml/radiobuttonlist/taxtype");

            if (taxtype == "3")
            {
                return(0);
            }

            var rateDic = GetRates();

            if (!rateDic.Any())
            {
                return(0);
            }

            // loop through each item and calc the tax for each.
            Double taxtotal = 0;

            var totalcost = cartItemInfo.GetXmlPropertyDouble("genxml/totalcost");

            // check if dealer and if dealertotal cost exists. ()
            if (cartItemInfo.GetXmlPropertyBool("genxml/isdealer"))
            {
                totalcost = cartItemInfo.GetXmlPropertyDouble("genxml/dealercost");
            }
            var taxratecode = cartItemInfo.GetXmlProperty("genxml/taxratecode");

            if (!Utils.IsNumeric(taxratecode))
            {
                taxratecode = "0";
            }
            if (!rateDic.ContainsKey(taxratecode))
            {
                taxratecode = "0";
            }
            Double taxrate = 0;

            if (rateDic.ContainsKey(taxratecode))
            {
                taxrate = rateDic[taxratecode]; // Can happen is no default tax added.
            }
            if (taxtype == "1")                 // included in unit price
            {
                taxtotal += totalcost - ((totalcost / (100 + taxrate)) * 100);
            }
            if (taxtype == "2") // NOT included in unit price
            {
                taxtotal += (totalcost / 100) * taxrate;
            }

            return(Math.Round(taxtotal, 2));
        }
Beispiel #27
0
        private void UnSharedRecord(NBrightInfo i)
        {
            var createdportalid = PortalSettings.Current.PortalId; // default previously shared record to this portal.

            if (Utils.IsNumeric(i.GetXmlProperty("genxml/createdportalid")))
            {
                createdportalid = i.GetXmlPropertyInt("genxml/createdportalid");
            }
            i.PortalId = createdportalid;
            ModCtrl.Update(i);
        }
Beispiel #28
0
        public IEncodedString DropDownList(NBrightInfo info, String xpath, String datavalue, String datatext, String attributes = "", String defaultValue = "")
        {
            if (datavalue.StartsWith("ResourceKey:"))
            {
                datavalue = ResourceKey(datavalue.Replace("ResourceKey:", "")).ToString();
            }
            if (datatext.StartsWith("ResourceKey:"))
            {
                datatext = ResourceKey(datatext.Replace("ResourceKey:", "")).ToString();
            }
            if (attributes.StartsWith("ResourceKey:"))
            {
                attributes = ResourceKey(attributes.Replace("ResourceKey:", "")).ToString();
            }
            if (defaultValue.StartsWith("ResourceKey:"))
            {
                defaultValue = ResourceKey(defaultValue.Replace("ResourceKey:", "")).ToString();
            }

            var strOut = "";
            var datav  = datavalue.Split(',');
            var datat  = datatext.Split(',');

            if (datav.Count() == datat.Count())
            {
                var upd = getUpdateAttr(xpath, attributes);
                var id  = getIdFromXpath(xpath);
                strOut = "<select id='" + id + "' " + upd + " " + attributes + ">";
                var c     = 0;
                var s     = "";
                var value = info.GetXmlProperty(xpath);
                if (value == "")
                {
                    value = defaultValue;
                }
                foreach (var v in datav)
                {
                    if (value == v)
                    {
                        s = "selected";
                    }
                    else
                    {
                        s = "";
                    }

                    strOut += "    <option value='" + v + "' " + s + ">" + datat[c] + "</option>";
                    c      += 1;
                }
                strOut += "</select>";
            }
            return(new RawString(strOut));
        }
Beispiel #29
0
        public IEncodedString RadioButtonList(NBrightInfo info, String xpath, String datavalue, String datatext, String attributes = "", String defaultValue = "", String labelattributes = "")
        {
            if (datavalue.StartsWith("ResourceKey:"))
            {
                datavalue = ResourceKey(datavalue.Replace("ResourceKey:", "")).ToString();
            }
            if (datatext.StartsWith("ResourceKey:"))
            {
                datatext = ResourceKey(datatext.Replace("ResourceKey:", "")).ToString();
            }
            if (attributes.StartsWith("ResourceKey:"))
            {
                attributes = ResourceKey(attributes.Replace("ResourceKey:", "")).ToString();
            }
            if (defaultValue.StartsWith("ResourceKey:"))
            {
                defaultValue = ResourceKey(defaultValue.Replace("ResourceKey:", "")).ToString();
            }

            var strOut = "";
            var datav  = datavalue.Split(',');
            var datat  = datatext.Split(',');

            if (datav.Count() == datat.Count())
            {
                var upd = getUpdateAttr(xpath, attributes);
                var id  = getIdFromXpath(xpath);
                strOut = "<div " + attributes + ">";
                var c     = 0;
                var s     = "";
                var value = info.GetXmlProperty(xpath);
                if (value == "")
                {
                    value = defaultValue;
                }
                foreach (var v in datav)
                {
                    if (value == v)
                    {
                        s = "checked";
                    }
                    else
                    {
                        s = "";
                    }
                    strOut += "    <label " + labelattributes + "><input id='" + id + "_" + c.ToString("") + "' " + upd + " name='" + id + "radio' type='radio' value='" + v + "'  " + s + "/>" + datat[c] + "</label>";
                    c      += 1;
                }
                strOut += "</div>";
            }
            return(new RawString(strOut));
        }
Beispiel #30
0
        /// <summary>
        /// Search filesystem for any new plugins that have been added. Removed any deleted ones.
        /// </summary>
        public void UpdateSystemPlugins()
        {
            if (!_portallevel) // only want to edit system level file
            {
                // Add new plugins
                var updated             = false;
                var pluginfoldermappath = System.Web.Hosting.HostingEnvironment.MapPath(StoreSettings.NBrightBuyPath() + "/Plugins");
                if (pluginfoldermappath != null && Directory.Exists(pluginfoldermappath))
                {
                    var ctrlList = new Dictionary <String, int>();
                    var flist    = Directory.GetFiles(pluginfoldermappath);
                    foreach (var f in flist)
                    {
                        if (f.EndsWith(".xml"))
                        {
                            var datain = File.ReadAllText(f);
                            try
                            {
                                var nbi = new NBrightInfo();
                                nbi.XMLData = datain;
                                AddPlugin(nbi);
                                ctrlList.Add(nbi.GetXmlProperty("genxml/textbox/ctrl"), nbi.GetXmlPropertyInt("genxml/hidden/index"));

                                updated = true;
                                File.Delete(f);
                            }
                            catch (Exception)
                            {
                                // data might not be XML complient (ignore)
                            }
                        }
                    }

                    if (updated)
                    {
                        Save(false); // only update system level
                        if (ctrlList.Count > 0)
                        {
                            // move new plugin to top.
                            foreach (var p in ctrlList)
                            {
                                var topPlugin = GetPlugin(p.Value);
                                if (topPlugin != null)
                                {
                                    MovePlugin(p.Key, topPlugin.GUIDKey, false);
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #31
0
        /// <summary>
        /// Add Adddress
        /// </summary>
        /// <param name="rpData"></param>
        /// <param name="debugMode"></param>
        public String AddAddress(Repeater rpData, Boolean debugMode = false)
        {
            var strXml = GenXmlFunctions.GetGenXml(rpData, "", "");
            // load into NBrigthInfo class, so it's easier to get at xml values.
            var objInfoIn = new NBrightInfo();

            objInfoIn.XMLData = strXml;
            var addIndex = objInfoIn.GetXmlProperty("genxml/hidden/index"); // addresses updated from manager should have a index hidden field.

            if (addIndex == "")
            {
                addIndex = objInfoIn.GetXmlProperty("genxml/dropdownlist/selectaddress");                 // updated from cart should have a selected address
            }
            if (!Utils.IsNumeric(addIndex))
            {
                addIndex = "-1";                             // assume new address.
            }
            var addressIndex = Convert.ToInt32(addIndex);

            AddAddress(objInfoIn, addressIndex);
            return(""); // if everything is OK, don't send a message back.
        }
Beispiel #32
0
        public void Update(NBrightInfo updateInfo)
        {
            // update email
            var email = updateInfo.GetXmlProperty("genxml/textbox/email");

            if (_userInfo != null && Utils.IsEmail(email) && (_userInfo.Email != email))
            {
                _userInfo.Email = email;
                UserController.UpdateUser(PortalSettings.Current.PortalId, _userInfo);
            }

            // ClientEditorRole
            var clientEditorRole = updateInfo.GetXmlProperty("genxml/checkbox/clienteditorrole");

            if (clientEditorRole == "True")
            {
                AddClientEditorRole();
            }
            else
            {
                RemoveClientEditorRole();
            }

            // save client data fields.
            var objCtrl = new NBrightBuyController();

            DataRecord         = objCtrl.GetByType(PortalId, -1, "CLIENT", _userInfo.UserID.ToString(""));
            DataRecord.XMLData = updateInfo.XMLData;
            DataRecord.RemoveXmlNode("genxml/hidden/xmlupdatediscountcodedata");
            DataRecord.RemoveXmlNode("genxml/hidden/xmlupdatevouchercodedata");
            objCtrl.Update(DataRecord);

            // update Discount codes
            var strXml = Utils.UnCode(updateInfo.GetXmlProperty("genxml/hidden/xmlupdatediscountcodedata"));

            UpdateDiscountCodes(strXml);
            strXml = Utils.UnCode(updateInfo.GetXmlProperty("genxml/hidden/xmlupdatevouchercodedata"));
            UpdateVoucherCodes(strXml);
        }
        public IEncodedString EntryUrl(NBrightInfo info, NBrightRazor model, Boolean relative = true, String categoryref = "")
        {
            var url = "";

            try
            {
                var navigationdata = new NavigationData(PortalSettings.Current.PortalId, model.GetSetting("modref"));

                var urlname = info.GetXmlProperty("genxml/lang/genxml/textbox/txtseoname");
                if (urlname == "")
                {
                    urlname = info.GetXmlProperty("genxml/lang/genxml/textbox/txtproductname");
                }

                // see if we've injected a categoryid into the data class, this is done in the case of the categorymenu when displaying products.
                var categoryid = info.GetXmlProperty("genxml/categoryid");
                if (categoryid == "")
                {
                    categoryid = navigationdata.CategoryId.ToString();
                }
                if (categoryid == "0")
                {
                    categoryid = "";                    // no category active if zero
                }
                var eid = info.ItemID.ToString() != "0" ? info.ItemID.ToString() : info.GetXmlProperty("genxml/productid");

                url = NBrightBuyUtils.GetEntryUrl(PortalSettings.Current.PortalId, eid, model.GetSetting("detailmodulekey"), urlname, model.GetSetting("ddldetailtabid"), categoryid, categoryref);
                if (relative)
                {
                    url = Utils.GetRelativeUrl(url);
                }
            }
            catch (Exception ex)
            {
                url = ex.ToString();
            }

            return(new RawString(url));
        }
Beispiel #34
0
        public override NBrightInfo CalculateShipping(NBrightInfo cartInfo)
        {
            var shipData = new ShippingData(Shippingkey);
            var shipoption = cartInfo.GetXmlProperty("genxml/extrainfo/genxml/radiobuttonlist/rblshippingoptions");
            Double rangeValue = 0;
            if (shipData.CalculationUnit == "1")
                rangeValue = cartInfo.GetXmlPropertyDouble("genxml/totalweight");
            else
                rangeValue = cartInfo.GetXmlPropertyDouble("genxml/appliedsubtotal");
            var countrycode = "";
            var regioncode = "";
            var regionkey = "";
            var total = cartInfo.GetXmlPropertyDouble("genxml/appliedsubtotal");
            switch (shipoption)
            {
                case "1":
                    countrycode = cartInfo.GetXmlProperty("genxml/billaddress/genxml/dropdownlist/country");
                    regionkey = cartInfo.GetXmlProperty("genxml/billaddress/genxml/dropdownlist/region");
                    break;
                case "2":
                    countrycode = cartInfo.GetXmlProperty("genxml/shipaddress/genxml/dropdownlist/country");
                    regionkey = cartInfo.GetXmlProperty("genxml/shipaddress/genxml/dropdownlist/region");
                    break;
            }

            if (regionkey != "")
            {
                var rl = regionkey.Split(':');
                if (rl.Count() == 2) regioncode = rl[1];
            }

            var shippingcost = shipData.CalculateShipping(countrycode, regioncode, rangeValue, total);
            var shippingdealercost = shippingcost;
            cartInfo.SetXmlPropertyDouble("genxml/shippingcost", shippingcost);
            cartInfo.SetXmlPropertyDouble("genxml/shippingdealercost", shippingdealercost);

            return cartInfo;
        }
Beispiel #35
0
        public String AddSingleItem(String strproductid, String strmodelId, String strqtyId, NBrightInfo objInfoIn, Boolean debugMode = false, int replaceIndex = -1)
        {
            if (!Utils.IsNumeric(strqtyId) || Convert.ToInt32(strqtyId) <= 0) return "";

            if (StoreSettings.Current.DebugModeFileOut) objInfoIn.XMLDoc.Save(PortalSettings.Current.HomeDirectoryMapPath + "debug_addtobasket.xml");

            var objInfo = new NBrightInfo();
            objInfo.XMLData = "<genxml></genxml>";

            // get productid
            if (Utils.IsNumeric(strproductid))
            {
                var itemcode = ""; // The itemcode var is used to decide if a cart item is new or already existing in the cart.
                var productData = ProductUtils.GetProductData(Convert.ToInt32(strproductid), Utils.GetCurrentCulture());

                if (productData.Info == null) return ""; // we may have a invalid productid that has been saved by a cookie, but since has been deleted.

                var modelInfo = productData.GetModel(strmodelId);
                if (modelInfo == null) return ""; // no valid model

                objInfo.AddSingleNode("productid", strproductid, "genxml");
                itemcode += strproductid + "-";

                objInfo.AddSingleNode("modelid", strmodelId, "genxml");
                itemcode += strmodelId + "-";

                // Get Qty
                objInfo.AddSingleNode("qty", strqtyId, "genxml");

                #region "Get model and product data"

                objInfo.AddSingleNode("productname", productData.Info.GetXmlPropertyRaw("genxml/lang/genxml/textbox/txtproductname"), "genxml");
                objInfo.AddSingleNode("summary", productData.Info.GetXmlPropertyRaw("genxml/lang/genxml/textbox/txtsummary"), "genxml");

                objInfo.AddSingleNode("modelref", modelInfo.GetXmlPropertyRaw("genxml/textbox/txtmodelref"), "genxml");
                objInfo.AddSingleNode("modeldesc", modelInfo.GetXmlPropertyRaw("genxml/lang/genxml/textbox/txtmodelname"), "genxml");
                objInfo.AddSingleNode("modelextra", modelInfo.GetXmlPropertyRaw("genxml/lang/genxml/textbox/txtextra"), "genxml");
                objInfo.AddSingleNode("unitcost", modelInfo.GetXmlPropertyRaw("genxml/textbox/txtunitcost"), "genxml");
                objInfo.AddSingleNode("dealercost", modelInfo.GetXmlPropertyRaw("genxml/textbox/txtdealercost"), "genxml");
                objInfo.AddSingleNode("taxratecode", modelInfo.GetXmlPropertyRaw("genxml/dropdownlist/taxrate"), "genxml");
                objInfo.AddSingleNode("saleprice", modelInfo.GetXmlPropertyRaw("genxml/textbox/txtsaleprice"), "genxml");
                objInfo.AddSingleNode("basecost", modelInfo.GetXmlPropertyRaw("genxml/textbox/txtunitcost"), "genxml");

                // flag if dealer
                var userInfo = UserController.Instance.GetCurrentUserInfo();
                if (userInfo != null && userInfo.IsInRole(StoreSettings.DealerRole) && StoreSettings.Current.Get("enabledealer") == "True")
                    objInfo.SetXmlProperty("genxml/isdealer", "True");
                else
                    objInfo.SetXmlProperty("genxml/isdealer", "False");

                //move all product and model data into cart item, so we can display bespoke fields.
                objInfo.AddSingleNode("productxml", productData.Info.XMLData, "genxml");

                #endregion

                #region "Get option Data"

                //build option data for cart
                Double additionalCosts = 0;
                var strXmlIn = "";
                var optionDataList = new Dictionary<String, String>();
                if (objInfoIn.XMLDoc != null)
                {
                    var nodList = objInfoIn.XMLDoc.SelectNodes("genxml/textbox/*[starts-with(name(), 'optiontxt')]");
                    if (nodList != null)
                        foreach (XmlNode nod in nodList)
                        {
                            strXmlIn = "<option>";
                            var idx = nod.Name.Replace("optiontxt", "");
                            var optionid = objInfoIn.GetXmlProperty("genxml/hidden/optionid" + idx);
                            var optionInfo = productData.GetOption(optionid);
                            var optvaltext = nod.InnerText;
                            strXmlIn += "<optid>" + optionid + "</optid>";
                            strXmlIn += "<optvaltext>" + optvaltext + "</optvaltext>";
                            itemcode += optionid + "-" + Utils.GetUniqueKey() + "-";
                            strXmlIn += "<optname>" + optionInfo.GetXmlProperty("genxml/lang/genxml/textbox/txtoptiondesc") + "</optname>";
                            strXmlIn += "</option>";
                            if (!optionDataList.ContainsKey(idx)) optionDataList.Add(idx, strXmlIn);
                        }
                    nodList = objInfoIn.XMLDoc.SelectNodes("genxml/dropdownlist/*[starts-with(name(), 'optionddl')]");
                    if (nodList != null)
                        foreach (XmlNode nod in nodList)
                        {
                            strXmlIn = "<option>";
                            var idx = nod.Name.Replace("optionddl", "");
                            var optionid = objInfoIn.GetXmlProperty("genxml/hidden/optionid" + idx);
                            var optionvalueid = nod.InnerText;
                            var optionValueInfo = productData.GetOptionValue(optionid, optionvalueid);
                            var optionInfo = productData.GetOption(optionid);
                            strXmlIn += "<optid>" + optionid + "</optid>";
                            strXmlIn += "<optvalueid>" + optionvalueid + "</optvalueid>";
                            itemcode += optionid + ":" + optionvalueid + "-";
                            strXmlIn += "<optname>" + optionInfo.GetXmlProperty("genxml/lang/genxml/textbox/txtoptiondesc") + "</optname>";
                            strXmlIn += "<optvalcost>" + optionValueInfo.GetXmlProperty("genxml/textbox/txtaddedcost") + "</optvalcost>";
                            strXmlIn += "<optvaltext>" + optionValueInfo.GetXmlProperty("genxml/lang/genxml/textbox/txtoptionvaluedesc") + "</optvaltext>";
                            strXmlIn += "</option>";
                            additionalCosts += optionValueInfo.GetXmlPropertyDouble("genxml/textbox/txtaddedcost");
                            if (!optionDataList.ContainsKey(idx)) optionDataList.Add(idx, strXmlIn);
                        }
                    nodList = objInfoIn.XMLDoc.SelectNodes("genxml/checkbox/*[starts-with(name(), 'optionchk')]");
                    if (nodList != null)
                        foreach (XmlNode nod in nodList)
                        {
                                strXmlIn = "<option>";
                                var idx = nod.Name.Replace("optionchk", "");
                                var optionid = objInfoIn.GetXmlProperty("genxml/hidden/optionid" + idx);
                                var optionvalueid = nod.InnerText;
                                var optionValueInfo = productData.GetOptionValue(optionid, ""); // checkbox does not have optionvalueid
                                var optionInfo = productData.GetOption(optionid);
                                strXmlIn += "<optid>" + optionid + "</optid>";
                                strXmlIn += "<optvalueid>" + optionvalueid + "</optvalueid>";
                                itemcode += optionid + ":" + optionvalueid + "-";
                                strXmlIn += "<optname>" + optionInfo.GetXmlProperty("genxml/lang/genxml/textbox/txtoptiondesc") + "</optname>";
                                strXmlIn += "<optvalcost>" + optionValueInfo.GetXmlProperty("genxml/textbox/txtaddedcost") + "</optvalcost>";
                                strXmlIn += "<optvaltext>" + optionValueInfo.GetXmlProperty("genxml/lang/genxml/textbox/txtoptionvaluedesc") + "</optvaltext>";
                                strXmlIn += "</option>";
                                if (nod.InnerText.ToLower() == "true") additionalCosts += optionValueInfo.GetXmlPropertyDouble("genxml/textbox/txtaddedcost");
                                if (!optionDataList.ContainsKey(idx)) optionDataList.Add(idx, strXmlIn);
                        }
                }

                // we need to save the options in the same order as in product, so index works correct on the template tokens.
                var strXmlOpt = "<options>";
                for (int i = 1; i <= optionDataList.Count; i++)
                {
                    if (optionDataList.ContainsKey(i.ToString("")))
                    {
                        strXmlOpt += optionDataList[i.ToString("")];
                    }
                }
                strXmlOpt += "</options>";

                objInfo.AddXmlNode(strXmlOpt, "options", "genxml");

                #endregion

                //add additional costs from optionvalues (Add to both dealer and unit cost)
                if (additionalCosts > 0)
                {
                    objInfo.SetXmlPropertyDouble("genxml/additionalcosts", additionalCosts);
                    var uc = objInfo.GetXmlPropertyDouble("genxml/unitcost");
                    var dc = objInfo.GetXmlPropertyDouble("genxml/dealercost");
                    uc += additionalCosts;
                    if (dc > 0) dc += additionalCosts; // only calc dealer cost if it's > zero (active)
                    objInfo.SetXmlPropertyDouble("genxml/unitcost", uc);
                    objInfo.SetXmlPropertyDouble("genxml/dealercost", dc);
                }

                objInfo.AddSingleNode("itemcode", itemcode.TrimEnd('-'), "genxml");

                // check if we have a client file upload
                var clientfileuopload = objInfoIn.GetXmlProperty("genxml/textbox/optionfilelist") != "";

                //replace the item if it's already in the list.
                var nodItem = PurchaseInfo.XMLDoc.SelectSingleNode("genxml/items/genxml[itemcode='" + itemcode.TrimEnd('-') + "']");
                if (nodItem == null || clientfileuopload)
                {
                    #region "Client Files"

                    if (clientfileuopload)
                    {
                        // client has uploaded files, so save these to client upload folder and create link in cart data.
                        var flist = objInfoIn.GetXmlProperty("genxml/textbox/optionfilelist").TrimEnd(',');
                        var fprefix = objInfoIn.GetXmlProperty("genxml/hidden/optionfileprefix") + "_";
                        var fileXml = "<clientfiles>";
                        foreach (var f in flist.Split(','))
                        {
                            var fullName = StoreSettings.Current.FolderTempMapPath.TrimEnd(Convert.ToChar("\\")) + "\\" + fprefix + f;
                            var extension = Path.GetExtension(fullName);
                            if (File.Exists(fullName))
                            {
                                var newDocFileName = StoreSettings.Current.FolderClientUploadsMapPath.TrimEnd(Convert.ToChar("\\")) + "\\" + Guid.NewGuid() + extension;
                                File.Copy(fullName, newDocFileName, true);
                                File.Delete(fullName);
                                var docurl = StoreSettings.Current.FolderClientUploads.TrimEnd('/') + "/" + Path.GetFileName(newDocFileName);
                                fileXml += "<file>";
                                fileXml += "<mappath>" + newDocFileName + "</mappath>";
                                fileXml += "<url>" + docurl + "</url>";
                                fileXml += "<name>" + f + "</name>";
                                fileXml += "<prefix>" + fprefix + "</prefix>";
                                fileXml += "</file>";
                            }
                        }
                        fileXml += "</clientfiles>";
                        objInfo.AddXmlNode(fileXml, "clientfiles", "genxml");
                    }

                    #endregion

                    if (replaceIndex >= 0 && replaceIndex < _itemList.Count)
                        _itemList[replaceIndex] = objInfo; //replace
                    else
                        _itemList.Add(objInfo); //add as new item
                }
                else
                {
                    //replace item
                    var qty = nodItem.SelectSingleNode("qty");
                    if (qty != null && Utils.IsNumeric(qty.InnerText) && Utils.IsNumeric(strqtyId))
                    {
                        var userqtylimit = objInfoIn.GetXmlPropertyInt("genxml/hidden/userqtylimit");
                        if (userqtylimit > 0 && Convert.ToInt32(qty.InnerText) >= userqtylimit) return "";

                        //add new qty and replace item
                        PurchaseInfo.RemoveXmlNode("genxml/items/genxml[itemcode='" + itemcode.TrimEnd('-') + "']");
                        _itemList = GetCartItemList();
                        var newQty = Convert.ToString(Convert.ToInt32(qty.InnerText) + Convert.ToInt32(strqtyId));
                        objInfo.SetXmlProperty("genxml/qty", newQty, TypeCode.String, false);
                        _itemList.Add(objInfo);
                    }
                }

                //add nodes for any fields that might exist in cart template
                objInfo.AddSingleNode("textbox", "", "genxml");
                objInfo.AddSingleNode("dropdownlist", "", "genxml");
                objInfo.AddSingleNode("radiobuttonlist", "", "genxml");
                objInfo.AddSingleNode("checkbox", "", "genxml");

                SavePurchaseData(); // need to save after each add, so it exists in data when we check it already exists for updating.

                // return the message status code in textData, non-critical (usually empty)
                return objInfo.TextData;
            }
            return "";
        }
Beispiel #36
0
        /// <summary>
        /// Add product to cart
        /// </summary>
        /// <param name="rpData"></param>
        /// <param name="nbSettings"></param>
        /// <param name="rowIndex"></param>
        /// <param name="debugMode"></param>
        public String AddItem(Repeater rpData, NBrightInfo nbSettings, int rowIndex, Boolean debugMode = false)
        {
            var strXml = GenXmlFunctions.GetGenXml(rpData, "", StoreSettings.Current.FolderUploadsMapPath, rowIndex);

            // load into NBrigthInfo class, so it's easier to get at xml values.
            var objInfoIn = new NBrightInfo();
            objInfoIn.XMLData = strXml;

            var strproductid = objInfoIn.GetXmlProperty("genxml/hidden/productid");
            // Get ModelID
            var modelidlist = new List<String>();
            var qtylist = new Dictionary<String, String>();
            var nodList = objInfoIn.XMLDoc.SelectNodes("genxml/repeaters/repeater[1]/*");
            if (nodList != null && nodList.Count > 0)
            {
                foreach (XmlNode nod in nodList)
                {
                    var nbi = new NBrightInfo();
                    nbi.XMLData = nod.OuterXml;
                    var strmodelId = nbi.GetXmlProperty("genxml/hidden/modelid");
                    var strqtyId = nbi.GetXmlProperty("genxml/textbox/selectedmodelqty");
                    if (Utils.IsNumeric(strqtyId))
                    {
                        modelidlist.Add(strmodelId);
                        qtylist.Add(strmodelId, strqtyId);
                    }
                }
            }
            if (qtylist.Count == 0)
            {
                var strmodelId = objInfoIn.GetXmlProperty("genxml/radiobuttonlist/rblmodelsel");
                if (strmodelId == "") strmodelId = objInfoIn.GetXmlProperty("genxml/dropdownlist/ddlmodelsel");
                if (strmodelId == "") strmodelId = objInfoIn.GetXmlProperty("genxml/hidden/modeldefault");

                modelidlist.Add(strmodelId);
                var strqtyId = objInfoIn.GetXmlProperty("genxml/textbox/selectedaddqty");
                if (!Utils.IsNumeric(strqtyId)) strqtyId = "1";
                qtylist.Add(strmodelId, strqtyId);
            }

            var strRtn = "";
            foreach (var m in modelidlist)
            {
                var numberofmodels = 0; // use additemqty field to add multiple items
                var additemqty = objInfoIn.GetXmlProperty("genxml/textbox/additemqty");
                if (Utils.IsNumeric(additemqty))
                    numberofmodels = Convert.ToInt32(additemqty); // zero should be allowed on add all to basket option.
                else
                    numberofmodels = 1; // if we have no numeric, assume we need to add it

                for (var i = 1; i <= numberofmodels; i++)
                {
                    strRtn += AddSingleItem(strproductid, m, qtylist[m], objInfoIn, debugMode);
                }
            }
            return strRtn;
        }
Beispiel #37
0
        public String AddPlugin(NBrightInfo pluginInfo, int index = -1)
        {
            // look to see if we already have the plugin
            var ctrl = pluginInfo.GetXmlProperty("genxml/textbox/ctrl");
            if (ctrl != "")
            {
                var ctrllist = from i in _pluginList where i.GetXmlProperty("genxml/textbox/ctrl") == ctrl select i;
                var nBrightInfos = ctrllist as IList<NBrightInfo> ?? ctrllist.ToList();
                if (nBrightInfos.Any())
                {
                    index = nBrightInfos.First().GetXmlPropertyInt("genxml/hidden/index");
                }
            }

            if (index == -1)
                _pluginList.Add(pluginInfo);
            else
                UpdatePlugin(pluginInfo.XMLData, index);

            return ""; // if everything is OK, don't send a message back.
        }
Beispiel #38
0
        /// <summary>
        /// Merges data entered in the cartview into the cart item
        /// </summary>
        /// <param name="index">index of cart item</param>
        /// <param name="inputInfo">genxml data of cartview item</param>
        public void MergeCartInputData(int index, NBrightInfo inputInfo)
        {
            //get cart item
            //_itemList = GetCartItemList();  // Don;t get get here, it resets previous altered itemlist records.
            if (_itemList[index] != null)
            {

                #region "merge option data"
                var nodList = inputInfo.XMLDoc.SelectNodes("genxml/hidden/*[starts-with(name(), 'optionid')]");
                if (nodList != null)
                    foreach (XmlNode nod in nodList)
                    {
                        var idx = nod.Name.Replace("optionid", "");
                        var optid = nod.InnerText;
                        var oldoptvalue = _itemList[index].GetXmlProperty("genxml/options/option[optid='" + optid + "']/optvalueid");
                        var newoptvalue = "";
                        if (inputInfo.GetXmlProperty("genxml/textbox/optiontxt" + idx) != "")
                        {
                            _itemList[index].SetXmlProperty("genxml/options/option[optid='" + optid + "']/optvaltext", inputInfo.GetXmlProperty("genxml/textbox/optiontxt" + idx));
                        }
                        if (inputInfo.GetXmlProperty("genxml/dropdownlist/optionddl" + idx) != "")
                        {
                            newoptvalue = inputInfo.GetXmlProperty("genxml/dropdownlist/optionddl" + idx);
                            _itemList[index].SetXmlProperty("genxml/options/option[optid='" + optid + "']/optvalueid", inputInfo.GetXmlProperty("genxml/dropdownlist/optionddl" + idx));
                            _itemList[index].SetXmlProperty("genxml/options/option[optid='" + optid + "']/optvaltext", inputInfo.GetXmlProperty("genxml/dropdownlist/optionddl" + idx + "/@selectedtext"));
                            if (oldoptvalue != newoptvalue) //rebuild itemcode
                            {
                                var icode = _itemList[index].GetXmlProperty("genxml/itemcode");
                                _itemList[index].SetXmlProperty("genxml/itemcode", icode.Replace(optid + ":" + oldoptvalue, optid + ":" + newoptvalue));
                            }
                        }
                        if (inputInfo.GetXmlProperty("genxml/checkbox/optionchk" + idx) != "")
                        {
                            newoptvalue = inputInfo.GetXmlProperty("genxml/checkbox/optionchk" + idx);
                            _itemList[index].SetXmlProperty("genxml/options/option[optid='" + optid + "']/optvalueid", newoptvalue);
                            if (oldoptvalue != newoptvalue) //rebuild itemcode
                            {
                                var icode = _itemList[index].GetXmlProperty("genxml/itemcode");
                                _itemList[index].SetXmlProperty("genxml/itemcode", icode.Replace(optid + ":" + oldoptvalue, optid + ":" + newoptvalue));
                            }
                        }

                    }

                #endregion

                var nods = inputInfo.XMLDoc.SelectNodes("genxml/textbox/*");
                if (nods != null)
                {
                    foreach (XmlNode nod in nods)
                    {
                        if (nod.Name.ToLower() == "qty")
                            _itemList[index].SetXmlProperty("genxml/" + nod.Name.ToLower(), nod.InnerText, TypeCode.String, false); //don't want cdata on qty field
                        else
                            _itemList[index].SetXmlProperty("genxml/textbox/" + nod.Name.ToLower(), nod.InnerText);
                    }
                }
                nods = inputInfo.XMLDoc.SelectNodes("genxml/radiobuttonlist/*");
                if (nods != null)
                {
                    foreach (XmlNode nod in nods)
                    {
                        if (nod.Name.ToLower() == "qty")
                            _itemList[index].SetXmlProperty("genxml/" + nod.Name.ToLower(), nod.InnerText, TypeCode.String, false); //don't want cdata on qty field
                        else
                        {
                            _itemList[index].SetXmlProperty("genxml/radiobuttonlist/" + nod.Name.ToLower(), nod.InnerText);
                            if (nod.Attributes != null && nod.Attributes["selectedtext"] != null) _itemList[index].SetXmlProperty("genxml/radiobuttonlist/" + nod.Name + "text", nod.Attributes["selectedtext"].Value);
                        }
                    }
                }
                nods = inputInfo.XMLDoc.SelectNodes("genxml/checkbox/*");
                if (nods != null)
                {
                    foreach (XmlNode nod in nods)
                    {
                        _itemList[index].SetXmlProperty("genxml/checkbox/" + nod.Name.ToLower(), nod.InnerText);
                    }
                }

                nods = inputInfo.XMLDoc.SelectNodes("genxml/dropdownlist/*");
                if (nods != null)
                {
                    foreach (XmlNode nod in nods)
                    {
                        if (nod.Name.ToLower() == "qty")
                            _itemList[index].SetXmlProperty("genxml/" + nod.Name.ToLower(), nod.InnerText, TypeCode.String, false); //don't want cdata on qty field
                        else
                        {
                            _itemList[index].SetXmlProperty("genxml/dropdownlist/" + nod.Name.ToLower(), nod.InnerText);
                            if (nod.Attributes != null && nod.Attributes["selectedtext"] != null) _itemList[index].SetXmlProperty("genxml/dropdownlist/" + nod.Name + "text", nod.Attributes["selectedtext"].Value);

                            // see if we've changed the model, if so update required fields
                            if (nod.Name.ToLower() == "ddlmodelsel")
                            {
                                var oldmodelid = _itemList[index].GetXmlProperty("genxml/modelid");
                                var newmodelid = nod.InnerText;
                                if (oldmodelid != newmodelid)
                                {
                                    AddSingleItem(_itemList[index].GetXmlProperty("genxml/productid"), newmodelid, _itemList[index].GetXmlProperty("genxml/qty"), inputInfo,false,index);
                                }
                            }
                        }
                    }
                }

            }
        }
Beispiel #39
0
        private void PageLoad()
        {
            #region "Data Repeater"
            if (UserId > 0) // only logged in users can see data on this module.
            {

                if (_displayentrypage)
                {
                    DisplayDataEntryRepeater(_entryid);
                }
                else
                {
                    var navigationData = new NavigationData(PortalId, "ClientsAdmin");

                    //setup paging
                    var pagesize = StoreSettings.Current.GetInt("pagesize");
                    var pagenumber = 1;
                    var strpagenumber = Utils.RequestParam(Context, "page");
                    if (Utils.IsNumeric(strpagenumber)) pagenumber = Convert.ToInt32(strpagenumber);
                    var recordcount = 0;

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

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

                    if (Utils.IsNumeric(navigationData.RecordCount))
                    {
                        recordcount = Convert.ToInt32(navigationData.RecordCount);
                    }
                    else
                    {
                        recordcount = ModCtrl.GetDnnUsersCount(PortalId, "%" + sInfo.GetXmlProperty("genxml/textbox/txtsearch") + "%");
                        navigationData.RecordCount = recordcount.ToString("");
                    }

                    //display list, with search filter
                    var userlist = ModCtrl.GetDnnUsers(PortalId, "%" + sInfo.GetXmlProperty("genxml/textbox/txtsearch") + "%", 0,pagenumber,pagesize,recordcount);
                    rpData.DataSource = userlist;
                    rpData.DataBind();

                    if (pagesize > 0)
                    {
                        CtrlPaging.PageSize = pagesize;
                        CtrlPaging.CurrentPage = pagenumber;
                        CtrlPaging.TotalRecords = recordcount;
                        CtrlPaging.BindPageLinks();
                    }

                }
            }

            #endregion

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

            // display footer
            base.DoDetail(rpDataF);
        }
Beispiel #40
0
 private Boolean IsModelInStock(NBrightInfo dataItem)
 {
     var stockOn = dataItem.GetXmlPropertyBool("genxml/checkbox/chkstockon");
     if (stockOn)
     {
         var modelstatus = dataItem.GetXmlProperty("genxml/dropdownlist/modelstatus");
         if (modelstatus == "010") return true;
     }
     else
     {
         return true;
     }
     return false;
 }
Beispiel #41
0
 private void ModelHiddenFieldDataBind(object sender, EventArgs e)
 {
     var txt = (HiddenField)sender;
     var container = (IDataItemContainer)txt.NamingContainer;
     var strXml = DataBinder.Eval(container.DataItem, _databindColumn).ToString();
     var nbi = new NBrightInfo();
     nbi.XMLData = strXml;
     txt.Value = nbi.GetXmlProperty("genxml/hidden/modelid");
     txt.Visible = visibleStatus.DefaultIfEmpty(true).First();
 }
Beispiel #42
0
        private void ConcatenateDataBinding(object sender, EventArgs e)
        {
            var l = (Literal)sender;
            var container = (IDataItemContainer)l.NamingContainer;
            var strXml = DataBinder.Eval(container.DataItem, _databindColumn).ToString();
            var nbi = new NBrightInfo();
            nbi.XMLData = strXml;
            try
            {
                var xlist = l.Text.Split(';');
                l.Text = "";
                foreach (var s in xlist)
                {
                    if (s != "" && !l.Text.Contains(nbi.GetXmlProperty(s))) l.Text += " " + nbi.GetXmlProperty(s);
                }
                l.Visible = visibleStatus.DefaultIfEmpty(true).First();

            }
            catch (Exception ex)
            {
                l.Text = ex.ToString();
            }
        }
Beispiel #43
0
        private String GetItemDisplay(NBrightInfo obj, String templ, Boolean displayPrices)
        {
            var isDealer = CmsProviderManager.Default.IsInRole(StoreSettings.DealerRole);
            var outText = templ;
            var stockOn = obj.GetXmlPropertyBool("genxml/checkbox/chkstockon");
            var stock = obj.GetXmlPropertyDouble("genxml/textbox/txtqtyremaining");
            if (stock > 0 || !stockOn)
            {
                outText = outText.Replace("{ref}", obj.GetXmlProperty("genxml/textbox/txtmodelref"));
                outText = outText.Replace("{name}", obj.GetXmlProperty("genxml/lang/genxml/textbox/txtmodelname"));
                outText = outText.Replace("{stock}", stock.ToString(""));

                if (displayPrices)
                {
                    //[TODO: add promotional calc]
                    var saleprice = obj.GetXmlPropertyDouble("genxml/textbox/txtsaleprice");
                    var price = obj.GetXmlPropertyDouble("genxml/textbox/txtunitcost");
                    var bestprice = price;
                    if (saleprice > 0 && saleprice < price) bestprice = saleprice;

                    var strprice = NBrightBuyUtils.FormatToStoreCurrency(price);
                    var strbestprice = NBrightBuyUtils.FormatToStoreCurrency(bestprice);
                    var strsaleprice = NBrightBuyUtils.FormatToStoreCurrency(saleprice);

                    var strdealerprice = "";
                    var dealerprice = obj.GetXmlPropertyDouble("genxml/textbox/txtdealercost");
                    if (isDealer)
                    {
                        strdealerprice = NBrightBuyUtils.FormatToStoreCurrency(dealerprice);
                        if (!outText.Contains("{dealerprice}") && (price > dealerprice)) strprice = strdealerprice;
                        if (dealerprice < bestprice) bestprice = dealerprice;
                    }

                    outText = outText.Replace("{price}", "(" + strprice + ")");
                    outText = outText.Replace("{dealerprice}", strdealerprice);
                    outText = outText.Replace("{bestprice}", strbestprice);
                    outText = outText.Replace("{saleprice}", strsaleprice);
                }
                else
                {
                    outText = outText.Replace("{price}", "");
                    outText = outText.Replace("{dealerprice}", "");
                    outText = outText.Replace("{bestprice}", "");
                    outText = outText.Replace("{saleprice}", "");
                }

                return outText;
            }
            return ""; // no stock so return empty string.
        }
Beispiel #44
0
        private void CartQtyTextDataBinding(object sender, EventArgs e)
        {
            var txt = (TextBox)sender;
            var container = (IDataItemContainer)txt.NamingContainer;

            try
            {
                txt.Visible = visibleStatus.DefaultIfEmpty(true).First();
                if (txt.Width == 0) txt.Visible = false; // always hide if we have a width of zero.
                else
                {
                    var strXML = Convert.ToString(DataBinder.Eval(container.DataItem,"XMLData" ));
                    var nbInfo = new NBrightInfo();
                    nbInfo.XMLData = strXML;
                    txt.Text = nbInfo.GetXmlProperty("genxml/qty");
                }
            }
            catch (Exception)
            {
                //do nothing
            }
        }
Beispiel #45
0
 private void UpdateCartInfo()
 {
     //update items
     foreach (RepeaterItem i in rpData.Items)
     {
         var strXml = GenXmlFunctions.GetGenXml(i);
         var cInfo = new NBrightInfo();
         cInfo.XMLData = strXml;
         _cartInfo.MergeCartInputData(cInfo.GetXmlProperty("genxml/hidden/itemcode"), cInfo);
     }
     //update data
     _cartInfo.AddExtraInfo(rpExtra);
     _cartInfo.AddShipData(rpShip);
 }
Beispiel #46
0
        private List<NBrightInfo> CalcPluginList(NBrightInfo info)
        {
            var rtnList = new List<NBrightInfo>();
            var xmlNodeList = info.XMLDoc.SelectNodes("genxml/plugin/*");
            if (xmlNodeList != null)
            {
                foreach (XmlNode carNod in xmlNodeList)
                {
                    var newInfo = new NBrightInfo { XMLData = carNod.OuterXml };
                    newInfo.ItemID = rtnList.Count;
                    newInfo.SetXmlProperty("genxml/hidden/index", rtnList.Count.ToString(""));
                    newInfo.GUIDKey = newInfo.GetXmlProperty("genxml/textbox/ctrl");
                    rtnList.Add(newInfo);
                }
            }

            // get the systemlevel, incase this is an update and we have new system level provider that needs to be added
            var menupluginsys = _templCtrl.GetTemplateData("menuplugin.xml", Utils.GetCurrentCulture(), true, true, false, storeSettings.Settings());
            var infosys = new NBrightInfo();
            infosys.XMLData = menupluginsys;
            if (infosys.XMLDoc != null)
            {
                var xmlNodeList2 = infosys.XMLDoc.SelectNodes("genxml/plugin/*");
                if (xmlNodeList2 != null)
                {
                    foreach (XmlNode carNod in xmlNodeList2)
                    {
                        var newInfo = new NBrightInfo {XMLData = carNod.OuterXml};
                        newInfo.GUIDKey = newInfo.GetXmlProperty("genxml/textbox/ctrl");
                        var resultsys = rtnList.Where(p => p.GUIDKey == newInfo.GUIDKey);
                        if (!resultsys.Any())
                        {
                            // add the missing plugin to the active list
                            newInfo.ItemID = rtnList.Count;
                            newInfo.SetXmlProperty("genxml/hidden/index", rtnList.Count.ToString(""));
                            newInfo.GUIDKey = newInfo.GetXmlProperty("genxml/textbox/ctrl");
                            rtnList.Add(newInfo);
                        }
                    }
                }
            }

            return rtnList;
        }
Beispiel #47
0
        /// <summary>
        /// Get Current Cart Item List
        /// </summary>
        /// <returns></returns>
        public List<NBrightInfo> GetCartItemList(Boolean groupByProduct = false)
        {
            var rtnList = new List<NBrightInfo>();
            var xmlNodeList = PurchaseInfo.XMLDoc.SelectNodes("genxml/items/*");
            if (xmlNodeList != null)
            {
                foreach (XmlNode carNod in xmlNodeList)
                {
                    var newInfo = new NBrightInfo {XMLData = carNod.OuterXml};
                    newInfo.GUIDKey = newInfo.GetXmlProperty("genxml/itemcode");
                    newInfo.PortalId = PortalId;
                    newInfo.ItemID = newInfo.GetXmlPropertyInt("genxml/productid");
                    rtnList.Add(newInfo);
                }
            }

            if (groupByProduct)
            {

                var grouped = from p in rtnList group p by p.GetXmlProperty("genxml/productid") into g select new {g.Key,Value = g};
                rtnList = new List<NBrightInfo>();
                foreach (var group in grouped)
                {
                    // inject header record for the product
                    var itemheader = (NBrightInfo)group.Value.First().Clone();
                    itemheader.SetXmlProperty("genxml/groupheader","True");
                    itemheader.SetXmlProperty("genxml/groupcount", group.Value.Count().ToString(""));
                    itemheader.SetXmlProperty("genxml/seeditemcode", itemheader.GUIDKey);
                    itemheader.GUIDKey = "";
                    // remove option data, so we get a clear item
                    itemheader.RemoveXmlNode("genxml/options");
                    rtnList.Add(itemheader);

                    foreach (var item in group.Value)
                    {
                        rtnList.Add(item);
                    }
                }
            }

            return rtnList;
        }
Beispiel #48
0
 private void ModelQtyFieldDataBind(object sender, EventArgs e)
 {
     var txt = (TextBox)sender;
     var container = (IDataItemContainer)txt.NamingContainer;
     var strXml = DataBinder.Eval(container.DataItem, _databindColumn).ToString();
     var nbi = new NBrightInfo();
     nbi.XMLData = strXml;
     if (nbi.GetXmlProperty("genxml/hidden/modelid") == "") txt.Text = "ERR! - MODELQTY can only be used on modellist template";
     txt.Attributes.Add("modelid", nbi.GetXmlProperty("genxml/hidden/modelid"));
     txt.Visible = visibleStatus.DefaultIfEmpty(true).First();
 }
Beispiel #49
0
 public int GetItemIndex(String itemCode)
 {
     var xmlNodeList = PurchaseInfo.XMLDoc.SelectNodes("genxml/items/*");
     if (xmlNodeList != null)
     {
         var lp = 0;
         foreach (XmlNode carNod in xmlNodeList)
         {
             var newInfo = new NBrightInfo { XMLData = carNod.OuterXml };
             if (newInfo.GetXmlProperty("genxml/itemcode") == itemCode)
             {
                 return lp;
             }
             lp += 1;
         }
     }
     return -1;
 }
Beispiel #50
0
        public void UpdateImages(NBrightInfo info)
        {
            var strAjaxXml = info.GetXmlProperty("genxml/hidden/xmlupdateproductimages");
            strAjaxXml = GenXmlFunctions.DecodeCDataTag(strAjaxXml);
            var imgList = NBrightBuyUtils.GetGenXmlListByAjax(strAjaxXml, "");
            UpdateImages(imgList);

            //add new image if uploaded
            var imgFile = info.GetXmlProperty("genxml/hidden/hidimage");
            if (imgFile != "")
            {
                AddNewImage(_storeSettings.FolderImages.TrimEnd('/') + "/" + imgFile, _storeSettings.FolderImagesMapPath.TrimEnd('\\') + "\\" + imgFile);
            }
        }
        private void DoImport(NBrightInfo nbi)
        {
            var fname = StoreSettings.Current.FolderTempMapPath + "\\" + nbi.GetXmlProperty("genxml/hidden/hiddatafile");
            if (System.IO.File.Exists(fname))
            {
                var xmlFile = new XmlDocument();
                try
                {
                    xmlFile.Load(fname);
                }
                catch (Exception e)
                {
                    Exceptions.LogException(e);
                    NBrightBuyUtils.SetNotfiyMessage(ModuleId, "xmlloadfail", NotifyCode.fail, ControlPath + "/App_LocalResources/Import.ascx.resx");
                    return;
                }

                // Ref old cat id , id new cat
                ////////////////////////////////////////////////////////////////////////////
                Dictionary<string, int> categoryListIDGiud = new Dictionary<string, int>();
                Dictionary<int, int> categoryListIDFather = new Dictionary<int, int>();
                ///////////////////////////////////////////////////////////////////////////

                var objCtrl = new NBrightBuyController();

                // get all valid languages
                var langList = DnnUtils.GetCultureCodeList(PortalId);
                foreach (var lang in langList)
                {

                    //Import Categories

                    #region "categories"

                    var nodList = xmlFile.SelectNodes("root/categories/" + lang + "/NB_Store_CategoriesInfo");
                    if (nodList != null)
                    {
                        var categoryid = -1;
                        foreach (XmlNode nod in nodList)
                        {
                            try
                            {

                                //if category Id exist replage guidKey
                                var guidKeyNod = nod.SelectSingleNode("CategoryID").InnerText;
                                if (guidKeyNod != null)
                                {

                                    var guidKey = guidKeyNod;
                                    categoryid = -1;
                                    // see if category already exists (update if so)
                                    var nbiImport = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "CATEGORY", guidKey);
                                    if (nbiImport != null) categoryid = nbiImport.ItemID;
                                    var CategoryData = new CategoryData(categoryid, lang);

                                    // clear down existing XML data
                                    var i = new NBrightInfo(true);
                                    i.PortalId = PortalSettings.Current.PortalId;
                                    CategoryData.DataRecord.XMLData = i.XMLData;
                                    CategoryData.DataLangRecord.XMLData = i.XMLData;

                                    // assign guidkey to legacy productid (guidKey)
                                    CategoryData.DataRecord.GUIDKey = guidKey;
                                    CategoryData.DataRecord.SetXmlProperty("genxml/textbox/txtcategoryref", guidKey);

                                    // do mapping of XML data
                                    // DATA FIELDS
                                    var cD_CategoryID = nod.SelectSingleNode("CategoryID").InnerText;
                                    var cD_PortalID = nod.SelectSingleNode("PortalID").InnerText;
                                    var cD_Archived = nod.SelectSingleNode("Archived").InnerText;
                                    var cD_Hide = nod.SelectSingleNode("Hide").InnerText;
                                    var cD_CreatedByUser = nod.SelectSingleNode("CreatedByUser").InnerText;
                                    var cD_CreatedDate = nod.SelectSingleNode("CreatedDate").InnerText;
                                    var cD_ParentCategoryID = nod.SelectSingleNode("ParentCategoryID").InnerText;
                                    var cD_ListOrder = nod.SelectSingleNode("ListOrder").InnerText;
                                    var cD_Lang = nod.SelectSingleNode("Lang").InnerText;
                                    var cD_ProductCount = nod.SelectSingleNode("ProductCount").InnerText;
                                    var cD_ProductTemplate = nod.SelectSingleNode("ProductTemplate").InnerText;
                                    var cD_ListItemTemplate = nod.SelectSingleNode("ListItemTemplate").InnerText;
                                    var cD_ListAltItemTemplate = nod.SelectSingleNode("ListAltItemTemplate").InnerText;
                                    var cD_ImageURL = nod.SelectSingleNode("ImageURL").InnerText;

                                    // DATA LANG FIELDS
                                    var cL_CategoryName = nod.SelectSingleNode("CategoryName").InnerText;
                                    var cL_ParentName = nod.SelectSingleNode("ParentName").InnerText;
                                    var cL_CategoryDesc = nod.SelectSingleNode("CategoryDesc").InnerText;
                                    var cL_Message = nod.SelectSingleNode("Message").InnerText;
                                    var cL_SEOPageTitle = nod.SelectSingleNode("SEOPageTitle").InnerText;
                                    var cL_SEOName = nod.SelectSingleNode("SEOName").InnerText;
                                    var cL_MetaDescription = nod.SelectSingleNode("MetaDescription").InnerText;
                                    var cL_MetaKeywords = nod.SelectSingleNode("MetaKeywords").InnerText;

                                    // Populate DATA CATEGORY
                                    CategoryData.DataRecord.SetXmlProperty("genxml/hidden/recordsortorder", cD_ListOrder);
                                    CategoryData.DataRecord.SetXmlProperty("genxml/checkbox/chkishidden", cD_Hide);
                                    CategoryData.DataRecord.SetXmlProperty("genxml/checkbox/chkdisable", "False");
                                    CategoryData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlgrouptype", "cat");

                                    if (cD_ParentCategoryID != null && cD_ParentCategoryID != "0") CategoryData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlparentcatid", cD_ParentCategoryID);

                                    // Populate DATA CATEGORY LANG

                                    if (cL_CategoryName != null && cL_CategoryName != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtcategoryname", cL_CategoryName);
                                    if (cL_CategoryDesc != null && cL_CategoryDesc != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtcategorydesc", cL_CategoryDesc);
                                    if (cL_MetaDescription != null && cL_MetaDescription != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtmetadescription", cL_MetaDescription);
                                    if (cL_MetaKeywords != null && cL_MetaKeywords != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtmetakeywords", cL_MetaKeywords);
                                    if (cL_SEOPageTitle != null && cL_SEOPageTitle != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtseopagetitle", cL_SEOPageTitle);
                                    if (cL_SEOName != null && cL_SEOName != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtseoname", cL_SEOName);
                                    if (cL_Message != null && cL_Message != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/edt/message", cL_Message);

                                    categoryListIDGiud.Add(CategoryData.CategoryRef, CategoryData.CategoryId);
                                    if (cD_ParentCategoryID != null && cD_ParentCategoryID != "" && cD_ParentCategoryID != "0")
                                        categoryListIDFather.Add(CategoryData.CategoryId, Convert.ToInt32(cD_ParentCategoryID));

                                    CategoryData.Save();

                                }

                            }
                            catch (Exception e)
                            {
                                var logMessage = "CATEGORY: CategoryId: " + categoryid.ToString() + " : " + e.ToString();
                                LogOutput.LogWrite(logMessage);
                            }

                        }

                    //loop on The dictionary
                    foreach (var catl in categoryListIDFather)
                        {
                            //Key
                            var tempNewID = catl.Key;
                            //Value
                            var tempOldFather = catl.Value;

                            var tempNewFather = categoryListIDGiud[tempOldFather.ToString()];

                            var CategoryData = new CategoryData(tempNewID, lang);
                            CategoryData.ParentItemId = tempNewFather;
                            CategoryData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlparentcatid", tempNewFather.ToString());
                            CategoryData.Save();

                        }

                    }

                    #endregion

                    // Import Products

                    #region "data"

                    nodList = xmlFile.SelectNodes("root/products/" + lang + "/P");
                    if (nodList != null)
                    {
                        var productid = -1;
                        var prodname = "";
                        foreach (XmlNode nod in nodList)
                        {

                            try
                            {

                                var guidKeyNod = nod.SelectSingleNode("NB_Store_ProductsInfo/ProductID");
                                if (guidKeyNod != null)
                                {
                                    var guidKey = guidKeyNod.InnerText;
                                    productid = -1;
                                    // See if e already have a product imported, if so we want to update (maybe multiple languages, or a 2nd migrate)
                                    var nbiImport = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "PRD", guidKey);
                                    if (nbiImport != null) productid = nbiImport.ItemID;
                                    var productData = new ProductData(productid, lang);

                                    productid = productData.Info.ItemID; // set productid, so we have the id if it goes wrong.
                                    prodname = productData.ProductName;

                                    // clear down existing XML data
                                    var i = new NBrightInfo(true);
                                    productData.DataRecord.XMLData = i.XMLData;
                                    productData.DataLangRecord.XMLData = i.XMLData;

                                    // assign guidkey to legacy productid (guidKey)
                                    productData.DataRecord.GUIDKey = guidKey;
                                    productData.DataRecord.SetXmlProperty("genxml/importref", guidKey);

                                    // do mapping of XML data
                                    // DATA FIELDS
                                    var pD_ProductID = nod.SelectSingleNode("NB_Store_ProductsInfo/ProductID").InnerText;
                                    var pD_PortalID = nod.SelectSingleNode("NB_Store_ProductsInfo/PortalID").InnerText;
                                    var pD_TaxCategoryID = nod.SelectSingleNode("NB_Store_ProductsInfo/TaxCategoryID").InnerText;
                                    var pD_Featured = nod.SelectSingleNode("NB_Store_ProductsInfo/Featured").InnerText;
                                    var pD_Archived = nod.SelectSingleNode("NB_Store_ProductsInfo/Archived").InnerText;
                                    var pD_CreatedByUser = nod.SelectSingleNode("NB_Store_ProductsInfo/CreatedByUser").InnerText;
                                    var pD_CreatedDate = nod.SelectSingleNode("NB_Store_ProductsInfo/CreatedDate").InnerText;
                                    var pD_IsDeleted = nod.SelectSingleNode("NB_Store_ProductsInfo/IsDeleted").InnerText;
                                    var pD_ProductRef = nod.SelectSingleNode("NB_Store_ProductsInfo/ProductRef").InnerText;
                                    var pD_Lang = nod.SelectSingleNode("NB_Store_ProductsInfo/Lang").InnerText;
                                    var pD_Manufacturer = nod.SelectSingleNode("NB_Store_ProductsInfo/Manufacturer").InnerText;
                                    var pD_ModifiedDate = nod.SelectSingleNode("NB_Store_ProductsInfo/ModifiedDate").InnerText;
                                    var pD_IsHidden = nod.SelectSingleNode("NB_Store_ProductsInfo/IsHidden").InnerText;
                                    // DATA LANG FIELDS
                                    var pL_ProductName = nod.SelectSingleNode("NB_Store_ProductsInfo/ProductName").InnerText;
                                    var pL_Summary = nod.SelectSingleNode("NB_Store_ProductsInfo/Summary").InnerText;
                                    var pL_Description = nod.SelectSingleNode("NB_Store_ProductsInfo/Description").InnerText;
                                    var pL_SEOName = nod.SelectSingleNode("NB_Store_ProductsInfo/SEOName").InnerText;
                                    var pL_TagWords = nod.SelectSingleNode("NB_Store_ProductsInfo/TagWords").InnerText;
                                    var pL_Desc = nod.SelectSingleNode("NB_Store_ProductsInfo/Description").InnerText;

                                    if (pD_ProductRef != null) productData.DataRecord.SetXmlProperty("genxml/textbox/txtproductref", pD_ProductRef);
                                    if (pD_Manufacturer != null) productData.DataRecord.SetXmlProperty("genxml/textbox/customorder", pD_Manufacturer);

                                    // langauge main fields
                                    if (pL_ProductName != null) productData.DataLangRecord.SetXmlProperty("genxml/textbox/txtproductname", pL_ProductName);
                                    if (pL_Summary != null) productData.DataLangRecord.SetXmlProperty("genxml/textbox/txtsummary", pL_Summary);
                                    if (pL_SEOName != null) productData.DataLangRecord.SetXmlProperty("genxml/textbox/txtseoname", pL_SEOName);
                                    if (pL_SEOName != null) productData.DataLangRecord.SetXmlProperty("genxml/textbox/txtseopagetitle", pL_SEOName);
                                    if (pL_TagWords != null) productData.DataLangRecord.SetXmlProperty("genxml/textbox/txttagwords", pL_TagWords);

                                    //edt

                                    if (pL_Desc != null)
                                    {
                                        productData.DataLangRecord.SetXmlProperty("genxml/edt", "");
                                        productData.DataLangRecord.SetXmlProperty("genxml/edt/description", pL_Desc);
                                    }

                                    ////////////////////////////// CUSTOM FIELDS /////////////////////////////////////
                                    ////////////////////////////// CUSTOM FIELDS /////////////////////////////////////
                                    ////////////////////////////// CUSTOM FIELDS /////////////////////////////////////
                                    #region "Custom Fields"

                                    // Custom Fields the Custom fields in Nbstore are stored in XmlData xml file area.

                                    if (nod.SelectSingleNode("NB_Store_ProductsInfo/XMLData").FirstChild != null) // verify if there are custom fileds
                                    {

                                        var InputCustomFieldsXml = new XmlDocument();
                                        InputCustomFieldsXml.Load(new StringReader(nod.SelectSingleNode("NB_Store_ProductsInfo/XMLData").InnerText));
                                        var nodListCustom = InputCustomFieldsXml.SelectSingleNode("genxml");
                                        var custominfo = new NBrightInfo();
                                        custominfo.XMLData = nodListCustom.OuterXml;

                                        // ***************************
                                        // process custom fields here.
                                        // ***************************

                                    }

                                    #endregion
                                    ////////////////////////////// END CUSTOM FIELDS /////////////////////////////////////
                                    ////////////////////////////// END CUSTOM FIELDS /////////////////////////////////////
                                    ////////////////////////////// END CUSTOM FIELDS /////////////////////////////////////

                                    // Models
                                    var nodListModels = nod.SelectNodes("M/NB_Store_ModelInfo");
                                    foreach (XmlNode nodMod in nodListModels)
                                    {
                                        //load single node module strucuture
                                        var ModelID = nodMod.SelectSingleNode("ModelID").InnerText;

                                        var ProductID = nodMod.SelectSingleNode("ProductID").InnerText;
                                        var ListOrder = nodMod.SelectSingleNode("ListOrder").InnerText;
                                        var UnitCost = nodMod.SelectSingleNode("UnitCost").InnerText;
                                        var Barcode = nodMod.SelectSingleNode("Barcode").InnerText;
                                        var ModelRef = nodMod.SelectSingleNode("ModelRef").InnerText;
                                        var Lang = nodMod.SelectSingleNode("Lang").InnerText;
                                        var ModelName = nodMod.SelectSingleNode("ModelName").InnerText;
                                        var QtyRemaining = nodMod.SelectSingleNode("QtyRemaining").InnerText;
                                        var QtyTrans = nodMod.SelectSingleNode("QtyTrans").InnerText;
                                        var QtyTransDate = nodMod.SelectSingleNode("QtyTransDate").InnerText;
                                        var ProductName = nodMod.SelectSingleNode("ProductName").InnerText;
                                        var PortalID = nodMod.SelectSingleNode("PortalID").InnerText;
                                        var Weight = nodMod.SelectSingleNode("Weight").InnerText;
                                        var Height = nodMod.SelectSingleNode("Height").InnerText;
                                        var Length = nodMod.SelectSingleNode("Length").InnerText;
                                        var Width = nodMod.SelectSingleNode("Width").InnerText;
                                        var Deleted = nodMod.SelectSingleNode("Deleted").InnerText;
                                        var QtyStockSet = nodMod.SelectSingleNode("QtyStockSet").InnerText;
                                        var DealerCost = nodMod.SelectSingleNode("DealerCost").InnerText;
                                        var PurchaseCost = nodMod.SelectSingleNode("PurchaseCost").InnerText;
                                        var XMLData = nodMod.SelectSingleNode("XMLData").InnerText;
                                        var Extra = nodMod.SelectSingleNode("Extra").InnerText;
                                        var DealerOnly = nodMod.SelectSingleNode("DealerOnly").InnerText;
                                        var Allow = nodMod.SelectSingleNode("Allow").InnerText;

                                        ////////////////////////////// FINE CUSTOM FIELDS /////////////////////////////////////
                                        ////////////////////////////// FINE CUSTOM FIELDS /////////////////////////////////////
                                        ////////////////////////////// FINE CUSTOM FIELDS /////////////////////////////////////

                                        //il dentro al tag model cè un genxml che identifica il modello
                                        // MODELLI CAMPI DATA
                                        ////////////////////////////// MODELS /////////////////////////////////////
                                        ////////////////////////////// MODELS /////////////////////////////////////
                                        ////////////////////////////// MODELS /////////////////////////////////////
                                        var newkey = Utils.GetUniqueKey();

                                        var strXmlModel = @"<genxml><models><genxml>
                                      <files />
                                      <hidden><modelid>" + newkey + "</modelid>" +
                                                          @"</hidden>
                                      <textbox>
                                        <availabledate datatype=""date"" />
                                        <txtqtyminstock>0</txtqtyminstock>
                                        <txtmodelref>" + ModelRef + @"</txtmodelref>
                                        <txtunitcost>" + UnitCost + @"</txtunitcost>
                                        <txtsaleprice>0.00</txtsaleprice>
                                        <txtbarcode>" + Barcode + @"</txtbarcode>
                                        <txtqtyremaining>" + QtyRemaining + @"</txtqtyremaining>
                                        <txtqtystockset>" + QtyStockSet + @"</txtqtystockset>
                                        <txtdealercost>" + DealerCost + @"</txtdealercost>
                                        <txtpurchasecost>" + PurchaseCost + @"</txtpurchasecost>
                                        <weight>" + Weight + @"</weight>
                                        <depth>" + Length + @"</depth>
                                        <width>" + Width + @"</width>
                                        <height>" + Height + @"</height>
                                        <unit />
                                        <delay />
                                      </textbox>
                                      <checkbox>
                                        <chkstockon>False</chkstockon>
                                        <chkishidden>False</chkishidden>
                                        <chkdeleted>False</chkdeleted>
                                        <chkdealeronly>False</chkdealeronly>
                                      </checkbox>
                                      <dropdownlist>
                                        <modelstatus>010</modelstatus>
                                      </dropdownlist>
                                      <checkboxlist />
                                      <radiobuttonlist />
                                    </genxml></models></genxml>";

                                        var strXmlModelLang = @"<genxml><models><genxml>
                                        <files />
                                        <hidden />
                                        <textbox>
                                            <txtmodelname>" + ModelName + "</txtmodelname>" +
                                                              "<txtextra>" + Extra + @"</txtextra>
                                        </textbox>
                                        <checkbox /><dropdownlist /><checkboxlist /><radiobuttonlist />
                                        </genxml></models></genxml>";

                                        if (productData.DataRecord.XMLDoc.SelectSingleNode("genxml/models") == null)
                                        {
                                            productData.DataRecord.AddXmlNode(strXmlModel, "genxml/models", "genxml");
                                            productData.DataLangRecord.AddXmlNode(strXmlModelLang, "genxml/models", "genxml");
                                        }
                                        else
                                        {
                                            productData.DataRecord.AddXmlNode(strXmlModel, "genxml/models/genxml", "genxml/models");
                                            productData.DataLangRecord.AddXmlNode(strXmlModelLang, "genxml/models/genxml", "genxml/models");
                                        }

                                    }

                                    ////////////////////////////// IMAGES /////////////////////////////////////
                                    ////////////////////////////// IMAGES /////////////////////////////////////
                                    ////////////////////////////// IMAGES /////////////////////////////////////
                                    ////////////////////////////// IMAGES /////////////////////////////////////
                                    // copy all the images from Portals\0\productimages to Portals\0\NBStore\images

                                    var nodListImages = nod.SelectNodes("I/NB_Store_ProductImageInfo");
                                    foreach (XmlNode nodImg in nodListImages)
                                    {
                                        var ImageID = nodImg.SelectSingleNode("ImageID").InnerText;
                                        var Hidden = nodImg.SelectSingleNode("Hidden").InnerText;
                                        var ImageUrl = nodImg.SelectSingleNode("ImageURL").InnerText;
                                        var ImagePath = nodImg.SelectSingleNode("ImagePath").InnerText;

                                        productData.AddNewImage(ImageUrl, ImagePath);
                                    }
                                    ////////////////////////////// DOCS /////////////////////////////////////
                                    ////////////////////////////// DOCS /////////////////////////////////////
                                    ////////////////////////////// DOCS /////////////////////////////////////
                                    ////////////////////////////// DOCS /////////////////////////////////////
                                    // copy all the DOCS from Portals\0\productdocs to Portals\0\NBStore\docs

                                    var nodListDocs = nod.SelectNodes("D/NB_Store_ProductDocInfo");
                                    var lp = 1;
                                    var objCtrlDoc = new NBrightBuyController();

                                    foreach (XmlNode nodDoc in nodListDocs)
                                    {
                                        var DocID = nodDoc.SelectSingleNode("DocID").InnerText;
                                        var ProductID = nodDoc.SelectSingleNode("ProductID").InnerText;
                                        var DocPath = nodDoc.SelectSingleNode("DocPath").InnerText;
                                        var ListOrder = nodDoc.SelectSingleNode("ListOrder").InnerText;
                                        var Hidden = nodDoc.SelectSingleNode("Hidden").InnerText;
                                        var FileName = nodDoc.SelectSingleNode("FileName").InnerText;
                                        var FileExt = nodDoc.SelectSingleNode("FileExt").InnerText;
                                        var Lang = nodDoc.SelectSingleNode("Lang").InnerText;
                                        var DocDesc = nodDoc.SelectSingleNode("DocDesc").InnerText;

                                        productData.AddNewDoc(DocPath, FileName);

                                        productData.DataRecord.SetXmlProperty("genxml/docs/genxml[" + lp.ToString() + "]/hidden/fileext", FileExt);
                                        DocPath = DocPath.Replace("productdocs", @"NBStore\docs");
                                        productData.DataRecord.SetXmlProperty("genxml/docs/genxml[" + lp.ToString() + "]/hidden/filepath", DocPath);

                                        objCtrlDoc.Update(productData.DataRecord);

                                        // if doesen't exisit the xml genxml strucuture inside the DataLangRecor I create it
                                        var strXml = "<genxml><docs><genxml><textbox/></genxml></docs></genxml>";
                                        if (productData.DataLangRecord.XMLDoc.SelectSingleNode("genxml/docs") == null)
                                        {
                                            productData.DataLangRecord.AddXmlNode(strXml, "genxml/docs", "genxml");
                                        }
                                        else
                                        {
                                            productData.DataLangRecord.AddXmlNode(strXml, "genxml/docs/genxml", "genxml/docs");
                                        }
                                        /////////////////////////////////////////////////
                                        productData.DataLangRecord.SetXmlProperty("genxml/docs/genxml[" + lp.ToString() + "]/textbox/txtdocdesc", DocDesc);
                                        productData.DataLangRecord.SetXmlProperty("genxml/docs/genxml[" + lp.ToString() + "]/textbox/txttitle", FileName);

                                        objCtrlDoc.Update(productData.DataLangRecord);

                                        lp += 1;
                                    }

                                    ////////////////////////////// CATEGORIES /////////////////////////////////////
                                    ////////////////////////////// CATEGORIES /////////////////////////////////////
                                    ////////////////////////////// CATEGORIES /////////////////////////////////////
                                    ////////////////////////////// CATEGORIES /////////////////////////////////////

                                    var nodListCat = nod.SelectNodes("C/NB_Store_ProductCategoryInfo");
                                    foreach (XmlNode nodCat in nodListCat)
                                    {
                                        var ProductID = nodCat.SelectSingleNode("ProductID").InnerText;
                                        var CategoryID = nodCat.SelectSingleNode("CategoryID").InnerText;

                                        if (ProductID == guidKey)
                                        {
                                            var newCategoryId = categoryListIDGiud[CategoryID];
                                            productData.AddCategory(newCategoryId);
                                        }

                                    }

                                    ////////////////////////////// SAVE PRODUCT /////////////////////////////////////
                                    productData.Save();

                                }

                            }
                            catch (Exception e)
                            {
                                var logMessage = "PRODUCTS: " + prodname +  " ProductId: " + productid.ToString() + " : " + e.ToString();
                                LogOutput.LogWrite(logMessage);
                            }

                        }
                    }

                    ////////////////////////////// RELATED PRODUCTS /////////////////////////////////////
                    //recicle on all the xml import Product and reconnect the related product
                    foreach (var lang2 in langList)
                    {
                        if (nodList != null)
                        {
                            foreach (XmlNode nod in nodList)
                            {

                                var guidKeyNod = nod.SelectSingleNode("NB_Store_ProductsInfo/ProductID");
                                if (guidKeyNod != null)
                                {

                                    var guidKey = guidKeyNod.InnerText;
                                    var productid = -1;
                                    try
                                    {
                                        // See if e already have a product imported, if so we want to update (maybe multiple languages, or a 2nd migrate)
                                        var nbiImport = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "PRD", guidKey);
                                        if (nbiImport != null) productid = nbiImport.ItemID;
                                        var productData = new ProductData(productid, lang2);

                                        ////////////////////////////// RELATED PRODUCTS /////////////////////////////////////
                                        ////////////////////////////// RELATED PRODUCTS /////////////////////////////////////
                                        var nodListRelated = nod.SelectNodes("R/NB_Store_ProductRelatedInfo");
                                        if (nodListRelated != null) //if there are related
                                        {

                                            foreach (XmlNode nodRel in nodListRelated)
                                            {
                                                // id in the related product import file
                                                var ImportRelatedProductID = nodRel.SelectSingleNode("RelatedProductID").InnerText;
                                                // extract Id of the new created product thet have the old id in the guidKey
                                                var tempID = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "PRD", ImportRelatedProductID);

                                                if (tempID != null)
                                                {
                                                    int IDRelatedprod = tempID.ItemID;
                                                    productData.AddRelatedProduct(IDRelatedprod);
                                                    productData.Save();
                                                }

                                            }
                                        }

                                    }
                                    catch (Exception e)
                                    {
                                        var logMessage = "RELATED PRODUCTS: ProductId: " + productid.ToString() + " : " + e.ToString();
                                        LogOutput.LogWrite(logMessage);
                                    }

                                }

                        }
                        }
                    }

                    LogOutput.LogWrite("END: " + DateTime.Now);

                    #endregion

                }

                NBrightBuyUtils.SetNotfiyMessage(ModuleId, "Import", NotifyCode.ok, ControlPath + "/App_LocalResources/Import.ascx.resx");

            }
        }
Beispiel #52
0
        public void UpdateDocs(NBrightInfo info)
        {
            var strAjaxXml = info.GetXmlProperty("genxml/hidden/xmlupdateproductdocs");
            strAjaxXml = GenXmlFunctions.DecodeCDataTag(strAjaxXml);
            var docList = NBrightBuyUtils.GetGenXmlListByAjax(strAjaxXml, "");
            UpdateDocs(docList);

            //add new doc if uploaded
            var docFile = info.GetXmlProperty("genxml/hidden/hiddocument");
            if (docFile != "")
            {
                var postedFile = info.GetXmlProperty("genxml/hidden/posteddocumentname");
                AddNewDoc(_storeSettings.FolderDocumentsMapPath.TrimEnd('\\') + "\\" + docFile, postedFile);
            }
        }
Beispiel #53
0
 public String UpdateRule(NBrightInfo ruleInfo, Boolean debugMode = false)
 {
     var addIndex = ruleInfo.GetXmlProperty("genxml/hidden/index");
     if (!Utils.IsNumeric(addIndex)) addIndex = "-1"; // assume new .
     var ruleIndex = Convert.ToInt32(addIndex);
     if (debugMode) ruleInfo.XMLDoc.Save(PortalSettings.Current.HomeDirectoryMapPath + "debug_ruleadd.xml");
     if (ruleIndex >= 0)
         {
             UpdateRule(ruleInfo.XMLData, ruleIndex);
         }
         else
         {
             _shippingList.Add(ruleInfo);
         }
     return ""; // if everything is OK, don't send a message back.
 }
Beispiel #54
0
        private void CartEmailAddressDataBinding(object sender, EventArgs e)
        {
            var txt = (TextBox)sender;
            var container = (IDataItemContainer)txt.NamingContainer;

            try
            {
                txt.Visible = visibleStatus.DefaultIfEmpty(true).First();
                if (txt.Width == 0) txt.Visible = false; // always hide if we have a width of zero.
                else
                {
                    var strXML = Convert.ToString(DataBinder.Eval(container.DataItem, "XMLData"));
                    var nbInfo = new NBrightInfo();
                    nbInfo.XMLData = strXML;
                    txt.Text = nbInfo.GetXmlProperty("genxml/textbox/cartemailaddress");
                    if (txt.Text == "")
                    {
                        var usr = UserController.GetCurrentUserInfo();
                        if (usr != null && usr.UserID > 0) txt.Text = usr.Email;
                    }
                }
            }
            catch (Exception)
            {
                //do nothing
            }
        }
Beispiel #55
0
        /// <summary>
        /// Save Data to DNN profile
        /// </summary>
        /// <param name="profile"></param>
        private void UpdateDnnProfile(NBrightInfo profile)
        {
            var flag = false;
            var prop1 = DnnUtils.GetUserProfileProperties(_uData.Info.UserId.ToString(""));
            var prop2 = DnnUtils.GetUserProfileProperties(_uData.Info.UserId.ToString(""));
            foreach (var p in prop1)
            {
                var n = profile.XMLDoc.SelectSingleNode("genxml/textbox/" + p.Key.ToLower());
                if (n != null)
                {
                    prop2[p.Key] = n.InnerText;
                    flag = true;
                }
                n = profile.XMLDoc.SelectSingleNode("genxml/dropdownlist/" + p.Key.ToLower());
                if (n != null)
                {
                    prop2[p.Key] = n.InnerText;
                    flag = true;
                }
                n = profile.XMLDoc.SelectSingleNode("genxml/radiobuttonlist/" + p.Key.ToLower());
                if (n != null)
                {
                    prop2[p.Key] = n.InnerText;
                    flag = true;
                }
            }
            if (flag) DnnUtils.SetUserProfileProperties(_uData.Info.UserId.ToString(""), prop2);

            // update email
            var email = profile.GetXmlProperty("genxml/textbox/email");
            if (email != "" && email != _uData.GetEmail()) _uData.UpdateEmail(email);
        }
Beispiel #56
0
        public String AddAjaxItem(NBrightInfo ajaxInfo, NBrightInfo nbSettings, Boolean debugMode = false)
        {
            var strproductid = ajaxInfo.GetXmlProperty("genxml/hidden/productid");
            // Get ModelID
            var modelidlist = new List<String>();
            // *************************************
            // Do Model List return
            var qtylist = new Dictionary<String, String>();
            var nodList = ajaxInfo.XMLDoc.SelectNodes("genxml/textbox/*");
            if (nodList != null && nodList.Count > 0)
            {
                foreach (XmlNode nod in nodList)
                {
                    if (nod.Name.StartsWith("selectedmodelqty")) // model list qty textbox has modelid appedix.
                    {
                        if (Utils.IsNumeric(nod.InnerText))
                        {
                            var fieldid = nod.Name.Replace("selectedmodelqty", "selectedmodelid"); //link to modelid in hidden field
                            var strmodelId = ajaxInfo.GetXmlProperty("genxml/hidden/" + fieldid);
                            var strqtyId = nod.InnerText;
                            if (Utils.IsNumeric(strqtyId))
                            {
                                modelidlist.Add(strmodelId);
                                qtylist.Add(strmodelId, strqtyId);
                            }
                        }
                    }
                }
            }
            // *************************************
            // do dropdown and radio return
            if (qtylist.Count == 0)
            {
                var strmodelId = ajaxInfo.GetXmlProperty("genxml/radiobuttonlist/rblmodelsel");
                if (strmodelId == "") strmodelId = ajaxInfo.GetXmlProperty("genxml/dropdownlist/ddlmodelsel");
                if (strmodelId == "") strmodelId = ajaxInfo.GetXmlProperty("genxml/hidden/modeldefault");
                if (strmodelId == "")
                {
                    var p = ProductUtils.GetProductData(strproductid,ajaxInfo.Lang);
                    strmodelId = p.Models[0].GetXmlProperty("genxml/hidden/modelid");
                }
                modelidlist.Add(strmodelId);
                var strqtyId = ajaxInfo.GetXmlProperty("genxml/textbox/selectedaddqty");
                if (!Utils.IsNumeric(strqtyId)) strqtyId = "1";
                qtylist.Add(strmodelId, strqtyId);
            }

            var strRtn = "";
            foreach (var m in modelidlist)
            {
                var numberofmodels = 0; // use additemqty field to add multiple items
                var additemqty = ajaxInfo.GetXmlProperty("genxml/textbox/additemqty");
                if (Utils.IsNumeric(additemqty))
                    numberofmodels = Convert.ToInt32(additemqty); // zero should be allowed on add all to basket option.
                else
                    numberofmodels = 1; // if we have no numeric, assume we need to add it

                for (var i = 1; i <= numberofmodels; i++)
                {
                    strRtn += AddSingleItem(strproductid, m, qtylist[m], ajaxInfo, debugMode);
                }
            }
            return strRtn;
        }
Beispiel #57
0
        private void ShippingProviderDataBind(object sender, EventArgs e)
        {
            var rbl = (RadioButtonList)sender;
            var container = (IDataItemContainer)rbl.NamingContainer;
            try
            {
                rbl.Visible = visibleStatus.DefaultIfEmpty(true).First();
                if (rbl.Visible)
                {
                    var strXML = Convert.ToString(DataBinder.Eval(container.DataItem, "XMLData"));
                    var nbInfo = new NBrightInfo();
                    nbInfo.XMLData = strXML;
                    var selectval = nbInfo.GetXmlProperty("genxml/radiobuttonlist/shippingprovider");

                    // get country code, to CheckBox if provider is valid.
                    var cartData = new CartData(PortalSettings.Current.PortalId);

                    var pluginData = new PluginData(PortalSettings.Current.PortalId);
                    var provList = pluginData.GetShippingProviders();
                        foreach (var d in provList)
                        {
                            var isValid = true;
                            var shipprov = ShippingInterface.Instance(d.Key);
                            if (shipprov != null) isValid = shipprov.IsValid(cartData.PurchaseInfo);
                            var p = d.Value;
                            if (isValid)
                            {
                                var li = new ListItem();
                                li.Text = p.GetXmlProperty("genxml/textbox/name");
                                li.Value = p.GetXmlProperty("genxml/textbox/ctrl");
                                if (li.Value == selectval) li.Selected = true;
                                rbl.Items.Add(li);
                            }
                        }
                        if (rbl.SelectedValue == "" && rbl.Items.Count > 0) rbl.SelectedIndex = 0;

                }

            }
            catch (Exception)
            {
                rbl.Visible = false;
            }
        }
Beispiel #58
0
        private NBrightInfo ValidateCartItem(int portalId, int userId, NBrightInfo cartItemInfo)
        {
            cartItemInfo = NBrightBuyUtils.ProcessEventProvider(EventActions.ValidateCartItemBefore, cartItemInfo);

            var modelid = cartItemInfo.GetXmlProperty("genxml/modelid");
            var prdid = cartItemInfo.GetXmlPropertyInt("genxml/productid");
            var qty = cartItemInfo.GetXmlPropertyDouble("genxml/qty");

            var prd = ProductUtils.GetProductData(prdid, Utils.GetCurrentCulture());
            if (!prd.Exists || prd.Disabled) return null; //Invalid product remove from cart
            var prdModel = prd.GetModel(modelid);
            if (prdModel == null) return null; // Invalid Model remove from cart
            // check if dealer (for tax calc)
            var userInfo = UserController.GetUserById(portalId, userId);
            if (userInfo != null && userInfo.IsInRole(StoreSettings.DealerRole) && StoreSettings.Current.Get("enabledealer") == "True")
                cartItemInfo.SetXmlProperty("genxml/isdealer", "True");
            else
                cartItemInfo.SetXmlProperty("genxml/isdealer", "False");

            // check for price change
            var unitcost = prdModel.GetXmlPropertyDouble("genxml/textbox/txtunitcost");
            var dealercost = prdModel.GetXmlPropertyDouble("genxml/textbox/txtdealercost");
            var saleprice = prdModel.GetXmlPropertyDouble("genxml/textbox/txtsaleprice");

            // calc sale price
            var sellcost = unitcost;
            if (saleprice > 0 && saleprice < sellcost) sellcost = saleprice;

            //stock control
            if (prdModel != null)
            {
                var stockon = prdModel.GetXmlPropertyBool("genxml/checkbox/chkstockon");
                var stocklevel = prdModel.GetXmlPropertyDouble("genxml/textbox/txtqtyremaining");
                var minStock = prdModel.GetXmlPropertyDouble("genxml/textbox/txtqtyminstock");
                if (minStock == 0) minStock = StoreSettings.Current.GetInt("minimumstocklevel");
                var maxStock = prdModel.GetXmlPropertyDouble("genxml/textbox/txtqtystockset");
                var weight = prdModel.GetXmlPropertyDouble("genxml/textbox/weight");
                if (stockon)
                {
                    stocklevel = stocklevel - minStock;
                    stocklevel = stocklevel - prd.GetModelTransQty(modelid, _cartId);
                    if (stocklevel < qty)
                    {
                        qty = stocklevel;
                        if (qty <= 0)
                        {
                            qty = 0;
                            cartItemInfo.SetXmlProperty("genxml/validatecode", "OUTOFSTOCK");
                        }
                        else
                        {
                            cartItemInfo.SetXmlProperty("genxml/validatecode", "STOCKADJ");
                        }
                        base.SetValidated(false);
                        cartItemInfo.SetXmlPropertyDouble("genxml/qty", qty.ToString(""));
                    }
                }

                Double additionalCosts = 0;
                var optNods = cartItemInfo.XMLDoc.SelectNodes("genxml/options/*");
                if (optNods != null)
                {
                    var lp = 1;
                    foreach (XmlNode nod in optNods)
                    {
                        var optid = nod.SelectSingleNode("optid");
                        if (optid != null)
                        {
                            var optvalueid = nod.SelectSingleNode("optvalueid");
                            if (optvalueid != null && optvalueid.InnerText != "False")
                            {
                                XmlNode  optvalcostnod;
                                if (optvalueid.InnerText == "True")
                                    optvalcostnod = cartItemInfo.XMLDoc.SelectSingleNode("genxml/productxml/genxml/optionvalues[@optionid='" + optid.InnerText + "']/genxml/textbox/txtaddedcost");
                                else
                                    optvalcostnod = cartItemInfo.XMLDoc.SelectSingleNode("genxml/productxml/genxml/optionvalues/genxml[./hidden/optionvalueid='" + optvalueid.InnerText + "']/textbox/txtaddedcost");

                                if (optvalcostnod != null)
                                {
                                    var optvalcost = optvalcostnod.InnerText;
                                    if (Utils.IsNumeric(optvalcost))
                                    {
                                        cartItemInfo.SetXmlPropertyDouble("genxml/options/option[" + lp + "]/optvalcost", optvalcost);
                                        var optvaltotal = Convert.ToDouble(optvalcost, CultureInfo.GetCultureInfo("en-US"))*qty;
                                        cartItemInfo.SetXmlPropertyDouble("genxml/options/option[" + lp + "]/optvaltotal", optvaltotal);
                                        additionalCosts += optvaltotal;
                                    }
                                }
                                else
                                {
                                    cartItemInfo.SetXmlPropertyDouble("genxml/options/option[" + lp + "]/optvalcost", "0");
                                    cartItemInfo.SetXmlPropertyDouble("genxml/options/option[" + lp + "]/optvaltotal", "0");
                                }
                            }
                        }
                        lp += 1;
                    }
                }

                if (qty > 0)  // can't devide by zero
                {
                    unitcost += (additionalCosts / qty);
                    if (dealercost > 0) dealercost += (additionalCosts / qty); // zero turns off
                    if (saleprice > 0) saleprice += (additionalCosts / qty); // zero turns off
                    sellcost += (additionalCosts / qty);
                }

                var totalcost = qty * sellcost;
                var totaldealercost = qty * dealercost;
                var totalweight = weight * qty;

                if (unitcost != cartItemInfo.GetXmlPropertyDouble("genxml/unitcost") || dealercost != cartItemInfo.GetXmlPropertyDouble("genxml/dealercost") || saleprice != cartItemInfo.GetXmlPropertyDouble("genxml/saleprice"))
                {
                    cartItemInfo.SetXmlPropertyDouble("genxml/unitcost", unitcost);
                    cartItemInfo.SetXmlPropertyDouble("genxml/dealercost", dealercost);
                    cartItemInfo.SetXmlPropertyDouble("genxml/saleprice", saleprice);
                    cartItemInfo.RemoveXmlNode("genxml/productxml");
                    cartItemInfo.AddSingleNode("productxml", prd.Info.XMLData, "genxml");
                }

                cartItemInfo.SetXmlPropertyDouble("genxml/totalweight", totalweight.ToString(""));
                cartItemInfo.SetXmlPropertyDouble("genxml/totalcost", totalcost);
                cartItemInfo.SetXmlPropertyDouble("genxml/totaldealercost", totaldealercost);
                cartItemInfo.SetXmlPropertyDouble("genxml/totaldealerbonus", (totalcost - totaldealercost));

                Double salediscount = 0;
                Double dealerdiscount = 0;
                Double discountcodeamt = 0;
                Double totaldiscount = 0;

                //add update genxml/discountcodeamt
                if (saleprice == 0) // discount codes are only valid for items not on sale
                {
                    var discountcode = PurchaseInfo.GetXmlProperty("genxml/extrainfo/genxml/textbox/promocode");
                    cartItemInfo = DiscountCodeInterface.UpdateItemPercentDiscountCode(PortalId, UserId, cartItemInfo, discountcode);
                    discountcodeamt = cartItemInfo.GetXmlPropertyDouble("genxml/discountcodeamt");
                    if (discountcodeamt > 0) PurchaseInfo.SetXmlProperty("genxml/discountprocessed", "False");
                    totaldiscount = discountcodeamt;
                }
                else
                {
                    salediscount = (unitcost - saleprice);
                    totaldiscount = salediscount * qty;
                }

                var totalsalediscount = salediscount * qty;
                var totaldealerdiscount = dealerdiscount * qty;
                cartItemInfo.SetXmlPropertyDouble("genxml/totaldiscount", totaldiscount);
                cartItemInfo.SetXmlPropertyDouble("genxml/salediscount", totalsalediscount);
                cartItemInfo.SetXmlPropertyDouble("genxml/totaldealerdiscount", totaldealerdiscount);

                cartItemInfo.SetXmlPropertyDouble("genxml/appliedtotalcost", AppliedCost(portalId, userId, totalcost, totaldealercost));
                cartItemInfo.SetXmlPropertyDouble("genxml/appliedcost", AppliedCost(portalId, userId, sellcost, dealercost));

                // calc tax for item
                var taxproviderkey = PurchaseInfo.GetXmlProperty("genxml/hidden/taxproviderkey");
                var taxprov = TaxInterface.Instance(taxproviderkey);
                if (taxprov != null)
                {
                    var nbi = (NBrightInfo)cartItemInfo.Clone();
                    cartItemInfo.SetXmlPropertyDouble("genxml/taxcost", taxprov.CalculateItemTax(nbi));
                }

            }

            cartItemInfo = NBrightBuyUtils.ProcessEventProvider(EventActions.ValidateCartItemAfter, cartItemInfo);

            return cartItemInfo;
        }
        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.

            var strOut = "No Category ID ('itemid' hidden fields needed on input form)";
            if (settings.ContainsKey("itemid"))
            {
                var catData = CategoryUtils.GetCategoryData(Convert.ToInt32(settings["itemid"]), StoreSettings.Current.EditLanguage);

                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);
                }
            }
            else
            {
                NBrightBuyUtils.SetNotfiyMessage(ModuleId, "categoryactionsave", NotifyCode.fail);
            }
            NBrightBuyUtils.RemoveModCachePortalWide(PortalId); //clear any cache
        }
Beispiel #60
0
        private List<NBrightInfo> BuildModelList(NBrightInfo dataItemObj,Boolean addSalePrices = false)
        {
            // see  if we have a cart record
            var xpathprefix = "";
            var cartrecord = dataItemObj.GetXmlProperty("genxml/productid") != ""; // if we have a productid node, then is datarecord is a cart item
            if (cartrecord) xpathprefix = "genxml/productxml/";

            //build models list
            var objL = new List<NBrightInfo>();
            var nodList = dataItemObj.XMLDoc.SelectNodes(xpathprefix + "genxml/models/*");
            if (nodList != null)
            {

                #region "Init"

                var isDealer = CmsProviderManager.Default.IsInRole(StoreSettings.DealerRole);

                #endregion

                var lp = 1;
                foreach (XmlNode nod in nodList)
                {
                    // check if Deleted
                    var selectDeletedFlag = nod.SelectSingleNode("checkbox/chkdeleted");
                    if ((selectDeletedFlag == null) || selectDeletedFlag.InnerText != "True")
                    {
                    // check if hidden
                        var selectHiddenFlag = nod.SelectSingleNode("checkbox/chkishidden");
                        if ((selectHiddenFlag == null) || selectHiddenFlag.InnerText != "True")
                        {
                            // check if dealer
                            var selectDealerFlag = nod.SelectSingleNode("checkbox/chkdealeronly");
                            if (((selectDealerFlag == null) || (!isDealer && (selectDealerFlag.InnerText != "True"))) | isDealer)
                            {
                                // get modelid
                                var nodModelId = nod.SelectSingleNode("hidden/modelid");
                                var modelId = "";
                                if (nodModelId != null) modelId = nodModelId.InnerText;

                                //Build NBrightInfo class for model
                                var o = new NBrightInfo();
                                o.XMLData = nod.OuterXml;

                                #region "Add Lanaguge Data"

                                var nodLang = dataItemObj.XMLDoc.SelectSingleNode(xpathprefix + "genxml/lang/genxml/models/genxml[" + lp.ToString("") + "]");
                                if (nodLang != null)
                                {
                                    o.AddSingleNode("lang", "", "genxml");
                                    o.AddXmlNode(nodLang.OuterXml, "genxml", "genxml/lang");
                                }

                                #endregion

                                #region "Prices"

                                if (addSalePrices)
                                {
                                    var uInfo = UserController.GetCurrentUserInfo();
                                    if (uInfo != null)
                                    {
                                        o.SetXmlPropertyDouble("genxml/hidden/saleprice", "-1"); // set to -1 so unitcost is displayed (turns off saleprice)
                                        //[TODO: convert to new promotion provider]
                                        //var objPromoCtrl = new PromoController();
                                        //var objPCtrl = new ProductController();
                                        //var objM = objPCtrl.GetModel(modelId, Utils.GetCurrentCulture());
                                        //var salePrice = objPromoCtrl.GetSalePrice(objM, uInfo);
                                        //o.AddSingleNode("saleprice", salePrice.ToString(CultureInfo.GetCultureInfo("en-US")), "genxml/hidden");
                                    }
                                }

                                #endregion

                                // product data for display in modellist
                                o.SetXmlProperty("genxml/lang/genxml/textbox/txtproductname", dataItemObj.GetXmlProperty(xpathprefix + "genxml/lang/genxml/textbox/txtproductname"));
                                o.SetXmlProperty("genxml/textbox/txtproductref", dataItemObj.GetXmlProperty(xpathprefix + "genxml/textbox/txtproductref"));

                                if (cartrecord)
                                    o.SetXmlProperty("genxml/hidden/productid", dataItemObj.GetXmlProperty("genxml/productid"));
                                else
                                o.SetXmlProperty("genxml/hidden/productid", dataItemObj.ItemID.ToString(""));

                                objL.Add(o);
                            }
                        }
                    }
                    lp += 1;
                }
            }
            return objL;
        }