Exemple #1
0
        private void Update(int productid)
        {
            if (productid > 0)
            {
                var prodData = ProductUtils.GetProductData(productid, StoreSettings.Current.EditLanguage);
                var strXml   = GenXmlFunctions.GetGenXml(rpData);
                var updInfo  = new NBrightInfo(true);
                updInfo.XMLData = strXml;

                GenXmlFunctions.UploadFile(rpData, "document", StoreSettings.Current.FolderDocumentsMapPath);
                var ctrl = ((HtmlGenericControl)rpData.Items[0].FindControl("hiddocument"));
                if (ctrl != null)
                {
                    var fName = ctrl.Attributes["value"];
                    updInfo.SetXmlProperty("genxml/hidden/hiddocument", fName);

                    var docCtrl = (FileUpload)rpData.Items[0].FindControl("document");
                    updInfo.SetXmlProperty("genxml/hidden/posteddocumentname", docCtrl.PostedFile.FileName);
                }

                prodData.Update(updInfo.XMLData);
                prodData.Save();
                prodData.FillEmptyLanguageFields();

                if (StoreSettings.Current.DebugModeFileOut)
                {
                    prodData.OutputDebugFile(PortalSettings.HomeDirectoryMapPath + "debug_productupdate.xml");
                }

                NBrightBuyUtils.RemoveModCachePortalWide(PortalId);
                ProductUtils.RemoveProductDataCache(prodData);
            }
        }
Exemple #2
0
        private NBrightInfo AddNew()
        {
            var objCtrl = new NBrightDataController();
            var nbi     = new NBrightInfo(true);

            nbi.PortalId = _portalId;
            nbi.TypeCode = "PL";
            nbi.ModuleId = -1;
            nbi.ItemID   = -1;
            nbi.GUIDKey  = TabInfo.TabID.ToString("");
            var itemId = objCtrl.Update(nbi);

            nbi.ItemID = itemId;

            foreach (var lang in DnnUtils.GetCultureCodeList(_portalId))
            {
                var nbi2 = new NBrightInfo(true);
                nbi2.PortalId     = _portalId;
                nbi2.TypeCode     = "PLLANG";
                nbi2.ModuleId     = -1;
                nbi2.ItemID       = -1;
                nbi2.Lang         = lang;
                nbi2.ParentItemId = itemId;
                nbi2.GUIDKey      = TabInfo.TabID.ToString("");
                nbi2.SetXmlProperty("genxml/textbox/pagename", TabInfo.TabName);
                nbi2.SetXmlProperty("genxml/textbox/pagetitle", TabInfo.Title);
                nbi2.SetXmlProperty("genxml/textbox/tagwords", TabInfo.KeyWords);
                nbi2.SetXmlProperty("genxml/textbox/pagedescription", TabInfo.Description);
                nbi2.ItemID = objCtrl.Update(nbi2);
            }

            return(nbi);
        }
Exemple #3
0
 public void UpdateItemList(string listname, string listcsv = "")
 {
     if (DataRecord.XMLDoc.SelectSingleNode("genxml/itemlists") == null)
     {
         DataRecord.SetXmlProperty("genxml/itemlists", "");
     }
     DataRecord.SetXmlProperty("genxml/itemlists/" + Utils.CleanInput(listname).Replace(" ", "-"), listcsv);
 }
Exemple #4
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);
            }
        }
Exemple #5
0
 public void UpdateItemList(string listkey, string listcsv, string listname)
 {
     if (DataRecord.XMLDoc.SelectSingleNode("genxml/itemlists") == null)
     {
         DataRecord.SetXmlProperty("genxml/itemlists", "");
     }
     DataRecord.SetXmlProperty("genxml/itemlists/" + listkey, listcsv);
     if (listname == "")
     {
         listname = listkey;
     }
     DataRecord.SetXmlProperty("genxml/itemlists/" + listkey + "/@name", listname);
 }
Exemple #6
0
        public void UpdateModels(String xmlAjaxData, string editlang)
        {
            var rtnstatuscode = "";
            var modelList     = NBrightBuyUtils.GetGenXmlListByAjax(xmlAjaxData, "", editlang);

            var basefields = "";

            // build xml for data records
            var strXml = "<genxml><interfaces>";

            foreach (var modelInfo in modelList)
            {
                // build list of xpath fields that need processing.
                var filedList = NBrightBuyUtils.GetAllFieldxPaths(modelInfo);
                foreach (var xpath in filedList)
                {
                    basefields += xpath + ",";
                }

                var objInfo = new NBrightInfo(true);

                var fields = basefields.Split(',');
                foreach (var f in fields.Where(f => f != ""))
                {
                    var datatype = modelInfo.GetXmlProperty(f + "/@datatype");
                    if (datatype == "date")
                    {
                        objInfo.SetXmlProperty(f, modelInfo.GetXmlProperty(f), TypeCode.DateTime);
                    }
                    else if (datatype == "double")
                    {
                        objInfo.SetXmlPropertyDouble(f, modelInfo.GetXmlProperty(f));
                    }
                    else if (datatype == "html")
                    {
                        objInfo.SetXmlProperty(f, modelInfo.GetXmlPropertyRaw(f));
                    }
                    else
                    {
                        objInfo.SetXmlProperty(f, modelInfo.GetXmlProperty(f));
                    }
                }
                strXml += objInfo.XMLData;
            }
            strXml += "</interfaces></genxml>";

            // replace models xml
            Info().ReplaceXmlNode(strXml, "genxml/interfaces", "genxml");
        }
        public IEncodedString FileSelectList(string selectedfilename, String relitiveRootFolder, String attributes = "", Boolean allowEmpty = true)
        {
            var nbi = new NBrightInfo(true);

            nbi.SetXmlProperty("genxml/selectedfilename", selectedfilename);
            return(FileSelectList(nbi, "genxml/selectedfilename", relitiveRootFolder, attributes, allowEmpty));
        }
Exemple #8
0
 public String AddNewRule()
 {
     var ruleInfo = new NBrightInfo(true);
     ruleInfo.ItemID = -1;
     ruleInfo.SetXmlProperty("genxml/hidden/index","-1");
     return UpdateRule(ruleInfo);
 }
        public String AddNewRule()
        {
            var ruleInfo = new NBrightInfo(true);

            ruleInfo.ItemID = -1;
            ruleInfo.SetXmlProperty("genxml/hidden/index", "-1");
            return(UpdateRule(ruleInfo));
        }
        public override NBrightInfo UpdatePercentUsage(int portalId, int userId, NBrightInfo purchaseInfo)
        {
            var discountcode = purchaseInfo.GetXmlProperty("genxml/extrainfo/genxml/textbox/promocode");

            if (!purchaseInfo.GetXmlPropertyBool("genxml/discountprocessed"))
            {
                if (userId > 0)
                {
                    if (discountcode == "")
                    {
                        return(purchaseInfo);
                    }
                    var clientData = new ClientData(portalId, userId);
                    if (clientData.DiscountCodes.Count > 0)
                    {
                        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");
                    }
                }

                var objCtrl = new NBrightBuyController();
                var dis     = objCtrl.GetByGuidKey(portalId, -1, "DISCOUNTCODE", discountcode);
                if (dis != null)
                {
                    var usage = dis.GetXmlPropertyDouble("genxml/textbox/usage");
                    dis.SetXmlPropertyDouble("genxml/textbox/usage", (usage + 1));
                    objCtrl.Update(dis);
                    purchaseInfo.SetXmlProperty("genxml/discountprocessed", "True");
                }
            }

            return(purchaseInfo);
        }
        private static String NewAddress(HttpContext context)
        {
            var addressData = new AddressData();
            var dummyaddr   = new NBrightInfo(true);

            dummyaddr.SetXmlProperty("genxml/textbox/dummy", "XXXXXXX"); // set dummy value so we activate a unknown address.
            addressData.AddAddress(dummyaddr, -1);
            return("");
        }
Exemple #12
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);
        }
