Пример #1
0
        protected override void OnLoad(EventArgs e)
        {
            try
            {
                if (UserId > 0) //do nothing if user not logged on
                {
                    _resxpath = StoreSettings.NBrightBuyPath() + "/App_LocalResources/Plugins.ascx.resx";

                    base.OnLoad(e);

                    var rpDataTemplH = ModCtrl.GetTemplateData(ModSettings, "menuheader.html",
                                                               Utils.GetCurrentCulture(), DebugMode);
                    var l = new Literal();
                    l.Text = rpDataTemplH;
                    phMenuH.Controls.Add(l);

                    l      = new Literal();
                    l.Text = GetMenu();
                    phMenuF.Controls.Add(l);

                    var rpDataTemplF = ModCtrl.GetTemplateData(ModSettings, "menufooter.html",
                                                               Utils.GetCurrentCulture(), DebugMode);
                    l      = new Literal();
                    l.Text = rpDataTemplF;
                    phMenuF.Controls.Add(l);
                }
            }
            catch (Exception exc) //Module failed to load
            {
                //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);
            }
        }
Пример #2
0
        public IEncodedString ShippingDropDown(NBrightInfo info, string xpath, string attributes = "", bool allowblank = true)
        {
            try
            {
                var resxPath = StoreSettings.NBrightBuyPath() + "/App_LocalResources/Admin.ascx.resx";

                var strOut = string.Empty;

                return(new RawString(strOut));
            }
            catch (Exception e)
            {
                return(new RawString(e.ToString()));
            }
        }
Пример #3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (Size != "16" & Size != "24" & Size != "32")
            {
                Size = "32";
            }

            //NOTE: We need to recreate dynamically created controls on postback for them to pickup the event.
            var enabledlanguages = LocaleController.Instance.GetLocales(PortalId);

            Controls.Add(new LiteralControl("<ul class='editlanguage'>"));
            foreach (var l in enabledlanguages)
            {
                Controls.Add(new LiteralControl("<li>"));
                var cmd = new LinkButton();
                cmd.Text            = "<img src='" + StoreSettings.NBrightBuyPath() + "/Themes/config/img/flags/" + Size + "/" + l.Value.Code + ".png' alt='" + l.Value.EnglishName + "' />";
                cmd.CommandArgument = l.Value.Code;
                cmd.CommandName     = "selectlang";
                cmd.Command        += (s, cmde) =>
                {
                    var param = new string[2];
                    if (_entryid != "")
                    {
                        param[0] = "eid=" + _entryid;
                    }
                    if (_ctrl != "")
                    {
                        param[1] = "ctrl=" + _ctrl;
                    }

                    //remove all cahce setting from cache for reload
                    //DNN is sticky with some stuff (had some issues with email addresses not updating), so to be sure clear it all.
                    DataCache.ClearCache();

                    StoreSettings.Current.EditLanguage = cmde.CommandArgument.ToString();
                    Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                };
                Controls.Add(cmd);
                Controls.Add(new LiteralControl("</li>"));
            }
            Controls.Add(new LiteralControl("</ul>"));
        }
