public void DeleteUserData() { //remove DB record var modCtrl = new NBrightBuyController(); modCtrl.Delete(Info.ItemID); Exists = false; }
public static Boolean ValidateLangaugeRef(int portalId, int categoryId) { var updaterequired = false; foreach (var lang in DnnUtils.GetCultureCodeList(portalId)) { var objCtrl = new NBrightBuyController(); var parentCatData = GetCategoryData(categoryId, lang); var grpCatCtrl = new GrpCatController(lang); var newGuidKey = grpCatCtrl.GetBreadCrumb(categoryId, 0, "-", false); if (newGuidKey != "") newGuidKey = GetUniqueGuidKey(portalId, categoryId, Utils.UrlFriendly(newGuidKey)).ToLower(); if (parentCatData.DataLangRecord.GUIDKey != newGuidKey) { parentCatData.DataLangRecord.SetXmlProperty("genxml/textbox/txtcategoryref", newGuidKey); parentCatData.DataLangRecord.GUIDKey = newGuidKey; objCtrl.Update(parentCatData.DataLangRecord); updaterequired = true; // need to update all children, so call validate recursive. foreach (var ch in parentCatData.GetDirectChildren()) { if (ch.ItemID != categoryId) ValidateLangaugeRef(portalId, ch.ItemID); } } } return updaterequired; }
protected override void OnInit(EventArgs e) { ModCtrl = new NBrightBuyController(); DebugMode = StoreSettings.Current.DebugMode; base.OnInit(e); #region "Get all Settings for module" //get Model Level Settings ModSettings = new ModSettings(ModuleId, Settings); ModuleKey = ModSettings.Get("modulekey"); #endregion if (EnablePaging) { CtrlPaging = new NBrightCore.controls.PagingCtrl(); this.Controls.Add(CtrlPaging); CtrlPaging.PageChanged += new RepeaterCommandEventHandler(PagingClick); } //add template provider to NBright Templating NBrightCore.providers.GenXProviderManager.AddProvider("NBrightBuy,Nevoweb.DNN.NBrightBuy.render.GenXmlTemplateExt"); // search for any other NBright Tenmplating providers that might have been added. var pluginData = new PluginData(PortalSettings.Current.PortalId); var l = pluginData.GetTemplateExtProviders(); foreach (var p in l) { var prov = p.Value; NBrightCore.providers.GenXProviderManager.AddProvider(prov.GetXmlProperty("genxml/textbox/assembly") + "," + prov.GetXmlProperty("genxml/textbox/namespaceclass")); } }
public CatMenuBuilder(String templateBody, ModSettings modSettings, int currentCatId, Boolean debugMode) { _catGrpCtrl = new GrpCatController(Utils.GetCurrentCulture()); _ctrlObj = new NBrightBuyController(); _modSettings = modSettings; _debugMode = debugMode; _templateBody = GetMenuTemplates(templateBody); _currentCatId = currentCatId; }
public static string CalcGroupPromo(int portalId) { var objCtrl = new NBrightBuyController(); var l = objCtrl.GetList(portalId, -1, "CATEGORYPROMO", "", "", 0, 0, 0, 0, Utils.GetCurrentCulture()); foreach (var p in l) { CalcGroupPromoItem(p); } return "OK"; }
/// <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 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 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; }
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); } } } } }
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"); } }
/// <summary> /// Get CartID from cookie or session /// </summary> /// <returns></returns> protected int PopulatePurchaseData(int entryId) { _entryId = entryId; //populate cart data var modCtrl = new NBrightBuyController(); PurchaseInfo = modCtrl.Get(Convert.ToInt32(_entryId)); if (PurchaseInfo == null) { PurchaseInfo = new NBrightInfo(true); PurchaseInfo.TypeCode = PurchaseTypeCode; //add items node so we can add items PurchaseInfo.AddSingleNode("items","","genxml"); if (entryId == -1) { PurchaseInfo.UserId = UserController.Instance.GetCurrentUserInfo().UserID; // new cart created from front office, so give current userid. EditMode = ""; } } PurchaseTypeCode = PurchaseInfo.TypeCode; UserId = PurchaseInfo.UserId; //retain theuserid, if created by a manager for a client. var currentuserInfo = UserController.Instance.GetCurrentUserInfo(); if (UserId > 0 && EditMode != "") // 0 is default userid for new cart { PurchaseInfo.SetXmlProperty("genxml/clientmode", "True", TypeCode.String, false); PurchaseInfo.SetXmlProperty("genxml/clientdisplayname", currentuserInfo.DisplayName); } else { PurchaseInfo.SetXmlProperty("genxml/clientmode", "False", TypeCode.String, false); PurchaseInfo.SetXmlProperty("genxml/clientdisplayname", ""); } //build item list PopulateItemList(); return Convert.ToInt32(_entryId); }
/// <summary> /// Save Purchase record /// </summary> /// <param name="copyrecord">Copy this data as a new record in the DB with a new id</param> /// <returns></returns> public int SavePurchaseData(Boolean copyrecord = false ) { if (copyrecord) { _entryId = -1; PurchaseInfo.SetXmlProperty("genxml/audit", ""); // remove audit } // langauge if (Lang == "") { Lang = Utils.GetCurrentCulture(); } ClientLang = Lang; var strXml = "<items>"; foreach (var info in _itemList) { // remove injected group header record for the product if (!info.GetXmlPropertyBool("genxml/groupheader")) strXml += info.XMLData; } strXml += "</items>"; PurchaseInfo.RemoveXmlNode("genxml/items"); PurchaseInfo.AddXmlNode(strXml, "items", "genxml"); var modCtrl = new NBrightBuyController(); PurchaseInfo.ItemID = _entryId; PurchaseInfo.PortalId = PortalId; PurchaseInfo.ModuleId = -1; PurchaseInfo.TypeCode = PurchaseTypeCode; if (UserController.Instance.GetCurrentUserInfo().UserID != -1) // This might be updated from out of context (payment provider) { if (UserId != UserController.Instance.GetCurrentUserInfo().UserID && EditMode == "") UserId = UserController.Instance.GetCurrentUserInfo().UserID; PurchaseInfo.UserId = UserId; if (EditMode == "" && !string.IsNullOrEmpty(UserController.Instance.GetCurrentUserInfo().Profile.PreferredLocale)) { ClientLang = UserController.Instance.GetCurrentUserInfo().Profile.PreferredLocale; } } // save the product refs of the order to an XML node, so we can search for product ref in the BO Order Admin. var productrefs = ""; foreach (var i in GetCartItemList()) { productrefs += i.GetXmlProperty("genxml/productxml/genxml/textbox/txtproductref") + ","; } PurchaseInfo.SetXmlProperty("genxml/productrefs", productrefs); if (PurchaseInfo.TypeCode != null) // if we're using this class to build cart in memory for procesisng only, don;t save to DB. { _entryId = modCtrl.Update(PurchaseInfo); NBrightBuyUtils.ProcessEventProvider(EventActions.AfterSavePurchaseData, PurchaseInfo); } return _entryId; }
private void XslInjectDataBind(object sender, EventArgs e) { var lc = (Literal)sender; var container = (IDataItemContainer)lc.NamingContainer; lc.Visible = visibleStatus.DefaultIfEmpty(true).First(); if (lc.Visible && container.DataItem != null) { var param = lc.Text.Split('*'); if (param.Count() == 2) { var argsList = new XsltArgumentList(); var templName = param[0]; foreach (var arg in param[1].Split(',')) { if (_settings != null && _settings.ContainsKey(arg)) argsList.AddParam(arg, "", _settings[arg]); } var buyCtrl = new NBrightBuyController(); var xslTempl = buyCtrl.GetTemplateData(-1, templName, Utils.GetCurrentCulture(), _settings, StoreSettings.Current.DebugMode); var nbi = (NBrightInfo) container.DataItem; var strOut = XslUtils.XslTransInMemory(nbi.XMLData, xslTempl, argsList); lc.Text = strOut; } } }
private void ProductlistDataBind(object sender, EventArgs e) { var lc = (Literal)sender; var container = (IDataItemContainer)lc.NamingContainer; try { var strOut = ""; lc.Visible = visibleStatus.DefaultIfEmpty(true).First(); if (lc.Visible) { var param = lc.Text.Split(':'); if (param.Count() == 4) { try { var strFilter = ""; var templName = param[0]; var cascade = param[1]; var strOrder = param[2]; var filter = param[3]; if ((templName != "")) { var nbi = (GroupCategoryData)container.DataItem; var lang = Utils.GetCurrentCulture(); var strCacheKey = lang + "*" + nbi.categoryid + "*" + lc.Text; if (!StoreSettings.Current.DebugMode) strOut = (String)Utils.GetCache(strCacheKey); if (String.IsNullOrEmpty(strOut)) { var buyCtrl = new NBrightBuyController(); var rpTempl = buyCtrl.GetTemplateData(-1, templName, lang, _settings, StoreSettings.Current.DebugMode); //remove templName from template, so we don't get a loop. if (rpTempl.Contains(templName)) rpTempl = rpTempl.Replace(templName, ""); //build models list var objQual = DotNetNuke.Data.DataProvider.Instance().ObjectQualifier; var dbOwner = DotNetNuke.Data.DataProvider.Instance().DatabaseOwner; if (cascade.ToLower() == "true") { strFilter = strFilter + " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where (typecode = 'CATCASCADE' or typecode = 'CATXREF') and XrefItemId = " + nbi.categoryid.ToString("") + ") "; } else strFilter = strFilter + " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where typecode = 'CATXREF' and XrefItemId = " + nbi.categoryid.ToString("") + ") "; if (strOrder == "{bycategoryproduct}") strOrder += nbi.categoryid.ToString(""); // do special custom sort in each cateogry if (filter != "") strFilter += " AND " + filter; var objL = buyCtrl.GetDataList(PortalSettings.Current.PortalId, -1, "PRD", "PRDLANG", Utils.GetCurrentCulture(), strFilter, strOrder); // inject the categoryid into the data, so the entryurl can have the correct catid foreach (var i in objL) { i.SetXmlProperty("genxml/categoryid", nbi.categoryid.ToString("")); } var itemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpTempl, _settings, PortalSettings.Current.HomeDirectory,visibleStatus); strOut = GenXmlFunctions.RenderRepeater(objL, itemTemplate); if (!StoreSettings.Current.DebugMode) NBrightBuyUtils.SetModCache(-1, strCacheKey, strOut); } } } catch (Exception exc) { strOut = "ERROR: <br/>" + exc; } } } lc.Text = strOut; } catch (Exception) { lc.Text = ""; } }
public int Validate() { var errorcount = 0; var objCtrl = new NBrightBuyController(); DataRecord.ValidateXmlFormat(); if (DataLangRecord == null) { // we have no datalang record for this language, so get an existing one and save it. var l = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "GROUPLANG", " and NB1.ParentItemId = " + Info.ItemID.ToString("")); if (l.Count > 0) { DataLangRecord = (NBrightInfo)l[0].Clone(); DataLangRecord.ItemID = -1; DataLangRecord.Lang = _lang; DataLangRecord.SetXmlProperty("genxml/textbox/groupname", DnnUtils.GetResourceString("/DesktopModules/NBright/NBrightBuy/App_LocalResources/", "General." + DataRecord.GUIDKey)); DataLangRecord.ValidateXmlFormat(); objCtrl.Update(DataLangRecord); } } var defaultname = Name; if (defaultname == "") { // find a valid default name foreach (var lang in DnnUtils.GetCultureCodeList(PortalSettings.Current.PortalId)) { var l = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "GROUPLANG", " and NB1.ParentItemId = " + Info.ItemID.ToString("") + " and NB1.Lang = '" + lang + "'"); if (l.Count == 1) { var nbi2 = (NBrightInfo)l[0]; if (nbi2.GetXmlProperty("genxml/textbox/groupname") != "") { defaultname = nbi2.GetXmlProperty("genxml/textbox/groupname"); Name = defaultname; Save(); break; } } } } // fix langauge records foreach (var lang in DnnUtils.GetCultureCodeList(PortalSettings.Current.PortalId)) { var l = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "GROUPLANG", " and NB1.ParentItemId = " + Info.ItemID.ToString("") + " and NB1.Lang = '" + lang + "'"); if (l.Count == 0 && DataLangRecord != null) { var nbi = (NBrightInfo)DataLangRecord.Clone(); nbi.ItemID = -1; nbi.Lang = lang; if (nbi.GetXmlProperty("genxml/textbox/groupname") == "") { nbi.SetXmlProperty("genxml/textbox/groupname", DnnUtils.GetResourceString("/DesktopModules/NBright/NBrightBuy/App_LocalResources/", "General." + DataRecord.GUIDKey)); } objCtrl.Update(nbi); errorcount += 1; } if (l.Count == 1) { var nbi2 = (NBrightInfo)l[0]; if (nbi2.GetXmlProperty("genxml/textbox/groupname") == "") { // if we have no name, use the default name we found early to update. nbi2.SetXmlProperty("genxml/textbox/groupname", DnnUtils.GetResourceString("/DesktopModules/NBright/NBrightBuy/App_LocalResources/", "General." + DataRecord.GUIDKey)); objCtrl.Update(nbi2); } } if (l.Count > 1) { // we have more records than should exists, remove any old ones. var l2 = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "GROUPLANG", " and NB1.ParentItemId = " + Info.ItemID.ToString("") + " and NB1.Lang = '" + lang + "'", "order by Modifieddate desc"); var lp = 1; foreach (var i in l2) { if (lp >= 2) { objCtrl.Delete(i.ItemID); } lp += 1; } } } if (Ref == "") { Ref = DataRecord.GUIDKey; objCtrl.Update(DataRecord); } // add required field values to make getting group easier. if (Ref != "" && DataRecord.GUIDKey != Ref) { DataRecord.GUIDKey = Ref; objCtrl.Update(DataRecord); } // check we have a groupt type, it might be missing if upgraded. if (Type == "") { if (Ref == "cat") { Type = "2"; } else { Type = "1"; } objCtrl.Update(DataRecord); } return(errorcount); }
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"); } }
public void Save() { var objCtrl = new NBrightBuyController(); objCtrl.Update(DataRecord); }
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 string GetReturnData(HttpContext context) { try { var strOut = ""; var strIn = HttpUtility.UrlDecode(Utils.RequestParam(context, "inputxml")); var xmlData = GenXmlFunctions.GetGenXmlByAjax(strIn, ""); var objInfo = new NBrightInfo(); objInfo.ItemID = -1; objInfo.TypeCode = "AJAXDATA"; objInfo.XMLData = xmlData; var settings = objInfo.ToDictionary(); var themeFolder = StoreSettings.Current.ThemeFolder; if (settings.ContainsKey("themefolder")) themeFolder = settings["themefolder"]; var templCtrl = NBrightBuyUtils.GetTemplateGetter(themeFolder); if (!settings.ContainsKey("portalid")) settings.Add("portalid", PortalSettings.Current.PortalId.ToString("")); // aways make sure we have portalid in settings var objCtrl = new NBrightBuyController(); // run SQL and template to return html if (settings.ContainsKey("sqltpl") && settings.ContainsKey("xsltpl")) { var strSql = templCtrl.GetTemplateData(settings["sqltpl"], _lang, true, true, true, StoreSettings.Current.Settings()); var xslTemp = templCtrl.GetTemplateData(settings["xsltpl"], _lang, true, true, true, StoreSettings.Current.Settings()); // replace any settings tokens (This is used to place the form data into the SQL) strSql = Utils.ReplaceSettingTokens(strSql, settings); strSql = Utils.ReplaceUrlTokens(strSql); strSql = GenXmlFunctions.StripSqlCommands(strSql); // don't allow anything to update through here. strOut = objCtrl.GetSqlxml(strSql); if (!strOut.StartsWith("<root>")) strOut = "<root>" + strOut + "</root>"; // always wrap with root node. strOut = XslUtils.XslTransInMemory(strOut, xslTemp); } return strOut; } catch (Exception ex) { return ex.ToString(); } }
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 void CreateFriendlyImages(int productid, string lang) { var objCtrl = new NBrightBuyController(); var imgList = new List <string>(); var productData = new ProductData(productid, lang); var productImgFolder = StoreSettings.Current.FolderImagesMapPath.TrimEnd('\\') + "\\" + productData.DataRecord.ItemID + "\\" + lang; Utils.CreateFolder(productImgFolder); foreach (var i in productData.Imgs) { //becuase of updates to sort order and alt text we NEED to delete the existing files. Utils.DeleteSysFile(i.GetXmlProperty("genxml/lang/genxml/hidden/fimagepath")); } var lp = 1; foreach (var i in productData.Imgs) { // use imageref to link langauges var imageref = i.GetXmlProperty("genxml/hidden/imageref"); if (imageref == "") { imageref = Utils.GetUniqueKey(); productData.DataRecord.SetXmlProperty("genxml/imgs/genxml[" + lp + "]/hidden/imageref", imageref); } var imgname = i.GetXmlProperty("genxml/lang/genxml/textbox/txtimagedesc"); if (imgname == "") { imgname = productData.ProductName; } if (imgname == "") { imgname = productData.ProductRef; } if (imgname != "") { var fullName = i.GetXmlProperty("genxml/hidden/imagepath"); var extension = Path.GetExtension(fullName); imgname = AlphaNumeric(CleanFileName(imgname.Replace(" ", "-"))); var imgnameext = imgname + extension; var newImageFileName = productImgFolder + "\\" + imgnameext; var lp2 = 1; while (File.Exists(newImageFileName)) { imgnameext = imgname + "-" + lp2 + extension; newImageFileName = productImgFolder + "\\" + imgnameext; lp2++; } var imgSize = StoreSettings.Current.GetInt(StoreSettingKeys.productimageresize); if (imgSize == 0) { imgSize = 960; } if (extension != null && extension.ToLower() == ".png") { newImageFileName = ImgUtils.ResizeImageToPng(fullName, newImageFileName, imgSize); } else { newImageFileName = ImgUtils.ResizeImageToJpg(fullName, newImageFileName, imgSize); } var newimageurl = StoreSettings.Current.FolderImages.TrimEnd('/') + "/" + productData.DataRecord.ItemID + "/" + lang + "/" + imgnameext; productData.DataLangRecord.SetXmlProperty("genxml/imgs/genxml[" + lp + "]/hidden/fimageurl", newimageurl); productData.DataLangRecord.SetXmlProperty("genxml/imgs/genxml[" + lp + "]/hidden/fimagepath", newImageFileName); productData.DataLangRecord.SetXmlProperty("genxml/imgs/genxml[" + lp + "]/hidden/fimageref", imageref); imgList.Add(newImageFileName); } lp += 1; } objCtrl.Update(productData.DataLangRecord); objCtrl.Update(productData.DataRecord); // remove any deleted images. var fl = Directory.GetFiles(productImgFolder); foreach (var f in fl) { if (!imgList.Contains(f)) { Utils.DeleteSysFile(f); } } // sort other language foreach (var l in DnnUtils.GetCultureCodeList()) { if (l != lang) { var strXml = ""; var pData = new ProductData(productid, l); var lp3 = 1; foreach (var langimg in pData.Imgs) { var imgref = langimg.GetXmlProperty("genxml/hidden/imageref"); var strNode = pData.DataLangRecord.GetXmlNode("genxml/imgs/genxml[./hidden/fimageref='" + imgref + "']"); if (strNode == "") { // create missing ref and get xml. (May misalign images alts) pData.DataLangRecord.SetXmlProperty("genxml/imgs/genxml[" + lp3 + "]/hidden/fimageref", imgref); strNode = pData.DataLangRecord.GetXmlNode("genxml/imgs/genxml[./hidden/fimageref='" + imgref + "']"); } strXml += "<genxml>" + strNode + "</genxml>"; lp3 += 1; } strXml = "<imgs>" + strXml + "</imgs>"; pData.DataLangRecord.RemoveXmlNode("genxml/imgs"); pData.DataLangRecord.AddXmlNode(strXml, "imgs", "genxml"); objCtrl.Update(pData.DataLangRecord); } } RemoveProductDataCache(PortalSettings.Current.PortalId, productid); }
private void RelatedlistDataBind(object sender, EventArgs e) { var lc = (Literal)sender; var container = (IDataItemContainer)lc.NamingContainer; try { var strOut = ""; lc.Visible = visibleStatus.DefaultIfEmpty(true).First(); if (lc.Visible) { var id = Convert.ToString(DataBinder.Eval(container.DataItem, "ItemId")); var templName = lc.Text; if (Utils.IsNumeric(id) && (templName != "")) { var modCtrl = new NBrightBuyController(); var rpTempl = modCtrl.GetTemplateData(-1, templName, Utils.GetCurrentCulture(), _settings, StoreSettings.Current.DebugMode); //remove templName from template, so we don't get a loop. if (rpTempl.Contains('"' + templName + '"')) rpTempl = rpTempl.Replace(templName, ""); //build list var objInfo = (NBrightInfo)container.DataItem; List<NBrightInfo> objL = null; var strCacheKey = Utils.GetCurrentCulture() + "RelatedList*" + objInfo.ItemID; if (!StoreSettings.Current.DebugMode) objL = (List<NBrightInfo>)Utils.GetCache(strCacheKey); if (objL == null) { var prodData = ProductUtils.GetProductData(objInfo.ItemID, Utils.GetCurrentCulture()); objL = prodData.GetRelatedProducts(); if (!StoreSettings.Current.DebugMode) NBrightBuyUtils.SetModCache(-1, strCacheKey, objL); } // render repeater try { var itemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpTempl, _settings, PortalSettings.Current.HomeDirectory, visibleStatus); strOut = GenXmlFunctions.RenderRepeater(objL, itemTemplate); } catch (Exception exc) { strOut = "ERROR: NOTE: sub rendered templates CANNOT contain postback controls.<br/>" + exc; } } } lc.Text = strOut; } catch (Exception) { lc.Text = ""; } }
public override void DoWork() { try { var portallist = DnnUtils.GetAllPortals(); foreach (var portal in portallist) { var storeSettings = new StoreSettings(portal.PortalID); if (Directory.Exists(storeSettings.FolderTempMapPath)) { // clear old carts var objCtrl = new NBrightBuyController(); var objQual = DotNetNuke.Data.DataProvider.Instance().ObjectQualifier; var dbOwner = DotNetNuke.Data.DataProvider.Instance().DatabaseOwner; var days = 60; var d = DateTime.Now.AddDays(days * -1); var strDate = d.ToString("s"); var stmt = ""; stmt = "delete from " + dbOwner + "[" + objQual + "NBrightBuy] where PortalId = " + portal.PortalID.ToString("") + " and typecode = 'CART' and ModifiedDate < '" + strDate + "' "; objCtrl.ExecSql(stmt); // clear down NBStore temp folder string[] files = Directory.GetFiles(storeSettings.FolderTempMapPath); foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.LastAccessTime < DateTime.Now.AddHours(-1)) { fi.Delete(); } } // DO Scheduler Jobs var pluginData = new PluginData(portal.PortalID); var l = pluginData.GetSchedulerProviders(); foreach (var p in l) { var prov = p.Value; ObjectHandle handle = null; handle = Activator.CreateInstance(prov.GetXmlProperty("genxml/textbox/assembly"), prov.GetXmlProperty("genxml/textbox/namespaceclass")); if (handle != null) { var objProvider = (SchedulerInterface)handle.Unwrap(); var strMsg = objProvider.DoWork(portal.PortalID); if (strMsg != "") { this.ScheduleHistoryItem.AddLogNote(strMsg); } } } } } this.ScheduleHistoryItem.Succeeded = true; } catch (Exception Ex) { //--intimate the schedule mechanism to write log note in schedule history this.ScheduleHistoryItem.Succeeded = false; this.ScheduleHistoryItem.AddLogNote("NBS Service Start. Failed. " + Ex.ToString()); this.Errored(ref Ex); } }
private void CartItemlistDataBind(object sender, EventArgs e) { var lc = (Literal)sender; var container = (IDataItemContainer)lc.NamingContainer; try { var strOut = ""; lc.Visible = visibleStatus.DefaultIfEmpty(true).First(); if (lc.Visible) { var id = Convert.ToString(DataBinder.Eval(container.DataItem, "ItemId")); var lang = Convert.ToString(DataBinder.Eval(container.DataItem, "lang")); if (lang == "") lang = Utils.GetCurrentCulture(); var groupresults = false; if (lc.Text.EndsWith(":GROUPBY")) { groupresults = true; lc.Text = lc.Text.Replace(":GROUPBY", ""); } var templName = lc.Text; if (Utils.IsNumeric(id) && (templName != "")) { var buyCtrl = new NBrightBuyController(); var rpTempl = buyCtrl.GetTemplateData(-1, templName, lang, _settings, StoreSettings.Current.DebugMode); //remove templName from template, so we don't get a loop. if (rpTempl.Contains(templName)) rpTempl = rpTempl.Replace(templName, ""); //build models list var objInfo = (NBrightInfo)container.DataItem; var cartData = new CartData(objInfo.PortalId); // render repeater try { var itemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpTempl, _settings, PortalSettings.Current.HomeDirectory, visibleStatus); strOut = GenXmlFunctions.RenderRepeater(cartData.GetCartItemList(groupresults), itemTemplate); } catch (Exception exc) { strOut = "ERROR: NOTE: sub rendered templates CANNOT contain postback controls.<br/>" + exc; } } } lc.Text = strOut; } catch (Exception) { lc.Text = ""; } }
public static string GetRelatedCats(int portalId, string parentItemId, string cultureCode, string templatePrefix, string controlMapPath, Boolean AllowCache = true) { var strOut = ""; if (Utils.IsNumeric(parentItemId)) { if (!AllowCache) { //Remove any cache for the module -1, we don't want any cache in BO //All xref records are portal wide, hence -1 in cahce key. NBrightBuyUtils.RemoveModCache(-1); } var objCtrl = new NBrightBuyController(); var templCtrl = new TemplateController(controlMapPath); var hTempl = templCtrl.GetTemplateData(templatePrefix + "_" + ModuleEventCodes.selectedheader + ".html", Utils.GetCurrentCulture()); var bTempl = templCtrl.GetTemplateData(templatePrefix + "_" + ModuleEventCodes.selectedbody + ".html", Utils.GetCurrentCulture()); var fTempl = templCtrl.GetTemplateData(templatePrefix + "_" + ModuleEventCodes.selectedfooter + ".html", Utils.GetCurrentCulture()); // replace Settings tags for ajax to work. hTempl = Utils.ReplaceUrlTokens(hTempl); bTempl = Utils.ReplaceUrlTokens(bTempl); fTempl = Utils.ReplaceUrlTokens(fTempl); var strFilter = " and parentitemid = " + parentItemId; var strOrderBy = GenXmlFunctions.GetSqlOrderBy(hTempl); if (strOrderBy == "") { strOrderBy = GenXmlFunctions.GetSqlOrderBy(bTempl); } var l = objCtrl.GetList(portalId, -1, "CATXREF", strFilter, strOrderBy); var objList = new List <NBrightInfo>(); foreach (var objXref in l) { var o = objCtrl.Get(objXref.XrefItemId, "CATEGORYLANG", cultureCode); if (o != null) { if (objXref.GetXmlProperty("genxml/hidden/defaultcat") != "") { // set the default flag in the category, for display in the entry only. o.SetXmlProperty("genxml/hidden/defaultcat", "True"); } o.GUIDKey = objXref.ItemID.ToString(); // overwrite with xref itemid for delete ajax action. o.TextData = o.GetXmlProperty("genxml/lang/genxml/textbox/txtname"); // set for sort o.Lang = cultureCode; // set lang so the GenXmlTemplateExt can pickup the edit langauge. objList.Add(o); objList.Sort(delegate(NBrightInfo p1, NBrightInfo p2) { return(p1.TextData.CompareTo(p2.TextData)); }); } } var obj = new NBrightInfo(); strOut += GenXmlFunctions.RenderRepeater(obj, hTempl); strOut += GenXmlFunctions.RenderRepeater(objList, bTempl); strOut += GenXmlFunctions.RenderRepeater(obj, fTempl); } return(strOut); }
public void TurnOffEditMode() { var modCtrl = new NBrightBuyController(); EditMode = ""; _entryId = modCtrl.Update(PurchaseInfo); }
public static NBrightInfo CalculateModels(NBrightInfo objInfo, String controlMapPath) { var objCtrl = new NBrightBuyController(); var optList = new List <NBrightInfo>(); // get list of active options for product models var xmlOptList = objInfo.XMLDoc.SelectNodes("genxml/prdopt/id"); if (xmlOptList != null) { foreach (XmlNode xNod in xmlOptList) { if (Utils.IsNumeric(xNod.InnerText)) { var objOpt = objCtrl.Get(Convert.ToInt32(xNod.InnerText)); if (objOpt != null) { optList.Add(objOpt); } } } } //sort into ItemId order so we get the same modelcode created. optList.Sort(delegate(NBrightInfo p1, NBrightInfo p2) { return(p1.ItemID.CompareTo(p2.ItemID)); }); //Build modelCode list int lp1 = 0; var mcList = new List <string>(); lp1 = 0; if (optList.Count == 1) { // only 1 option with stock, so no need to do a recursive build. var xmlNodList2 = optList[0].XMLDoc.SelectNodes("genxml/optionval/genxml"); if (xmlNodList2 != null) { foreach (XmlNode xNod2 in xmlNodList2) { var xNod = xNod2.SelectSingleNode("textbox/txtoptionvalue"); if (xNod != null) { mcList.Add(xNod.InnerText); } } } } else { // do recursive build on options. while (lp1 < (optList.Count - 1)) { mcList = BuildModelCodes(optList, lp1, "", "", mcList); lp1++; } } //Merge with existing models var templCtrl = new TemplateGetter(controlMapPath, controlMapPath); Repeater rpEntity; var strTemplate = templCtrl.GetTemplateData("AdminProducts_Models.html", Utils.GetCurrentCulture(), true, true, true, StoreSettings.Current.Settings()); // remove models no longer needed XmlNodeList nodes = objInfo.XMLDoc.SelectNodes("genxml/models/genxml"); for (int i = nodes.Count - 1; i >= 0; i--) { var mCode = nodes[i].SelectSingleNode("hidden/modelcode"); if (mCode != null) { if (!mcList.Contains(mCode.InnerText)) { var parentNode = nodes[i].ParentNode; if (parentNode != null) { parentNode.RemoveChild(nodes[i]); } } } else { // no modelcode, invalid, so remove var parentNode = nodes[i].ParentNode; if (parentNode != null) { parentNode.RemoveChild(nodes[i]); } } } // save changes back to the product object objInfo.XMLData = objInfo.XMLDoc.OuterXml; // add new models var idx = 0; foreach (var modelCode in mcList) { if (objInfo.XMLDoc.SelectSingleNode("genxml/models/genxml/hidden/modelcode[.='" + modelCode + "']") == null) { var obj = new NBrightInfo(); rpEntity = GenXmlFunctions.InitRepeater(obj, strTemplate); GenXmlFunctions.SetHiddenField(rpEntity.Items[0], "modelcode", modelCode); GenXmlFunctions.SetHiddenField(rpEntity.Items[0], "entityindex", idx.ToString(CultureInfo.InvariantCulture)); var strXml = GenXmlFunctions.GetGenXml(rpEntity, 0); objInfo = AddEntity(objInfo, "models", 1, strXml); idx += 1; } } return(objInfo); }
public void DeleteCart() { //remove DB record var modCtrl = new NBrightBuyController(); modCtrl.Delete(_entryId); }
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()); } DealerRole = Get("dealerrole"); if (DealerRole == "") { DealerRole = "Dealer"; } }
protected override void OnInit(EventArgs e) { base.OnInit(e); LogOutput = new LogWriter("START: " + DateTime.Now); try { _modCtrl = new NBrightBuyController(); _ctrlkey = (String)HttpContext.Current.Session["nbrightbackofficectrl"]; #region "load templates" var t2 = "Importbody.html"; // Get Display Header var rpDataHTempl = GetTemplateData(t2); rpData.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataHTempl, StoreSettings.Current.Settings(), PortalSettings.HomeDirectory); #endregion } catch (Exception exc) { //display the error on the template (don;t want to log it here, prefer to deal with errors directly.) var l = new Literal(); l.Text = exc.ToString(); Controls.Add(l); } }
private List <GroupCategoryData> GetGrpCatListFromDatabase(String lang = "") { // this process seems to be creating an error on DB connection after the cache is release. //[TODO: re-write this code to stop DB conection failure. For now Module level caching has been increased to 2 days to stop this processing re-running] var objCtrl = new NBrightBuyController(); const string strOrderBy = " order by [XMLData].value('(genxml/hidden/recordsortorder)[1]','decimal(10,2)') "; var grpcatList = new List <GroupCategoryData>(); var l = objCtrl.GetList(_portalId, -1, "CATEGORY", "", strOrderBy, 0, 0, 0, 0, "", ""); var lg = objCtrl.GetList(_portalId, -1, "CATEGORYLANG", "and NB1.lang = '" + lang + "'", "", 0, 0, 0, 0, "", ""); var lx = objCtrl.GetList(_portalId, -1, "CATCASCADE", "", "", 0, 0, 0, 0, "", ""); var lx2 = objCtrl.GetList(_portalId, -1, "CATXREF", "", "", 0, 0, 0, 0, "", ""); lx.AddRange(lx2); foreach (var i in l) { var grpcat = new GroupCategoryData(); grpcat.categoryid = i.ItemID; grpcat.recordsortorder = i.GetXmlPropertyDouble("genxml/hidden/recordsortorder"); grpcat.imageurl = i.GetXmlProperty("genxml/hidden/imageurl"); grpcat.categoryref = i.GetXmlProperty("genxml/textbox/txtcategoryref"); grpcat.propertyref = i.GetXmlProperty("genxml/textbox/propertyref"); grpcat.archived = i.GetXmlPropertyBool("genxml/checkbox/chkarchived"); grpcat.ishidden = i.GetXmlPropertyBool("genxml/checkbox/chkishidden"); grpcat.disabled = i.GetXmlPropertyBool("genxml/checkbox/chkdisable"); grpcat.grouptyperef = i.GetXmlProperty("genxml/dropdownlist/ddlgrouptype"); grpcat.attributecode = i.GetXmlProperty("genxml/dropdownlist/ddlattrcode"); grpcat.parentcatid = i.ParentItemId; grpcat.entrycount = GetEntryCount(lx, grpcat.categoryid); if (GroupsDictionary.ContainsKey(grpcat.grouptyperef)) { grpcat.groupname = GroupsDictionary[grpcat.grouptyperef]; } // get the language data var langItem = GetLangData(lg, grpcat.categoryid); if (langItem != null) { grpcat.categoryname = langItem.GetXmlProperty("genxml/textbox/txtcategoryname"); grpcat.categorydesc = langItem.GetXmlProperty("genxml/textbox/txtcategorydesc"); grpcat.seoname = langItem.GetXmlProperty("genxml/textbox/txtseoname"); if (grpcat.seoname == "") { grpcat.seoname = langItem.GetXmlProperty("genxml/textbox/txtcategoryname"); } grpcat.metadescription = langItem.GetXmlProperty("genxml/textbox/txtmetadescription"); grpcat.metakeywords = langItem.GetXmlProperty("genxml/textbox/txtmetakeywords"); grpcat.seopagetitle = langItem.GetXmlProperty("genxml/textbox/txtseopagetitle"); grpcat.message = langItem.GetXmlProperty("genxml/edt/message"); grpcat.categoryrefGUIDKey = langItem.GUIDKey; } //get parents var p = GetParentList(l, grpcat.categoryid); foreach (var pi in p) { grpcat.Parents.Add(pi.ItemID); } grpcatList.Add(grpcat); } // we don;t have the depth number at this point, so use recussive call to calc it. CalcCategoryDepthList(grpcatList, 0, 0); return(grpcatList); }
/// <summary> /// Save cart /// </summary> public void Save(Boolean debugMode = false) { //save cart var strXML = "<list>"; var lp = 0; foreach (var info in _shippingList) { info.SetXmlProperty("genxml/hidden/index",lp.ToString("D")); strXML += info.XMLData; lp += 1; } strXML += "</list>"; Info.RemoveXmlNode("genxml/list"); Info.AddXmlNode(strXML, "list", "genxml"); if (Info != null) { var modCtrl = new NBrightBuyController(); Info.ItemID = modCtrl.Update(Info); } }
private void AddNewImage(int itemId,String imageurl, String imagepath) { var objCtrl = new NBrightBuyController(); var dataRecord = objCtrl.Get(itemId); if (dataRecord != null) { var strXml = "<genxml><imgs><genxml><hidden><imagepath>" + imagepath + "</imagepath><imageurl>" + imageurl + "</imageurl></hidden></genxml></imgs></genxml>"; if (dataRecord.XMLDoc.SelectSingleNode("genxml/imgs") == null) { dataRecord.AddXmlNode(strXml, "genxml/imgs", "genxml"); } else { dataRecord.AddXmlNode(strXml, "genxml/imgs/genxml", "genxml/imgs"); } objCtrl.Update(dataRecord); } }
private String GetProductListData(Dictionary<String, String> settings,bool paging = true) { var strOut = ""; if (!settings.ContainsKey("header")) settings.Add("header", ""); if (!settings.ContainsKey("body")) settings.Add("body", ""); if (!settings.ContainsKey("footer")) settings.Add("footer", ""); if (!settings.ContainsKey("filter")) settings.Add("filter", ""); if (!settings.ContainsKey("orderby")) settings.Add("orderby", ""); if (!settings.ContainsKey("returnlimit")) settings.Add("returnlimit", "0"); if (!settings.ContainsKey("pagenumber")) settings.Add("pagenumber", "0"); if (!settings.ContainsKey("pagesize")) settings.Add("pagesize", "0"); if (!settings.ContainsKey("searchtext")) settings.Add("searchtext", ""); if (!settings.ContainsKey("searchcategory")) settings.Add("searchcategory", ""); if (!settings.ContainsKey("cascade")) settings.Add("cascade", "False"); var header = settings["header"]; var body = settings["body"]; var footer = settings["footer"]; var filter = settings["filter"]; var orderby = settings["orderby"]; var returnLimit = Convert.ToInt32(settings["returnlimit"]); var pageNumber = Convert.ToInt32(settings["pagenumber"]); var pageSize = Convert.ToInt32(settings["pagesize"]); var cascade = Convert.ToBoolean(settings["cascade"]); var searchText = settings["searchtext"]; var searchCategory = settings["searchcategory"]; if (searchText != "") filter += " and (NB3.[ProductName] like '%" + searchText + "%' or NB3.[ProductRef] like '%" + searchText + "%' or NB3.[Summary] like '%" + searchText + "%' ) "; if (Utils.IsNumeric(searchCategory)) { if (orderby == "{bycategoryproduct}") orderby += searchCategory; var objQual = DataProvider.Instance().ObjectQualifier; var dbOwner = DataProvider.Instance().DatabaseOwner; if (!cascade) filter += " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where typecode = 'CATXREF' and XrefItemId = " + searchCategory + ") "; else filter += " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where (typecode = 'CATXREF' and XrefItemId = " + searchCategory + ") or (typecode = 'CATCASCADE' and XrefItemId = " + searchCategory + ")) "; } else { if (orderby == "{bycategoryproduct}") orderby = " order by NB3.productname "; } var recordCount = 0; var themeFolder = StoreSettings.Current.ThemeFolder; if (settings.ContainsKey("themefolder")) themeFolder = settings["themefolder"]; var templCtrl = NBrightBuyUtils.GetTemplateGetter(themeFolder); if (!settings.ContainsKey("portalid")) settings.Add("portalid", PortalSettings.Current.PortalId.ToString("")); // aways make sure we have portalid in settings var objCtrl = new NBrightBuyController(); var headerTempl = templCtrl.GetTemplateData(header, _lang, true, true, true, StoreSettings.Current.Settings()); var bodyTempl = templCtrl.GetTemplateData(body, _lang, true, true, true, StoreSettings.Current.Settings()); var footerTempl = templCtrl.GetTemplateData(footer, _lang, true, true, true, StoreSettings.Current.Settings()); // replace any settings tokens (This is used to place the form data into the SQL) headerTempl = Utils.ReplaceSettingTokens(headerTempl, settings); headerTempl = Utils.ReplaceUrlTokens(headerTempl); bodyTempl = Utils.ReplaceSettingTokens(bodyTempl, settings); bodyTempl = Utils.ReplaceUrlTokens(bodyTempl); footerTempl = Utils.ReplaceSettingTokens(footerTempl, settings); footerTempl = Utils.ReplaceUrlTokens(footerTempl); var obj = new NBrightInfo(true); strOut = GenXmlFunctions.RenderRepeater(obj, headerTempl); if (paging) // get record count for paging { if (pageNumber == 0) pageNumber = 1; if (pageSize == 0) pageSize = StoreSettings.Current.GetInt("pagesize"); recordCount = objCtrl.GetListCount(PortalSettings.Current.PortalId, -1, "PRD", filter,"PRDLANG",_lang); } var objList = objCtrl.GetDataList(PortalSettings.Current.PortalId, -1, "PRD", "PRDLANG", _lang, filter, orderby, StoreSettings.Current.DebugMode,"",returnLimit,pageNumber,pageSize,recordCount); strOut += GenXmlFunctions.RenderRepeater(objList, bodyTempl); strOut += GenXmlFunctions.RenderRepeater(obj, footerTempl); // add paging if needed if (paging) { var pg = new NBrightCore.controls.PagingCtrl(); strOut += pg.RenderPager(recordCount, pageSize, pageNumber); } return strOut; }
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 String MoveProductAdmin(HttpContext context) { try { //get uploaded params var settings = GetAjaxFields(context); if (!settings.ContainsKey("moveproductid")) settings.Add("moveproductid", "0"); var moveproductid = settings["moveproductid"]; if (!settings.ContainsKey("movetoproductid")) settings.Add("movetoproductid", "0"); var movetoproductid = settings["movetoproductid"]; if (!settings.ContainsKey("searchcategory")) settings.Add("searchcategory", "0"); var searchcategory = settings["searchcategory"]; var objCtrl = new NBrightBuyController(); objCtrl.GetListCustom(PortalSettings.Current.PortalId, -1, "NBrightBuy_MoveProductinCateogry", 0, "", searchcategory + ";" + moveproductid + ";" + movetoproductid); DataCache.ClearCache(); return GetProductListData(settings); } catch (Exception ex) { return ex.ToString(); } }
/// <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 deleted = 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")) { var sysrecord = objCtrl.GetByGuidKey(99999, -1, "PLUGIN", nbi2.GUIDKey); objCtrl.Delete(existingrecord.ItemID); objCtrl.Delete(sysrecord.ItemID); File.Delete(f); deleted = true; } else { objCtrl.Update(nbi2); updated = true; } } else { objCtrl.Update(nbi2); updated = true; } } } if (updated) { File.Delete(f); //load entity typecode to DB idx settings. NBrightBuyUtils.RegisterEnityTypeToDataBase(); } } catch (Exception) { // data might not be XML complient (ignore) } } } } if (updated || deleted) { if (updated) { CopySystemPluginsToPortal(); } if (deleted) { DotNetNuke.Common.Utilities.DataCache.ClearCache(); } ClearPluginCache(PortalSettings.Current.PortalId); } }
public void ProcessRequest(HttpContext context) { #region "Initialize" var strOut = ""; var paramCmd = Utils.RequestQueryStringParam(context, "cmd"); var itemId = Utils.RequestQueryStringParam(context, "itemid"); var ctlType = Utils.RequestQueryStringParam(context, "ctltype"); var idXref = Utils.RequestQueryStringParam(context, "idxref"); var xpathpdf = Utils.RequestQueryStringParam(context, "pdf"); var xpathref = Utils.RequestQueryStringParam(context, "pdfref"); var lang = Utils.RequestQueryStringParam(context, "lang"); var language = Utils.RequestQueryStringParam(context, "language"); var moduleId = Utils.RequestQueryStringParam(context, "mid"); var moduleKey = Utils.RequestQueryStringParam(context, "mkey"); var parentid = Utils.RequestQueryStringParam(context, "parentid"); var entryid = Utils.RequestQueryStringParam(context, "entryid"); var entryxid = Utils.RequestQueryStringParam(context, "entryxid"); var catid = Utils.RequestQueryStringParam(context, "catid"); var catxid = Utils.RequestQueryStringParam(context, "catxid"); var templatePrefix = Utils.RequestQueryStringParam(context, "tprefix"); var value = Utils.RequestQueryStringParam(context, "value"); var itemListName = Utils.RequestQueryStringParam(context, "listname"); if (itemListName == "") itemListName = "ItemList"; if (itemListName == "*") itemListName = "ItemList"; #region "setup language" // because we are using a webservice the system current thread culture might not be set correctly, // so use the lang/lanaguge param to set it. if (lang == "") lang = language; if (!string.IsNullOrEmpty(lang)) _lang = lang; // default to current thread if we have no language. if (_lang == "") _lang = System.Threading.Thread.CurrentThread.CurrentCulture.ToString(); System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(_lang); #endregion #endregion #region "Do processing of command" var intModuleId = 0; if (Utils.IsNumeric(moduleId)) intModuleId = Convert.ToInt32(moduleId); var objCtrl = new NBrightBuyController(); var uInfo = new UserDataInfo(UserController.GetCurrentUserInfo().PortalID, intModuleId, objCtrl, ctlType); strOut = "ERROR!! - No Security rights for current user!"; switch (paramCmd) { case "test": strOut = "<root>" + UserController.GetCurrentUserInfo().Username + "</root>"; break; case "setdata": break; case "deldata": break; //case "setcategoryadminform": // if (CheckRights()) strOut = SetCategoryForm(context); // break; case "getdata": strOut = GetReturnData(context); break; case "additemlist": if (Utils.IsNumeric(itemId)) { var cw = new ItemListData(itemListName); cw.Add(itemId); strOut = cw.ItemList; } break; case "removeitemlist": if (Utils.IsNumeric(itemId)) { var cw1 = new ItemListData(itemListName); cw1.Remove(itemId); strOut = cw1.ItemList; } break; case "deleteitemlist": var cw2 = new ItemListData(itemListName); cw2.Delete(); strOut = "deleted"; break; case "getproductselectlist": strOut = GetProductList(context); break; case "getproductlist": strOut = GetProductList(context); break; case "getcategoryproductlist": strOut = GetCategoryProductList(context); break; case "setdefaultcategory": if (CheckRights()) strOut = SetDefaultCategory(context); break; case "deletecatxref": if (CheckRights()) strOut = DeleteCatXref(context); break; case "selectcatxref": if (CheckRights()) strOut = SelectCatXref(context); break; case "deleteallcatxref": if (CheckRights()) strOut = DeleteAllCatXref(context); break; case "copyallcatxref": if (CheckRights()) strOut = CopyAllCatXref(context); break; case "moveallcatxref": if (CheckRights()) strOut = CopyAllCatXref(context,true); break; case "editproduct": if (CheckRights()) strOut = GetProductGeneralData(context); break; case "productdescription": if (CheckRights()) strOut = GetProductDescription(context); break; case "productmodels": if (CheckRights()) strOut = GetProductModels(context); break; case "productoptions": if (CheckRights()) strOut = GetProductOptions(context); break; case "productoptionvalues": if (CheckRights()) strOut = GetProductOptionValues(context); break; case "productimages": if (CheckRights()) strOut = GetProductImages(context); break; case "productdocs": if (CheckRights()) strOut = GetProductDocs(context); break; case "productrelatedproducts": if (CheckRights()) strOut = GetProductModels(context); break; case "productcategories": if (CheckRights()) strOut = GetProductCategories(context); break; case "productisincategory": if (CheckRights()) strOut = ProductIsInCategory(context).ToString(); break; case "productgroupcategories": if (CheckRights()) strOut = GetProductGroupCategories(context); break; case "productrelated": if (CheckRights()) strOut = GetProductRelated(context); break; case "addproductmodels": if (CheckRights()) strOut = AddProductModels(context); break; case "addproductoptions": if (CheckRights()) strOut = AddProductOptions(context); break; case "addproductoptionvalues": if (CheckRights()) strOut = AddProductOptionValues(context); break; case "addproductcategory": if (CheckRights()) strOut = AddProductCategory(context); break; case "addproductgroupcategory": if (CheckRights()) strOut = AddProductGroupCategory(context); break; case "removeproductcategory": if (CheckRights()) strOut = RemoveProductCategory(context); break; case "removeproductgroupcategory": if (CheckRights()) strOut = RemoveProductGroupCategory(context); break; case "populatecategorylist": if (CheckRights()) strOut = GetGroupCategoryListBox(context); break; case "addrelatedproduct": if (CheckRights()) strOut = AddRelatedProduct(context); break; case "removerelatedproduct": if (CheckRights()) strOut = RemoveRelatedProduct(context); break; case "clientdiscountcodes": if (CheckRights()) strOut = GetClientDiscountCodes(context); break; case "addclientdiscountcode": if (CheckRights()) strOut = AddClientDiscountCodes(context); break; case "clientvouchercodes": if (CheckRights()) strOut = GetClientVoucherCodes(context); break; case "addclientvouchercode": if (CheckRights()) strOut = AddClientVoucherCodes(context); break; case "moveproductadmin": if (CheckRights()) strOut = MoveProductAdmin(context); break; case "fileupload": if (CheckRights() && Utils.IsNumeric(itemId)) { strOut = FileUpload(context); } break; case "updateproductimages": if (CheckRights()) { UpdateProductImages(context); strOut = GetProductImages(context); } break; } #endregion #region "return results" //send back xml as plain text context.Response.Clear(); context.Response.ContentType = "text/plain"; context.Response.Write(strOut); context.Response.End(); #endregion }
private void Createmodelslist(Control container, XmlNode xmlNod) { if (xmlNod.Attributes != null && (xmlNod.Attributes["template"] != null)) { var templName = xmlNod.Attributes["template"].Value; var buyCtrl = new NBrightBuyController(); var rpTempl = buyCtrl.GetTemplateData(-1, templName, Utils.GetCurrentCulture(), _settings, StoreSettings.Current.DebugMode); //remove templName from template, so we don't get a loop. if (rpTempl.Contains(templName)) rpTempl = rpTempl.Replace(templName, ""); var rpt = new Repeater { ItemTemplate = new GenXmlTemplate(rpTempl, _settings,visibleStatus) }; rpt.Init += ModelslistInit; // databind causes infinate loop container.Controls.Add(rpt); } }
private string DeleteAllCatXref(HttpContext context) { var strOut = NBrightBuyUtils.GetResxMessage("general_fail"); try { var settings = GetAjaxFields(context); if (settings.ContainsKey("itemid")) { var strFilter = " and XrefItemId = {Settings:itemid} "; strFilter = Utils.ReplaceSettingTokens(strFilter, settings); var objCtrl = new NBrightBuyController(); var objList = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "CATXREF", strFilter); foreach (var obj in objList) { DeleteCatXref(settings["itemid"], obj.ParentItemId.ToString("")); } strOut = NBrightBuyUtils.GetResxMessage(); } } catch (Exception e) { return e.ToString(); } return strOut; }
/// <summary> /// Return a list of category ids for all the valid categories for a given product list (selected by a categoryid) /// </summary> /// <param name="categoryId"></param> /// <returns></returns> private List<int> GetCateoriesInProductList(int categoryId) { var objQual = DotNetNuke.Data.DataProvider.Instance().ObjectQualifier; var dbOwner = DotNetNuke.Data.DataProvider.Instance().DatabaseOwner; var objCtrl = new NBrightBuyController(); var strXML = objCtrl.GetSqlxml("select distinct XrefItemId from " + dbOwner + "[" + objQual + "NBrightBuy] where (typecode = 'CATCASCADE' or typecode = 'CATXREF') and parentitemid in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where (typecode = 'CATCASCADE' or typecode = 'CATXREF') and XrefItemId in (" + categoryId + ")) for xml raw "); // get returned XML into generic List var xmlDoc = new XmlDocument(); xmlDoc.LoadXml("<root>" + strXML + "</root>"); var nList = xmlDoc.SelectNodes("root/row"); var rtnList = new List<int>(); foreach (XmlNode n in nList) { if (n.Attributes["XrefItemId"].Value != null && Utils.IsNumeric(n.Attributes["XrefItemId"].Value)) { rtnList.Add(Convert.ToInt32(n.Attributes["XrefItemId"].Value)); } } return rtnList; }