Exemple #13
0
        private int AddNew()
        {
            var nbi = new NBrightInfo(true);

            if (StoreSettings.Current.GetBool(StoreSettingKeys.sharecategories)) // option in storesetting to share products created here across all portals.
            {
                _portalId = -1;
            }
            else
            {
                _portalId = PortalSettings.Current.PortalId;
            }
            nbi.PortalId = _portalId;
            nbi.TypeCode = "CATEGORY";
            nbi.ModuleId = -1;
            nbi.ItemID   = -1;
            nbi.SetXmlProperty("genxml/dropdownlist/ddlgrouptype", "cat");
            nbi.SetXmlProperty("genxml/checkbox/chkishidden", "True");
            nbi.SetXmlPropertyDouble("genxml/hidden/recordsortorder", 99999);
            var itemId = _objCtrl.Update(nbi);

            // update again, so we get a valid sort order based on itemid
            nbi.ItemID = itemId;
            nbi.SetXmlPropertyDouble("genxml/hidden/recordsortorder", itemId);
            _objCtrl.Update(nbi);

            foreach (var lang in DnnUtils.GetCultureCodeList(_portalId))
            {
                nbi = new NBrightInfo(true)
                {
                    PortalId     = _portalId,
                    TypeCode     = "CATEGORYLANG",
                    ModuleId     = -1,
                    ItemID       = -1,
                    Lang         = lang,
                    ParentItemId = itemId
                };
                _objCtrl.Update(nbi);
            }

            return(itemId);
        }
Exemple #14
0
        private void RemoveLogo()
        {
            var modCtrl = new NBrightBuyController();
            var strXml  = GenXmlFunctions.GetGenXml(rpDataH, "", StoreSettings.Current.FolderImagesMapPath);

            _info.XMLData = strXml;
            _info.SetXmlProperty("genxml/hidden/hidmanualpaymentlogo", "");
            modCtrl.Update(_info);

            //remove current setting from cache for reload
            Utils.RemoveCache("ManualPaymentProvider" + PortalSettings.Current.PortalId.ToString(""));
        }
Exemple #15
0
        private void SharedRecord(NBrightInfo i)
        {
            var createdportalid = i.PortalId;

            if (createdportalid == -1)
            {
                createdportalid = PortalSettings.Current.PortalId;                        // previously shared record, so defualt to current.
            }
            i.SetXmlProperty("genxml/createdportalid", createdportalid.ToString(""));
            i.PortalId = -1;
            ModCtrl.Update(i);
        }
        private void Update()
        {
            var modCtrl = new NBrightBuyController();
            var strXml  = GenXmlFunctions.GetGenXml(rpDataH);

            _info.XMLData = strXml;
            _info.SetXmlProperty("genxml/debugmsg", "");
            modCtrl.Update(_info);

            //remove current setting from cache for reload
            Utils.RemoveCache("NBrightPxPayPaymentProvider" + PortalSettings.Current.PortalId.ToString(""));
        }
        public static string GetProductItemListPopup(ItemListData itemListData, string listkey = "", string entityTypeCode = "PRD", string entityTypeCodeLang = "PRDLANG")
        {
            var ajaxInfo = new NBrightInfo(true);

            ajaxInfo.SetXmlProperty("genxml/products", itemListData.products);
            ajaxInfo.SetXmlProperty("genxml/listkeys", itemListData.listkeys);
            ajaxInfo.SetXmlProperty("genxml/list", "");
            foreach (var l in itemListData.listnames)
            {
                ajaxInfo.SetXmlProperty("genxml/list/" + l.Key, l.Value);
            }
            ajaxInfo.SetXmlProperty("genxml/productsinlist", "");
            foreach (var l in itemListData.productsInList)
            {
                ajaxInfo.SetXmlProperty("genxml/productsinlist/" + l.Key, l.Value);
            }

            var modelsetings = StoreSettings.Current.Settings();

            if (!modelsetings.ContainsKey("listkeys"))
            {
                modelsetings.Add("listkeys", itemListData.listkeys);
            }
            var strOut = NBrightBuyUtils.RazorTemplRender("ItemListPopupBody.cshtml", -1, "", ajaxInfo, "/DesktopModules/NBright/NBrightBuy", _themeFolder, Utils.GetCurrentCulture(), modelsetings);

            return(strOut);
        }
Exemple #18
0
        public string UpdateCategoryImages(HttpContext context, string editLangCurrent)
        {
            EditLangCurrent = editLangCurrent;
            //get uploaded params
            var ajaxInfo      = NBrightBuyUtils.GetAjaxFields(context);
            var catitemid     = ajaxInfo.GetXmlPropertyInt("genxml/hidden/selectedcatid");
            var imguploadlist = ajaxInfo.GetXmlProperty("genxml/hidden/imguploadlist");
            var strOut        = "";

            if (catitemid > 0)
            {
                var imgs = imguploadlist.Split(',');
                foreach (var img in imgs)
                {
                    if (ImgUtils.IsImageFile(Path.GetExtension(img)) && img != "")
                    {
                        var extension = Path.GetExtension(img);
                        var fn        = DnnUtils.Encrypt(img, StoreSettings.Current.Get("adminpin"));
                        foreach (char c in System.IO.Path.GetInvalidFileNameChars())
                        {
                            fn = fn.Replace(c, '_');
                        }
                        fn = extension + "-" + fn; // add extension to front, so it cannot be servered but we can add to order data.

                        var fullName = StoreSettings.Current.FolderTempMapPath.TrimEnd(Convert.ToChar("\\")) + "\\" + fn;
                        if (File.Exists(fullName))
                        {
                            // process image provider
                            var imageInfo = new NBrightInfo(true);
                            imageInfo.SetXmlProperty("genxml/uploadedimagemappath", fullName);
                            imageInfo = NBrightBuyUtils.ProcessImageProvider("product", imageInfo);
                            fullName  = imageInfo.GetXmlProperty("genxml/uploadedimagemappath");

                            // deal with image
                            File.Move(fullName, fullName + extension);
                            fullName = fullName + extension;
                            var imgResize = StoreSettings.Current.GetInt(StoreSettingKeys.productimageresize);
                            if (imgResize == 0)
                            {
                                imgResize = 800;
                            }
                            var productFunctions = new ProductFunctions();
                            var imagepath        = productFunctions.ResizeImage(fullName, imgResize);
                            var imageurl         = StoreSettings.Current.FolderImages.TrimEnd('/') + "/" + Path.GetFileName(imagepath);
                            AddNewImage(catitemid, imageurl, imagepath, EditLangCurrent);
                        }
                    }
                }
            }
            return(CategoryAdminDetail(context, 0, EditLangCurrent));
        }