Пример #4
0
        override protected void OnInit(EventArgs e)
        {
            _eid           = Utils.RequestQueryStringParam(Context, "eid");
            _print         = Utils.RequestParam(Context, "print");
            _printtemplate = Utils.RequestParam(Context, "template");
            _controlPath   = ControlPath;

            EnablePaging = true;

            base.OnInit(e);

            if (ModSettings != null)
            {
                // check if we're using a typcode for the data.
                var modentitytypecode = ModSettings.Get("entitytypecode");
                if (modentitytypecode != "")
                {
                    EntityTypeCode     = modentitytypecode;
                    EntityTypeCodeLang = modentitytypecode + "LANG";
                }
                // check if we're using a provider controlpath for the templates.
                var providercontrolpath = ModSettings.Get("providercontrolpath");
                if (providercontrolpath != "")
                {
                    _controlPath = "/DesktopModules/NBright/" + providercontrolpath + "/";
                }
            }


            // if guidkey entered instead of eid, find it using the guid and assign to _eid
            _guidkey = Utils.RequestQueryStringParam(Context, "guidkey");
            if (_guidkey == "")
            {
                _guidkey = Utils.RequestQueryStringParam(Context, "ref");
            }

            Logging.Info($"ProductRazorView requested with: eid={_eid}, guidkey={_guidkey}.");

            if (_eid == "" && _guidkey != "")
            {
                var guidData = ModCtrl.GetByGuidKey(PortalId, -1, EntityTypeCode, _guidkey);
                if (guidData != null)
                {
                    _eid = guidData.ItemID.ToString("D");
                }
                else
                {
                    _eid = "0";
                }
            }

            // if we want to print 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(), "printproduct", "window.open('" + StoreSettings.NBrightBuyPath() + "/PrintView.aspx?itemid=" + _eid + "&printcode=" + _print + "&template=" + _printtemplate + "&theme=" + ModSettings.Get("themefolder") + "','_blank');", true);
            }

            if (ModuleKey == "")  // if we don't have module setting jump out
            {
                var lit = new Literal();
                lit.Text = "NO MODULE SETTINGS";
                phData.Controls.Add(lit);
                return;
            }

            _navigationdata = new NavigationData(PortalId, ModuleKey);

            // Pass in a template specifying the token to create a friendly url for paging.
            // (NOTE: we need this in NBS becuase the edit product from list return url will copy the page number and hence paging will not work after editing if we don;t do this)
            CtrlPaging.HrefLinkTemplate = "[<tag type='valueof' databind='PreText' />][<tag type='if' databind='Text' testvalue='' display='{OFF}' />][<tag type='hrefpagelink' moduleid='" + ModuleId.ToString("") + "' />][<tag type='endif' />][<tag type='valueof' databind='PostText' />]";
            CtrlPaging.UseListDisplay   = true;
            try
            {
                _catid   = Utils.RequestQueryStringParam(Context, "catid");
                _catname = Utils.RequestQueryStringParam(Context, "catref");

                #region "set templates based on entry id (eid) from url"

                _ename        = Utils.RequestQueryStringParam(Context, "entry");
                _modkey       = Utils.RequestQueryStringParam(Context, "modkey");
                _pagemid      = Utils.RequestQueryStringParam(Context, "pagemid");
                _pagenum      = Utils.RequestQueryStringParam(Context, "page");
                _pagesize     = Utils.RequestQueryStringParam(Context, "pagesize");
                _orderbyindex = Utils.RequestQueryStringParam(Context, "orderby");

                // see if we need to display the entry page.
                if ((_modkey == ModuleKey | _modkey == "") && (_eid != "" | _ename != ""))
                {
                    _displayentrypage = true;
                }

                // if we have entry detail display, but no catd, get the default one.
                if (_displayentrypage && _catid == "" && Utils.IsNumeric(_eid))
                {
                    var prdData = ProductUtils.GetProductData(Convert.ToInt32(_eid), Utils.GetCurrentCulture(), true, EntityTypeCode);
                    var defcat  = prdData.GetDefaultCategory();
                    if (defcat != null)
                    {
                        _catid = defcat.categoryid.ToString("");
                    }
                }

                if (ModSettings.Get("listonly").ToLower() == "true")
                {
                    _displayentrypage = false;
                }

                // get template codes
                if (_displayentrypage)
                {
                    _templD = ModSettings.Get("razordetailtemplate");
                    if (_templD == "")
                    {
                        _templD = ModSettings.Get("txtdisplayentrybody");                // legacy name
                    }
                }
                else
                {
                    _templD = ModSettings.Get("razorlisttemplate");
                    if (_templD == "")
                    {
                        _templD = ModSettings.Get("txtdisplaybody");                // legacy name
                    }
                }

                #endregion
            }
            catch (Exception exc)
            {
                // remove any cookie which might store SQL in error.
                _navigationdata.Delete();
                DisplayProductError(exc.ToString());
            }
        }
