/// <summary> /// Save cart /// </summary> public void Save(Boolean debugMode = false) { if (Info != null) { Info.RemoveXmlNode("genxml/docs"); var strDocs = "<docs>"; foreach (var d in DocList) { var nbi = d.Value; if (nbi.XMLData != "") { strDocs += nbi.XMLData; } } strDocs += "</docs>"; Info.AddXmlNode(strDocs, "docs", "genxml"); var modCtrl = new NBrightBuyController(); Info.ItemID = modCtrl.Update(Info); if (StoreSettings.Current.DebugModeFileOut) { Info.XMLDoc.Save(PortalSettings.Current.HomeDirectoryMapPath + "debug_userdata.xml"); } Exists = true; } }
public void AddInterface() { var objCtrl = new NBrightBuyController(); _pluginInfo.AddXmlNode("<genxml></genxml>", "genxml", "genxml/interfaces"); objCtrl.Update(_pluginInfo); }
public void AddNewDiscountCode(String xmldata = "") { if (xmldata == "") { xmldata = "<genxml><discountcodes><genxml><textbox><coderef>" + Utils.GetUniqueKey().ToUpper() + "</coderef></textbox></genxml></discountcodes></genxml>"; } if (!xmldata.StartsWith("<genxml><discountcodes>")) { xmldata = "<genxml><discountcodes>" + xmldata + "</discountcodes></genxml>"; } if (DataRecord.XMLDoc.SelectSingleNode("genxml/discountcodes") == null) { DataRecord.AddXmlNode(xmldata, "genxml/discountcodes", "genxml"); } else { DataRecord.AddXmlNode(xmldata, "genxml/discountcodes/genxml", "genxml/discountcodes"); } DiscountCodes = GetEntityList("discountcodes"); }
/// <summary> /// Save cart /// </summary> public void Save(Boolean debugMode = false) { //save cart var strXML = "<list>"; var lp = 0; foreach (var info in _discountcodesList) { 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 static NBrightInfo UpdateLangNodeFields(String xmlname, NBrightInfo baseInfo, NBrightInfo dlang) { var nodList3I = baseInfo.XMLDoc.SelectNodes("genxml/" + xmlname + "/genxml"); if (nodList3I != null) { for (int i = 1; i <= nodList3I.Count; i++) { var nodList3 = baseInfo.XMLDoc.SelectNodes("genxml/" + xmlname + "/genxml[" + i + "]/textbox/*"); if (nodList3 != null) { foreach (XmlNode nod in nodList3) { if (nod.InnerText.Trim() != "") { if (dlang.GetXmlProperty("genxml/" + xmlname + "/genxml[" + i + "]/textbox/" + nod.Name) == "") { if (dlang.XMLDoc.SelectSingleNode("genxml/" + xmlname + "/genxml[" + i + "]") == null) { var baseXml = baseInfo.XMLDoc.SelectSingleNode("genxml/" + xmlname + "/genxml[" + i + "]"); if (baseXml != null) { if (dlang.XMLDoc.SelectSingleNode("genxml/" + xmlname) == null) { dlang.AddSingleNode(xmlname, "", "genxml"); } dlang.AddXmlNode(baseXml.OuterXml, "genxml", "genxml/" + xmlname); } } dlang.SetXmlProperty("genxml/" + xmlname + "/genxml[" + i + "]/textbox/" + nod.Name, nod.InnerText); } } } } } } return(dlang); }
/// <summary> /// Save cart /// </summary> public void Save(Boolean portallevelsave = true) { //save cart var strXml = "<plugin>"; var lp = 0; foreach (var info in _pluginList) { info.SetXmlProperty("genxml/hidden/index", lp.ToString(""), TypeCode.String, false); info.SetXmlProperty("genxml/textbox/ctrl", info.GetXmlProperty("genxml/textbox/ctrl").Trim().ToLower()); strXml += info.XMLData; lp += 1; } strXml += "</plugin>"; var nbi = new NBrightInfo(true); nbi.RemoveXmlNode("genxml/plugin"); nbi.AddXmlNode(strXml, "plugin", "genxml"); _templCtrl.SaveTemplate("menuplugin.xml", nbi.XMLData, portallevelsave); NBrightBuyUtils.RemoveModCache(0); Load(); // reload newly created plugin file, to ensure cache and pluigin list is correct. }
public void Update(NBrightInfo info) { // build list of xpath fields that need processing. var updatefields = new List <String>(); var fieldList = NBrightBuyUtils.GetAllFieldxPaths(info); foreach (var xpath in fieldList) { if (info.GetXmlProperty(xpath + "/@update") == "lang") { updatefields.Add(xpath); } } foreach (var f in updatefields) { if (f.EndsWith("/message")) { // special processing for editor, to place code in standard place. if (DataLangRecord.XMLDoc.SelectSingleNode("genxml/edt") == null) { DataLangRecord.AddSingleNode("edt", "", "genxml"); } if (info.GetXmlProperty("genxml/textbox/message") == "") { DataLangRecord.SetXmlProperty("genxml/edt/message", info.GetXmlPropertyRaw("genxml/edt/message")); } else { DataLangRecord.SetXmlProperty("genxml/edt/message", info.GetXmlPropertyRaw("genxml/textbox/message")); // ajax on ckeditor (Ajax diesn't work for telrik) } } else { DataLangRecord.RemoveXmlNode(f); var xpathDest = f.Split('/'); if (xpathDest.Count() >= 2) { DataLangRecord.AddXmlNode(info.XMLData, f, xpathDest[0] + "/" + xpathDest[1]); } } var datatype = info.GetXmlProperty(f + "/@datatype"); if (datatype == "date") { DataLangRecord.SetXmlProperty(f, info.GetXmlProperty(f), TypeCode.DateTime); } else if (datatype == "double") { DataLangRecord.SetXmlPropertyDouble(f, info.GetXmlProperty(f)); } else if (datatype == "html") { DataLangRecord.SetXmlProperty(f, info.GetXmlPropertyRaw(f)); } else { DataLangRecord.SetXmlProperty(f, info.GetXmlProperty(f).Trim()); } DataRecord.RemoveXmlNode(f); } updatefields = new List <String>(); fieldList = NBrightBuyUtils.GetAllFieldxPaths(info); foreach (var xpath in fieldList) { var id = xpath.Split('/').Last(); if (info.GetXmlProperty(xpath + "/@update") == "save") { updatefields.Add(xpath); } } foreach (var f in updatefields) { var datatype = info.GetXmlProperty(f + "/@datatype"); if (datatype == "date") { DataRecord.SetXmlProperty(f, info.GetXmlProperty(f), TypeCode.DateTime); } else if (datatype == "double") { DataRecord.SetXmlPropertyDouble(f, info.GetXmlProperty(f)); } else if (datatype == "html") { DataRecord.SetXmlProperty(f, info.GetXmlPropertyRaw(f)); } else { DataRecord.SetXmlProperty(f, info.GetXmlProperty(f)); } // if we have a image field then we need to create the imageurl field if (info.GetXmlProperty(f.Replace("textbox/", "hidden/hidinfo")) == "Img=True") { DataRecord.SetXmlProperty(f.Replace("textbox/", "hidden/") + "url", StoreSettings.Current.FolderImages + "/" + info.GetXmlProperty(f.Replace("textbox/", "hidden/hid"))); DataRecord.SetXmlProperty(f.Replace("textbox/", "hidden/") + "path", StoreSettings.Current.FolderImagesMapPath + "\\" + info.GetXmlProperty(f.Replace("textbox/", "hidden/hid"))); } if (f == "genxml/dropdownlist/ddlparentcatid") { var parentitemid = info.GetXmlProperty(f); if (!Utils.IsNumeric(parentitemid)) { parentitemid = "0"; } if (DataRecord.ParentItemId != Convert.ToInt32(parentitemid)) { _oldcatcascadeid = DataRecord.ParentItemId; _doCascadeIndex = true; DataRecord.ParentItemId = Convert.ToInt32(parentitemid); } } DataLangRecord.RemoveXmlNode(f); } }
public String AddSingleItem(String strproductid, String strmodelId, String strqtyId, NBrightInfo objInfoIn, Boolean debugMode = false, int replaceIndex = -1) { if (!Utils.IsNumeric(strqtyId) || Convert.ToInt32(strqtyId) <= 0) return ""; if (StoreSettings.Current.DebugModeFileOut) objInfoIn.XMLDoc.Save(PortalSettings.Current.HomeDirectoryMapPath + "debug_addtobasket.xml"); var objInfo = new NBrightInfo(); objInfo.XMLData = "<genxml></genxml>"; // get productid if (Utils.IsNumeric(strproductid)) { var itemcode = ""; // The itemcode var is used to decide if a cart item is new or already existing in the cart. var productData = ProductUtils.GetProductData(Convert.ToInt32(strproductid), Utils.GetCurrentCulture()); if (productData.Info == null) return ""; // we may have a invalid productid that has been saved by a cookie, but since has been deleted. var modelInfo = productData.GetModel(strmodelId); if (modelInfo == null) return ""; // no valid model objInfo.AddSingleNode("productid", strproductid, "genxml"); itemcode += strproductid + "-"; objInfo.AddSingleNode("modelid", strmodelId, "genxml"); itemcode += strmodelId + "-"; // Get Qty objInfo.AddSingleNode("qty", strqtyId, "genxml"); #region "Get model and product data" objInfo.AddSingleNode("productname", productData.Info.GetXmlPropertyRaw("genxml/lang/genxml/textbox/txtproductname"), "genxml"); objInfo.AddSingleNode("summary", productData.Info.GetXmlPropertyRaw("genxml/lang/genxml/textbox/txtsummary"), "genxml"); objInfo.AddSingleNode("modelref", modelInfo.GetXmlPropertyRaw("genxml/textbox/txtmodelref"), "genxml"); objInfo.AddSingleNode("modeldesc", modelInfo.GetXmlPropertyRaw("genxml/lang/genxml/textbox/txtmodelname"), "genxml"); objInfo.AddSingleNode("modelextra", modelInfo.GetXmlPropertyRaw("genxml/lang/genxml/textbox/txtextra"), "genxml"); objInfo.AddSingleNode("unitcost", modelInfo.GetXmlPropertyRaw("genxml/textbox/txtunitcost"), "genxml"); objInfo.AddSingleNode("dealercost", modelInfo.GetXmlPropertyRaw("genxml/textbox/txtdealercost"), "genxml"); objInfo.AddSingleNode("taxratecode", modelInfo.GetXmlPropertyRaw("genxml/dropdownlist/taxrate"), "genxml"); objInfo.AddSingleNode("saleprice", modelInfo.GetXmlPropertyRaw("genxml/textbox/txtsaleprice"), "genxml"); objInfo.AddSingleNode("basecost", modelInfo.GetXmlPropertyRaw("genxml/textbox/txtunitcost"), "genxml"); // flag if dealer var userInfo = UserController.Instance.GetCurrentUserInfo(); if (userInfo != null && userInfo.IsInRole(StoreSettings.DealerRole) && StoreSettings.Current.Get("enabledealer") == "True") objInfo.SetXmlProperty("genxml/isdealer", "True"); else objInfo.SetXmlProperty("genxml/isdealer", "False"); //move all product and model data into cart item, so we can display bespoke fields. objInfo.AddSingleNode("productxml", productData.Info.XMLData, "genxml"); #endregion #region "Get option Data" //build option data for cart Double additionalCosts = 0; var strXmlIn = ""; var optionDataList = new Dictionary<String, String>(); if (objInfoIn.XMLDoc != null) { var nodList = objInfoIn.XMLDoc.SelectNodes("genxml/textbox/*[starts-with(name(), 'optiontxt')]"); if (nodList != null) foreach (XmlNode nod in nodList) { strXmlIn = "<option>"; var idx = nod.Name.Replace("optiontxt", ""); var optionid = objInfoIn.GetXmlProperty("genxml/hidden/optionid" + idx); var optionInfo = productData.GetOption(optionid); var optvaltext = nod.InnerText; strXmlIn += "<optid>" + optionid + "</optid>"; strXmlIn += "<optvaltext>" + optvaltext + "</optvaltext>"; itemcode += optionid + "-" + Utils.GetUniqueKey() + "-"; strXmlIn += "<optname>" + optionInfo.GetXmlProperty("genxml/lang/genxml/textbox/txtoptiondesc") + "</optname>"; strXmlIn += "</option>"; if (!optionDataList.ContainsKey(idx)) optionDataList.Add(idx, strXmlIn); } nodList = objInfoIn.XMLDoc.SelectNodes("genxml/dropdownlist/*[starts-with(name(), 'optionddl')]"); if (nodList != null) foreach (XmlNode nod in nodList) { strXmlIn = "<option>"; var idx = nod.Name.Replace("optionddl", ""); var optionid = objInfoIn.GetXmlProperty("genxml/hidden/optionid" + idx); var optionvalueid = nod.InnerText; var optionValueInfo = productData.GetOptionValue(optionid, optionvalueid); var optionInfo = productData.GetOption(optionid); strXmlIn += "<optid>" + optionid + "</optid>"; strXmlIn += "<optvalueid>" + optionvalueid + "</optvalueid>"; itemcode += optionid + ":" + optionvalueid + "-"; strXmlIn += "<optname>" + optionInfo.GetXmlProperty("genxml/lang/genxml/textbox/txtoptiondesc") + "</optname>"; strXmlIn += "<optvalcost>" + optionValueInfo.GetXmlProperty("genxml/textbox/txtaddedcost") + "</optvalcost>"; strXmlIn += "<optvaltext>" + optionValueInfo.GetXmlProperty("genxml/lang/genxml/textbox/txtoptionvaluedesc") + "</optvaltext>"; strXmlIn += "</option>"; additionalCosts += optionValueInfo.GetXmlPropertyDouble("genxml/textbox/txtaddedcost"); if (!optionDataList.ContainsKey(idx)) optionDataList.Add(idx, strXmlIn); } nodList = objInfoIn.XMLDoc.SelectNodes("genxml/checkbox/*[starts-with(name(), 'optionchk')]"); if (nodList != null) foreach (XmlNode nod in nodList) { strXmlIn = "<option>"; var idx = nod.Name.Replace("optionchk", ""); var optionid = objInfoIn.GetXmlProperty("genxml/hidden/optionid" + idx); var optionvalueid = nod.InnerText; var optionValueInfo = productData.GetOptionValue(optionid, ""); // checkbox does not have optionvalueid var optionInfo = productData.GetOption(optionid); strXmlIn += "<optid>" + optionid + "</optid>"; strXmlIn += "<optvalueid>" + optionvalueid + "</optvalueid>"; itemcode += optionid + ":" + optionvalueid + "-"; strXmlIn += "<optname>" + optionInfo.GetXmlProperty("genxml/lang/genxml/textbox/txtoptiondesc") + "</optname>"; strXmlIn += "<optvalcost>" + optionValueInfo.GetXmlProperty("genxml/textbox/txtaddedcost") + "</optvalcost>"; strXmlIn += "<optvaltext>" + optionValueInfo.GetXmlProperty("genxml/lang/genxml/textbox/txtoptionvaluedesc") + "</optvaltext>"; strXmlIn += "</option>"; if (nod.InnerText.ToLower() == "true") additionalCosts += optionValueInfo.GetXmlPropertyDouble("genxml/textbox/txtaddedcost"); if (!optionDataList.ContainsKey(idx)) optionDataList.Add(idx, strXmlIn); } } // we need to save the options in the same order as in product, so index works correct on the template tokens. var strXmlOpt = "<options>"; for (int i = 1; i <= optionDataList.Count; i++) { if (optionDataList.ContainsKey(i.ToString(""))) { strXmlOpt += optionDataList[i.ToString("")]; } } strXmlOpt += "</options>"; objInfo.AddXmlNode(strXmlOpt, "options", "genxml"); #endregion //add additional costs from optionvalues (Add to both dealer and unit cost) if (additionalCosts > 0) { objInfo.SetXmlPropertyDouble("genxml/additionalcosts", additionalCosts); var uc = objInfo.GetXmlPropertyDouble("genxml/unitcost"); var dc = objInfo.GetXmlPropertyDouble("genxml/dealercost"); uc += additionalCosts; if (dc > 0) dc += additionalCosts; // only calc dealer cost if it's > zero (active) objInfo.SetXmlPropertyDouble("genxml/unitcost", uc); objInfo.SetXmlPropertyDouble("genxml/dealercost", dc); } objInfo.AddSingleNode("itemcode", itemcode.TrimEnd('-'), "genxml"); // check if we have a client file upload var clientfileuopload = objInfoIn.GetXmlProperty("genxml/textbox/optionfilelist") != ""; //replace the item if it's already in the list. var nodItem = PurchaseInfo.XMLDoc.SelectSingleNode("genxml/items/genxml[itemcode='" + itemcode.TrimEnd('-') + "']"); if (nodItem == null || clientfileuopload) { #region "Client Files" if (clientfileuopload) { // client has uploaded files, so save these to client upload folder and create link in cart data. var flist = objInfoIn.GetXmlProperty("genxml/textbox/optionfilelist").TrimEnd(','); var fprefix = objInfoIn.GetXmlProperty("genxml/hidden/optionfileprefix") + "_"; var fileXml = "<clientfiles>"; foreach (var f in flist.Split(',')) { var fullName = StoreSettings.Current.FolderTempMapPath.TrimEnd(Convert.ToChar("\\")) + "\\" + fprefix + f; var extension = Path.GetExtension(fullName); if (File.Exists(fullName)) { var newDocFileName = StoreSettings.Current.FolderClientUploadsMapPath.TrimEnd(Convert.ToChar("\\")) + "\\" + Guid.NewGuid() + extension; File.Copy(fullName, newDocFileName, true); File.Delete(fullName); var docurl = StoreSettings.Current.FolderClientUploads.TrimEnd('/') + "/" + Path.GetFileName(newDocFileName); fileXml += "<file>"; fileXml += "<mappath>" + newDocFileName + "</mappath>"; fileXml += "<url>" + docurl + "</url>"; fileXml += "<name>" + f + "</name>"; fileXml += "<prefix>" + fprefix + "</prefix>"; fileXml += "</file>"; } } fileXml += "</clientfiles>"; objInfo.AddXmlNode(fileXml, "clientfiles", "genxml"); } #endregion if (replaceIndex >= 0 && replaceIndex < _itemList.Count) _itemList[replaceIndex] = objInfo; //replace else _itemList.Add(objInfo); //add as new item } else { //replace item var qty = nodItem.SelectSingleNode("qty"); if (qty != null && Utils.IsNumeric(qty.InnerText) && Utils.IsNumeric(strqtyId)) { var userqtylimit = objInfoIn.GetXmlPropertyInt("genxml/hidden/userqtylimit"); if (userqtylimit > 0 && Convert.ToInt32(qty.InnerText) >= userqtylimit) return ""; //add new qty and replace item PurchaseInfo.RemoveXmlNode("genxml/items/genxml[itemcode='" + itemcode.TrimEnd('-') + "']"); _itemList = GetCartItemList(); var newQty = Convert.ToString(Convert.ToInt32(qty.InnerText) + Convert.ToInt32(strqtyId)); objInfo.SetXmlProperty("genxml/qty", newQty, TypeCode.String, false); _itemList.Add(objInfo); } } //add nodes for any fields that might exist in cart template objInfo.AddSingleNode("textbox", "", "genxml"); objInfo.AddSingleNode("dropdownlist", "", "genxml"); objInfo.AddSingleNode("radiobuttonlist", "", "genxml"); objInfo.AddSingleNode("checkbox", "", "genxml"); SavePurchaseData(); // need to save after each add, so it exists in data when we check it already exists for updating. // return the message status code in textData, non-critical (usually empty) return objInfo.TextData; } return ""; }
private List<NBrightInfo> BuildModelList(NBrightInfo dataItemObj,Boolean addSalePrices = false) { // see if we have a cart record var xpathprefix = ""; var cartrecord = dataItemObj.GetXmlProperty("genxml/productid") != ""; // if we have a productid node, then is datarecord is a cart item if (cartrecord) xpathprefix = "genxml/productxml/"; //build models list var objL = new List<NBrightInfo>(); var nodList = dataItemObj.XMLDoc.SelectNodes(xpathprefix + "genxml/models/*"); if (nodList != null) { #region "Init" var isDealer = CmsProviderManager.Default.IsInRole(StoreSettings.DealerRole); #endregion var lp = 1; foreach (XmlNode nod in nodList) { // check if Deleted var selectDeletedFlag = nod.SelectSingleNode("checkbox/chkdeleted"); if ((selectDeletedFlag == null) || selectDeletedFlag.InnerText != "True") { // check if hidden var selectHiddenFlag = nod.SelectSingleNode("checkbox/chkishidden"); if ((selectHiddenFlag == null) || selectHiddenFlag.InnerText != "True") { // check if dealer var selectDealerFlag = nod.SelectSingleNode("checkbox/chkdealeronly"); if (((selectDealerFlag == null) || (!isDealer && (selectDealerFlag.InnerText != "True"))) | isDealer) { // get modelid var nodModelId = nod.SelectSingleNode("hidden/modelid"); var modelId = ""; if (nodModelId != null) modelId = nodModelId.InnerText; //Build NBrightInfo class for model var o = new NBrightInfo(); o.XMLData = nod.OuterXml; #region "Add Lanaguge Data" var nodLang = dataItemObj.XMLDoc.SelectSingleNode(xpathprefix + "genxml/lang/genxml/models/genxml[" + lp.ToString("") + "]"); if (nodLang != null) { o.AddSingleNode("lang", "", "genxml"); o.AddXmlNode(nodLang.OuterXml, "genxml", "genxml/lang"); } #endregion #region "Prices" if (addSalePrices) { var uInfo = UserController.GetCurrentUserInfo(); if (uInfo != null) { o.SetXmlPropertyDouble("genxml/hidden/saleprice", "-1"); // set to -1 so unitcost is displayed (turns off saleprice) //[TODO: convert to new promotion provider] //var objPromoCtrl = new PromoController(); //var objPCtrl = new ProductController(); //var objM = objPCtrl.GetModel(modelId, Utils.GetCurrentCulture()); //var salePrice = objPromoCtrl.GetSalePrice(objM, uInfo); //o.AddSingleNode("saleprice", salePrice.ToString(CultureInfo.GetCultureInfo("en-US")), "genxml/hidden"); } } #endregion // product data for display in modellist o.SetXmlProperty("genxml/lang/genxml/textbox/txtproductname", dataItemObj.GetXmlProperty(xpathprefix + "genxml/lang/genxml/textbox/txtproductname")); o.SetXmlProperty("genxml/textbox/txtproductref", dataItemObj.GetXmlProperty(xpathprefix + "genxml/textbox/txtproductref")); if (cartrecord) o.SetXmlProperty("genxml/hidden/productid", dataItemObj.GetXmlProperty("genxml/productid")); else o.SetXmlProperty("genxml/hidden/productid", dataItemObj.ItemID.ToString("")); objL.Add(o); } } } lp += 1; } } return objL; }
/// <summary> /// Save cart /// </summary> public void Save(Boolean portallevelsave = true) { //save cart var strXml = "<plugin>"; var lp = 0; foreach (var info in _pluginList) { info.SetXmlProperty("genxml/hidden/index", lp.ToString(""), TypeCode.String, false); info.SetXmlProperty("genxml/textbox/ctrl", info.GetXmlProperty("genxml/textbox/ctrl").Trim().ToLower()); strXml += info.XMLData; lp += 1; } strXml += "</plugin>"; var nbi = new NBrightInfo(true); nbi.RemoveXmlNode("genxml/plugin"); nbi.AddXmlNode(strXml, "plugin", "genxml"); _templCtrl.SaveTemplate("menuplugin.xml", nbi.XMLData, portallevelsave); NBrightBuyUtils.RemoveModCache(0); }
public List<NBrightInfo> GetOptionValuesById(String optionid) { var l = new List<NBrightInfo>(); if (Info != null) { var xmlNodList = Info.XMLDoc.SelectNodes("genxml/optionvalues[@optionid='" + optionid + "']/*"); if (xmlNodList != null && xmlNodList.Count > 0) { var lp = 1; foreach (XmlNode xNod in xmlNodList) { var obj = new NBrightInfo(); obj.XMLData = xNod.OuterXml; var nodLang = "<genxml>" + Info.GetXmlNode("genxml/lang/genxml/optionvalues[@optionid='" + optionid + "']/genxml[" + lp + "]") + "</genxml>"; if (nodLang != "") { obj.SetXmlProperty("genxml/hidden/productid", Info.ItemID.ToString("")); obj.SetXmlProperty("genxml/hidden/lang", Info.Lang.Trim()); obj.SetXmlProperty("genxml/hidden/optionid", optionid); var selectSingleNode = xNod.SelectSingleNode("hidden/optionvalueid"); if (selectSingleNode != null) obj.SetXmlProperty("genxml/hidden/optionvalueid", selectSingleNode.InnerText); obj.AddSingleNode("lang", "", "genxml"); obj.AddXmlNode(nodLang, "genxml", "genxml/lang"); } obj.ParentItemId = Info.ItemID; l.Add(obj); lp += 1; } } } return l; }
private List<NBrightInfo> GetEntityList(String entityName) { var l = new List<NBrightInfo>(); if (Info != null && Info.XMLDoc != null) { var xmlNodList = Info.XMLDoc.SelectNodes("genxml/" + entityName + "/*"); // build generic list to bind to rpModelsLang List if (xmlNodList != null && xmlNodList.Count > 0) { var lp = 1; foreach (XmlNode xNod in xmlNodList) { var obj = new NBrightInfo(); obj.XMLData = xNod.OuterXml; obj.ItemID = lp; obj.Lang = Info.Lang; var nodLang = "<genxml>" + Info.GetXmlNode("genxml/lang/genxml/" + entityName + "/genxml[" + lp.ToString("") + "]") + "</genxml>"; if (nodLang != "") { obj.AddSingleNode("lang", "", "genxml"); obj.AddXmlNode(nodLang, "genxml", "genxml/lang"); } obj.ParentItemId = Info.ItemID; l.Add(obj); lp += 1; } } } return l; }
/// <summary> /// Save cookie to client /// </summary> public void Save() { #region "Get temp filename" var tempfilename = ""; if (_storageType == DataStorageType.SessionMemory) { if (HttpContext.Current.Session[_cookieName + "tempname"] != null) tempfilename = (String) HttpContext.Current.Session[_cookieName + "tempname"]; } else { tempfilename = Cookie.GetCookieValue(_portalId, _cookieName, "tempname", ""); } if (tempfilename == "") tempfilename = Utils.GetUniqueKey(12); if (_storageType == DataStorageType.SessionMemory) { HttpContext.Current.Session[_cookieName + "tempname"] = tempfilename; } else { Cookie.SetCookieValue(_portalId, _cookieName, "tempname", tempfilename, 1, ""); } #endregion var nbi = new NBrightInfo(true); if (XmlData != "") nbi.XMLData = XmlData; nbi.SetXmlProperty("genxml/Criteria", _criteria); nbi.SetXmlProperty("genxml/PageModuleId", PageModuleId); nbi.SetXmlProperty("genxml/PageNumber", PageNumber); nbi.SetXmlProperty("genxml/PageName", PageName); nbi.SetXmlProperty("genxml/PageSize", PageSize); nbi.SetXmlProperty("genxml/OrderBy", OrderBy); nbi.SetXmlProperty("genxml/CategoryId", CategoryId.ToString("D")); nbi.SetXmlProperty("genxml/RecordCount", RecordCount); nbi.SetXmlProperty("genxml/Mode", Mode); nbi.SetXmlProperty("genxml/OrderByIdx", OrderByIdx); if (!String.IsNullOrEmpty(SearchFormData)) { nbi.RemoveXmlNode("genxml/SearchFormData"); nbi.SetXmlProperty("genxml/SearchFormData", "",TypeCode.String,false); nbi.AddXmlNode(SearchFormData,"genxml", "genxml/SearchFormData"); } var filePath = StoreSettings.Current.FolderTempMapPath + "\\" + tempfilename; Utils.SaveFile(filePath, nbi.XMLData); Exists = true; }
/// <summary> /// Save cookie to client /// </summary> public void Save() { #region "Get temp filename" var tempfilename = ""; if (_storageType == DataStorageType.SessionMemory) { if (HttpContext.Current.Session[_cookieName + "tempname"] != null) tempfilename = (String)HttpContext.Current.Session[_cookieName + "tempname"]; } else { tempfilename = Cookie.GetCookieValue(_portalId, _cookieName, "tempname", ""); } if (tempfilename == "") tempfilename = Utils.GetUniqueKey(12); if (_storageType == DataStorageType.SessionMemory) { HttpContext.Current.Session[_cookieName + "tempname"] = tempfilename; } else { Cookie.SetCookieValue(_portalId, _cookieName, "tempname", tempfilename, 1, ""); } #endregion var nbi = new NBrightInfo(true); if (XmlData != "") nbi.XMLData = XmlData; nbi.SetXmlProperty("genxml/Criteria", _criteria); nbi.SetXmlProperty("genxml/PageModuleId", PageModuleId); nbi.SetXmlProperty("genxml/PageNumber", PageNumber); nbi.SetXmlProperty("genxml/PageName", PageName); nbi.SetXmlProperty("genxml/PageSize", PageSize); nbi.SetXmlProperty("genxml/OrderBy", OrderBy); nbi.SetXmlProperty("genxml/CategoryId", CategoryId.ToString("D")); nbi.SetXmlProperty("genxml/RecordCount", RecordCount); nbi.SetXmlProperty("genxml/Mode", Mode); nbi.SetXmlProperty("genxml/OrderByIdx", OrderByIdx); nbi.SetXmlProperty("genxml/FilterPropertyList", FilterPropertyList); var filterCSV = ""; foreach (var f in _filterPropertiesByProduct) { filterCSV += f.ToString() + ","; } nbi.SetXmlProperty("genxml/filterpropertycsv", filterCSV.TrimEnd(',')); if (!String.IsNullOrEmpty(SearchFormData)) { nbi.RemoveXmlNode("genxml/SearchFormData"); nbi.SetXmlProperty("genxml/SearchFormData", "", TypeCode.String, false); nbi.AddXmlNode(SearchFormData, "genxml", "genxml/SearchFormData"); } var filePath = StoreSettings.Current.FolderTempMapPath + "\\" + tempfilename; try { Utils.SaveFile(filePath, nbi.XMLData); } catch (Exception e) { // this is because the file's in use sometimes // we call it bad luck in those cases } Exists = true; }
/// <summary> /// Save cookie to client /// </summary> public void Save() { #region "Get temp filename" var tempfilename = ""; if (_storageType == DataStorageType.SessionMemory) { if (HttpContext.Current.Session[_cookieName + "tempname"] != null) { tempfilename = (String)HttpContext.Current.Session[_cookieName + "tempname"]; } } else { tempfilename = Cookie.GetCookieValue(_portalId, _cookieName, "tempname", ""); } if (tempfilename == "") { tempfilename = Utils.GetUniqueKey(12); } if (_storageType == DataStorageType.SessionMemory) { HttpContext.Current.Session[_cookieName + "tempname"] = tempfilename; } else { Cookie.SetCookieValue(_portalId, _cookieName, "tempname", tempfilename, 1, ""); } #endregion var nbi = new NBrightInfo(true); if (XmlData != "") { nbi.XMLData = XmlData; } nbi.SetXmlProperty("genxml/Criteria", _criteria); nbi.SetXmlProperty("genxml/PageModuleId", PageModuleId); nbi.SetXmlProperty("genxml/PageNumber", PageNumber); nbi.SetXmlProperty("genxml/PageName", PageName); nbi.SetXmlProperty("genxml/PageSize", PageSize); nbi.SetXmlProperty("genxml/OrderBy", OrderBy); nbi.SetXmlProperty("genxml/CategoryId", CategoryId.ToString("D")); nbi.SetXmlProperty("genxml/RecordCount", RecordCount); nbi.SetXmlProperty("genxml/Mode", Mode); nbi.SetXmlProperty("genxml/OrderByIdx", OrderByIdx); if (!String.IsNullOrEmpty(SearchFormData)) { nbi.RemoveXmlNode("genxml/SearchFormData"); nbi.SetXmlProperty("genxml/SearchFormData", "", TypeCode.String, false); nbi.AddXmlNode(SearchFormData, "genxml", "genxml/SearchFormData"); } var filePath = StoreSettings.Current.FolderTempMapPath + "\\" + tempfilename; Utils.SaveFile(filePath, nbi.XMLData); Exists = true; }
private static NBrightInfo UpdateLangNodeFields(String xmlname, NBrightInfo baseInfo, NBrightInfo dlang) { var nodList3I = baseInfo.XMLDoc.SelectNodes("genxml/" + xmlname + "/genxml"); if (nodList3I != null) { for (int i = 1; i <= nodList3I.Count; i++) { var nodList3 = baseInfo.XMLDoc.SelectNodes("genxml/" + xmlname + "/genxml[" + i + "]/textbox/*"); if (nodList3 != null) { foreach (XmlNode nod in nodList3) { if (nod.InnerText.Trim() != "") { if (dlang.GetXmlProperty("genxml/" + xmlname + "/genxml[" + i + "]/textbox/" + nod.Name) == "") { if (dlang.XMLDoc.SelectSingleNode("genxml/" + xmlname + "/genxml[" + i + "]") == null) { var baseXml = baseInfo.XMLDoc.SelectSingleNode("genxml/" + xmlname + "/genxml[" + i + "]"); if (baseXml != null) { if (dlang.XMLDoc.SelectSingleNode("genxml/" + xmlname) == null) { dlang.AddSingleNode(xmlname, "", "genxml"); } dlang.AddXmlNode(baseXml.OuterXml, "genxml", "genxml/" + xmlname); } } dlang.SetXmlProperty("genxml/" + xmlname + "/genxml[" + i + "]/textbox/" + nod.Name, nod.InnerText); } } } } } } return dlang; }