Exemple #19
0
 private void PopulateData(String userId)
 {
     Exists       = false;
     UserData     = new UserData(userId);
     _addressList = GetAddressList();
     //if we have no address create a default one from DNN profile
     if (_addressList.Count == 0 && UserData.Exists)
     {
         var newDefault = new NBrightInfo(true);
         newDefault.SetXmlProperty("genxml/hidden/default", "True");
         newDefault.SetXmlProperty("genxml/hidden/index", _addressList.Count.ToString(""));
         var prop = DnnUtils.GetUserProfileProperties(UserData.Info.UserId.ToString(""));
         foreach (var p in prop)
         {
             newDefault.SetXmlProperty("genxml/textbox/" + p.Key.ToLower(), p.Value);
         }
         _addressList.Add(newDefault);
         Save();
     }
     else
     {
         //UpdateDefaultProfileAddress(); //alway update default address to profile, to keep it in-line.
     }
 }
 /// <summary>
 /// Get Current Cart Item List
 /// </summary>
 /// <returns></returns>
 public List<NBrightInfo> GetRuleList()
 {
     var rtnList = new List<NBrightInfo>();
         var xmlNodeList = Info.XMLDoc.SelectNodes("genxml/list/*");
         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(""));
                 rtnList.Add(newInfo);
             }
         }
     return rtnList;
 }
        private void Update()
        {
            var modCtrl = new NBrightBuyController();
            var strXml  = GenXmlFunctions.GetGenXml(rpDataH);

            _info.XMLData = strXml;
            _info.SetXmlProperty("genxml/debugmsg", "");
            modCtrl.Update(_info);

            var resxDic     = GenXmlFunctions.GetGenXmlResx(rpDataH);
            var genTempl    = (GenXmlTemplate)rpDataH.ItemTemplate;
            var resxfolders = genTempl.GetResxFolders();
            var resxUpdate  = NBrightBuyUtils.UpdateResxFields(resxDic, resxfolders, StoreSettings.Current.EditLanguage, true);

            //remove current setting from cache for reload
            Utils.RemoveCache("NBrightPayPalPaymentProvider" + PortalSettings.Current.PortalId.ToString(""));
        }
        private string AddReport(HttpContext context)
        {
            var objCtrl = new NBrightBuyController();
            var obj     = new NBrightInfo(true);

            obj.TypeCode = "NBSREPORT";
            obj.SetXmlProperty("genxml/lang/genxml/textbox/name", "New Report");
            obj.PortalId = PortalSettings.Current.PortalId;
            obj.ModuleId = -1;
            obj.ItemID   = -1;
            objCtrl.Update(obj);

            var cachekey = "GetReportListData*" + PortalSettings.Current.PortalId.ToString("");

            Utils.RemoveCache(cachekey);

            return("");
        }
        public List <NBrightInfo> GetRuleList()
        {
            var rtnList     = new List <NBrightInfo>();
            var xmlNodeList = Info.XMLDoc.SelectNodes("genxml/list/*");

            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(""));
                    rtnList.Add(newInfo);
                }
            }
            return(rtnList);
        }
Exemple #24
0
        /// <summary>
        /// Gets singe record of language Data.
        /// </summary>
        /// <param name="parentItemId">Parent itemId</param>
        /// <param name="lang">Entity langauge to select</param>
        /// <param name="seluserId">select by userid</param>
        /// <returns></returns>
        public NBrightInfo GetDataLang(int parentItemId, string lang = "", string seluserId = "")
        {
            if (lang == "")
            {
                lang = EntityLangauge;
            }
            var strFilter = " and NB1.parentitemid = '" + parentItemId + "' and ISNULL(NB2.[Lang],ISNULL(NB1.[Lang],'''')) =  '" + lang + "' ";

            if (seluserId != "")
            {
                strFilter += " and userid = '" + seluserId + "' ";
            }
            var l = GetList(PortalId, ModuleId, EntityTypeCodeLang, strFilter, "", 0);

            // START: FIX DATA ISSUES
            // In some cases we have a mismatch between the itemid of the record and the itemid in the XML data
            // I'm not sure how this happens (maybe import/export), but here we just make sure it's OK.
            NBrightInfo rtnObj = null;

            if (l.Count >= 1)
            {
                rtnObj = l[0];
                var i = rtnObj.GetXmlProperty("genxml/hidden/itemid");
                if (i != "" && i != rtnObj.ItemID.ToString("")) // record might not have a hidden itemid field.
                {
                    rtnObj.SetXmlProperty("genxml/hidden/itemid", rtnObj.ItemID.ToString(""));
                    ObjCtrl.Update(rtnObj); // fix record.
                }
            }
            // I think!! because of the above issue we might have multiple lang record, remove the invalid ones.
            if (l.Count >= 2)
            {
                for (int i = 1; i < l.Count; i++)
                {
                    NBrightInfo obj = l[i];
                    ObjCtrl.Delete(obj.ItemID);
                }
            }
            // END: FIX.

            return(rtnObj);
        }
Exemple #25
0
        private void SystemConfigMerge(NBrightInfo info)
        {
            var sysList     = new Dictionary <String, NBrightInfo>();
            var addList     = new Dictionary <String, 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 = sysList.Count;
                    newInfo.SetXmlProperty("genxml/hidden/index", sysList.Count.ToString(""));
                    newInfo.GUIDKey = newInfo.GetXmlProperty("genxml/textbox/ctrl");
                    sysList.Add(newInfo.GUIDKey, newInfo);
                    addList.Add(newInfo.GUIDKey, newInfo);
                }

                var newpluginList = new List <NBrightInfo>();
                foreach (var pluginInfo in _pluginList)
                {
                    if (sysList.ContainsKey(pluginInfo.GUIDKey))
                    {
                        newpluginList.Add(sysList[pluginInfo.GUIDKey]);
                        addList.Remove(pluginInfo.GUIDKey);
                    }
                    else
                    {
                        newpluginList.Add(pluginInfo);
                    }
                }
                foreach (var newplugin in addList)
                {
                    newpluginList.Add(addList[newplugin.Key]);
                }

                _pluginList = newpluginList;
            }
        }
Exemple #26
0
        /// <summary>
        /// Build list of plugins from XML config or legacy files.
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private static List <NBrightInfo> CalcSystemPluginList(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.PortalId = 99999;
                    newInfo.SetXmlProperty("genxml/hidden/index", rtnList.Count.ToString(""), TypeCode.Double);
                    newInfo.GUIDKey = newInfo.GetXmlProperty("genxml/textbox/ctrl");
                    rtnList.Add(newInfo);
                }
            }

            return(rtnList);
        }
Exemple #27
0
        private static NBrightInfo UpdateLangNodeFields(String xmlname, NBrightInfo baseInfo, NBrightInfo dlang)
        {
            var nodList3I = baseInfo.XMLDoc.SelectNodes("genxml/" + xmlname + "/genxml");

            if (nodList3I != null)
            {
                for (int i = 1; i <= nodList3I.Count; i++)
                {
                    var nodList3 = baseInfo.XMLDoc.SelectNodes("genxml/" + xmlname + "/genxml[" + i + "]/textbox/*");
                    if (nodList3 != null)
                    {
                        foreach (XmlNode nod in nodList3)
                        {
                            if (nod.InnerText.Trim() != "")
                            {
                                if (dlang.GetXmlProperty("genxml/" + xmlname + "/genxml[" + i + "]/textbox/" + nod.Name) == "")
                                {
                                    if (dlang.XMLDoc.SelectSingleNode("genxml/" + xmlname + "/genxml[" + i + "]") == null)
                                    {
                                        var baseXml = baseInfo.XMLDoc.SelectSingleNode("genxml/" + xmlname + "/genxml[" + i + "]");
                                        if (baseXml != null)
                                        {
                                            if (dlang.XMLDoc.SelectSingleNode("genxml/" + xmlname) == null)
                                            {
                                                dlang.AddSingleNode(xmlname, "", "genxml");
                                            }
                                            dlang.AddXmlNode(baseXml.OuterXml, "genxml", "genxml/" + xmlname);
                                        }
                                    }

                                    dlang.SetXmlProperty("genxml/" + xmlname + "/genxml[" + i + "]/textbox/" + nod.Name, nod.InnerText);
                                }
                            }
                        }
                    }
                }
            }
            return(dlang);
        }
        private String AddNew(String moduleid, String typeCode)
        {
            if (!Utils.IsNumeric(moduleid))
            {
                moduleid = "-2";                             // -2 for razor
            }
            var objCtrl = new NBrightBuyController();
            var nbi     = new NBrightInfo(true);

            nbi.PortalId = PortalSettings.Current.PortalId;
            nbi.TypeCode = typeCode;
            nbi.ModuleId = Convert.ToInt32(moduleid);
            nbi.ItemID   = -1;
            if (typeCode == "DISCOUNTCODE")
            {
                nbi.SetXmlProperty("genxml/textbox/code", Utils.GetUniqueKey().ToUpper());
                nbi.GUIDKey = nbi.GetXmlProperty("genxml/textbox/code");
            }
            var itemId = objCtrl.Update(nbi);

            nbi.ItemID = itemId;

            foreach (var lang in DnnUtils.GetCultureCodeList(PortalSettings.Current.PortalId))
            {
                var nbi2 = new NBrightInfo(true);
                nbi2.PortalId     = PortalSettings.Current.PortalId;
                nbi2.TypeCode     = typeCode + "LANG";
                nbi2.ModuleId     = Convert.ToInt32(moduleid);
                nbi2.ItemID       = -1;
                nbi2.Lang         = lang;
                nbi2.ParentItemId = itemId;
                nbi2.GUIDKey      = "";
                nbi2.ItemID       = objCtrl.Update(nbi2);
            }

            NBrightBuyUtils.RemoveModCache(nbi.ModuleId);

            return(nbi.ItemID.ToString(""));
        }
