public static String GetTemplateData(String templatename, NBrightInfo info) { var controlMapPath = HttpContext.Current.Server.MapPath("/DesktopModules/NBright/NBrightBuy/Providers/ManualPaymentProvider"); var templCtrl = new NBrightCore.TemplateEngine.TemplateGetter(PortalSettings.Current.HomeDirectoryMapPath, controlMapPath, "Themes\\config", ""); var templ = templCtrl.GetTemplateData(templatename, Utils.GetCurrentCulture()); var dic = new Dictionary <String, String>(); foreach (var d in StoreSettings.Current.Settings()) { dic.Add(d.Key, d.Value); } foreach (var d in info.ToDictionary()) { if (dic.ContainsKey(d.Key)) { dic[d.Key] = d.Value; } else { dic.Add(d.Key, d.Value); } } templ = Utils.ReplaceSettingTokens(templ, dic); templ = Utils.ReplaceUrlTokens(templ); return(templ); }
public static String GetTemplateData(String templatename, NBrightInfo pluginInfo) { var controlMapPath = HttpContext.Current.Server.MapPath("/DesktopModules/NBright/OS_SystemPay"); var templCtrl = new NBrightCore.TemplateEngine.TemplateGetter(PortalSettings.Current.HomeDirectoryMapPath, controlMapPath, "Themes\\config", ""); var templ = templCtrl.GetTemplateData(templatename, Utils.GetCurrentCulture()); templ = Utils.ReplaceSettingTokens(templ, pluginInfo.ToDictionary()); templ = Utils.ReplaceUrlTokens(templ); return(templ); }
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"], _uilang, true, true, true, StoreSettings.Current.Settings()); var xslTemp = templCtrl.GetTemplateData(settings["xsltpl"], _uilang, 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 static String RenderPluginAdminList(List <NBrightInfo> list, NBrightInfo ajaxInfo, int recordCount) { try { if (NBrightBuyUtils.CheckRights()) { if (list == null) { return(""); } var strOut = ""; // select a specific entity data type for the product (used by plugins) var themeFolder = ajaxInfo.GetXmlProperty("genxml/hidden/themefolder"); if (themeFolder == "") { themeFolder = "config"; } var razortemplate = ajaxInfo.GetXmlProperty("genxml/hidden/razortemplate"); if (razortemplate == "") { razortemplate = "Admin_pluginsList.cshtml"; } var passSettings = new Dictionary <string, string>(); foreach (var s in ajaxInfo.ToDictionary()) { if (!passSettings.ContainsKey(s.Key)) { passSettings.Add(s.Key, s.Value); } } foreach (var s in StoreSettings.Current.Settings()) // copy store setting, otherwise we get a byRef assignement { if (passSettings.ContainsKey(s.Key)) { passSettings[s.Key] = s.Value; } else { passSettings.Add(s.Key, s.Value); } } strOut = NBrightBuyUtils.RazorTemplRenderList(razortemplate, 0, "", list, TemplateRelPath, themeFolder, Utils.GetCurrentCulture(), passSettings); return(strOut); } return(""); } catch (Exception ex) { return(ex.ToString()); } }
private Dictionary <String, String> GetAjaxFields(HttpContext context) { 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 dic = objInfo.ToDictionary(); return(dic); }
public static String GetTemplateData(String templatename, NBrightInfo info) { var controlMapPath = HttpContext.Current.Server.MapPath("/DesktopModules/NBright/NBrightBuy/Providers/ManualPaymentProvider"); var templCtrl = new NBrightCore.TemplateEngine.TemplateGetter(PortalSettings.Current.HomeDirectoryMapPath, controlMapPath, "Themes\\config", ""); var templ = templCtrl.GetTemplateData(templatename, Utils.GetCurrentCulture()); var dic = new Dictionary<String, String>(); foreach (var d in StoreSettings.Current.Settings()) { dic.Add(d.Key,d.Value); } foreach (var d in info.ToDictionary()) { if (dic.ContainsKey(d.Key)) dic[d.Key] = d.Value; else dic.Add(d.Key, d.Value); } templ = Utils.ReplaceSettingTokens(templ, dic); templ = Utils.ReplaceUrlTokens(templ); return templ; }
private NBrightInfo GetAjaxFields(HttpContext context) { 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 dic = objInfo.ToDictionary(); // set langauge if we have it passed. if (dic.ContainsKey("lang") && dic["lang"] != "") { _lang = dic["lang"]; } // set the context culturecode, so any DNN functions use the correct culture (entryurl tag token) if (_lang != "" && _lang != System.Threading.Thread.CurrentThread.CurrentCulture.ToString()) { System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(_lang); } return(objInfo); }
private Dictionary<String, String> GetAjaxFields(HttpContext context) { 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 dic = objInfo.ToDictionary(); // set langauge if we have it passed. if (dic.ContainsKey("lang") && dic["lang"] != "") _lang = dic["lang"]; // set the context culturecode, so any DNN functions use the correct culture (entryurl tag token) if (_lang != "" && _lang != System.Threading.Thread.CurrentThread.CurrentCulture.ToString()) System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(_lang); return dic; }
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(); } }
private void UpdateRecord() { var xmlData = GenXmlFunctions.GetGenXml(rpData, "", StoreSettings.Current.FolderImagesMapPath); var objInfo = new NBrightInfo(); objInfo.ItemID = -1; objInfo.TypeCode = "POSTDATA"; objInfo.XMLData = xmlData; var settings = objInfo.ToDictionary(); // put the fieds into a dictionary, so we can get them easy. // check we don't have an invalid parentitemid var parentitemid = objInfo.GetXmlPropertyInt("genxml/dropdownlist/ddlparentcatid"); var strOut = "No Category ID ('itemid' hidden fields needed on input form)"; if (settings.ContainsKey("itemid")) { if (parentitemid != Convert.ToInt32(settings["itemid"])) { var catData = CategoryUtils.GetCategoryData(Convert.ToInt32(settings["itemid"]), StoreSettings.Current.EditLanguage); // check we've not put a category under it's child if (IsParentInChildren(catData, parentitemid)) { NBrightBuyUtils.SetNotfiyMessage(ModuleId, "categoryactionsave", NotifyCode.fail); } else { var catDirectList = catData.GetDirectArticles(); var oldparentitemId = catData.ParentItemId; if (parentitemid != oldparentitemId) { // remove articles for category, so we realign the cascade records. foreach (var p in catDirectList) { var prdData = new ProductData(p.ParentItemId, p.PortalId, p.Lang); prdData.RemoveCategory(catData.CategoryId); } } catData.Update(objInfo); if (!String.IsNullOrEmpty(Edittype) && Edittype.ToLower() == "group") { var grptype = objInfo.GetXmlProperty("genxml/dropdownlist/ddlparentcatid"); var grp = ModCtrl.GetByGuidKey(PortalSettings.PortalId, -1, "GROUP", grptype); if (grp != null) { var newGuidKey = objInfo.GetXmlProperty("genxml/textbox/propertyref"); if (newGuidKey != "") { newGuidKey = GetUniqueGuidKey(catData.CategoryId, Utils.UrlFriendly(newGuidKey)); } catData.DataRecord.GUIDKey = newGuidKey; catData.DataRecord.SetXmlProperty("genxml/textbox/txtcategoryref", newGuidKey); catData.DataRecord.ParentItemId = grp.ItemID; // list done using ddlgrouptype, in GetCatList catData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlgrouptype", grptype); catData.Save(); NBrightBuyUtils.RemoveModCachePortalWide(PortalId); } } else { // the base category ref cannot have language dependant refs, we therefore just use a unique key var catref = catData.DataRecord.GetXmlProperty("genxml/textbox/txtcategoryref"); if (catref == "") { if (catData.DataRecord.GUIDKey == "") { catref = Utils.GetUniqueKey().ToLower(); catData.DataRecord.SetXmlProperty("genxml/textbox/txtcategoryref", catref); catData.DataRecord.GUIDKey = catref; } else { catData.DataRecord.SetXmlProperty("genxml/textbox/txtcategoryref", catData.DataRecord.GUIDKey); } } catData.Save(); CategoryUtils.ValidateLangaugeRef(PortalId, Convert.ToInt32(settings["itemid"])); // do validate so we update all refs and children refs NBrightBuyUtils.RemoveModCachePortalWide(PortalId); } if (parentitemid != oldparentitemId) { // all all articles for category. so we realign the cascade records. foreach (var p in catDirectList) { var prdData = new ProductData(p.ParentItemId, p.PortalId, p.Lang); prdData.AddCategory(catData.CategoryId); } } NBrightBuyUtils.SetNotfiyMessage(ModuleId, "categoryactionsave", NotifyCode.ok); } } else { NBrightBuyUtils.SetNotfiyMessage(ModuleId, "categoryactionsave", NotifyCode.fail); } } NBrightBuyUtils.RemoveModCachePortalWide(PortalId); //clear any cache }
private void UpdateRecord() { var xmlData = GenXmlFunctions.GetGenXml(rpData, "", StoreSettings.Current.FolderImagesMapPath); var objInfo = new NBrightInfo(); objInfo.ItemID = -1; objInfo.TypeCode = "POSTDATA"; objInfo.XMLData = xmlData; var settings = objInfo.ToDictionary(); // put the fieds into a dictionary, so we can get them easy. var strOut = "No Category ID ('itemid' hidden fields needed on input form)"; if (settings.ContainsKey("itemid")) { var catData = CategoryUtils.GetCategoryData(Convert.ToInt32(settings["itemid"]), StoreSettings.Current.EditLanguage); catData.Update(objInfo); if (!String.IsNullOrEmpty(Edittype) && Edittype.ToLower() == "group") { var grptype = objInfo.GetXmlProperty("genxml/dropdownlist/ddlparentcatid"); var grp = ModCtrl.GetByGuidKey(PortalSettings.PortalId, -1, "GROUP", grptype); if (grp != null) { var newGuidKey = objInfo.GetXmlProperty("genxml/textbox/propertyref"); if (newGuidKey != "") newGuidKey = GetUniqueGuidKey(catData.CategoryId, Utils.UrlFriendly(newGuidKey)); catData.DataRecord.GUIDKey = newGuidKey; catData.DataRecord.SetXmlProperty("genxml/textbox/txtcategoryref", newGuidKey); catData.DataRecord.ParentItemId = grp.ItemID; // list done using ddlgrouptype, in GetCatList catData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlgrouptype", grptype); catData.Save(); NBrightBuyUtils.RemoveModCachePortalWide(PortalId); } } else { // the base category ref cannot have language dependant refs, we therefore just use a unique key var catref = catData.DataRecord.GetXmlProperty("genxml/textbox/txtcategoryref"); if (catref == "") { if (catData.DataRecord.GUIDKey == "") { catref = Utils.GetUniqueKey().ToLower(); catData.DataRecord.SetXmlProperty("genxml/textbox/txtcategoryref", catref); catData.DataRecord.GUIDKey = catref; } else { catData.DataRecord.SetXmlProperty("genxml/textbox/txtcategoryref", catData.DataRecord.GUIDKey); } } catData.Save(); CategoryUtils.ValidateLangaugeRef(PortalId, Convert.ToInt32(settings["itemid"])); // do validate so we update all refs and children refs NBrightBuyUtils.RemoveModCachePortalWide(PortalId); } } else { NBrightBuyUtils.SetNotfiyMessage(ModuleId, "categoryactionsave", NotifyCode.fail); } NBrightBuyUtils.RemoveModCachePortalWide(PortalId); //clear any cache }
public static String RenderProductAdminList(List <NBrightInfo> list, NBrightInfo ajaxInfo, int recordCount) { try { if (NBrightBuyUtils.CheckRights()) { if (list == null) { return(""); } if (UserController.Instance.GetCurrentUserInfo().UserID <= 0) { return(""); } var strOut = ""; // select a specific entity data type for the product (used by plugins) var themeFolder = "config"; var pageNumber = ajaxInfo.GetXmlPropertyInt("genxml/hidden/pagenumber"); var pageSize = ajaxInfo.GetXmlPropertyInt("genxml/hidden/pagesize"); var razortemplate = ajaxInfo.GetXmlProperty("genxml/hidden/razortemplate"); var editlang = ajaxInfo.GetXmlProperty("genxml/hidden/editlang"); if (editlang == "") { editlang = Utils.GetCurrentCulture(); } var templateControl = "/DesktopModules/NBright/OS_BulkEdit"; bool paging = pageSize > 0; var passSettings = new Dictionary <string, string>(); foreach (var s in ajaxInfo.ToDictionary()) { passSettings.Add(s.Key, s.Value); } foreach (var s in StoreSettings.Current.Settings()) // copy store setting, otherwise we get a byRef assignement { if (passSettings.ContainsKey(s.Key)) { passSettings[s.Key] = s.Value; } else { passSettings.Add(s.Key, s.Value); } } strOut = NBrightBuyUtils.RazorTemplRenderList(razortemplate, 0, "", list, templateControl, themeFolder, editlang, passSettings); // add paging if needed if (paging && (recordCount > pageSize)) { var pg = new NBrightCore.controls.PagingCtrl(); strOut += pg.RenderPager(recordCount, pageSize, pageNumber); } return(strOut); } return(""); } catch (Exception ex) { return(ex.ToString()); } }
private List<NBrightInfo> GetAjaxInfoList(HttpContext context) { var rtnList = new List<NBrightInfo>(); var strIn = HttpUtility.UrlDecode(Utils.RequestParam(context, "inputxml")); var xmlDoc1 = new XmlDocument(); if (!String.IsNullOrEmpty(strIn)) { xmlDoc1.LoadXml(strIn); var xmlNodeList = xmlDoc1.SelectNodes("root/*"); if (xmlNodeList != null) { foreach (XmlNode nod in xmlNodeList) { var xmlData = GenXmlFunctions.GetGenXmlByAjax(nod.OuterXml, ""); var objInfo = new NBrightInfo(); objInfo.ItemID = -1; objInfo.TypeCode = "AJAXDATA"; objInfo.PortalId = PortalSettings.Current.PortalId; objInfo.XMLData = xmlData; var dic = objInfo.ToDictionary(); // set langauge if we have it passed. if (dic.ContainsKey("lang") && dic["lang"] != "") _lang = dic["lang"]; rtnList.Add(objInfo); } } } return rtnList; }
/// <summary> /// Put Ajax data into a NBrightInfo class for processing /// </summary> /// <param name="context">Http context</param> /// <param name="updatefields">If true only fields marked with update attribute are returned.</param> /// <returns></returns> private NBrightInfo GetAjaxInfo(HttpContext context, Boolean updatefields = false) { var strIn = HttpUtility.UrlDecode(Utils.RequestParam(context, "inputxml")); var objInfo = new NBrightInfo(); objInfo.ItemID = -1; objInfo.TypeCode = "AJAXDATA"; objInfo.PortalId = PortalSettings.Current.PortalId; if (updatefields) { objInfo.UpdateAjax(strIn); } else { var xmlData = GenXmlFunctions.GetGenXmlByAjax(strIn, ""); objInfo.XMLData = xmlData; } var dic = objInfo.ToDictionary(); // set langauge if we have it passed. if (dic.ContainsKey("lang") && dic["lang"] != "") _lang = dic["lang"]; // set the context culturecode, so any DNN functions use the correct culture (entryurl tag token) if (_lang != "" && _lang != System.Threading.Thread.CurrentThread.CurrentCulture.ToString()) System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(_lang); objInfo.Lang = _lang; // make sure we have the langauge in the object. return objInfo; }