Пример #5
0
        override protected void OnInit(EventArgs e)
        {
            _eid           = Utils.RequestQueryStringParam(Context, "eid");
            _print         = Utils.RequestParam(Context, "print");
            _printtemplate = Utils.RequestParam(Context, "template");

            EnablePaging = true;

            base.OnInit(e);

            // if guidkey entered instead of eid, find it using the guid and assign to _eid
            _guidkey = Utils.RequestQueryStringParam(Context, "guidkey");
            if (_guidkey == "")
            {
                _guidkey = Utils.RequestQueryStringParam(Context, "ref");
            }
            if (_eid == "" && _guidkey != "")
            {
                var guidData = ModCtrl.GetByGuidKey(PortalId, -1, "PRD", _guidkey);
                if (guidData != null)
                {
                    _eid = guidData.ItemID.ToString("D");
                }
                else
                {
                    _eid = "0";
                }
            }

            // if we want to print 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(), "printproduct", "window.open('" + StoreSettings.NBrightBuyPath() + "/PrintView.aspx?itemid=" + _eid + "&printcode=" + _print + "&template=" + _printtemplate + "&theme=" + ModSettings.Get("themefolder") + "','_blank');", true);
            }

            if (ModuleKey == "")  // if we don't have module setting jump out
            {
                rpDataH.ItemTemplate = new GenXmlTemplate("NO MODULE SETTINGS");
                return;
            }

            _navigationdata = new NavigationData(PortalId, ModuleKey);

            // Pass in a template specifying the token to create a friendly url for paging.
            // (NOTE: we need this in NBS becuase the edit product from list return url will copy the page number and hence paging will not work after editing if we don;t do this)
            CtrlPaging.HrefLinkTemplate = "[<tag type='valueof' databind='PreText' />][<tag type='if' databind='Text' testvalue='' display='{OFF}' />][<tag type='hrefpagelink' moduleid='" + ModuleId.ToString("") + "' />][<tag type='endif' />][<tag type='valueof' databind='PostText' />]";
            CtrlPaging.UseListDisplay   = true;
            try
            {
                _catid   = Utils.RequestQueryStringParam(Context, "catid");
                _catname = Utils.RequestQueryStringParam(Context, "catref");

                #region "set templates based on entry id (eid) from url"

                _ename        = Utils.RequestQueryStringParam(Context, "entry");
                _modkey       = Utils.RequestQueryStringParam(Context, "modkey");
                _pagemid      = Utils.RequestQueryStringParam(Context, "pagemid");
                _pagenum      = Utils.RequestQueryStringParam(Context, "page");
                _pagesize     = Utils.RequestQueryStringParam(Context, "pagesize");
                _orderbyindex = Utils.RequestQueryStringParam(Context, "orderby");


                // see if we need to display the entry page.
                if ((_modkey == ModuleKey | _modkey == "") && (_eid != "" | _ename != ""))
                {
                    _displayentrypage = true;
                }

                // if we have entry detail display, but no catd, get the default one.
                if (_displayentrypage && _catid == "" && Utils.IsNumeric(_eid))
                {
                    var prdData = ProductUtils.GetProductData(Convert.ToInt32(_eid), Utils.GetCurrentCulture());
                    var defcat  = prdData.GetDefaultCategory();
                    if (defcat != null)
                    {
                        _catid = defcat.categoryid.ToString("");
                    }
                }

                if (ModSettings.Get("listonly").ToLower() == "true")
                {
                    _displayentrypage = false;
                }

                // get template codes
                if (_displayentrypage)
                {
                    _templH = ModSettings.Get("txtdisplayentryheader");
                    _templD = ModSettings.Get("txtdisplayentrybody");
                    _templF = ModSettings.Get("txtdisplayentryfooter");
                }
                else
                {
                    _templH = ModSettings.Get("txtdisplayheader");
                    _templD = ModSettings.Get("txtdisplaybody");
                    _templF = ModSettings.Get("txtdisplayfooter");
                }


                #endregion


                // Get Display Header
                var rpDataHTempl = ModCtrl.GetTemplateData(ModSettings, _templH, Utils.GetCurrentCulture(), DebugMode);

                //-------------------------------------------------------------------------
                //Get default sort order and filter from the displayheader template.  Use template data, becuase repeater is not fully initialized yet.
                _strOrder = _navigationdata.OrderBy;
                if (String.IsNullOrEmpty(_strOrder))
                {
                    _strOrder = GenXmlFunctions.GetSqlOrderBy(rpDataHTempl); // get default
                }
                if (_orderbyindex != "")                                     // if we have orderby set in url, find the meta tags
                {
                    _strOrder = GenXmlFunctions.GetSqlOrderBy(rpDataHTempl, _orderbyindex);
                    // save the selected orderby to the cookie, so we can page with it.
                    _navigationdata.OrderBy = _strOrder;
                }
                //-------------------------------------------------------------------------

                var cachekey = "GenXmlTemplate*rpDataH" + _templH + "*" + ModuleId.ToString();
                _templateHeader = (GenXmlTemplate)Utils.GetCache(cachekey);
                if (_templateHeader == null || StoreSettings.Current.DebugMode)
                {
                    _templateHeader = NBrightBuyUtils.GetGenXmlTemplate(rpDataHTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                }
                rpDataH.ItemTemplate = _templateHeader;

                // insert page header text
                NBrightBuyUtils.IncludePageHeaders(ModCtrl, ModuleId, Page, _templateHeader, ModSettings.Settings(), null, DebugMode);

                // Get Display Body
                var rpDataTempl = ModCtrl.GetTemplateData(ModSettings, _templD, Utils.GetCurrentCulture(), DebugMode);
                //if body template doesn't contain a default moduleid add it.
                if (!rpDataTempl.ToLower().Contains("nbs:modeldefault"))
                {
                    rpDataTempl = "[<tag type='nbs:modeldefault' />]" + rpDataTempl;
                }
                // always add a productid hidden field to the data template (for add to cart)
                rpDataTempl = "[<tag type='hidden' id='productid' value='databind:itemid' />]" + rpDataTempl;

                cachekey = "GenXmlTemplate*rpData" + _templD + "*" + ModuleId.ToString();
                var gXml = (GenXmlTemplate)Utils.GetCache(cachekey);
                if (gXml == null || StoreSettings.Current.DebugMode)
                {
                    gXml = NBrightBuyUtils.GetGenXmlTemplate(rpDataTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                }
                rpData.ItemTemplate = gXml;

                // Get Display Footer
                var rpDataFTempl = ModCtrl.GetTemplateData(ModSettings, _templF, Utils.GetCurrentCulture(), DebugMode);

                cachekey = "GenXmlTemplate*rpDataF" + _templF + "*" + ModuleId.ToString();
                gXml     = (GenXmlTemplate)Utils.GetCache(cachekey);
                if (gXml == null || StoreSettings.Current.DebugMode)
                {
                    gXml = NBrightBuyUtils.GetGenXmlTemplate(rpDataFTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                }
                rpDataF.ItemTemplate = gXml;
            }
            catch (Exception exc)
            {
                // remove any cookie which might store SQL in error.
                _navigationdata.Delete();
                DisplayProductError(exc.ToString());
            }
        }
Пример #6
0
        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 = ModCtrl.GetTemplateData(ModSettings, "orderssearch.html", Utils.GetCurrentCulture(), DebugMode);
                _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 = ModCtrl.GetTemplateData(ModSettings, t1, Utils.GetCurrentCulture(), DebugMode);
                rpDataH.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataHTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                // Get Display Body
                var rpDataTempl = ModCtrl.GetTemplateData(ModSettings, t2, Utils.GetCurrentCulture(), DebugMode);
                rpData.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                // Get Display Footer
                var rpDataFTempl = ModCtrl.GetTemplateData(ModSettings, t3, Utils.GetCurrentCulture(), DebugMode);
                rpDataF.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataFTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                if (Utils.IsNumeric(_entryid))
                {
                    var rpItemHTempl = ModCtrl.GetTemplateData(ModSettings, "ordersdetailitemheader.html", Utils.GetCurrentCulture(), DebugMode);
                    rpItemH.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpItemHTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                    // Get Display Body
                    var rpItemTempl = ModCtrl.GetTemplateData(ModSettings, "ordersdetailitem.html", Utils.GetCurrentCulture(), DebugMode);
                    rpItem.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpItemTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                    // Get Display Footer
                    var rpItemFTempl = ModCtrl.GetTemplateData(ModSettings, "ordersdetailitemfooter.html", Utils.GetCurrentCulture(), DebugMode);
                    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);
            }
        }