Exemple #29
0
        public static String PluginAddNew(HttpContext context)
        {
            try
            {
                if (NBrightBuyUtils.CheckRights())
                {
                    var ajaxInfo = NBrightBuyUtils.GetAjaxInfo(context);

                    var strOut      = "";
                    var themeFolder = ajaxInfo.GetXmlProperty("genxml/hidden/themefolder");
                    if (themeFolder == "")
                    {
                        themeFolder = "config";
                    }
                    var razortemplate = ajaxInfo.GetXmlProperty("genxml/hidden/razortemplate");

                    var passSettings = NBrightBuyUtils.GetPassSettings(ajaxInfo);

                    var info = new NBrightInfo(true);
                    info.ItemID   = -1;
                    info.PortalId = PortalSettings.Current.PortalId;
                    info.Lang     = Utils.GetCurrentCulture();
                    info.SetXmlProperty("genxml/hidden/index", "99");
                    info.TypeCode = "PLUGIN";
                    info.GUIDKey  = Utils.GetUniqueKey(12);
                    var objCtrl = new NBrightBuyController();
                    info.ItemID = objCtrl.Update(info);
                    var pluginRecord = new PluginRecord(info);

                    strOut = NBrightBuyUtils.RazorTemplRender(razortemplate, 0, "", pluginRecord, TemplateRelPath, themeFolder, Utils.GetCurrentCulture(), passSettings);
                    return(strOut);
                }
                return("");
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Exemple #30
0
        /// <summary>
        /// Get Current Cart Item List
        /// </summary>
        /// <returns></returns>
        public List <NBrightInfo> GetAddressList()
        {
            var rtnList = new List <NBrightInfo>();

            if (UserData.Exists)
            {
                var xmlNodeList = UserData.Info.XMLDoc.SelectNodes("genxml/address/*");
                if (xmlNodeList != null)
                {
                    foreach (XmlNode carNod in xmlNodeList)
                    {
                        var newInfo = new NBrightInfo {
                            XMLData = carNod.OuterXml
                        };
                        newInfo.PortalId = UserData.Info.PortalId;
                        newInfo.SetXmlProperty("genxml/hidden/index", rtnList.Count.ToString(""));
                        rtnList.Add(newInfo);
                    }
                }
            }
            return(rtnList);
        }
Exemple #31
0
        private void Update(int productid)
        {
            if (productid > 0)
            {
                var prodData = ProductUtils.GetProductData(productid, StoreSettings.Current.EditLanguage);
                var strXml = GenXmlFunctions.GetGenXml(rpData);
                var updInfo = new NBrightInfo(true);
                updInfo.XMLData = strXml;

                GenXmlFunctions.UploadFile(rpData, "document", StoreSettings.Current.FolderDocumentsMapPath);
                var ctrl = ((HtmlGenericControl) rpData.Items[0].FindControl("hiddocument"));
                if (ctrl != null)
                {
                    var fName = ctrl.Attributes["value"];
                    updInfo.SetXmlProperty("genxml/hidden/hiddocument", fName);

                    var docCtrl = (FileUpload) rpData.Items[0].FindControl("document");
                    updInfo.SetXmlProperty("genxml/hidden/posteddocumentname", docCtrl.PostedFile.FileName);
                }

                prodData.Update(updInfo.XMLData);
                prodData.Save();

                if (StoreSettings.Current.DebugModeFileOut) prodData.OutputDebugFile(PortalSettings.HomeDirectoryMapPath + "debug_productupdate.xml");

                NBrightBuyUtils.RemoveModCachePortalWide(PortalId);
                ProductUtils.RemoveProductDataCache(productid, StoreSettings.Current.EditLanguage);

            }
        }
        /// <summary>
        /// Save cookie to client
        /// </summary>
        public void Save()
        {
            #region "Get temp filename"

            var 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", "");
            }

            if (tempfilename == "") tempfilename = Utils.GetUniqueKey(12);

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

            #endregion

            var nbi = new NBrightInfo(true);
            if (XmlData != "") nbi.XMLData = XmlData;

            nbi.SetXmlProperty("genxml/Criteria", _criteria);
            nbi.SetXmlProperty("genxml/PageModuleId", PageModuleId);
            nbi.SetXmlProperty("genxml/PageNumber", PageNumber);
            nbi.SetXmlProperty("genxml/PageName", PageName);
            nbi.SetXmlProperty("genxml/PageSize", PageSize);
            nbi.SetXmlProperty("genxml/OrderBy", OrderBy);
            nbi.SetXmlProperty("genxml/CategoryId", CategoryId.ToString("D"));
            nbi.SetXmlProperty("genxml/RecordCount", RecordCount);
            nbi.SetXmlProperty("genxml/Mode", Mode);
            nbi.SetXmlProperty("genxml/OrderByIdx", OrderByIdx);

            if (!String.IsNullOrEmpty(SearchFormData))
            {
                nbi.RemoveXmlNode("genxml/SearchFormData");
                nbi.SetXmlProperty("genxml/SearchFormData", "",TypeCode.String,false);
                nbi.AddXmlNode(SearchFormData,"genxml", "genxml/SearchFormData");
            }

            var filePath = StoreSettings.Current.FolderTempMapPath + "\\" + tempfilename;
            Utils.SaveFile(filePath, nbi.XMLData);

            Exists = true;
        }
        private static NBrightInfo UpdateLangNodeFields(String xmlname, NBrightInfo baseInfo, NBrightInfo dlang)
        {
            var nodList3I = baseInfo.XMLDoc.SelectNodes("genxml/" + xmlname + "/genxml");
            if (nodList3I != null)
            {
                for (int i = 1; i <= nodList3I.Count; i++)
                {
                    var nodList3 = baseInfo.XMLDoc.SelectNodes("genxml/" + xmlname + "/genxml[" + i + "]/textbox/*");
                    if (nodList3 != null)
                    {
                        foreach (XmlNode nod in nodList3)
                        {
                            if (nod.InnerText.Trim() != "")
                            {
                                if (dlang.GetXmlProperty("genxml/" + xmlname + "/genxml[" + i + "]/textbox/" + nod.Name) == "")
                                {
                                    if (dlang.XMLDoc.SelectSingleNode("genxml/" + xmlname + "/genxml[" + i + "]") == null)
                                    {
                                        var baseXml = baseInfo.XMLDoc.SelectSingleNode("genxml/" + xmlname + "/genxml[" + i + "]");
                                        if (baseXml != null)
                                        {
                                            if (dlang.XMLDoc.SelectSingleNode("genxml/" + xmlname) == null)
                                            {
                                                dlang.AddSingleNode(xmlname, "", "genxml");
                                            }
                                            dlang.AddXmlNode(baseXml.OuterXml, "genxml", "genxml/" + xmlname);
                                        }
                                    }

                                    dlang.SetXmlProperty("genxml/" + xmlname + "/genxml[" + i + "]/textbox/" + nod.Name, nod.InnerText);
                                }
                            }
                        }
                    }
                }
            }
            return dlang;
        }
Exemple #34
0
        public void Update(NBrightInfo info)
        {
            // build list of xpath fields that need processing.
            var updatefields = new List <String>();
            var fieldList    = NBrightBuyUtils.GetAllFieldxPaths(info);

            foreach (var xpath in fieldList)
            {
                if (info.GetXmlProperty(xpath + "/@update") == "lang")
                {
                    updatefields.Add(xpath);
                }
            }

            foreach (var f in updatefields)
            {
                if (f.EndsWith("/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("genxml/edt/message", info.GetXmlPropertyRaw("genxml/edt/message"));
                    }
                    else
                    {
                        DataLangRecord.SetXmlProperty("genxml/edt/message", info.GetXmlPropertyRaw("genxml/textbox/message")); // ajax on ckeditor (Ajax diesn't work for telrik)
                    }
                }
                else
                {
                    DataLangRecord.RemoveXmlNode(f);
                    var xpathDest = f.Split('/');
                    if (xpathDest.Count() >= 2)
                    {
                        DataLangRecord.AddXmlNode(info.XMLData, f, xpathDest[0] + "/" + xpathDest[1]);
                    }
                }

                var datatype = info.GetXmlProperty(f + "/@datatype");
                if (datatype == "date")
                {
                    DataLangRecord.SetXmlProperty(f, info.GetXmlProperty(f), TypeCode.DateTime);
                }
                else if (datatype == "double")
                {
                    DataLangRecord.SetXmlPropertyDouble(f, info.GetXmlProperty(f));
                }
                else if (datatype == "html")
                {
                    DataLangRecord.SetXmlProperty(f, info.GetXmlPropertyRaw(f));
                }
                else
                {
                    DataLangRecord.SetXmlProperty(f, info.GetXmlProperty(f).Trim());
                }


                DataRecord.RemoveXmlNode(f);
            }


            updatefields = new List <String>();
            fieldList    = NBrightBuyUtils.GetAllFieldxPaths(info);
            foreach (var xpath in fieldList)
            {
                var id = xpath.Split('/').Last();
                if (info.GetXmlProperty(xpath + "/@update") == "save")
                {
                    updatefields.Add(xpath);
                }
            }

            foreach (var f in updatefields)
            {
                var datatype = info.GetXmlProperty(f + "/@datatype");
                if (datatype == "date")
                {
                    DataRecord.SetXmlProperty(f, info.GetXmlProperty(f), TypeCode.DateTime);
                }
                else if (datatype == "double")
                {
                    DataRecord.SetXmlPropertyDouble(f, info.GetXmlProperty(f));
                }
                else if (datatype == "html")
                {
                    DataRecord.SetXmlProperty(f, info.GetXmlPropertyRaw(f));
                }
                else
                {
                    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);
            }
        }
Exemple #35
0
        public NBrightInfo GetExtraInfo()
        {
            var rtnInfo = new NBrightInfo(true);
            rtnInfo.PortalId = PortalId;
            var xmlNode = PurchaseInfo.XMLDoc.SelectSingleNode("genxml/extrainfo");
            if (xmlNode != null) rtnInfo.XMLData = xmlNode.InnerXml;

            var nodList = PurchaseInfo.XMLDoc.SelectNodes("genxml/*");
            if (nodList != null)
                foreach (XmlNode nod in nodList)
                {
                    if (nod.FirstChild != null && nod.FirstChild.Name != "genxml") rtnInfo.SetXmlProperty("genxml/" + nod.Name, nod.InnerText);
                }

            return rtnInfo;
        }
        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;
        }
