public static String GetCatIdFromName(String catname) { var catid = "0"; if (catname != "") { var objCtrl = new NBrightBuyController(); var objCat = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "CATEGORYLANG", catname); if (objCat == null) { // check it's not just a single language objCat = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "CATEGORY", catname); if (objCat != null) { catid = objCat.ItemID.ToString(""); } } else { catid = objCat.ParentItemId.ToString(""); } } return(catid); }
/// <summary> /// /// </summary> /// <param name="portalfinfo"></param> /// <returns></returns> public override string DoWork() { try { var objCtrl = new NBrightBuyController(); // the sceduler runs at host level, we therefore need to loop through ALL portals to process data at a portal level. var portalList = NBrightDNN.DnnUtils.GetAllPortals(); foreach (var portal in portalList) { // check if we have NBS in this portal by looking for default settings. var nbssetting = objCtrl.GetByGuidKey(portal.PortalID, -1, "SETTINGS", "NBrightBuySettings"); if (nbssetting != null) { var storeSettings = new StoreSettings(portal.PortalID); var pluginData = new PluginData(portal.PortalID); // get plugin data to see if this scheduler is active on this portal var plugin = pluginData.GetPluginByCtrl("dnnsearchindex"); if (plugin != null && plugin.GetXmlPropertyBool("genxml/checkbox/active")) { // The NBS scheduler is normally set to run hourly, therefore if we only want a process to run daily we need the logic this function. // To to this we keep a last run flag on the sceduler settings var setting = objCtrl.GetByGuidKey(portal.PortalID, -1, "DNNIDXSCHEDULER", "DNNIDXSCHEDULER"); if (setting == null) { setting = new NBrightInfo(true); setting.ItemID = -1; setting.PortalId = portal.PortalID; setting.TypeCode = "DNNIDXSCHEDULER"; setting.GUIDKey = "DNNIDXSCHEDULER"; setting.ModuleId = -1; setting.XMLData = "<genxml></genxml>"; } var lastrun = setting.GetXmlPropertyRaw("genxml/lastrun"); var lastrundate = DateTime.Now.AddYears(-99); if (Utils.IsDate(lastrun)) lastrundate = Convert.ToDateTime(lastrun); var rtnmsg = DoProductIdx(portal, lastrundate, storeSettings.DebugMode); setting.SetXmlProperty("genxml/lastrun", DateTime.Now.ToString("s"), TypeCode.DateTime); objCtrl.Update(setting); if (rtnmsg != "") return rtnmsg; } } } return " - NBS-DNNIDX scheduler OK "; } catch (Exception ex) { return " - NBS-DNNIDX scheduler FAIL: " + ex.ToString() + " : "; } }
public GroupCategoryData GetCategoryByRef(int portalId, String catref) { // the catref might not be in the CategoryList because the language has changed but the url is still displaying the old catref langauge // try and find it. NASTY!!!! incorrect langyage url left after langauge change!! var catLang = _objCtrl.GetByGuidKey(portalId, -1, "CATEGORYLANG", catref); if (catLang != null) { return(GetCategory(catLang.ParentItemId)); } return(null); }
public static void CopySystemPluginsToPortal() { var objCtrl = new NBrightBuyController(); var rtnList = objCtrl.GetList(99999, -1, "PLUGIN", "", "order by nb1.xmldata.value('(genxml/hidden/index)[1]','float')"); foreach (var p in rtnList) { var existingrecord = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "PLUGIN", p.GUIDKey); if (existingrecord == null) { var filepath = HttpContext.Current.Server.MapPath(p.GetXmlProperty("genxml/textbox/path")); if (File.Exists(filepath)) { p.ItemID = -1; p.PortalId = PortalSettings.Current.PortalId; objCtrl.Update(p); } else { objCtrl.Delete(p.ItemID); } } } PluginUtils.ResequenceRecords(); }
public static string GetUniqueGuidKey(int portalId, int categoryId, string newGUIDKey) { // make sure we have a unique guidkey var objCtrl = new NBrightBuyController(); var doloop = true; var lp = 1; var testGUIDKey = newGUIDKey.ToLower(); while (doloop) { var obj = objCtrl.GetByGuidKey(portalId, -1, "CATEGORY", testGUIDKey); if (obj != null && obj.ItemID != categoryId) { testGUIDKey = newGUIDKey + lp; } else { doloop = false; } lp += 1; if (lp > 999) { doloop = false; // make sure we never get a infinate loop } } return(testGUIDKey); }
/// <summary> /// Get CartID from cookie or session /// </summary> /// <returns></returns> private int GetCartId(String cartId = "") { if (!Utils.IsNumeric(cartId)) { NBrightInfo nbi = null; var userid = UserController.Instance.GetCurrentUserInfo().UserID; if (userid > 0) { // get any cart linked to a user. var modCtrl = new NBrightBuyController(); nbi = modCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "CART", userid.ToString(""), userid.ToString(""), true); if (nbi != null) { cartId = nbi.ItemID.ToString(""); } } if (nbi == null) { _cookie = HttpContext.Current.Request.Cookies[_cookieName]; if (_cookie == null) { _cookie = new HttpCookie(_cookieName); _cookie.SameSite = SameSiteMode.Lax; } else { if (_cookie["cartId"] != null) { cartId = _cookie["cartId"]; } } } if (!Utils.IsNumeric(cartId)) { cartId = "-1"; } } else { _cartId = Convert.ToInt32(cartId); } //populate cart data var rtnid = PopulatePurchaseData(Convert.ToInt32(cartId)); if (PurchaseTypeCode == "CART") { return(rtnid); } // this class has only rights to edit CART items, so reset cartid to new cart Item. PurchaseTypeCode = "CART"; var rtnId = PopulatePurchaseData(-1); SaveCartId(); //created from order, so save cartid for client. return(rtnId); }
public static String GetCatIdFromName(String catname) { var catid = ""; if (catname != "") { var objCtrl = new NBrightBuyController(); var objCat = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "CATEGORYLANG", catname); if (objCat == null) { // check it's not just a single language objCat = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "CATEGORY", catname); if (objCat != null) catid = objCat.ItemID.ToString(""); } else { catid = objCat.ParentItemId.ToString(""); } } return catid; }
public static void CopySystemPluginsToPortal() { var objCtrl = new NBrightBuyController(); var rtnList = objCtrl.GetList(99999, -1, "PLUGIN", "", "order by nb1.xmldata.value('(genxml/hidden/index)[1]','float')"); foreach (var p in rtnList) { var existingrecord = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "PLUGIN", p.GUIDKey); if (existingrecord == null) { p.ItemID = -1; p.PortalId = PortalSettings.Current.PortalId; objCtrl.Update(p); } } PluginUtils.ResequenceRecords(); }
public NBrightInfo GetPluginSinglePageData(string GuidKey, string typeCode, string lang, int portalid) { DataCache.ClearCache(); // clear ALL cache. var objCtrl = new NBrightBuyController(); var info = objCtrl.GetByGuidKey(portalid, -1, typeCode, GuidKey); if (info == null) { // create record if not in DB info = new NBrightInfo(true); info.GUIDKey = GuidKey; info.TypeCode = typeCode; info.ModuleId = -1; info.PortalId = portalid; info.ItemID = objCtrl.Update(info); } var nbilang = objCtrl.GetDataLang(info.ItemID, lang); if (nbilang == null) { // create lang records if not in DB foreach (var lg in DnnUtils.GetCultureCodeList(portalid)) { nbilang = objCtrl.GetDataLang(info.ItemID, lg); if (nbilang == null) { nbilang = new NBrightInfo(true); nbilang.GUIDKey = ""; nbilang.TypeCode = typeCode + "LANG"; nbilang.ParentItemId = info.ItemID; nbilang.Lang = lg; nbilang.ModuleId = -1; nbilang.PortalId = portalid; nbilang.ItemID = objCtrl.Update(nbilang); } } } // do edit field data if a itemid has been selected var nbi = objCtrl.Get(info.ItemID, typeCode + "LANG", lang); return(nbi); }
private static void CreateDBrecords(List <NBrightInfo> pluginList, int portalId) { var objCtrl = new NBrightBuyController(); foreach (var p in pluginList) { p.ItemID = -1; p.GUIDKey = p.GetXmlProperty("genxml/textbox/ctrl"); p.PortalId = portalId; p.Lang = ""; p.ParentItemId = 0; p.ModuleId = -1; p.XrefItemId = 0; p.UserId = 0; p.TypeCode = "PLUGIN"; p.SetXmlProperty("genxml/hidden/index", p.GetXmlPropertyDouble("genxml/hidden/index").ToString("00.0"), TypeCode.Double); var interfaces = p.XMLDoc.SelectNodes("genxml/interfaces/*"); if (interfaces.Count == 0) { // possible legacy format, change. p.SetXmlProperty("genxml/interfaces", ""); p.SetXmlProperty("genxml/interfaces/genxml", ""); p.SetXmlProperty("genxml/interfaces/genxml/dropdownlist", ""); p.SetXmlProperty("genxml/interfaces/genxml/checkbox", ""); p.SetXmlProperty("genxml/interfaces/genxml/textbox", ""); p.SetXmlProperty("genxml/interfaces/genxml/dropdownlist/providertype", p.GetXmlProperty("genxml/dropdownlist/providertype")); p.SetXmlProperty("genxml/interfaces/genxml/checkbox/active", p.GetXmlProperty("genxml/checkbox/active")); p.SetXmlProperty("genxml/interfaces/genxml/textbox/namespaceclass", p.GetXmlProperty("genxml/textbox/namespaceclass")); p.SetXmlProperty("genxml/interfaces/genxml/textbox/assembly", p.GetXmlProperty("genxml/textbox/assembly")); } // check if record exists (should NOT) but lets replace if it does. var existingrecord = objCtrl.GetByGuidKey(portalId, -1, "PLUGIN", p.GUIDKey); if (existingrecord != null) { p.ItemID = existingrecord.ItemID; } objCtrl.Update(p); } }
public static string GetUniqueGuidKey(int portalId, int categoryId, string newGUIDKey) { // make sure we have a unique guidkey var objCtrl = new NBrightBuyController(); var doloop = true; var lp = 1; var testGUIDKey = newGUIDKey.ToLower(); while (doloop) { var obj = objCtrl.GetByGuidKey(portalId, -1, "CATEGORY", testGUIDKey); if (obj != null && obj.ItemID != categoryId) { testGUIDKey = newGUIDKey + lp; } else doloop = false; lp += 1; if (lp > 999) doloop = false; // make sure we never get a infinate loop } return testGUIDKey; }
public static NBrightInfo GetProviderSettings(String ctrlkey) { var info = (NBrightInfo)Utils.GetCache("NBrightPayPalPaymentProvider" + PortalSettings.Current.PortalId.ToString("")); if (info == null) { var modCtrl = new NBrightBuyController(); info = modCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "NBrightPayPalPAYMENT", ctrlkey); if (info == null) { info = new NBrightInfo(true); info.GUIDKey = ctrlkey; info.TypeCode = "NBrightPayPalPAYMENT"; info.ModuleId = -1; info.PortalId = PortalSettings.Current.PortalId; } Utils.SetCache("NBrightPayPalPaymentProvider" + PortalSettings.Current.PortalId.ToString(""), info); } return info; }
public StoreSettings(int portalId) { DebugMode = false; DebugModeFileOut = false; _settingDic = new Dictionary <string, string>(); //Get NBrightBuy Portal Settings. var modCtrl = new NBrightBuyController(); SettingsInfo = modCtrl.GetByGuidKey(portalId, -1, "SETTINGS", "NBrightBuySettings"); if (SettingsInfo != null) { AddToSettingDic(SettingsInfo, "genxml/hidden/*"); AddToSettingDic(SettingsInfo, "genxml/textbox/*"); AddToSettingDic(SettingsInfo, "genxml/checkbox/*"); AddToSettingDic(SettingsInfo, "genxml/dropdownlist/*"); AddToSettingDic(SettingsInfo, "genxml/radiobuttonlist/*"); AddToSettingDicSelectedTextAttr(SettingsInfo, "genxml/dropdownlist/*"); AddToSettingDicSelectedTextAttr(SettingsInfo, "genxml/radiobuttonlist/*"); } //add DNN Portalsettings if (!_settingDic.ContainsKey("portalid")) { _settingDic.Add("portalid", portalId.ToString("")); } if (PortalSettings.Current == null) { var portalsettings = NBrightDNN.DnnUtils.GetPortalSettings(portalId); if (!_settingDic.ContainsKey("portalname")) { _settingDic.Add("portalname", portalsettings.PortalName); } if (!_settingDic.ContainsKey("homedirectory")) { _settingDic.Add("homedirectory", portalsettings.HomeDirectory); } if (!_settingDic.ContainsKey("homedirectorymappath")) { _settingDic.Add("homedirectorymappath", portalsettings.HomeDirectoryMapPath); } HomeDirectoryMapPath = portalsettings.HomeDirectoryMapPath; HomeDirectory = portalsettings.HomeDirectory; } else { if (!_settingDic.ContainsKey("portalname")) { _settingDic.Add("portalname", PortalSettings.Current.PortalName); } if (!_settingDic.ContainsKey("homedirectory")) { _settingDic.Add("homedirectory", PortalSettings.Current.HomeDirectory); } if (!_settingDic.ContainsKey("homedirectorymappath")) { _settingDic.Add("homedirectorymappath", PortalSettings.Current.HomeDirectoryMapPath); } HomeDirectoryMapPath = PortalSettings.Current.HomeDirectoryMapPath; HomeDirectory = PortalSettings.Current.HomeDirectory; } if (!_settingDic.ContainsKey("culturecode")) { _settingDic.Add("culturecode", Utils.GetCurrentCulture()); } ThemeFolder = Get("themefolder"); if (_settingDic.ContainsKey("debug.mode") && _settingDic["debug.mode"] == "True") { DebugMode = true; // set debug mmode } if (_settingDic.ContainsKey("debugfileout") && _settingDic["debugfileout"] == "True") { DebugModeFileOut = true; // set debug mmode } if (_settingDic.ContainsKey("enablefilelogging") && _settingDic["enablefilelogging"] == "True") { EnableFileLogging = true; // set File Logging } StorageTypeClient = DataStorageType.Cookie; SEOimages = false; if (_settingDic.ContainsKey("seoimages") && _settingDic["seoimages"] == "True") { SEOimages = true; // set debug mmode } AdminEmail = Get("adminemail"); ManagerEmail = Get("manageremail"); FolderDocumentsMapPath = Get("homedirectorymappath").TrimEnd('\\') + "\\" + Get("folderdocs"); FolderImagesMapPath = Get("homedirectorymappath").TrimEnd('\\') + "\\" + Get("folderimages"); FolderUploadsMapPath = Get("homedirectorymappath").TrimEnd('\\') + "\\" + Get("folderuploads"); FolderClientUploadsMapPath = Get("homedirectorymappath").TrimEnd('\\') + "\\" + Get("folderclientuploads"); FolderTempMapPath = Get("homedirectorymappath").TrimEnd('\\') + "\\NBSTemp"; FolderNBStoreMapPath = Get("homedirectorymappath").TrimEnd('\\') + "\\NBStore"; RootMapPath = Get("rootmappath"); FolderDocuments = Get("homedirectory").TrimEnd('/') + "/" + Get("folderdocs").Replace("\\", "/"); FolderImages = Get("homedirectory").TrimEnd('/') + "/" + Get("folderimages").Replace("\\", "/"); FolderUploads = Get("homedirectory").TrimEnd('/') + "/" + Get("folderuploads").Replace("\\", "/"); FolderClientUploads = Get("homedirectory").TrimEnd('/') + "/" + Get("folderclientuploads").Replace("\\", "/"); FolderTemp = Get("homedirectory").TrimEnd('/') + "/NBSTemp"; FolderNBStore = Get("homedirectory").TrimEnd('/') + "/NBStore"; if (!_settingDic.ContainsKey("FolderDocumentsMapPath")) { _settingDic.Add("FolderDocumentsMapPath", FolderDocumentsMapPath); } if (!_settingDic.ContainsKey("FolderImagesMapPath")) { _settingDic.Add("FolderImagesMapPath", FolderImagesMapPath); } if (!_settingDic.ContainsKey("FolderUploadsMapPath")) { _settingDic.Add("FolderUploadsMapPath", FolderUploadsMapPath); } if (!_settingDic.ContainsKey("FolderDocuments")) { _settingDic.Add("FolderDocuments", FolderDocuments); } if (!_settingDic.ContainsKey("FolderImages")) { _settingDic.Add("FolderImages", FolderImages); } if (!_settingDic.ContainsKey("FolderUploads")) { _settingDic.Add("FolderUploads", FolderUploads); } if (!_settingDic.ContainsKey("NBrightBuyPath")) { _settingDic.Add("NBrightBuyPath", NBrightBuyPath()); } DealerRole = Get("dealerrole"); if (DealerRole == "") { DealerRole = "Dealer"; } }
public override NBrightInfo CalculateVoucherAmount(int portalId, int userId, NBrightInfo cartInfo, string discountcode) { cartInfo.SetXmlPropertyDouble("genxml/discountstatus", ""); cartInfo.SetXmlPropertyDouble("genxml/voucherdiscount", "0"); // reset discount amount Double discountcodeamt = 0; if (userId > 0) { var clientData = new ClientData(portalId, userId); if (clientData.DiscountCodes.Count > 0) { var subtotal = cartInfo.GetXmlPropertyDouble("genxml/subtotal"); // do client voucher discount on total cart foreach (var d in clientData.VoucherCodes) { var validutil = d.GetXmlProperty("genxml/textbox/validuntil"); var validutildate = DateTime.Today; if (Utils.IsDate(validutil)) validutildate = Convert.ToDateTime(validutil); if (d.GetXmlProperty("genxml/textbox/coderef").ToLower() == discountcode.ToLower() && validutildate >= DateTime.Today) { var amount = d.GetXmlPropertyDouble("genxml/textbox/amount"); if (amount > 0) { if (subtotal >= amount) discountcodeamt = amount; else discountcodeamt = subtotal; cartInfo.SetXmlPropertyDouble("genxml/discountstatus", "valid"); } else { cartInfo.SetXmlPropertyDouble("genxml/discountstatus", "invalid"); } } if (discountcodeamt > 0) break; } } } if (discountcodeamt == 0) // if no client level, calc any portal level percentage discount { var objCtrl = new NBrightBuyController(); var d = objCtrl.GetByGuidKey(portalId, -1, "DISCOUNTCODE", discountcode); if (d != null) { var validutil = d.GetXmlProperty("genxml/textbox/validuntil"); var validutildate = DateTime.Today; if (Utils.IsDate(validutil)) validutildate = Convert.ToDateTime(validutil); if (validutildate >= DateTime.Today && d.GetXmlProperty("genxml/radiobuttonlist/amounttype") == "1") { var minamountlimit = d.GetXmlPropertyDouble("genxml/textbox/minamountlimit"); var amount = d.GetXmlPropertyDouble("genxml/textbox/amount"); var usage = d.GetXmlPropertyDouble("genxml/textbox/usage"); var usagelimit = d.GetXmlPropertyDouble("genxml/textbox/usagelimit"); var appliedsubtotal = cartInfo.GetXmlPropertyDouble("genxml/appliedsubtotal"); if (amount > 0 && (usagelimit == 0 || usagelimit > usage) && (appliedsubtotal >= minamountlimit)) { discountcodeamt = amount; cartInfo.SetXmlPropertyDouble("genxml/discountstatus", "valid"); } else { cartInfo.SetXmlPropertyDouble("genxml/discountstatus", "invalid"); } } } } cartInfo.SetXmlPropertyDouble("genxml/voucherdiscount", discountcodeamt); // reset discount amount return cartInfo; }
public void AddRelatedProduct(int productid) { if (productid!= Info.ItemID) //cannot be related to itself { var strGuid = productid.ToString("") + "x" + Info.ItemID.ToString(""); var objCtrl = new NBrightBuyController(); var nbi = objCtrl.GetByGuidKey(_portalId, -1, "PRDXREF", strGuid); if (nbi == null) { nbi = new NBrightInfo(); nbi.ItemID = -1; nbi.PortalId = _portalId; nbi.ModuleId = -1; nbi.TypeCode = "PRDXREF"; nbi.XrefItemId = productid; nbi.ParentItemId = Info.ItemID; nbi.XMLData = null; nbi.TextData = null; nbi.Lang = null; nbi.GUIDKey = strGuid; objCtrl.Update(nbi); } } }
public void AddProperty(String propertyref) { var objCtrl = new NBrightBuyController(); var pinfo = objCtrl.GetByGuidKey(_portalId, -1,"CATEGORY",propertyref); if (pinfo == null) { // not using the unique ref, look for the friendly propertyref name. var l = objCtrl.GetList(_portalId, -1, "CATEGORY", " and [XMLData].value('(genxml/textbox/propertyref)[1]','nvarchar(max)') = '" + propertyref + "' ", "", 1); if (l.Any()) pinfo = l[0]; } if (pinfo != null && Utils.IsNumeric(pinfo.ItemID) && pinfo.ItemID > 0) AddCategory(pinfo.ItemID); }
public void AddCategory(int categoryid) { if (Info != null) { var strGuid = categoryid.ToString("") + "x" + Info.ItemID.ToString(""); var objCtrl = new NBrightBuyController(); var nbi = objCtrl.GetByGuidKey(_portalId, -1, "CATXREF", strGuid); if (nbi == null) { nbi = new NBrightInfo(); nbi.ItemID = -1; nbi.PortalId = _portalId; nbi.ModuleId = -1; nbi.TypeCode = "CATXREF"; nbi.XrefItemId = categoryid; nbi.ParentItemId = Info.ItemID; nbi.XMLData = null; nbi.TextData = null; nbi.Lang = null; nbi.GUIDKey = strGuid; var newitemid = objCtrl.Update(nbi); nbi = objCtrl.Get(newitemid); nbi.XMLData = "<genxml><sort>" + newitemid.ToString() + "</sort></genxml>"; objCtrl.Update(nbi); //add all cascade xref var objGrpCtrl = new GrpCatController(_lang, true); var parentcats = objGrpCtrl.GetCategory(categoryid); if (parentcats != null) { foreach (var p in parentcats.Parents) { strGuid = p.ToString("") + "x" + Info.ItemID.ToString(""); var obj = objCtrl.GetByGuidKey(_portalId, -1, "CATCASCADE", strGuid); if (obj == null) { nbi = new NBrightInfo(); nbi.ItemID = -1; nbi.PortalId = _portalId; nbi.ModuleId = -1; nbi.XrefItemId = p; nbi.ParentItemId = Info.ItemID; nbi.TypeCode = "CATCASCADE"; nbi.GUIDKey = strGuid; newitemid = objCtrl.Update(nbi); nbi = objCtrl.Get(newitemid); nbi.XMLData = "<genxml><sort>" + newitemid.ToString() + "</sort></genxml>"; objCtrl.Update(nbi); } } } } } }
private void PopulateData(String key) { var modCtrl = new NBrightBuyController(); Info = modCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "PROMOCODES", key); if (Info == null) { Info = new NBrightInfo(true); Info.GUIDKey = key; Info.TypeCode = "PROMOCODES"; Info.ModuleId = -1; Info.PortalId = PortalSettings.Current.PortalId; } _discountcodesList = GetRuleList(); }
public StoreSettings(int portalId) { DebugMode = false; DebugModeFileOut = false; _settingDic = new Dictionary<string, string>(); //Get NBrightBuy Portal Settings. var modCtrl = new NBrightBuyController(); SettingsInfo = modCtrl.GetByGuidKey(portalId, -1, "SETTINGS", "NBrightBuySettings"); if (SettingsInfo != null) { AddToSettingDic(SettingsInfo, "genxml/hidden/*"); AddToSettingDic(SettingsInfo, "genxml/textbox/*"); AddToSettingDic(SettingsInfo, "genxml/checkbox/*"); AddToSettingDic(SettingsInfo, "genxml/dropdownlist/*"); AddToSettingDic(SettingsInfo, "genxml/radiobuttonlist/*"); AddToSettingDicSelectedTextAttr(SettingsInfo, "genxml/dropdownlist/*"); AddToSettingDicSelectedTextAttr(SettingsInfo, "genxml/radiobuttonlist/*"); } //add DNN Portalsettings if (!_settingDic.ContainsKey("portalid")) _settingDic.Add("portalid", portalId.ToString("")); if (PortalSettings.Current == null) { var portalsettings = NBrightDNN.DnnUtils.GetPortalSettings(portalId); if (!_settingDic.ContainsKey("portalname")) _settingDic.Add("portalname", portalsettings.PortalName); if (!_settingDic.ContainsKey("homedirectory")) _settingDic.Add("homedirectory", portalsettings.HomeDirectory); if (!_settingDic.ContainsKey("homedirectorymappath")) _settingDic.Add("homedirectorymappath", portalsettings.HomeDirectoryMapPath); } else { if (!_settingDic.ContainsKey("portalname")) _settingDic.Add("portalname", PortalSettings.Current.PortalName); if (!_settingDic.ContainsKey("homedirectory")) _settingDic.Add("homedirectory", PortalSettings.Current.HomeDirectory); if (!_settingDic.ContainsKey("homedirectorymappath")) _settingDic.Add("homedirectorymappath", PortalSettings.Current.HomeDirectoryMapPath); } if (!_settingDic.ContainsKey("culturecode")) _settingDic.Add("culturecode", Utils.GetCurrentCulture()); ThemeFolder = Get("themefolder"); if (_settingDic.ContainsKey("debug.mode") && _settingDic["debug.mode"] == "True") DebugMode = true; // set debug mmode if (_settingDic.ContainsKey("debugfileout") && _settingDic["debugfileout"] == "True") DebugModeFileOut = true; // set debug mmode StorageTypeClient = DataStorageType.Cookie; if (Get("storagetypeclient") == "SessionMemory") StorageTypeClient = DataStorageType.SessionMemory; AdminEmail = Get("adminemail"); ManagerEmail = Get("manageremail"); FolderDocumentsMapPath = Get("homedirectorymappath").TrimEnd('\\') + "\\" + Get("folderdocs"); FolderImagesMapPath = Get("homedirectorymappath").TrimEnd('\\') + "\\" + Get("folderimages"); FolderUploadsMapPath = Get("homedirectorymappath").TrimEnd('\\') + "\\" + Get("folderuploads"); FolderClientUploadsMapPath = Get("homedirectorymappath").TrimEnd('\\') + "\\" + Get("folderclientuploads"); FolderTempMapPath = Get("homedirectorymappath").TrimEnd('\\') + "\\NBSTemp"; FolderNBStoreMapPath = Get("homedirectorymappath").TrimEnd('\\') + "\\NBStore"; FolderDocuments = Get("homedirectory").TrimEnd('/') + "/" + Get("folderdocs").Replace("\\", "/"); FolderImages = Get("homedirectory").TrimEnd('/') + "/" + Get("folderimages").Replace("\\", "/"); FolderUploads = Get("homedirectory").TrimEnd('/') + "/" + Get("folderuploads").Replace("\\", "/"); FolderClientUploads = Get("homedirectory").TrimEnd('/') + "/" + Get("folderclientuploads").Replace("\\", "/"); FolderTemp = Get("homedirectory").TrimEnd('/') + "/NBSTemp"; FolderNBStore = Get("homedirectory").TrimEnd('/') + "/NBStore"; if (!_settingDic.ContainsKey("FolderDocumentsMapPath")) _settingDic.Add("FolderDocumentsMapPath",FolderDocumentsMapPath ); if (!_settingDic.ContainsKey("FolderImagesMapPath")) _settingDic.Add("FolderImagesMapPath",FolderImagesMapPath ); if (!_settingDic.ContainsKey("FolderUploadsMapPath")) _settingDic.Add("FolderUploadsMapPath",FolderUploadsMapPath ); if (!_settingDic.ContainsKey("FolderDocuments")) _settingDic.Add("FolderDocuments", FolderDocuments); if (!_settingDic.ContainsKey("FolderImages")) _settingDic.Add("FolderImages",FolderImages ); if (!_settingDic.ContainsKey("FolderUploads")) _settingDic.Add("FolderUploads", FolderUploads); if (!_settingDic.ContainsKey("NBrightBuyPath")) _settingDic.Add("NBrightBuyPath", NBrightBuyPath()); }
public static int GetEntryIdFromUrl(int portalId, System.Web.HttpRequest request) { var entryId = 0; var qryitemid = Utils.RequestQueryStringParam(request, "eid"); if (Utils.IsNumeric(qryitemid)) { entryId = Convert.ToInt32(qryitemid); } else { var qryguidkey = Utils.RequestQueryStringParam(request, "guidkey"); if (qryguidkey == "") qryguidkey = Utils.RequestQueryStringParam(request, "ref"); if (qryguidkey != "") { var objCtrl = new NBrightBuyController(); var guidData = objCtrl.GetByGuidKey(portalId, -1, "PRD", qryguidkey); if (guidData != null) entryId = guidData.ItemID; } } return entryId; }
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 GroupCategoryData GetCurrentCategoryData(int portalId, System.Web.HttpRequest request, int entryId = 0, Dictionary<string, string> settings = null, String targetModuleKey = "") { var defcatid = 0; var qrycatid = Utils.RequestQueryStringParam(request, "catid"); if (qrycatid == "") { var qrycatref = Utils.RequestQueryStringParam(request, "catref"); if (qrycatref != "") { var catrefData = GetCategoryByRef(portalId, qrycatref); if (catrefData != null) qrycatid = catrefData.categoryid.ToString(""); } } // always use the catid in url if we have no target module if (Utils.IsNumeric(qrycatid) && targetModuleKey == "") return GetCategory(Convert.ToInt32(qrycatid)); if (targetModuleKey != "") { var navigationdata = new NavigationData(portalId, targetModuleKey); if (Utils.IsNumeric(navigationdata.CategoryId) && navigationdata.FilterMode) defcatid = Convert.ToInt32(navigationdata.CategoryId); // always use the catid in url if we have no navigation categoryid for the target module. if (Utils.IsNumeric(qrycatid) && defcatid == 0) return GetCategory(Convert.ToInt32(qrycatid)); } // if we have no catid in url, make sure we have any possible entryid if (entryId == 0) { var qryitemid = Utils.RequestQueryStringParam(request, "eid"); if (Utils.IsNumeric(qryitemid)) { entryId = Convert.ToInt32(qryitemid); } else { var qryguidkey = Utils.RequestQueryStringParam(request, "guidkey"); if (qryguidkey == "") qryguidkey = Utils.RequestQueryStringParam(request, "ref"); if (qryguidkey != "") { var objCtrl = new NBrightBuyController(); var guidData = objCtrl.GetByGuidKey(portalId, -1, "PRD", qryguidkey); if (guidData != null) entryId = guidData.ItemID; } } } // use the first/default category the proiduct has if (Utils.IsNumeric(entryId) && entryId > 0) return GetDefaultCategory(entryId); // get any default set in the settings if (defcatid == 0) { if (settings != null && settings["defaultcatid"] != null) { var setcatid = settings["defaultcatid"]; if (Utils.IsNumeric(setcatid)) defcatid = Convert.ToInt32(setcatid); } } return GetCategory(defcatid); }
private String CopyAllCatXref(HttpContext context,Boolean moverecords = false) { var strOut = NBrightBuyUtils.GetResxMessage("general_fail"); try { var settings = GetAjaxFields(context); var strFilter = " and XrefItemId = {Settings:itemid} "; strFilter = Utils.ReplaceSettingTokens(strFilter, settings); var newcatid = ""; if (settings.ContainsKey("selectedcatid")) newcatid = settings["selectedcatid"]; if (Utils.IsNumeric(newcatid) && settings.ContainsKey("itemid")) { var objCtrl = new NBrightBuyController(); var objList = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "CATXREF", strFilter); foreach (var obj in objList) { var strGuid = newcatid + "x" + obj.ParentItemId.ToString(""); var nbi = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "CATXREF", strGuid); if (nbi == null) { if (!moverecords) obj.ItemID = -1; obj.XrefItemId = Convert.ToInt32(newcatid); obj.GUIDKey = strGuid; obj.XMLData = null; obj.TextData = null; obj.Lang = null; objCtrl.Update(obj); //add all cascade xref var objGrpCtrl = new GrpCatController(_lang, true); var parentcats = objGrpCtrl.GetCategory(Convert.ToInt32(newcatid)); foreach (var p in parentcats.Parents) { strGuid = p.ToString("") + "x" + obj.ParentItemId.ToString(""); nbi = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "CATCASCADE", strGuid); if (nbi == null) { obj.XrefItemId = p; obj.TypeCode = "CATCASCADE"; obj.GUIDKey = strGuid; objCtrl.Update(obj); } } } } if (moverecords) DeleteAllCatXref(context); strOut = NBrightBuyUtils.GetResxMessage(); } } catch (Exception ex) { return ex.ToString(); } return strOut; }
private void DoImport(NBrightInfo nbi) { var fname = StoreSettings.Current.FolderTempMapPath + "\\" + nbi.GetXmlProperty("genxml/hidden/hiddatafile"); if (System.IO.File.Exists(fname)) { var xmlFile = new XmlDocument(); try { xmlFile.Load(fname); } catch (Exception e) { Exceptions.LogException(e); NBrightBuyUtils.SetNotfiyMessage(ModuleId, "xmlloadfail", NotifyCode.fail, ControlPath + "/App_LocalResources/Import.ascx.resx"); return; } // Ref old cat id , id new cat //////////////////////////////////////////////////////////////////////////// Dictionary<string, int> categoryListIDGiud = new Dictionary<string, int>(); Dictionary<int, int> categoryListIDFather = new Dictionary<int, int>(); /////////////////////////////////////////////////////////////////////////// var objCtrl = new NBrightBuyController(); // get all valid languages var langList = DnnUtils.GetCultureCodeList(PortalId); foreach (var lang in langList) { //Import Categories #region "categories" var nodList = xmlFile.SelectNodes("root/categories/" + lang + "/NB_Store_CategoriesInfo"); if (nodList != null) { var categoryid = -1; foreach (XmlNode nod in nodList) { try { //if category Id exist replage guidKey var guidKeyNod = nod.SelectSingleNode("CategoryID").InnerText; if (guidKeyNod != null) { var guidKey = guidKeyNod; categoryid = -1; // see if category already exists (update if so) var nbiImport = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "CATEGORY", guidKey); if (nbiImport != null) categoryid = nbiImport.ItemID; var CategoryData = new CategoryData(categoryid, lang); // clear down existing XML data var i = new NBrightInfo(true); i.PortalId = PortalSettings.Current.PortalId; CategoryData.DataRecord.XMLData = i.XMLData; CategoryData.DataLangRecord.XMLData = i.XMLData; // assign guidkey to legacy productid (guidKey) CategoryData.DataRecord.GUIDKey = guidKey; CategoryData.DataRecord.SetXmlProperty("genxml/textbox/txtcategoryref", guidKey); // do mapping of XML data // DATA FIELDS var cD_CategoryID = nod.SelectSingleNode("CategoryID").InnerText; var cD_PortalID = nod.SelectSingleNode("PortalID").InnerText; var cD_Archived = nod.SelectSingleNode("Archived").InnerText; var cD_Hide = nod.SelectSingleNode("Hide").InnerText; var cD_CreatedByUser = nod.SelectSingleNode("CreatedByUser").InnerText; var cD_CreatedDate = nod.SelectSingleNode("CreatedDate").InnerText; var cD_ParentCategoryID = nod.SelectSingleNode("ParentCategoryID").InnerText; var cD_ListOrder = nod.SelectSingleNode("ListOrder").InnerText; var cD_Lang = nod.SelectSingleNode("Lang").InnerText; var cD_ProductCount = nod.SelectSingleNode("ProductCount").InnerText; var cD_ProductTemplate = nod.SelectSingleNode("ProductTemplate").InnerText; var cD_ListItemTemplate = nod.SelectSingleNode("ListItemTemplate").InnerText; var cD_ListAltItemTemplate = nod.SelectSingleNode("ListAltItemTemplate").InnerText; var cD_ImageURL = nod.SelectSingleNode("ImageURL").InnerText; // DATA LANG FIELDS var cL_CategoryName = nod.SelectSingleNode("CategoryName").InnerText; var cL_ParentName = nod.SelectSingleNode("ParentName").InnerText; var cL_CategoryDesc = nod.SelectSingleNode("CategoryDesc").InnerText; var cL_Message = nod.SelectSingleNode("Message").InnerText; var cL_SEOPageTitle = nod.SelectSingleNode("SEOPageTitle").InnerText; var cL_SEOName = nod.SelectSingleNode("SEOName").InnerText; var cL_MetaDescription = nod.SelectSingleNode("MetaDescription").InnerText; var cL_MetaKeywords = nod.SelectSingleNode("MetaKeywords").InnerText; // Populate DATA CATEGORY CategoryData.DataRecord.SetXmlProperty("genxml/hidden/recordsortorder", cD_ListOrder); CategoryData.DataRecord.SetXmlProperty("genxml/checkbox/chkishidden", cD_Hide); CategoryData.DataRecord.SetXmlProperty("genxml/checkbox/chkdisable", "False"); CategoryData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlgrouptype", "cat"); if (cD_ParentCategoryID != null && cD_ParentCategoryID != "0") CategoryData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlparentcatid", cD_ParentCategoryID); // Populate DATA CATEGORY LANG if (cL_CategoryName != null && cL_CategoryName != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtcategoryname", cL_CategoryName); if (cL_CategoryDesc != null && cL_CategoryDesc != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtcategorydesc", cL_CategoryDesc); if (cL_MetaDescription != null && cL_MetaDescription != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtmetadescription", cL_MetaDescription); if (cL_MetaKeywords != null && cL_MetaKeywords != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtmetakeywords", cL_MetaKeywords); if (cL_SEOPageTitle != null && cL_SEOPageTitle != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtseopagetitle", cL_SEOPageTitle); if (cL_SEOName != null && cL_SEOName != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtseoname", cL_SEOName); if (cL_Message != null && cL_Message != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/edt/message", cL_Message); categoryListIDGiud.Add(CategoryData.CategoryRef, CategoryData.CategoryId); if (cD_ParentCategoryID != null && cD_ParentCategoryID != "" && cD_ParentCategoryID != "0") categoryListIDFather.Add(CategoryData.CategoryId, Convert.ToInt32(cD_ParentCategoryID)); CategoryData.Save(); } } catch (Exception e) { var logMessage = "CATEGORY: CategoryId: " + categoryid.ToString() + " : " + e.ToString(); LogOutput.LogWrite(logMessage); } } //loop on The dictionary foreach (var catl in categoryListIDFather) { //Key var tempNewID = catl.Key; //Value var tempOldFather = catl.Value; var tempNewFather = categoryListIDGiud[tempOldFather.ToString()]; var CategoryData = new CategoryData(tempNewID, lang); CategoryData.ParentItemId = tempNewFather; CategoryData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlparentcatid", tempNewFather.ToString()); CategoryData.Save(); } } #endregion // Import Products #region "data" nodList = xmlFile.SelectNodes("root/products/" + lang + "/P"); if (nodList != null) { var productid = -1; var prodname = ""; foreach (XmlNode nod in nodList) { try { var guidKeyNod = nod.SelectSingleNode("NB_Store_ProductsInfo/ProductID"); if (guidKeyNod != null) { var guidKey = guidKeyNod.InnerText; productid = -1; // See if e already have a product imported, if so we want to update (maybe multiple languages, or a 2nd migrate) var nbiImport = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "PRD", guidKey); if (nbiImport != null) productid = nbiImport.ItemID; var productData = new ProductData(productid, lang); productid = productData.Info.ItemID; // set productid, so we have the id if it goes wrong. prodname = productData.ProductName; // clear down existing XML data var i = new NBrightInfo(true); productData.DataRecord.XMLData = i.XMLData; productData.DataLangRecord.XMLData = i.XMLData; // assign guidkey to legacy productid (guidKey) productData.DataRecord.GUIDKey = guidKey; productData.DataRecord.SetXmlProperty("genxml/importref", guidKey); // do mapping of XML data // DATA FIELDS var pD_ProductID = nod.SelectSingleNode("NB_Store_ProductsInfo/ProductID").InnerText; var pD_PortalID = nod.SelectSingleNode("NB_Store_ProductsInfo/PortalID").InnerText; var pD_TaxCategoryID = nod.SelectSingleNode("NB_Store_ProductsInfo/TaxCategoryID").InnerText; var pD_Featured = nod.SelectSingleNode("NB_Store_ProductsInfo/Featured").InnerText; var pD_Archived = nod.SelectSingleNode("NB_Store_ProductsInfo/Archived").InnerText; var pD_CreatedByUser = nod.SelectSingleNode("NB_Store_ProductsInfo/CreatedByUser").InnerText; var pD_CreatedDate = nod.SelectSingleNode("NB_Store_ProductsInfo/CreatedDate").InnerText; var pD_IsDeleted = nod.SelectSingleNode("NB_Store_ProductsInfo/IsDeleted").InnerText; var pD_ProductRef = nod.SelectSingleNode("NB_Store_ProductsInfo/ProductRef").InnerText; var pD_Lang = nod.SelectSingleNode("NB_Store_ProductsInfo/Lang").InnerText; var pD_Manufacturer = nod.SelectSingleNode("NB_Store_ProductsInfo/Manufacturer").InnerText; var pD_ModifiedDate = nod.SelectSingleNode("NB_Store_ProductsInfo/ModifiedDate").InnerText; var pD_IsHidden = nod.SelectSingleNode("NB_Store_ProductsInfo/IsHidden").InnerText; // DATA LANG FIELDS var pL_ProductName = nod.SelectSingleNode("NB_Store_ProductsInfo/ProductName").InnerText; var pL_Summary = nod.SelectSingleNode("NB_Store_ProductsInfo/Summary").InnerText; var pL_Description = nod.SelectSingleNode("NB_Store_ProductsInfo/Description").InnerText; var pL_SEOName = nod.SelectSingleNode("NB_Store_ProductsInfo/SEOName").InnerText; var pL_TagWords = nod.SelectSingleNode("NB_Store_ProductsInfo/TagWords").InnerText; var pL_Desc = nod.SelectSingleNode("NB_Store_ProductsInfo/Description").InnerText; if (pD_ProductRef != null) productData.DataRecord.SetXmlProperty("genxml/textbox/txtproductref", pD_ProductRef); if (pD_Manufacturer != null) productData.DataRecord.SetXmlProperty("genxml/textbox/customorder", pD_Manufacturer); // langauge main fields if (pL_ProductName != null) productData.DataLangRecord.SetXmlProperty("genxml/textbox/txtproductname", pL_ProductName); if (pL_Summary != null) productData.DataLangRecord.SetXmlProperty("genxml/textbox/txtsummary", pL_Summary); if (pL_SEOName != null) productData.DataLangRecord.SetXmlProperty("genxml/textbox/txtseoname", pL_SEOName); if (pL_SEOName != null) productData.DataLangRecord.SetXmlProperty("genxml/textbox/txtseopagetitle", pL_SEOName); if (pL_TagWords != null) productData.DataLangRecord.SetXmlProperty("genxml/textbox/txttagwords", pL_TagWords); //edt if (pL_Desc != null) { productData.DataLangRecord.SetXmlProperty("genxml/edt", ""); productData.DataLangRecord.SetXmlProperty("genxml/edt/description", pL_Desc); } ////////////////////////////// CUSTOM FIELDS ///////////////////////////////////// ////////////////////////////// CUSTOM FIELDS ///////////////////////////////////// ////////////////////////////// CUSTOM FIELDS ///////////////////////////////////// #region "Custom Fields" // Custom Fields the Custom fields in Nbstore are stored in XmlData xml file area. if (nod.SelectSingleNode("NB_Store_ProductsInfo/XMLData").FirstChild != null) // verify if there are custom fileds { var InputCustomFieldsXml = new XmlDocument(); InputCustomFieldsXml.Load(new StringReader(nod.SelectSingleNode("NB_Store_ProductsInfo/XMLData").InnerText)); var nodListCustom = InputCustomFieldsXml.SelectSingleNode("genxml"); var custominfo = new NBrightInfo(); custominfo.XMLData = nodListCustom.OuterXml; // *************************** // process custom fields here. // *************************** } #endregion ////////////////////////////// END CUSTOM FIELDS ///////////////////////////////////// ////////////////////////////// END CUSTOM FIELDS ///////////////////////////////////// ////////////////////////////// END CUSTOM FIELDS ///////////////////////////////////// // Models var nodListModels = nod.SelectNodes("M/NB_Store_ModelInfo"); foreach (XmlNode nodMod in nodListModels) { //load single node module strucuture var ModelID = nodMod.SelectSingleNode("ModelID").InnerText; var ProductID = nodMod.SelectSingleNode("ProductID").InnerText; var ListOrder = nodMod.SelectSingleNode("ListOrder").InnerText; var UnitCost = nodMod.SelectSingleNode("UnitCost").InnerText; var Barcode = nodMod.SelectSingleNode("Barcode").InnerText; var ModelRef = nodMod.SelectSingleNode("ModelRef").InnerText; var Lang = nodMod.SelectSingleNode("Lang").InnerText; var ModelName = nodMod.SelectSingleNode("ModelName").InnerText; var QtyRemaining = nodMod.SelectSingleNode("QtyRemaining").InnerText; var QtyTrans = nodMod.SelectSingleNode("QtyTrans").InnerText; var QtyTransDate = nodMod.SelectSingleNode("QtyTransDate").InnerText; var ProductName = nodMod.SelectSingleNode("ProductName").InnerText; var PortalID = nodMod.SelectSingleNode("PortalID").InnerText; var Weight = nodMod.SelectSingleNode("Weight").InnerText; var Height = nodMod.SelectSingleNode("Height").InnerText; var Length = nodMod.SelectSingleNode("Length").InnerText; var Width = nodMod.SelectSingleNode("Width").InnerText; var Deleted = nodMod.SelectSingleNode("Deleted").InnerText; var QtyStockSet = nodMod.SelectSingleNode("QtyStockSet").InnerText; var DealerCost = nodMod.SelectSingleNode("DealerCost").InnerText; var PurchaseCost = nodMod.SelectSingleNode("PurchaseCost").InnerText; var XMLData = nodMod.SelectSingleNode("XMLData").InnerText; var Extra = nodMod.SelectSingleNode("Extra").InnerText; var DealerOnly = nodMod.SelectSingleNode("DealerOnly").InnerText; var Allow = nodMod.SelectSingleNode("Allow").InnerText; ////////////////////////////// FINE CUSTOM FIELDS ///////////////////////////////////// ////////////////////////////// FINE CUSTOM FIELDS ///////////////////////////////////// ////////////////////////////// FINE CUSTOM FIELDS ///////////////////////////////////// //il dentro al tag model cè un genxml che identifica il modello // MODELLI CAMPI DATA ////////////////////////////// MODELS ///////////////////////////////////// ////////////////////////////// MODELS ///////////////////////////////////// ////////////////////////////// MODELS ///////////////////////////////////// var newkey = Utils.GetUniqueKey(); var strXmlModel = @"<genxml><models><genxml> <files /> <hidden><modelid>" + newkey + "</modelid>" + @"</hidden> <textbox> <availabledate datatype=""date"" /> <txtqtyminstock>0</txtqtyminstock> <txtmodelref>" + ModelRef + @"</txtmodelref> <txtunitcost>" + UnitCost + @"</txtunitcost> <txtsaleprice>0.00</txtsaleprice> <txtbarcode>" + Barcode + @"</txtbarcode> <txtqtyremaining>" + QtyRemaining + @"</txtqtyremaining> <txtqtystockset>" + QtyStockSet + @"</txtqtystockset> <txtdealercost>" + DealerCost + @"</txtdealercost> <txtpurchasecost>" + PurchaseCost + @"</txtpurchasecost> <weight>" + Weight + @"</weight> <depth>" + Length + @"</depth> <width>" + Width + @"</width> <height>" + Height + @"</height> <unit /> <delay /> </textbox> <checkbox> <chkstockon>False</chkstockon> <chkishidden>False</chkishidden> <chkdeleted>False</chkdeleted> <chkdealeronly>False</chkdealeronly> </checkbox> <dropdownlist> <modelstatus>010</modelstatus> </dropdownlist> <checkboxlist /> <radiobuttonlist /> </genxml></models></genxml>"; var strXmlModelLang = @"<genxml><models><genxml> <files /> <hidden /> <textbox> <txtmodelname>" + ModelName + "</txtmodelname>" + "<txtextra>" + Extra + @"</txtextra> </textbox> <checkbox /><dropdownlist /><checkboxlist /><radiobuttonlist /> </genxml></models></genxml>"; if (productData.DataRecord.XMLDoc.SelectSingleNode("genxml/models") == null) { productData.DataRecord.AddXmlNode(strXmlModel, "genxml/models", "genxml"); productData.DataLangRecord.AddXmlNode(strXmlModelLang, "genxml/models", "genxml"); } else { productData.DataRecord.AddXmlNode(strXmlModel, "genxml/models/genxml", "genxml/models"); productData.DataLangRecord.AddXmlNode(strXmlModelLang, "genxml/models/genxml", "genxml/models"); } } ////////////////////////////// IMAGES ///////////////////////////////////// ////////////////////////////// IMAGES ///////////////////////////////////// ////////////////////////////// IMAGES ///////////////////////////////////// ////////////////////////////// IMAGES ///////////////////////////////////// // copy all the images from Portals\0\productimages to Portals\0\NBStore\images var nodListImages = nod.SelectNodes("I/NB_Store_ProductImageInfo"); foreach (XmlNode nodImg in nodListImages) { var ImageID = nodImg.SelectSingleNode("ImageID").InnerText; var Hidden = nodImg.SelectSingleNode("Hidden").InnerText; var ImageUrl = nodImg.SelectSingleNode("ImageURL").InnerText; var ImagePath = nodImg.SelectSingleNode("ImagePath").InnerText; productData.AddNewImage(ImageUrl, ImagePath); } ////////////////////////////// DOCS ///////////////////////////////////// ////////////////////////////// DOCS ///////////////////////////////////// ////////////////////////////// DOCS ///////////////////////////////////// ////////////////////////////// DOCS ///////////////////////////////////// // copy all the DOCS from Portals\0\productdocs to Portals\0\NBStore\docs var nodListDocs = nod.SelectNodes("D/NB_Store_ProductDocInfo"); var lp = 1; var objCtrlDoc = new NBrightBuyController(); foreach (XmlNode nodDoc in nodListDocs) { var DocID = nodDoc.SelectSingleNode("DocID").InnerText; var ProductID = nodDoc.SelectSingleNode("ProductID").InnerText; var DocPath = nodDoc.SelectSingleNode("DocPath").InnerText; var ListOrder = nodDoc.SelectSingleNode("ListOrder").InnerText; var Hidden = nodDoc.SelectSingleNode("Hidden").InnerText; var FileName = nodDoc.SelectSingleNode("FileName").InnerText; var FileExt = nodDoc.SelectSingleNode("FileExt").InnerText; var Lang = nodDoc.SelectSingleNode("Lang").InnerText; var DocDesc = nodDoc.SelectSingleNode("DocDesc").InnerText; productData.AddNewDoc(DocPath, FileName); productData.DataRecord.SetXmlProperty("genxml/docs/genxml[" + lp.ToString() + "]/hidden/fileext", FileExt); DocPath = DocPath.Replace("productdocs", @"NBStore\docs"); productData.DataRecord.SetXmlProperty("genxml/docs/genxml[" + lp.ToString() + "]/hidden/filepath", DocPath); objCtrlDoc.Update(productData.DataRecord); // if doesen't exisit the xml genxml strucuture inside the DataLangRecor I create it var strXml = "<genxml><docs><genxml><textbox/></genxml></docs></genxml>"; if (productData.DataLangRecord.XMLDoc.SelectSingleNode("genxml/docs") == null) { productData.DataLangRecord.AddXmlNode(strXml, "genxml/docs", "genxml"); } else { productData.DataLangRecord.AddXmlNode(strXml, "genxml/docs/genxml", "genxml/docs"); } ///////////////////////////////////////////////// productData.DataLangRecord.SetXmlProperty("genxml/docs/genxml[" + lp.ToString() + "]/textbox/txtdocdesc", DocDesc); productData.DataLangRecord.SetXmlProperty("genxml/docs/genxml[" + lp.ToString() + "]/textbox/txttitle", FileName); objCtrlDoc.Update(productData.DataLangRecord); lp += 1; } ////////////////////////////// CATEGORIES ///////////////////////////////////// ////////////////////////////// CATEGORIES ///////////////////////////////////// ////////////////////////////// CATEGORIES ///////////////////////////////////// ////////////////////////////// CATEGORIES ///////////////////////////////////// var nodListCat = nod.SelectNodes("C/NB_Store_ProductCategoryInfo"); foreach (XmlNode nodCat in nodListCat) { var ProductID = nodCat.SelectSingleNode("ProductID").InnerText; var CategoryID = nodCat.SelectSingleNode("CategoryID").InnerText; if (ProductID == guidKey) { var newCategoryId = categoryListIDGiud[CategoryID]; productData.AddCategory(newCategoryId); } } ////////////////////////////// SAVE PRODUCT ///////////////////////////////////// productData.Save(); } } catch (Exception e) { var logMessage = "PRODUCTS: " + prodname + " ProductId: " + productid.ToString() + " : " + e.ToString(); LogOutput.LogWrite(logMessage); } } } ////////////////////////////// RELATED PRODUCTS ///////////////////////////////////// //recicle on all the xml import Product and reconnect the related product foreach (var lang2 in langList) { if (nodList != null) { foreach (XmlNode nod in nodList) { var guidKeyNod = nod.SelectSingleNode("NB_Store_ProductsInfo/ProductID"); if (guidKeyNod != null) { var guidKey = guidKeyNod.InnerText; var productid = -1; try { // See if e already have a product imported, if so we want to update (maybe multiple languages, or a 2nd migrate) var nbiImport = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "PRD", guidKey); if (nbiImport != null) productid = nbiImport.ItemID; var productData = new ProductData(productid, lang2); ////////////////////////////// RELATED PRODUCTS ///////////////////////////////////// ////////////////////////////// RELATED PRODUCTS ///////////////////////////////////// var nodListRelated = nod.SelectNodes("R/NB_Store_ProductRelatedInfo"); if (nodListRelated != null) //if there are related { foreach (XmlNode nodRel in nodListRelated) { // id in the related product import file var ImportRelatedProductID = nodRel.SelectSingleNode("RelatedProductID").InnerText; // extract Id of the new created product thet have the old id in the guidKey var tempID = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "PRD", ImportRelatedProductID); if (tempID != null) { int IDRelatedprod = tempID.ItemID; productData.AddRelatedProduct(IDRelatedprod); productData.Save(); } } } } catch (Exception e) { var logMessage = "RELATED PRODUCTS: ProductId: " + productid.ToString() + " : " + e.ToString(); LogOutput.LogWrite(logMessage); } } } } } LogOutput.LogWrite("END: " + DateTime.Now); #endregion } NBrightBuyUtils.SetNotfiyMessage(ModuleId, "Import", NotifyCode.ok, ControlPath + "/App_LocalResources/Import.ascx.resx"); } }
public List <MenuNode> ManipulateNodes(List <MenuNode> nodes, DotNetNuke.Entities.Portals.PortalSettings portalSettings) { var parentcatref = ""; // jump out if we don't have [CAT] token in nodes if (nodes.Count(x => x.Text.ToUpper() == "[CAT]") == 0 && nodes.Count(x => x.Text.ToUpper().StartsWith("[CAT:")) == 0) { return(nodes); } // use cache () var nodeTabList = "*"; foreach (var n in nodes) { nodeTabList += n.Text + n.TabId + "*" + n.Breadcrumb + "*"; } var cachekey = "NBrightPL*" + portalSettings.PortalId + "*" + Utils.GetCurrentCulture() + "*" + nodeTabList; // use nodeTablist incase the DDRMenu has a selector. var rtnnodes = (List <MenuNode>)Utils.GetCache(cachekey); if (rtnnodes != null) { return(rtnnodes); } var categoryInjectList = new Dictionary <int, int>(); var idx1 = 0; var listCats = new List <int>(); if (nodes.Count(x => x.Text.ToUpper().StartsWith("[CAT")) > 0) { // find the selected node. var nods = nodes.Where(x => (x.Text.ToUpper().StartsWith("[CAT"))).ToList(); foreach (var n in nods) { if (n.Text.ToUpper().StartsWith("[CAT:")) { var s = n.Text.Split(':'); if (s.Count() >= 2) { parentcatref = s[1].TrimEnd(']'); var objCtrl = new NBrightBuyController(); var parentcat = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "CATEGORY", parentcatref); if (parentcat != null) { listCats.Add(parentcat.ItemID); categoryInjectList.Add(idx1, n.TabId); idx1 += 1; } } } else { categoryInjectList.Add(0, n.TabId); listCats.Add(0); } } } var lp = 0; foreach (var parentItemId in listCats) { _tabid = PortalSettings.Current.ActiveTab.TabID.ToString(""); var defaultListPage = ""; defaultListPage = StoreSettings.Current.Get("productlisttab"); var catNodeList = GetCatNodeXml(_tabid, categoryInjectList[lp], parentItemId, true, 0, null, defaultListPage); // see if we need to merge into the current pages, by searching for marker page [cat] int idx = 0; var catNods = new Dictionary <int, MenuNode>(); foreach (var n in nodes) { if (n.Text.ToLower() == "[cat]" || n.Text.ToLower().StartsWith("[cat:")) { catNods.Add(idx, n); break; } idx += 1; } if (catNods.Count > 0) { foreach (var catNod in catNods) { // remove marker page [cat] nodes.Remove(catNod.Value); } var insidx = idx; foreach (var n2 in catNodeList) { if (n2.Parent == null) { nodes.Insert(insidx, n2); } insidx += 1; } } lp += 1; } Utils.SetCacheList(cachekey, nodes, "category_cachelist"); return(nodes); }
public static int ModuleSettingsGetCatIdFromRef(NBrightInfo settingsInfo) { var ModCtrl = new NBrightBuyController(); // categoryid no longer exists, see if we can get it back with the catref (might be lost due to cleardown and import) var catref = settingsInfo.GetXmlProperty("genxml/catref"); var nbi = ModCtrl.GetByGuidKey(settingsInfo.PortalId, -1, "CATEGORY", catref); if (nbi != null) return nbi.ItemID; return -1; }
private NBrightInfo ValidateCartItem(int portalId, int userId, NBrightInfo cartItemInfo, Boolean removeZeroQtyItems = false) { #region "get cart values" 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 lang = cartItemInfo.GetXmlProperty("genxml/lang"); if (removeZeroQtyItems && qty == 0) { return(null); // Remove zero qty item } if (lang == "") { lang = Utils.GetCurrentCulture(); } var prd = ProductUtils.GetProductData(prdid, lang); if (!prd.Exists || prd.Disabled) { return(null); //Invalid product remove from cart } // update product xml data on cart (product may have change via plugin so always replace) cartItemInfo.RemoveXmlNode("genxml/productxml"); // add entitytype for validation methods prd.Info.SetXmlProperty("genxml/entitytypecode", prd.Info.TypeCode); cartItemInfo.AddSingleNode("productxml", prd.Info.XMLData, "genxml"); var prdModel = prd.GetModel(modelid); if (prdModel == null) { return(null); // Invalid Model remove from cart } // check if dealer (for tax calc) if (NBrightBuyUtils.IsDealer()) { 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"); var dealersalecost = prdModel.GetXmlPropertyDouble("genxml/textbox/txtdealersale"); // use dynamic price is flagged in cartitem. if (cartItemInfo.GetXmlPropertyBool("genxml/dynamicpriceflag") && cartItemInfo.GetXmlProperty("genxml/dynamicprice") != "") { unitcost = cartItemInfo.GetXmlPropertyDouble("genxml/dynamicprice"); dealercost = cartItemInfo.GetXmlPropertyDouble("genxml/dynamicprice"); saleprice = cartItemInfo.GetXmlPropertyDouble("genxml/dynamicprice"); dealersalecost = cartItemInfo.GetXmlPropertyDouble("genxml/dynamicprice"); } // always make sale price best price if (unitcost > 0 && (unitcost < saleprice || saleprice <= 0)) { saleprice = unitcost; } // if we have a promoprice use it as saleprice (This is passed in via events provider like "Multi-Buy promotions") if (cartItemInfo.GetXmlPropertyDouble("genxml/promoprice") > 0 && cartItemInfo.GetXmlPropertyDouble("genxml/promoprice") < saleprice) { saleprice = cartItemInfo.GetXmlPropertyDouble("genxml/promoprice"); } // always assign the dealercost the best price. if (dealersalecost > 0 && dealersalecost < dealercost) { dealercost = dealersalecost; } if (saleprice > 0 && (saleprice < dealercost || dealercost <= 0)) { dealercost = saleprice; } if (unitcost > 0 && (unitcost < dealercost || dealercost <= 0)) { dealercost = unitcost; } // calc sell price // sellcost = the calculated cost of the item. var sellcost = unitcost; if (saleprice > 0 && saleprice < sellcost) { sellcost = saleprice; } if (NBrightBuyUtils.IsDealer()) { if (dealercost > 0 && dealercost < sellcost) { sellcost = dealercost; } } // -------------------------------------------- #endregion if (prdModel != null) { #region "Stock Control" 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("")); } } #endregion #region "Addtional options costs" 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); } #endregion var totalcost = qty * unitcost; var totalsellcost = qty * sellcost; var totalweight = weight * qty; cartItemInfo.SetXmlPropertyDouble("genxml/unitcost", unitcost); cartItemInfo.SetXmlPropertyDouble("genxml/dealercost", dealercost); cartItemInfo.SetXmlPropertyDouble("genxml/saleprice", saleprice); cartItemInfo.SetXmlPropertyDouble("genxml/totalweight", totalweight.ToString("")); cartItemInfo.SetXmlPropertyDouble("genxml/totalcost", totalcost); cartItemInfo.SetXmlPropertyDouble("genxml/totaldealerbonus", (totalcost - (qty * dealercost))); Double salediscount = 0; Double discountcodeamt = 0; Double totaldiscount = 0; //add update genxml/discountcodeamt var discountcode = PurchaseInfo.GetXmlProperty("genxml/extrainfo/genxml/textbox/promocode"); if (!string.IsNullOrWhiteSpace(discountcode)) { var objCtrl = new NBrightBuyController(); var discountCodeInfo = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "DISCOUNTCODE", discountcode); if (discountCodeInfo != null && !discountCodeInfo.GetXmlPropertyBool("genxml/checkbox/disabled")) { cartItemInfo = DiscountCodeInterface.UpdateItemPercentDiscountCode(PortalId, UserId, cartItemInfo, discountcode); discountcodeamt = cartItemInfo.GetXmlPropertyDouble("genxml/discountcodeamt"); if (discountcodeamt > 0) { PurchaseInfo.SetXmlProperty("genxml/discountprocessed", "False"); } } } if (NBrightBuyUtils.IsDealer()) { salediscount = (unitcost - dealercost); } else { salediscount = (unitcost - saleprice); } totaldiscount = (salediscount * qty) + discountcodeamt; // add on any promo code amount if (totaldiscount < 0) { totaldiscount = 0; } // if we have a promodiscount use it if (cartItemInfo.GetXmlPropertyDouble("genxml/promodiscount") > 0) { totaldiscount = cartItemInfo.GetXmlPropertyDouble("genxml/promodiscount"); totalcost = totalcost - totaldiscount; if (totalcost < 0) { totalcost = 0; } cartItemInfo.SetXmlPropertyDouble("genxml/appliedtotalcost", totalcost); } cartItemInfo.SetXmlPropertyDouble("genxml/totaldiscount", totaldiscount); // if product is on sale then we need to display the sale price in the cart, and any discount codes don;t show at this cart item level, only on the order total. cartItemInfo.SetXmlPropertyDouble("genxml/appliedtotalcost", totalsellcost); cartItemInfo.SetXmlPropertyDouble("genxml/appliedcost", sellcost); // calc tax for item var taxproviderkey = PurchaseInfo.GetXmlProperty("genxml/hidden/taxproviderkey"); var taxprov = TaxInterface.Instance(taxproviderkey); if (taxprov != null) { var nbi = (NBrightInfo)cartItemInfo.Clone(); cartItemInfo.SetXmlPropertyDouble("genxml/taxcost", taxprov.CalculateItemTax(nbi)); } } cartItemInfo = NBrightBuyUtils.ProcessEventProvider(EventActions.ValidateCartItemAfter, cartItemInfo); return(cartItemInfo); }
private void PopulateData(String shippingkey) { var modCtrl = new NBrightBuyController(); Info = modCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "SHIPPING", shippingkey); if (Info == null) { Info = new NBrightInfo(true); Info.GUIDKey = shippingkey; Info.TypeCode = "SHIPPING"; Info.ModuleId = -1; Info.PortalId = PortalSettings.Current.PortalId; } _shippingList = GetRuleList(); // build range Data _rangeData = new List<RangeItem>(); foreach (var i in _shippingList) { var rangeList = i.GetXmlProperty("genxml/textbox/shiprange"); var rl = rangeList.Split(new string[] {"\n", "\r\n"}, StringSplitOptions.RemoveEmptyEntries); foreach (var s in rl) { var ri = s.Split('='); if (ri.Count() == 2 && Utils.IsNumeric(ri[1])) { var riV = ri[0].Split('-'); if (riV.Count() == 2 && Utils.IsNumeric(riV[0]) && Utils.IsNumeric(riV[1])) { var rItem = new RangeItem(); rItem.RefCsv = "," + i.GetXmlProperty("genxml/textbox/shipref") + ","; rItem.RangeLow = Convert.ToDouble(riV[0],CultureInfo.GetCultureInfo("en-US")); rItem.Cost = Convert.ToDouble(ri[1], CultureInfo.GetCultureInfo("en-US")); rItem.RangeHigh = Convert.ToDouble(riV[1],CultureInfo.GetCultureInfo("en-US")); _rangeData.Add(rItem); } } } } }
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 GetUniqueGuidKey(int productId, string newGUIDKey) { // make sure we have a unique guidkey var objCtrl = new NBrightBuyController(); var doloop = true; var lp = 1; var testGUIDKey = newGUIDKey.ToLower(); while (doloop) { var obj = objCtrl.GetByGuidKey(_portalId, -1, _typeCode, testGUIDKey); if (obj != null && obj.ItemID != productId) { testGUIDKey = newGUIDKey + lp; } else doloop = false; lp += 1; if (lp > 999) doloop = false; // make sure we never get a infinate loop } return testGUIDKey; }
public void AddClient(int userid) { var strGuid = userid.ToString("") + "x" + Info.ItemID.ToString(""); var objCtrl = new NBrightBuyController(); var nbi = objCtrl.GetByGuidKey(_portalId, -1, "USERPRDXREF", strGuid); if (nbi == null) { nbi = new NBrightInfo(); nbi.ItemID = -1; nbi.PortalId = _portalId; nbi.ModuleId = -1; nbi.TypeCode = "USERPRDXREF"; nbi.XrefItemId = 0; nbi.ParentItemId = Info.ItemID; nbi.TextData = null; nbi.Lang = null; nbi.UserId = userid; nbi.GUIDKey = strGuid; objCtrl.Update(nbi); } }
/// <summary> /// Search filesystem for any new plugins that have been added. Removed any deleted ones. /// </summary> public static void UpdateSystemPlugins() { // Add new plugins var updated = false; var pluginfoldermappath = System.Web.Hosting.HostingEnvironment.MapPath(StoreSettings.NBrightBuyPath() + "/Plugins"); if (pluginfoldermappath != null && Directory.Exists(pluginfoldermappath)) { var objCtrl = new NBrightBuyController(); var flist = Directory.GetFiles(pluginfoldermappath, "*.xml"); foreach (var f in flist) { if (f.EndsWith(".xml")) { var datain = File.ReadAllText(f); try { var nbi = new NBrightInfo(); nbi.XMLData = datain; // check if we are injecting multiple var nodlist = nbi.XMLDoc.SelectNodes("genxml"); if (nodlist != null && nodlist.Count > 0) { foreach (XmlNode nod in nodlist) { var nbi2 = new NBrightInfo(); nbi2.XMLData = nod.OuterXml; nbi2.ItemID = -1; nbi2.GUIDKey = nbi.GetXmlProperty("genxml/textbox/ctrl"); nbi2.PortalId = 99999; nbi2.Lang = ""; nbi2.ParentItemId = 0; nbi2.ModuleId = -1; nbi2.XrefItemId = 0; nbi2.UserId = 0; nbi2.TypeCode = "PLUGIN"; // check if record exists (should NOT) but lets replace if it does. var existingrecord = objCtrl.GetByGuidKey(-1, -1, "PLUGIN", nbi2.GUIDKey); if (existingrecord != null) { nbi2.ItemID = existingrecord.ItemID; if (nbi2.GetXmlPropertyBool("genxml/delete")) { objCtrl.Delete(existingrecord.ItemID); } else { objCtrl.Update(nbi2); updated = true; } } else { objCtrl.Update(nbi2); updated = true; } } } if (updated) { File.Delete(f); } } catch (Exception) { // data might not be XML complient (ignore) } } } } if (updated) { CopySystemPluginsToPortal(); ClearPluginCache(PortalSettings.Current.PortalId); } }
private string RecalculateSummary(HttpContext context) { var objCtrl = new NBrightBuyController(); var currentcart = new CartData(PortalSettings.Current.PortalId); var ajaxInfo = GetAjaxInfo(context, true); var shipoption = currentcart.GetShippingOption(); // ship option already set in address update. currentcart.AddExtraInfo(ajaxInfo); currentcart.SetShippingOption(shipoption); currentcart.PurchaseInfo.SetXmlProperty("genxml/currentcartstage", "cartsummary"); // (Legacy) we need to set this so the cart calcs shipping currentcart.PurchaseInfo.SetXmlProperty("genxml/extrainfo/genxml/radiobuttonlist/shippingprovider", ajaxInfo.GetXmlProperty("genxml/radiobuttonlist/shippingprovider")); var shipref = ajaxInfo.GetXmlProperty("genxml/radiobuttonlist/shippingprovider"); var displayanme = ""; var shipInfo = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "SHIPPING", shipref); if (shipInfo != null) { displayanme = shipInfo.GetXmlProperty("genxml/textbox/shippingdisplayname"); } if (displayanme == "") displayanme = shipref; currentcart.PurchaseInfo.SetXmlProperty("genxml/extrainfo/genxml/hidden/shippingdisplayanme", displayanme); var shippingproductcode = ajaxInfo.GetXmlProperty("genxml/hidden/shippingproductcode"); currentcart.PurchaseInfo.SetXmlProperty("genxml/shippingproductcode", shippingproductcode); var pickuppointref = ajaxInfo.GetXmlProperty("genxml/hidden/pickuppointref"); currentcart.PurchaseInfo.SetXmlProperty("genxml/pickuppointref", pickuppointref); var pickuppointaddr = ajaxInfo.GetXmlProperty("genxml/hidden/pickuppointaddr"); currentcart.PurchaseInfo.SetXmlProperty("genxml/pickuppointaddr", pickuppointaddr); currentcart.Lang = ajaxInfo.Lang; // set lang so we can send emails in same language the order was made in. currentcart.Save(); return "OK"; }