Пример #7
0
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var cArg  = e.CommandArgument.ToString();
            var tabId = TabId;
            var param = new string[4];

            if (_uid != "")
            {
                param[0] = "uid=" + _uid;
            }
            var navigationData = new NavigationData(PortalId, "AdminOrders");
            var cmd            = e.CommandName.ToLower();
            var resxpath       = StoreSettings.NBrightBuyPath() + "/App_LocalResources/Notification.ascx.resx";
            var emailoption    = "";

            switch (cmd)
            {
            case "entrydetail":
                param[0] = "eid=" + cArg;
                if (_page != "")
                {
                    param[1] = "page=" + _page;
                }
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "reorder":
                param[0] = "";
                if (Utils.IsNumeric(cArg))
                {
                    var orderData = new OrderData(PortalId, Convert.ToInt32(cArg));
                    orderData.CopyToCart(DebugMode);
                    tabId = StoreSettings.Current.GetInt("carttab");
                    if (tabId == 0)
                    {
                        tabId = TabId;
                    }
                }
                Response.Redirect(NBrightBuyUtils.AdminUrl(tabId, param), true);
                break;

            case "editorder":
                param[0] = "";
                if (Utils.IsNumeric(cArg))
                {
                    var orderData = new OrderData(PortalId, Convert.ToInt32(cArg));
                    orderData.ConvertToCart(DebugMode);
                    tabId = StoreSettings.Current.GetInt("carttab");
                    if (tabId == 0)
                    {
                        tabId = TabId;
                    }
                }
                Response.Redirect(NBrightBuyUtils.AdminUrl(tabId, param), true);
                break;

            case "return":
                param[0] = "";
                if (_page != "")
                {
                    param[1] = "page=" + _page;
                }
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "search":
                var strXml = GenXmlFunctions.GetGenXml(rpSearch, "", "");
                navigationData.Build(strXml, _templSearch);
                navigationData.OrderBy = GenXmlFunctions.GetSqlOrderBy(rpSearch);
                navigationData.XmlData = GenXmlFunctions.GetGenXml(rpSearch);
                navigationData.Save();
                if (StoreSettings.Current.DebugModeFileOut)
                {
                    strXml = "<root><sql><![CDATA[" + navigationData.Criteria + "]]></sql>" + strXml + "</root>";
                    var xmlDoc = new System.Xml.XmlDocument();
                    xmlDoc.LoadXml(strXml);
                    xmlDoc.Save(PortalSettings.HomeDirectoryMapPath + "debug_search.xml");
                }
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "resetsearch":
                // clear cookie info
                navigationData.Delete();
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "orderby":
                navigationData.OrderBy = GenXmlFunctions.GetSqlOrderBy(rpData);
                navigationData.Save();
                break;

            case "viewclient":
                param[1] = "ctrl=clients";
                if (Utils.IsNumeric(cArg))
                {
                    var orderData = new OrderData(PortalId, Convert.ToInt32(cArg));
                    param[0] = "uid=" + orderData.UserId.ToString("");
                }
                Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                break;

            case "save":
                param[0] = "eid=" + _entryid;
                var result = Update();
                NBrightBuyUtils.SetNotfiyMessage(ModuleId, NotifyRef + cmd, result);
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "printorder":
                param[0] = "eid=" + _entryid;
                param[1] = "print=printorder";
                param[2] = "template=printorder.html";
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "printreceipt":
                param[0] = "eid=" + _entryid;
                param[1] = "print=printorder";
                param[2] = "template=printreceipt.html";
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "printdeliverylabel":
                param[0] = "eid=" + _entryid;
                param[1] = "print=printorder";
                param[2] = "template=printdeliverylabel.html";
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "emailamended":
                param[0]    = "eid=" + _entryid;
                emailoption = DnnUtils.GetLocalizedString("orderamended_emailsubject.Text", resxpath, Utils.GetCurrentCulture());
                Update(emailoption);
                SendOrderEmail(Convert.ToInt32(_entryid), "orderamendedemail.html", "orderamended_emailsubject.Text");
                NBrightBuyUtils.SetNotfiyMessage(ModuleId, NotifyRef + cmd, NotifyCode.ok);
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "emailreceipt":
                param[0]    = "eid=" + _entryid;
                emailoption = DnnUtils.GetLocalizedString("orderreceipt_emailsubject.Text", resxpath, Utils.GetCurrentCulture());
                Update(emailoption);
                SendOrderEmail(Convert.ToInt32(_entryid), "orderreceiptemail.html", "orderreceipt_emailsubject.Text");
                NBrightBuyUtils.SetNotfiyMessage(ModuleId, NotifyRef + cmd, NotifyCode.ok);
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "emailshipped":
                param[0]    = "eid=" + _entryid;
                emailoption = DnnUtils.GetLocalizedString("ordershipped_emailsubject.Text", resxpath, Utils.GetCurrentCulture());
                Update(emailoption);
                SendOrderEmail(Convert.ToInt32(_entryid), "ordershippedemail.html", "ordershipped_emailsubject.Text");
                NBrightBuyUtils.SetNotfiyMessage(ModuleId, NotifyRef + cmd, NotifyCode.ok);
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "emailvalidated":
                param[0]    = "eid=" + _entryid;
                emailoption = DnnUtils.GetLocalizedString("ordervalidated_emailsubject.Text", resxpath, Utils.GetCurrentCulture());
                Update(emailoption);
                SendOrderEmail(Convert.ToInt32(_entryid), "ordervalidatedemail.html", "ordervalidated_emailsubject.Text");
                NBrightBuyUtils.SetNotfiyMessage(ModuleId, NotifyRef + cmd, NotifyCode.ok);
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "downloadinvoice":
                DownloadInvoice(Convert.ToInt32(cArg));
                break;

            case "deleteinvoice":
                DeleteInvoice(Convert.ToInt32(cArg));
                param[0] = "eid=" + _entryid;
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "export":
                DoExport();
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;
            }
        }
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var cArg  = e.CommandArgument.ToString();
            var tabId = TabId;
            var param = new string[4];

            if (_uid != "")
            {
                param[0] = "uid=" + _uid;
            }
            var navigationData = new NavigationData(PortalId, "AdminOrders");
            var cmd            = e.CommandName.ToLower();
            var resxpath       = StoreSettings.NBrightBuyPath() + "/App_LocalResources/Notification.ascx.resx";
            var emailoption    = "";

            switch (cmd)
            {
            case "entrydetail":
                param[0] = "eid=" + cArg;
                if (_page != "")
                {
                    param[1] = "page=" + _page;
                }
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "movetoorder":
                param[0] = "";
                if (Utils.IsNumeric(cArg))
                {
                    var obj = ModCtrl.Get(Convert.ToInt32(cArg));
                    obj.TypeCode = "ORDER";
                    ModCtrl.Update(obj);
                    var ordData = new OrderData(obj.ItemID);
                    ordData.OrderStatus = "010";
                    ordData.CreatedDate = DateTime.Now.ToString("O");
                    ordData.OrderNumber = obj.ItemID.ToString();
                    ordData.AddAuditMessage(DnnUtils.GetLocalizedString("movetoordermsg.Text", "/DesktopModules/NBright/NBrightBuyCartReview/Themes/config/resx", Utils.GetCurrentCulture()), "msg", UserInfo.Username, "False");
                    ordData.Save();
                }
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "return":
                param[0] = "";
                if (_page != "")
                {
                    param[1] = "page=" + _page;
                }
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "search":
                var strXml = GenXmlFunctions.GetGenXml(rpSearch, "", "");
                navigationData.Build(strXml, _templSearch);
                navigationData.OrderBy = GenXmlFunctions.GetSqlOrderBy(rpSearch);
                navigationData.XmlData = GenXmlFunctions.GetGenXml(rpSearch);
                navigationData.Save();
                if (StoreSettings.Current.DebugModeFileOut)
                {
                    strXml = "<root><sql><![CDATA[" + navigationData.Criteria + "]]></sql>" + strXml + "</root>";
                    var xmlDoc = new System.Xml.XmlDataDocument();
                    xmlDoc.LoadXml(strXml);
                    xmlDoc.Save(PortalSettings.HomeDirectoryMapPath + "debug_search.xml");
                }
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "resetsearch":
                // clear cookie info
                navigationData.Delete();
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "orderby":
                navigationData.OrderBy = GenXmlFunctions.GetSqlOrderBy(rpData);
                navigationData.Save();
                break;

            case "viewclient":
                param[1] = "ctrl=clients";
                if (Utils.IsNumeric(cArg))
                {
                    var cartData = new CartData(Convert.ToInt32(cArg));
                    param[0] = "uid=" + cartData.UserId.ToString("");
                }
                Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                break;

            case "delete":
                if (Utils.IsNumeric(cArg))
                {
                    ModCtrl.Delete(Convert.ToInt32(cArg));
                }
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;
            }
        }