Exemple #37
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;
        }
 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;
 }
Exemple #39
0
        public void UpdateOptions(String xmlAjaxData)
        {
            var objList = NBrightBuyUtils.GetGenXmlListByAjax(xmlAjaxData, "");

            // build xml for data records
            var strXml = "<genxml><options>";
            var strXmlLang = "<genxml><options>";
            foreach (var objDataInfo in objList)
            {
                var objInfo = new NBrightInfo(true);
                var objInfoLang = new NBrightInfo(true);

                var localfields = objDataInfo.GetXmlProperty("genxml/hidden/localizedfields").Split(',');
                foreach (var f in localfields.Where(f => f != ""))
                {
                    var datatype = objDataInfo.GetXmlProperty(f + "/@datatype");
                    if (datatype == "date")
                        objInfoLang.SetXmlProperty(f, objDataInfo.GetXmlProperty(f), TypeCode.DateTime);
                    else if (datatype == "double")
                        objInfoLang.SetXmlProperty(f, objDataInfo.GetXmlProperty(f), TypeCode.Double);
                    else
                        objInfoLang.SetXmlProperty(f, objDataInfo.GetXmlProperty(f));
                }
                strXmlLang += objInfoLang.XMLData;

                var fields = objDataInfo.GetXmlProperty("genxml/hidden/fields").Split(',');
                foreach (var f in fields.Where(f => f != ""))
                {
                    var datatype = objDataInfo.GetXmlProperty(f + "/@datatype");
                    if (datatype == "date")
                        objInfo.SetXmlProperty(f, objDataInfo.GetXmlProperty(f), TypeCode.DateTime);
                    else if (datatype == "double")
                        objInfo.SetXmlProperty(f, objDataInfo.GetXmlProperty(f), TypeCode.Double);
                    else
                        objInfo.SetXmlProperty(f, objDataInfo.GetXmlProperty(f));
                }
                strXml += objInfo.XMLData;
            }
            strXml += "</options></genxml>";
            strXmlLang += "</options></genxml>";

            // replace models xml
            DataRecord.ReplaceXmlNode(strXml, "genxml/options", "genxml");
            DataLangRecord.ReplaceXmlNode(strXmlLang, "genxml/options", "genxml");
        }
Exemple #40
0
        public void UpdateImages(List<NBrightInfo> imgList)
        {
            // build xml for data records
            var strXml = "<genxml><imgs>";
            var strXmlLang = "<genxml><imgs>";
            foreach (var imgInfo in imgList)
            {
                var objInfo = new NBrightInfo(true);
                var objInfoLang = new NBrightInfo(true);

                var localfields = imgInfo.GetXmlProperty("genxml/hidden/localizedfields").Split(',');
                foreach (var f in localfields.Where(f => f != ""))
                {
                    objInfoLang.SetXmlProperty(f, imgInfo.GetXmlProperty(f));
                }
                strXmlLang += objInfoLang.XMLData;

                var fields = imgInfo.GetXmlProperty("genxml/hidden/fields").Split(',');
                foreach (var f in fields.Where(f => f != ""))
                {
                    objInfo.SetXmlProperty(f, imgInfo.GetXmlProperty(f));
                }
                strXml += objInfo.XMLData;
            }
            strXml += "</imgs></genxml>";
            strXmlLang += "</imgs></genxml>";

            // replace models xml
            DataRecord.ReplaceXmlNode(strXml, "genxml/imgs", "genxml");
            DataLangRecord.ReplaceXmlNode(strXmlLang, "genxml/imgs", "genxml");
        }
Exemple #41
0
        public void UpdateDocs(List<NBrightInfo> docList)
        {
            // build xml for data records
            var strXml = "<genxml><docs>";
            var strXmlLang = "<genxml><docs>";
            foreach (var docInfo in docList)
            {
                var objInfo = new NBrightInfo(true);
                var objInfoLang = new NBrightInfo(true);

                var localfields = docInfo.GetXmlProperty("genxml/hidden/localizedfields").Split(',');
                foreach (var f in localfields.Where(f => f != ""))
                {
                    objInfoLang.SetXmlProperty(f, docInfo.GetXmlProperty(f));
                }
                strXmlLang += objInfoLang.XMLData;

                var fields = docInfo.GetXmlProperty("genxml/hidden/fields").Split(',');
                foreach (var f in fields.Where(f => f != ""))
                {
                    objInfo.SetXmlProperty(f, docInfo.GetXmlProperty(f));
                    if (f == "genxml/hidden/filepath")
                    {
                        // save relitive path also
                        var fname = Path.GetFileName(docInfo.GetXmlProperty(f));
                        objInfo.SetXmlProperty("genxml/hidden/filename", fname);
                        objInfo.SetXmlProperty("genxml/hidden/filerelpath", StoreSettings.Current.FolderDocuments + "/" + fname);
                    }
                }
                strXml += objInfo.XMLData;
            }
            strXml += "</docs></genxml>";
            strXmlLang += "</docs></genxml>";

            // replace models xml
            DataRecord.ReplaceXmlNode(strXml, "genxml/docs", "genxml");
            DataLangRecord.ReplaceXmlNode(strXmlLang, "genxml/docs", "genxml");
        }
