private String ReportSelection(HttpContext context)

        {
            try
            {
                var settings = GetAjaxFields(context);
                var strOut   = "Error!! - Invalid ItemId on Selection Report";
                if (settings.ContainsKey("itemid") && Utils.IsNumeric(settings["itemid"]))
                {
                    if (!settings.ContainsKey("portalid"))
                    {
                        settings.Add("portalid", PortalSettings.Current.PortalId.ToString(""));                                    // aways make sure we have portalid in settings
                    }
                    var objCtrl = new NBrightBuyController();
                    var obj     = objCtrl.Get(Convert.ToInt32(settings["itemid"]));
                    if (obj != null)
                    {
                        var bodyTempl = NBrightBuyUtils.GetTemplateData("Admin.cshtml", "", "config", StoreSettings.Current.Settings());
                        var strTempl  = obj.GetXmlProperty("genxml/textbox/selectiondetails");
                        bodyTempl = bodyTempl.Replace("[Template:selectiondetails]", strTempl);
                        bodyTempl = Utils.ReplaceSettingTokens(bodyTempl, settings);
                        bodyTempl = Utils.ReplaceUrlTokens(bodyTempl);

                        strOut = GenXmlFunctions.RenderRepeater(obj, bodyTempl);
                    }
                }

                return(strOut);
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Ejemplo n.º 2
0
        protected override void OnInit(EventArgs e)
        {
            //Remove any cache for the module, we don't want any cache in/after the BO editing.
            NBrightBuyUtils.RemoveModCache(ModuleId);

            // add required controls.
            RpData              = new Repeater();
            RpData.ItemCommand += CtrlItemCommand;

            this.Controls.Add(RpData);

            //set default Data controller
            ModCtrl = new NBrightBuyController();


            #region "Get all Settings for module"
            //get Model Level Settings
            ModSettings = new ModSettings(ModuleId, Settings);

            #endregion

            var strTemplate = "";
            if (!String.IsNullOrEmpty(CtrlPluginPath))
            {
                //search plugin path for template
                strTemplate = NBrightBuyUtils.GetTemplateData(CtrlTypeCode + "_Settings.html", CtrlPluginPath, "config", ModSettings.Settings());
            }
            if (strTemplate == "")
            {
                // add themefolder to settings, incase module has independant theme.
                strTemplate = ModCtrl.GetTemplateData(ModSettings, CtrlTypeCode + "_Settings.html", Utils.GetCurrentCulture(), StoreSettings.Current.DebugMode);
            }
            if (strTemplate != "")
            {
                RpData.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(strTemplate, ModSettings.Settings(), PortalSettings.HomeDirectory);
            }

            //add template provider to NBright Templating
            NBrightCore.providers.GenXProviderManager.AddProvider("NBrightBuy,Nevoweb.DNN.NBrightBuy.render.GenXmlTemplateExt");
            var pInfo = ModCtrl.GetByGuidKey(PortalId, -1, "PROVIDERS", "NBrightTempalteProviders");
            if (pInfo != null)
            {
                NBrightCore.providers.GenXProviderManager.AddProvider(pInfo.XMLDoc);
            }


            base.OnInit(e);
        }
        override protected void OnInit(EventArgs e)
        {
            _entryid       = Utils.RequestQueryStringParam(Context, "eid");
            _uid           = Utils.RequestParam(Context, "uid");
            _print         = Utils.RequestParam(Context, "print");
            _printtemplate = Utils.RequestParam(Context, "template");
            _page          = Utils.RequestParam(Context, "page");
            EnablePaging   = true;

            base.OnInit(e);

            // if we want to print a order we need to open the browser with a startup script, this points to a Printview.aspx. (Must go after the ModSettings has been init.)
            if (_print != "")
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "printorder", "window.open('" + StoreSettings.NBrightBuyPath() + "/PrintView.aspx?itemid=" + _entryid + "&printcode=" + _print + "&template=" + _printtemplate + "&theme=" + ModSettings.Get("theme") + "','_blank');", true);
            }

            CtrlPaging.Visible        = true;
            CtrlPaging.UseListDisplay = true;
            try
            {
                if (_entryid != "")
                {
                    _displayentrypage = true;
                }

                #region "load templates"

                // Get Search
                var rpSearchTempl = NBrightBuyUtils.GetTemplateData("orderssearch.html", ctrlpath);
                _templSearch          = NBrightBuyUtils.GetGenXmlTemplate(rpSearchTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                rpSearch.ItemTemplate = _templSearch;

                var t1 = "ordersheader.html";
                var t2 = "ordersbody.html";
                var t3 = "ordersfooter.html";

                if (Utils.IsNumeric(_entryid))
                {
                    t1 = "ordersdetailheader.html";
                    t2 = "ordersdetail.html";
                    t3 = "ordersdetailfooter.html";
                }

                // Get Display Header
                var rpDataHTempl = NBrightBuyUtils.GetTemplateData(t1, ctrlpath);
                rpDataH.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataHTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                // Get Display Body
                var rpDataTempl = NBrightBuyUtils.GetTemplateData(t2, ctrlpath);
                rpData.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                // Get Display Footer
                var rpDataFTempl = NBrightBuyUtils.GetTemplateData(t3, ctrlpath);
                rpDataF.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataFTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                if (Utils.IsNumeric(_entryid))
                {
                    var rpItemHTempl = NBrightBuyUtils.GetTemplateData("ordersdetailitemheader.html", ctrlpath);
                    rpItemH.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpItemHTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                    // Get Display Body
                    var rpItemTempl = NBrightBuyUtils.GetTemplateData("ordersdetailitem.html", ctrlpath);
                    rpItem.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpItemTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                    // Get Display Footer
                    var rpItemFTempl = NBrightBuyUtils.GetTemplateData("ordersdetailitemfooter.html", ctrlpath);
                    rpItemF.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpItemFTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                }
                else
                {
                    rpItemH.Visible = false;
                    rpItem.Visible  = false;
                    rpItemF.Visible = false;
                }
                #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();
                phData.Controls.Add(l);
            }
        }