Пример #9
0
        /// <summary>
        /// Thumbnail image
        /// </summary>
        /// <param name="info">NBrightInfo class of PRD type</param>
        /// <param name="width">width</param>
        /// <param name="height">height</param>
        /// <param name="idx">index of the image to display</param>
        /// <param name="attributes">free text added onto end of url parameters</param>
        /// <returns>Thumbnailer url</returns>
        public IEncodedString ProductImage(NBrightInfo info, string width = "150", string height = "0", string idx = "1", string attributes = "", bool fileImage = false, bool outputPNG = false)
        {
            var url         = "";
            var imageurlsrc = info.GetXmlProperty("genxml/imgs/genxml[" + idx + "]/hidden/imageurl");

            if (fileImage)
            {
                var src = HttpContext.Current.Server.MapPath(imageurlsrc);

                var strCacheKey = info.PortalId + "*" + src + "*" + Utils.GetCurrentCulture() + "*imgfile:" + width + "*" + height + "*";
                url = (String)Utils.GetCache(strCacheKey);

                if (String.IsNullOrEmpty(url))
                {
                    var imgpath = Path.GetFileNameWithoutExtension(src);
                    var ext     = ".jpg";
                    if (outputPNG)
                    {
                        ext = ".png";
                    }
                    var thumbname = imgpath + "_Thumb" + width + "x" + height + ext;
                    imgpath = Path.GetFullPath(src).Replace(Path.GetFileName(src), "") + thumbname;
                    url     = imageurlsrc.Replace(Path.GetFileName(src), thumbname);

                    if (!File.Exists(imgpath))
                    {
                        var            newImage = ImgUtils.CreateThumbnail(src, Convert.ToInt32(width), Convert.ToInt32(height));
                        ImageCodecInfo useEncoder;
                        useEncoder = ImgUtils.GetEncoder(ImageFormat.Jpeg);
                        if (outputPNG)
                        {
                            useEncoder = ImgUtils.GetEncoder(ImageFormat.Png);
                        }

                        var encoderParameters = new EncoderParameters(1);
                        encoderParameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 85L);

                        try
                        {
                            newImage.Save(imgpath, useEncoder, encoderParameters);
                        }
                        catch (Exception exc)
                        {
                            if (StoreSettings.Current.DebugMode)
                            {
                                url = exc.ToString();
                            }
                        }
                    }

                    if (!StoreSettings.Current.DebugMode)
                    {
                        Utils.SetCache(strCacheKey, url);
                    }
                }
            }
            else
            {
                url = StoreSettings.NBrightBuyPath() + "/NBrightThumb.ashx?src=" + imageurlsrc + "&w=" + width + "&h=" + height + attributes;
            }
            return(new RawString(url));
        }