Exemple #42
0
 public List<NBrightInfo> GetOptionValuesById(String optionid)
 {
     var l = new List<NBrightInfo>();
     if (Info != null)
     {
         var xmlNodList = Info.XMLDoc.SelectNodes("genxml/optionvalues[@optionid='" + optionid + "']/*");
         if (xmlNodList != null && xmlNodList.Count > 0)
         {
             var lp = 1;
             foreach (XmlNode xNod in xmlNodList)
             {
                 var obj = new NBrightInfo();
                 obj.XMLData = xNod.OuterXml;
                 var nodLang = "<genxml>" + Info.GetXmlNode("genxml/lang/genxml/optionvalues[@optionid='" + optionid + "']/genxml[" + lp + "]") + "</genxml>";
                 if (nodLang != "")
                 {
                     obj.SetXmlProperty("genxml/hidden/productid", Info.ItemID.ToString(""));
                     obj.SetXmlProperty("genxml/hidden/lang", Info.Lang.Trim());
                     obj.SetXmlProperty("genxml/hidden/optionid", optionid);
                     var selectSingleNode = xNod.SelectSingleNode("hidden/optionvalueid");
                     if (selectSingleNode != null) obj.SetXmlProperty("genxml/hidden/optionvalueid", selectSingleNode.InnerText);
                     obj.AddSingleNode("lang", "", "genxml");
                     obj.AddXmlNode(nodLang, "genxml", "genxml/lang");
                 }
                 obj.ParentItemId = Info.ItemID;
                 l.Add(obj);
                 lp += 1;
             }
         }
     }
     return l;
 }
Exemple #43
0
 /// <summary>
 /// Get Current Cart Item List
 /// </summary>
 /// <returns></returns>
 public List<NBrightInfo> GetAddressList()
 {
     var rtnList = new List<NBrightInfo>();
     if (UserData.Exists)
     {
         var xmlNodeList = UserData.Info.XMLDoc.SelectNodes("genxml/address/*");
         if (xmlNodeList != null)
         {
             foreach (XmlNode carNod in xmlNodeList)
             {
                 var newInfo = new NBrightInfo {XMLData = carNod.OuterXml};
                 newInfo.SetXmlProperty("genxml/hidden/index", rtnList.Count.ToString(""));
                 rtnList.Add(newInfo);
             }
         }
     }
     return rtnList;
 }
Exemple #44
0
        private int AddNew()
        {
            var nbi = new NBrightInfo(true);
            if (StoreSettings.Current.Get("shareproducts") == "True") // option in storesetting to share products created here across all portals.
                _portalId = -1;
            else
                _portalId = PortalSettings.Current.PortalId;
            nbi.PortalId = _portalId;
            nbi.TypeCode = "CATEGORY";
            nbi.ModuleId = -1;
            nbi.ItemID = -1;
            nbi.SetXmlProperty("genxml/dropdownlist/ddlgrouptype", "cat");
            nbi.SetXmlProperty("genxml/checkbox/chkishidden", "True");
            nbi.SetXmlPropertyDouble("genxml/hidden/recordsortorder", 99999);
            var objCtrl = new NBrightBuyController();
            var itemId = objCtrl.Update(nbi);

            foreach (var lang in DnnUtils.GetCultureCodeList(_portalId))
            {
                nbi = new NBrightInfo(true);
                nbi.PortalId = _portalId;
                nbi.TypeCode = "CATEGORYLANG";
                nbi.ModuleId = -1;
                nbi.ItemID = -1;
                nbi.Lang = lang;
                nbi.ParentItemId = itemId;
                objCtrl.Update(nbi);
            }

            return itemId;
        }
Exemple #45
0
 private void PopulateData(String userId)
 {
     Exists = false;
     UserData = new UserData(userId);
     _addressList = GetAddressList();
     //if we have no address create a default one from DNN profile
     if (_addressList.Count == 0 && UserData.Exists)
     {
         var newDefault = new NBrightInfo(true);
         newDefault.SetXmlProperty("genxml/hidden/default", "True");
         newDefault.SetXmlProperty("genxml/hidden/index", _addressList.Count.ToString(""));
         var prop = DnnUtils.GetUserProfileProperties(UserData.Info.UserId.ToString(""));
         foreach (var p in prop)
         {
             newDefault.SetXmlProperty("genxml/textbox/" + p.Key.ToLower(), p.Value);
         }
         _addressList.Add(newDefault);
         Save();
     }
     else
     {
         UpdateDefaultProfileAddress(); //alway update default address to profile, to keep it in-line.
     }
 }
Exemple #46
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 "";
        }
Exemple #47
0
        private void PopulateClientData(int userId)
        {
            _clientInfo = new NBrightInfo(true);
            _clientInfo.ItemID = userId;
            _clientInfo.UserId = userId;
            _clientInfo.PortalId = PortalId;

            _userInfo = UserController.GetUserById(PortalId, userId);
            if (_userInfo != null)
            {
                Exists = true;

                _clientInfo.ModifiedDate = _userInfo.Membership.CreatedDate;

                foreach (var propertyInfo in _userInfo.GetType().GetProperties())
                {
                    if (propertyInfo.CanRead)
                    {
                        var pv = propertyInfo.GetValue(_userInfo, null);
                        if (pv == null) pv = "";
                        _clientInfo.SetXmlProperty("genxml/textbox/" + propertyInfo.Name.ToLower(), pv.ToString());
                    }
                }

                foreach (DotNetNuke.Entities.Profile.ProfilePropertyDefinition p in _userInfo.Profile.ProfileProperties)
                {
                    _clientInfo.SetXmlProperty("genxml/textbox/" + p.PropertyName.ToLower(), p.PropertyValue);
                }

                _clientInfo.AddSingleNode("membership", "", "genxml");
                foreach (var propertyInfo in _userInfo.Membership.GetType().GetProperties())
                {
                    if (propertyInfo.CanRead)
                    {
                        var pv = propertyInfo.GetValue(_userInfo.Membership, null);
                        if (pv != null) _clientInfo.SetXmlProperty("genxml/membership/" + propertyInfo.Name.ToLower(), pv.ToString());
                    }
                }

                if (_userInfo.IsInRole(StoreSettings.ClientEditorRole))
                {
                    _clientInfo.SetXmlProperty("genxml/checkbox/clienteditorrole", "True");
                }
                else
                {
                    _clientInfo.SetXmlProperty("genxml/checkbox/clienteditorrole", "False");
                }

                var objCtrl = new NBrightBuyController();
                DataRecord = objCtrl.GetByType(PortalId, -1, "CLIENT", _userInfo.UserID.ToString(""));
                if (DataRecord == null)
                {
                    DataRecord = new NBrightInfo(true);
                    DataRecord.ItemID = -1;
                    DataRecord.UserId = _userInfo.UserID;
                    DataRecord.PortalId = PortalId;
                    DataRecord.ModuleId = -1;
                    DataRecord.TypeCode = "CLIENT";
                }
                DiscountCodes = GetEntityList("discountcodes");
                VoucherCodes = GetEntityList("vouchercodes");

            }
        }
