示例#1
0
        private List <string> GetMenuTemplates(string basetempl)
        {
            var rtnL  = new List <string>();
            var templ = _ctrlObj.GetTemplateData(_modSettings, basetempl, Utils.GetCurrentCulture(), _debugMode);

            rtnL.Add(templ);

            var lp = 1;

            templ = _ctrlObj.GetTemplateData(_modSettings, basetempl.Replace(".html", lp.ToString("") + ".html"), Utils.GetCurrentCulture(), _debugMode);
            while (!String.IsNullOrEmpty(templ))
            {
                lp += 1;
                rtnL.Add(templ);
                templ = _ctrlObj.GetTemplateData(_modSettings, basetempl.Replace(".html", lp.ToString("") + ".html"), Utils.GetCurrentCulture(), _debugMode);
                if (lp > 99)
                {
                    templ += "POSSIBLE INFINATE LOOP: CatMenuBuilder.cs, GenMenuTemplate";
                    rtnL.Add(templ);
                    break;
                }
            }

            return(rtnL);
        }
示例#2
0
        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 = "";
            }
        }
示例#3
0
 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;
         }
     }
 }
示例#4
0
        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 = "";
            }
        }
示例#5
0
        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 = "";
            }
        }
示例#6
0
        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);
            }
        }
示例#7
0
        public static void SendEmail(String toEmail, String templateName, NBrightInfo dataObj, String emailsubjectresxkey, String fromEmail,String lang)
        {
            dataObj = ProcessEventProvider(EventActions.BeforeSendEmail, dataObj, templateName);

            if (!dataObj.GetXmlPropertyBool("genxml/stopprocess"))
            {

                if (lang == "") lang = Utils.GetCurrentCulture();
                var emaillist = toEmail;
                if (emaillist != "")
                {
                    var emailsubject = "";
                    if (emailsubjectresxkey != "")
                    {
                        var resxpath = StoreSettings.NBrightBuyPath() + "/App_LocalResources/Notification.ascx.resx";
                        emailsubject = DnnUtils.GetLocalizedString(emailsubjectresxkey, resxpath, lang);
                        if (emailsubject == null) emailsubject = emailsubjectresxkey;
                    }

                    // we can't use StoreSettings.Current.Settings(), becuase of external calls from providers to this function, so load in the settings directly
                    var modCtrl = new NBrightBuyController();
                    var storeSettings = modCtrl.GetStoreSettings(dataObj.PortalId);

                    var strTempl = modCtrl.GetTemplateData(-1, templateName, lang, storeSettings.Settings(), storeSettings.DebugMode);

                    var emailbody = GenXmlFunctions.RenderRepeater(dataObj, strTempl, "", "XMLData", lang, storeSettings.Settings());
                    if (templateName.EndsWith(".xsl")) emailbody = XslUtils.XslTransInMemory(dataObj.XMLData, emailbody);
                    if (fromEmail == "") fromEmail = storeSettings.AdminEmail;
                    var emailarray = emaillist.Split(',');
                    emailsubject = storeSettings.Get("storename") + " : " + emailsubject;
                    foreach (var email in emailarray)
                    {
                        if (!string.IsNullOrEmpty(email.Trim()) && Utils.IsEmail(fromEmail.Trim()) && Utils.IsEmail(email.Trim()))
                        {
                            // multiple attachments as csv with "|" seperator
                            DotNetNuke.Services.Mail.Mail.SendMail(fromEmail.Trim(), email.Trim(), "", emailsubject, emailbody, dataObj.GetXmlProperty("genxml/emailattachment"), "HTML", "", "", "", "");
                        }
                    }
                }
            }

            ProcessEventProvider(EventActions.AfterSendEmail, dataObj, templateName);
        }
示例#8
0
        /// <summary>
        /// Include and template data into header, if specified in meta tag token (includeinheader).  
        /// </summary>
        /// <param name="modCtrl"></param>
        /// <param name="moduleId"></param>
        /// <param name="page"></param>
        /// <param name="template"></param>
        /// <param name="settings"></param>
        /// <param name="objInfo"></param>
        /// <param name="debugMode"></param>
        /// <returns></returns>
        public static string IncludePageHeaders(NBrightBuyController modCtrl, int moduleId, Page page, GenXmlTemplate template, Dictionary<String, String> settings, NBrightInfo objInfo = null, bool debugMode = false)
        {
            foreach (var mt in template.MetaTags)
            {
                var id = GenXmlFunctions.GetGenXmlValue(mt, "tag/@id");
                if (id == "includeinheader")
                {
                    var templ = GenXmlFunctions.GetGenXmlValue(mt, "tag/@value");
                    if (templ != "")
                    {

                        var includetext = modCtrl.GetTemplateData(moduleId, templ, Utils.GetCurrentCulture(), settings, debugMode);
                        if (objInfo == null) objInfo = new NBrightInfo(); //create a object so we process the tag values (resourcekey)
                        includetext = GenXmlFunctions.RenderRepeater(objInfo, includetext);
                        if (includetext != "")
                        {
                            if (!page.Items.Contains("nbrightbuyinject")) page.Items.Add("nbrightbuyinject", "");
                            if (templ != "" && !page.Items["nbrightbuyinject"].ToString().Contains(templ + ","))
                            {
                                PageIncludes.IncludeTextInHeader(page, includetext);
                                page.Items["nbrightbuyinject"] = page.Items["nbrightbuyinject"] + templ + ",";
                            }
                        }
                    }
                }
            }
            return "";
        }