Exemple #48
0
        private string RunReport(HttpContext context)
        {
            var strOut = "- No Data Returned -";
            var strSql = "";

            try
            {
                var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);
                //var itemid = ajaxInfo.GetXmlPropertyInt("genxml/hidden/itemid");
                var razortemplate = ajaxInfo.GetXmlProperty("genxml/hidden/razortemplate");
                var portalid      = PortalSettings.Current.PortalId.ToString("");

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

                if (selecteditemid > 0)
                {
                    var objCtrl = new NBrightBuyController();
                    var obj     = objCtrl.Get(selecteditemid);
                    if (obj != null)
                    {
                        var inline = obj.GetXmlPropertyBool("genxml/checkbox/inline");
                        strSql = obj.GetXmlProperty("genxml/textbox/sql");
                        // replace any settings tokens (This is used to place the form data into the SQL)
                        strSql = Utils.ReplaceSettingTokens(strSql, ajaxInfo.ToDictionary());
                        strSql = Utils.ReplaceUrlTokens((strSql));

                        strSql = GenXmlFunctions.StripSqlCommands(strSql); // don't allow anything to update through here.

                        // add FOR XML if not there, this function will only output XML results.
                        if (!strSql.ToLower().Contains("for xml"))
                        {
                            strSql += " FOR XML PATH ('item'), ROOT ('root')";
                        }

                        var strXmlResults = objCtrl.GetSqlxml(strSql);
                        if (strXmlResults != "")
                        {
                            var xdoc       = XDocument.Parse(strXmlResults);
                            var headerInfo = new NBrightInfo(false);
                            headerInfo.XMLData = "<item></item>";
                            var elementsList = xdoc.XPathSelectElements("root/item[1]/*");
                            var xmlList      = new List <NBrightInfo>();

                            if (obj.GetXmlProperty("genxml/radiobuttonlist/reportformat") == "csv")
                            {
                                var lp = 1;
                                foreach (XElement xmlitem in elementsList)
                                {
                                    headerInfo.SetXmlProperty("item/header" + lp, xmlitem.Name.ToString());
                                    lp += 1;
                                }
                                xmlList.Add(headerInfo);
                            }

                            foreach (XElement xmlitem in xdoc.XPathSelectElements("root/item"))
                            {
                                var nbi = new NBrightInfo(false);
                                nbi.XMLData = xmlitem.ToString();
                                xmlList.Add(nbi);
                            }

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

                            if (obj.GetXmlProperty("genxml/radiobuttonlist/reportformat") == "html")
                            {
                                if (inline)
                                {
                                    razortemplate = "reporthtmlinline.cshtml";
                                }
                                else
                                {
                                    razortemplate = "reporthtml.cshtml";
                                }
                            }
                            if (obj.GetXmlProperty("genxml/radiobuttonlist/reportformat") == "csv")
                            {
                                inline        = false;
                                razortemplate = "reportcsv.cshtml";
                            }
                            //project
                            if (obj.GetXmlProperty("genxml/radiobuttonlist/reportformat") == "barchart")
                            {
                                inline        = true;
                                razortemplate = "reportbar.cshtml";
                            }

                            strOut = NBrightBuyUtils.RazorTemplRenderList(razortemplate, -1, "", xmlList, templateControl, "config", editlang, StoreSettings.Current.Settings());

                            if (!inline)
                            {
                                var outfile = StoreSettings.Current.FolderTempMapPath + "\\" + selecteditemid + "." + obj.GetXmlProperty("genxml/radiobuttonlist/reportformat");
                                Utils.SaveFile(outfile, strOut);
                                strOut = "<br/><h1>Completed: <a target='_blank' href='" + StoreSettings.Current.FolderTemp + "/" + selecteditemid + "."
                                         + obj.GetXmlProperty("genxml/radiobuttonlist/reportformat") + "?key=" + Utils.GetUniqueKey() + "' >View</a></h1>";
                            }
                        }
                        return(strOut);
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.ToString() + " <hr/> " + strSql);
            }
            return(strOut);
        }
        public override NBrightInfo UpdatePercentUsage(int portalId, int userId, NBrightInfo purchaseInfo)
        {
            var discountcode = purchaseInfo.GetXmlProperty("genxml/extrainfo/genxml/textbox/promocode");
            if (!purchaseInfo.GetXmlPropertyBool("genxml/discountprocessed"))
            {
                if (userId > 0)
                {
                    if (discountcode == "") return purchaseInfo;
                    var clientData = new ClientData(portalId, userId);
                    if (clientData.DiscountCodes.Count > 0)
                    {
                        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");
                    }
                }

                var objCtrl = new NBrightBuyController();
                var dis = objCtrl.GetByGuidKey(portalId, -1, "DISCOUNTCODE", discountcode);
                if (dis != null)
                {
                    var usage = dis.GetXmlPropertyDouble("genxml/textbox/usage");
                    dis.SetXmlPropertyDouble("genxml/textbox/usage", (usage + 1));
                    objCtrl.Update(dis);
                    purchaseInfo.SetXmlProperty("genxml/discountprocessed", "True");
                }
            }

            return purchaseInfo;
        }
 public static NBrightInfo ModuleSettingsSaveCatRefFromId(NBrightInfo objInfo)
 {
     var catid = objInfo.GetXmlPropertyInt("genxml/dropdownlist/defaultcatid");
     var catData = CategoryUtils.GetCategoryData(catid, Utils.GetCurrentCulture());
     if (catData.Exists) objInfo.SetXmlProperty("genxml/catref", catData.CategoryRef);
     return objInfo;
 }
Exemple #51
0
        public void UpdateOptionValues(String xmlAjaxData)
        {
            var objList = NBrightBuyUtils.GetGenXmlListByAjax(xmlAjaxData, "");
            if (objList != null)
            {
                if (objList.Count == 0)
                {
                    // no optionvalues, so remove all
                    var nodList = DataRecord.XMLDoc.SelectNodes("genxml/optionvalues");
                    if (nodList != null)
                        for (int i = nodList.Count - 1; i >= 0; i--)
                        {
                            var parentNode = nodList[i].ParentNode;
                            if (parentNode != null) parentNode.RemoveChild(nodList[i]);
                        }
                    nodList = DataLangRecord.XMLDoc.SelectNodes("genxml/optionvalues");
                    if (nodList != null)
                        for (int i = nodList.Count - 1; i >= 0; i--)
                        {
                            var parentNode = nodList[i].ParentNode;
                            if (parentNode != null) parentNode.RemoveChild(nodList[i]);
                        }
                }
                else
                {

                    // get a list of optionid that need to be processed
                    var distinctOptionIds = new Dictionary<String, String>();
                    foreach (var o in objList)
                    {
                        if (!distinctOptionIds.ContainsKey(o.GetXmlProperty("genxml/hidden/optionid")))
                            distinctOptionIds.Add(o.GetXmlProperty("genxml/hidden/optionid"),
                                o.GetXmlProperty("genxml/hidden/optionid"));
                    }

                    foreach (var optid in distinctOptionIds.Keys)
                    {
                        // build xml for data records
                        var strXml = "<genxml><optionvalues optionid='" + optid + "'>";
                        var strXmlLang = "<genxml><optionvalues optionid='" + optid + "'>";
                        foreach (var objDataInfo in objList)
                        {
                            if (objDataInfo.GetXmlProperty("genxml/hidden/optionid") == optid)
                            {
                                var objInfo = new NBrightInfo(true);
                                var objInfoLang = new NBrightInfo(true);

                                var localfields = objDataInfo.GetXmlProperty("genxml/hidden/localizedfields").Split(',');
                                foreach (var f in localfields.Where(f => f != ""))
                                {
                                    objInfoLang.SetXmlProperty(f, objDataInfo.GetXmlProperty(f));
                                }
                                strXmlLang += objInfoLang.XMLData;

                                var fields = objDataInfo.GetXmlProperty("genxml/hidden/fields").Split(',');
                                foreach (var f in fields.Where(f => f != ""))
                                {
                                    objInfo.SetXmlProperty(f, objDataInfo.GetXmlProperty(f));
                                }
                                strXml += objInfo.XMLData;
                            }
                        }
                        strXml += "</optionvalues></genxml>";
                        strXmlLang += "</optionvalues></genxml>";

                        // replace  xml
                        DataRecord.ReplaceXmlNode(strXml, "genxml/optionvalues[@optionid='" + optid + "']", "genxml");
                        DataLangRecord.ReplaceXmlNode(strXmlLang, "genxml/optionvalues[@optionid='" + optid + "']",
                            "genxml");
                    }

                    // tidy up any invlid option values (usually created in a migration phase)
                    var nodList = DataRecord.XMLDoc.SelectNodes("genxml/options/genxml");
                    var optionids = new Dictionary<String, String>();
                    if (nodList != null)
                        foreach (XmlNode nod in nodList)
                        {
                            var selectSingleNode = nod.SelectSingleNode("hidden/optionid");
                            if (selectSingleNode != null)
                                optionids.Add(selectSingleNode.InnerText, selectSingleNode.InnerText);
                        }
                    nodList = DataRecord.XMLDoc.SelectNodes("genxml/optionvalues");
                    if (nodList != null)
                        foreach (XmlNode nod in nodList)
                        {
                            if (nod.Attributes != null && nod.Attributes["optionid"] != null)
                            {
                                if (!optionids.ContainsKey(nod.Attributes["optionid"].InnerText))
                                {
                                    DataRecord.RemoveXmlNode("genxml/optionvalues[@optionid='" +
                                                             nod.Attributes["optionid"].InnerText + "']");
                                    DataLangRecord.RemoveXmlNode("genxml/optionvalues[@optionid='" +
                                                                 nod.Attributes["optionid"].InnerText + "']");
                                }
                            }
                        }
                }
            }
        }
Exemple #52
0
        public static string CalcGroupPromoItem(NBrightInfo p)
        {
            var objCtrl = new NBrightBuyController();
                var typeselect = p.GetXmlProperty("genxml/radiobuttonlist/typeselect");
                var catgroupid = p.GetXmlProperty("genxml/dropdownlist/catgroupid");
                var propgroupid = p.GetXmlProperty("genxml/dropdownlist/propgroupid");
                var promoname = p.GetXmlProperty("genxml/textbox/name");
                var amounttype = p.GetXmlProperty("genxml/radiobuttonlist/amounttype");
                var amount = p.GetXmlPropertyDouble("genxml/textbox/amount");
                var validfrom = p.GetXmlProperty("genxml/textbox/validfrom");
                var validuntil = p.GetXmlProperty("genxml/textbox/validuntil");
                var overwrite = p.GetXmlPropertyBool("genxml/checkbox/overwrite");
                var disabled = p.GetXmlPropertyBool("genxml/checkbox/disabled");
                var lastcalculated = p.GetXmlProperty("genxml/hidden/lastcalculated");

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

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

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

                        p.SetXmlProperty("genxml/hidden/lastcalculated", DateTime.Now.AddSeconds(10).ToString("O")); // Add 10 sec to time so we don't get exact clash with update time.
                        objCtrl.Update(p);
                    }
                }
            return "OK";
        }
 public static NBrightInfo ModuleSettingsResetCatIdFromRef(NBrightInfo objInfo)
 {
     var ModCtrl = new NBrightBuyController();
     var catid = objInfo.GetXmlPropertyInt("genxml/dropdownlist/defaultcatid");
     var nbi = ModCtrl.Get(catid);
     if (nbi == null)
     {
         // categoryid no longer exists, see if we can get it back with the catref (might be lost due to cleardown and import)
         var catref = objInfo.GetXmlProperty("genxml/catref");
         nbi = ModCtrl.GetByGuidKey(objInfo.PortalId, -1, "CATEGORY", catref);
         if (nbi != null)
         {
             objInfo.SetXmlProperty("genxml/dropdownlist/defaultcatid", nbi.ItemID.ToString(""));
         }
     }
     return objInfo;
 }
        private String AddNew(String moduleid,String typeCode)
        {
            if (!Utils.IsNumeric(moduleid)) moduleid = "-2"; // -2 for razor

            var objCtrl = new NBrightBuyController();
            var nbi = new NBrightInfo(true);
            nbi.PortalId = PortalSettings.Current.PortalId;
            nbi.TypeCode = typeCode;
            nbi.ModuleId = Convert.ToInt32(moduleid);
            nbi.ItemID = -1;
            nbi.SetXmlProperty("genxml/textbox/code", Utils.GetUniqueKey().ToUpper());
            nbi.GUIDKey = nbi.GetXmlProperty("genxml/textbox/code");
            var itemId = objCtrl.Update(nbi);
            nbi.ItemID = itemId;

            foreach (var lang in DnnUtils.GetCultureCodeList(PortalSettings.Current.PortalId))
            {
                var nbi2 = new NBrightInfo(true);
                nbi2.PortalId = PortalSettings.Current.PortalId;
                nbi2.TypeCode = typeCode + "LANG";
                nbi2.ModuleId = Convert.ToInt32(moduleid);
                nbi2.ItemID = -1;
                nbi2.Lang = lang;
                nbi2.ParentItemId = itemId;
                nbi2.GUIDKey = "";
                nbi2.ItemID = objCtrl.Update(nbi2);
            }

            NBrightBuyUtils.RemoveModCache(nbi.ModuleId);

            return nbi.ItemID.ToString("");
        }
Exemple #55
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;
        }
Exemple #56
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;
        }
Exemple #57
0
 public NBrightInfo GetPluginByCtrl(String ctrlname)
 {
     var p = new NBrightInfo(true);
     p.SetXmlProperty("genxml/checkbox/hidden", "True");
     var nod = Info.XMLDoc.SelectSingleNode("genxml/plugin/*[./textbox/ctrl='"+ ctrlname + "']");
     if (nod != null) p.XMLData = nod.OuterXml;
     return p;
 }
Exemple #58
0
        private int AddNew()
        {
            var nbi = new NBrightInfo(true);
            if (StoreSettings.Current.Get("shareproducts") == "True") // option in storesetting to share products created here across all portals.
                _portalId = -1;
            else
                _portalId = PortalSettings.Current.PortalId;
            nbi.PortalId = _portalId;
            nbi.TypeCode = "PRD";
            nbi.ModuleId = -1;
            nbi.ItemID = -1;
            nbi.SetXmlProperty("genxml/checkbox/chkishidden", "True");
            nbi.AddSingleNode("models", "<genxml><hidden><modelid>" + Utils.GetUniqueKey() + "</modelid></hidden></genxml>", "genxml");
            var objCtrl = new NBrightBuyController();
            var itemId = objCtrl.Update(nbi);

            foreach (var lang in DnnUtils.GetCultureCodeList(_portalId))
            {
                nbi = new NBrightInfo(true);
                nbi.PortalId = _portalId;
                nbi.TypeCode = "PRDLANG";
                nbi.ModuleId = -1;
                nbi.ItemID = -1;
                nbi.Lang = lang;
                nbi.ParentItemId = itemId;
                objCtrl.Update(nbi);
            }

            return itemId;
        }
Exemple #59
0
        private void SystemConfigMerge(NBrightInfo info)
        {
            var sysList = new Dictionary<String, NBrightInfo>();
            var addList = new Dictionary<String, 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 = sysList.Count;
                    newInfo.SetXmlProperty("genxml/hidden/index", sysList.Count.ToString(""));
                    newInfo.GUIDKey = newInfo.GetXmlProperty("genxml/textbox/ctrl");
                    sysList.Add(newInfo.GUIDKey, newInfo);
                    addList.Add(newInfo.GUIDKey, newInfo);
                }

                var newpluginList  = new List<NBrightInfo>();
                foreach (var pluginInfo in _pluginList)
                {
                    if (sysList.ContainsKey(pluginInfo.GUIDKey))
                    {
                        newpluginList.Add(sysList[pluginInfo.GUIDKey]);
                        addList.Remove(pluginInfo.GUIDKey);
                    }
                    else
                    {
                        newpluginList.Add(pluginInfo);
                    }
                }
                foreach (var newplugin in addList)
                {
                    newpluginList.Add(addList[newplugin.Key]);
                }

                _pluginList = newpluginList;
            }
        }