コード例 #1
0
ファイル: ShippingProvider.cs プロジェクト: Lewy-H/NBrightBuy
        public override bool IsValid(NBrightInfo cartInfo)
        {
            // check if this provider is valid for the counrty in the checkout
            var shipoption = cartInfo.GetXmlProperty("genxml/extrainfo/genxml/radiobuttonlist/rblshippingoptions");
            var countrycode = "";
            switch (shipoption)
            {
                case "1":
                    countrycode = cartInfo.GetXmlProperty("genxml/billaddress/genxml/dropdownlist/country");
                    break;
                case "2":
                    countrycode = cartInfo.GetXmlProperty("genxml/shipaddress/genxml/dropdownlist/country");
                    break;
            }

            var isValid = true;
            var shipData = new ShippingData(Shippingkey);
            var validlist = "," + shipData.Info.GetXmlProperty("genxml/textbox/validcountrycodes") + ",";
            var notvalidlist = "," + shipData.Info.GetXmlProperty("genxml/textbox/notvalidcountrycodes") + ",";
            if (validlist.Trim(',') != "")
            {
                isValid = false;
                if (validlist.Contains("," + countrycode + ",")) isValid = true;
            }
            if (notvalidlist.Trim(',') != "" && notvalidlist.Contains("," + countrycode + ",")) isValid = false;

            return isValid;
        }
コード例 #2
0
 public override NBrightInfo UpdatePercentUsage(int portalId, int userId, NBrightInfo purchaseInfo)
 {
     if (userId <= 0) return purchaseInfo;
     var discountcode = purchaseInfo.GetXmlProperty("genxml/extrainfo/genxml/textbox/promocode");
     if (!purchaseInfo.GetXmlPropertyBool("genxml/discountprocessed"))
     {
         if (discountcode == "") return purchaseInfo;
         var clientData = new ClientData(portalId, userId);
         if (clientData.DiscountCodes.Count == 0) return purchaseInfo;
         var list = clientData.DiscountCodes;
         foreach (var d in list)
         {
             if (d.GetXmlProperty("genxml/textbox/coderef").ToLower() == discountcode.ToLower())
             {
                 var usageleft = d.GetXmlPropertyDouble("genxml/textbox/usageleft");
                 var used = d.GetXmlPropertyDouble("genxml/textbox/used");
                 d.SetXmlPropertyDouble("genxml/textbox/usageleft", (usageleft - 1));
                 d.SetXmlPropertyDouble("genxml/textbox/used", (used + 1));
             }
         }
         clientData.UpdateDiscountCodeList(list);
         clientData.Save();
         purchaseInfo.SetXmlProperty("genxml/discountprocessed", "True");
     }
     return purchaseInfo;
 }
コード例 #3
0
        public override NBrightInfo CalculateItemPercentDiscount(int portalId, int userId, NBrightInfo cartItemInfo,String discountcode)
        {
            if (userId <= 0) return cartItemInfo;
            cartItemInfo.SetXmlPropertyDouble("genxml/discountcodeamt", "0"); // reset discount amount
            if (discountcode == "") return cartItemInfo;
            var clientData = new ClientData(portalId,userId);
            if (clientData.DiscountCodes.Count == 0) return cartItemInfo;

            Double discountcodeamt = 0;
            foreach (var d in clientData.DiscountCodes)
            {
                var validutil = d.GetXmlProperty("genxml/textbox/validuntil");
                var validutildate = DateTime.Today;
                if (Utils.IsDate(validutil)) validutildate = Convert.ToDateTime(validutil);
                if (d.GetXmlProperty("genxml/textbox/coderef").ToLower() == discountcode.ToLower() && validutildate >= DateTime.Today)
                {
                    var usageleft = d.GetXmlPropertyDouble("genxml/textbox/usageleft");
                    var percentage = d.GetXmlPropertyDouble("genxml/textbox/percentage");
                    if (percentage > 0 && usageleft > 0)
                    {
                        var appliedtotalcost = cartItemInfo.GetXmlPropertyDouble("genxml/appliedtotalcost");
                        discountcodeamt = ((appliedtotalcost/100)*percentage);
                    }
                }
                if (discountcodeamt > 0) break;
            }
            cartItemInfo.SetXmlPropertyDouble("genxml/discountcodeamt", discountcodeamt);

            return cartItemInfo;
        }
コード例 #4
0
ファイル: ShippingData.cs プロジェクト: Lewy-H/NBrightBuy
 public String AddNewRule()
 {
     var ruleInfo = new NBrightInfo(true);
     ruleInfo.ItemID = -1;
     ruleInfo.SetXmlProperty("genxml/hidden/index","-1");
     return UpdateRule(ruleInfo);
 }
コード例 #5
0
        public override string GetTemplate(NBrightInfo cartInfo)
        {
            var info = ProviderUtils.GetProviderSettings("NBrightPayPalpayment");
            var templ = ProviderUtils.GetTemplateData(info.GetXmlProperty("genxml/textbox/checkouttemplate"));

            return templ;
        }
コード例 #6
0
ファイル: NBrightBuyBase.cs プロジェクト: Lewy-H/NBrightBuy
 /// <summary>
 /// Display template with moduleid set
 /// </summary>
 /// <param name="rp1"></param>
 /// <param name="moduleId"></param>
 public void DoDetail(Repeater rp1,int moduleId)
 {
     var obj = new NBrightInfo(true);
     obj.ModuleId = moduleId;
     var l = new List<object> { obj };
     rp1.DataSource = l;
     rp1.DataBind();
 }
コード例 #7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="portalfinfo"></param>
        /// <returns></returns>
        public override string DoWork()
        {
            try
            {
                var objCtrl = new NBrightBuyController();

                // the sceduler runs at host level, we therefore need to loop through ALL portals to process data at a portal level.
                var portalList = NBrightDNN.DnnUtils.GetAllPortals();
                foreach (var portal in portalList)
                {
                    // check if we have NBS in this portal by looking for default settings.
                    var nbssetting = objCtrl.GetByGuidKey(portal.PortalID, -1, "SETTINGS", "NBrightBuySettings");
                    if (nbssetting != null)
                    {
                        var storeSettings = new StoreSettings(portal.PortalID);
                        var pluginData = new PluginData(portal.PortalID); // get plugin data to see if this scheduler is active on this portal
                        var plugin = pluginData.GetPluginByCtrl("dnnsearchindex");
                        if (plugin != null && plugin.GetXmlPropertyBool("genxml/checkbox/active"))
                        {
                            // The NBS scheduler is normally set to run hourly, therefore if we only want a process to run daily we need the logic this function.
                            // To to this we keep a last run flag on the sceduler settings
                            var setting = objCtrl.GetByGuidKey(portal.PortalID, -1, "DNNIDXSCHEDULER", "DNNIDXSCHEDULER");
                            if (setting == null)
                            {
                                setting = new NBrightInfo(true);
                                setting.ItemID = -1;
                                setting.PortalId = portal.PortalID;
                                setting.TypeCode = "DNNIDXSCHEDULER";
                                setting.GUIDKey = "DNNIDXSCHEDULER";
                                setting.ModuleId = -1;
                                setting.XMLData = "<genxml></genxml>";
                            }

                            var lastrun = setting.GetXmlPropertyRaw("genxml/lastrun");
                            var lastrundate = DateTime.Now.AddYears(-99);
                            if (Utils.IsDate(lastrun)) lastrundate = Convert.ToDateTime(lastrun);

                            var rtnmsg = DoProductIdx(portal, lastrundate, storeSettings.DebugMode);
                            setting.SetXmlProperty("genxml/lastrun", DateTime.Now.ToString("s"), TypeCode.DateTime);
                            objCtrl.Update(setting);
                            if (rtnmsg != "") return rtnmsg;

                        }
                    }

                }

                return " - NBS-DNNIDX scheduler OK ";
            }
            catch (Exception ex)
            {
                return " - NBS-DNNIDX scheduler FAIL: " + ex.ToString() + " : ";
            }
        }
コード例 #8
0
ファイル: Orders.ascx.cs プロジェクト: DNNMonster/NBrightBuy
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            // inject any pageheader we need
            var nbi = new NBrightInfo();
            nbi.Lang = Utils.GetCurrentCulture();
            nbi.PortalId = PortalId;
            var pageheaderTempl = NBrightBuyUtils.RazorTemplRender("Admin_Orders_head.cshtml", 0, "", nbi, "/DesktopModules/NBright/NBrightBuy", "config", Utils.GetCurrentCulture(), StoreSettings.Current.Settings());
            PageIncludes.IncludeTextInHeader(Page, pageheaderTempl);
        }
コード例 #9
0
 public static string DoXslTransOnTemplate(string strTemplateText, NBrightInfo objInfo)
 {
     if (strTemplateText.ToLower().Contains("<xsl:stylesheet"))
     {
         var xmlOut = "<root>";
         var l = new List<NBrightInfo> {objInfo};
         xmlOut += NBrightBuyUtils.FormatListtoXml(l);
         xmlOut += "</root>";
         return XslUtils.XslTransInMemory(xmlOut, strTemplateText);
     }
     return strTemplateText;
 }
コード例 #10
0
ファイル: AddressData.cs プロジェクト: Lewy-H/NBrightBuy
 /// <summary>
 /// Add Adddress
 /// </summary>
 /// <param name="rpData"></param>
 /// <param name="debugMode"></param>
 public String AddAddress(Repeater rpData, Boolean debugMode = false)
 {
     var strXml = GenXmlFunctions.GetGenXml(rpData, "", "");
     // load into NBrigthInfo class, so it's easier to get at xml values.
     var objInfoIn = new NBrightInfo();
     objInfoIn.XMLData = strXml;
     var addIndex = objInfoIn.GetXmlProperty("genxml/hidden/index"); // addresses updated from manager should have a index hidden field.
     if (addIndex == "") addIndex = objInfoIn.GetXmlProperty("genxml/dropdownlist/selectaddress"); // updated from cart should have a selected address
     if (!Utils.IsNumeric(addIndex)) addIndex = "-1"; // assume new address.
     var addressIndex = Convert.ToInt32(addIndex);
     AddAddress(objInfoIn,addressIndex);
     return ""; // if everything is OK, don't send a message back.
 }
コード例 #11
0
 public static NBrightInfo UpdateItemPercentDiscountCode(int portalId, int userId, NBrightInfo cartItemInfo, String discountcode)
 {
     cartItemInfo.SetXmlPropertyDouble("genxml/discountcodeamt", "0");
     foreach (var prov in ProviderList)
     {
         var newItemInfo = prov.Value.CalculateItemPercentDiscount(portalId, userId, cartItemInfo, discountcode);
         if (cartItemInfo.GetXmlPropertyDouble("genxml/discountcodeamt") < newItemInfo.GetXmlPropertyDouble("genxml/discountcodeamt"))
         {
             cartItemInfo.SetXmlPropertyDouble("genxml/discountcodeamt", newItemInfo.GetXmlPropertyDouble("genxml/discountcodeamt"));
         }
     }
     return cartItemInfo;
 }
コード例 #12
0
ファイル: ProfileData.cs プロジェクト: fujinguyen/NBrightBuy
 public NBrightInfo GetProfile()
 {
     var pInfo = new NBrightInfo(true);
     if (_uData.Exists)
     {
         var xmlNode = _uData.Info.XMLDoc.SelectSingleNode("genxml/profile/genxml");
         if (xmlNode != null)
         {
             pInfo.PortalId = _uData.Info.PortalId;
             pInfo.Lang = _uData.Info.Lang;
             pInfo.XMLData = xmlNode.OuterXml;
         }
     }
     return pInfo;
 }
コード例 #13
0
 /// <summary>
 /// Get Current Cart Item List
 /// </summary>
 /// <returns></returns>
 public List<NBrightInfo> GetRuleList()
 {
     var rtnList = new List<NBrightInfo>();
         var xmlNodeList = Info.XMLDoc.SelectNodes("genxml/list/*");
         if (xmlNodeList != null)
         {
             foreach (XmlNode carNod in xmlNodeList)
             {
                 var newInfo = new NBrightInfo {XMLData = carNod.OuterXml};
                 newInfo.ItemID = rtnList.Count;
                 newInfo.SetXmlProperty("genxml/hidden/index", rtnList.Count.ToString(""));
                 rtnList.Add(newInfo);
             }
         }
     return rtnList;
 }
コード例 #14
0
ファイル: PluginData.cs プロジェクト: Lewy-H/NBrightBuy
        public PluginData(int portalId, Boolean systemlevel = false)
        {
            _templCtrl = NBrightBuyUtils.GetTemplateGetter(portalId,"config");

            portallevel = !systemlevel;

            if (StoreSettings.Current == null)
            {
                storeSettings = new StoreSettings(portalId);
            }
            else
            {
                storeSettings = StoreSettings.Current;
            }

            var menuplugin = _templCtrl.GetTemplateData("menuplugin.xml", Utils.GetCurrentCulture(), true, true, portallevel, storeSettings.Settings());
            if (menuplugin != "")
            {
                Info = new NBrightInfo();
                Info.XMLData = menuplugin;
                _pluginList = new List<NBrightInfo>();
                _pluginList = GetPluginList();
            }
            else
            {
                // no menuplugin.xml exists, so must be new install, get new config
                var pluginfoldermappath = System.Web.Hosting.HostingEnvironment.MapPath(StoreSettings.NBrightBuyPath() + "/Plugins");
                if (pluginfoldermappath != null && Directory.Exists(pluginfoldermappath))
                {
                    var xmlDoc = new XmlDocument();
                    xmlDoc.Load(pluginfoldermappath + "\\menu.config");
                    pluginfoldermappath = System.Web.Hosting.HostingEnvironment.MapPath(StoreSettings.NBrightBuyPath() + "/Themes/config/default");
                    xmlDoc.Save(pluginfoldermappath + "\\menuplugin.xml");
                    //load new config
                    menuplugin = _templCtrl.GetTemplateData("menuplugin.xml", Utils.GetCurrentCulture(), true, true, portallevel, storeSettings.Settings());
                    if (menuplugin != "")
                    {
                        Info = new NBrightInfo();
                        Info.XMLData = menuplugin;
                        _pluginList = new List<NBrightInfo>();
                        _pluginList = GetPluginList();
                    }
                }
            }
        }
コード例 #15
0
ファイル: AddressData.cs プロジェクト: Lewy-H/NBrightBuy
        public String AddAddress(NBrightInfo addressInfo, int addressIndex, Boolean debugMode = false)
        {
            if (StoreSettings.Current.DebugModeFileOut) addressInfo.XMLDoc.Save(PortalSettings.Current.HomeDirectoryMapPath + "debug_addressadd.xml");
            var addrExists = AddressExists(addressInfo);
            if (!addrExists)
            {
                if (addressIndex >= 0)
                {
                    UpdateAddress(addressInfo.XMLData, addressIndex);
                }
                else
                {
                    _addressList.Add(addressInfo);
                    Save(debugMode);
                }
            }

            return ""; // if everything is OK, don't send a message back.
        }
コード例 #16
0
ファイル: Payment.ascx.cs プロジェクト: leedavi/NBrightPayPal
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            try
            {
                _ctrlkey = "nbrightpaypalpayment";
                _info = ProviderUtils.GetProviderSettings(_ctrlkey);
                var rpDataHTempl = ProviderUtils.GetTemplateData("settings.html");
                rpDataH.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataHTempl, StoreSettings.Current.Settings(), PortalSettings.HomeDirectory);
            }
            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();
                Controls.Add(l);
            }
        }
コード例 #17
0
ファイル: ProductUtils.cs プロジェクト: DNNMonster/NBrightBuy
 public static NBrightInfo AddEntity(NBrightInfo objInfo, String entityName, int numberToAdd = 1, String genxmlData = "<genxml></genxml>")
 {
     var xNod = objInfo.XMLDoc.SelectSingleNode("genxml/" + entityName.ToLower());
     if (xNod != null)
     {
         var strModelXml = "";
         for (int i = 0; i < numberToAdd; i++)
         {
             strModelXml += genxmlData;
         }
         // Create a document fragment to contain the XML to be inserted.
         var docFrag = objInfo.XMLDoc.CreateDocumentFragment();
         // Set the contents of the document fragment.
         docFrag.InnerXml = strModelXml;
         //Add new model data
         xNod.AppendChild(docFrag);
         objInfo.XMLData = objInfo.XMLDoc.OuterXml;
     }
     return objInfo;
 }
コード例 #18
0
ファイル: ModSettings.cs プロジェクト: Lewy-H/NBrightBuy
 private void AddToSettingDic(NBrightInfo settings, string xpath)
 {
     if (settings.XMLDoc != null)
     {
         var nods = settings.XMLDoc.SelectNodes(xpath);
         if (nods != null)
         {
             foreach (XmlNode nod in nods)
             {
                 if (_settingsDic.ContainsKey(nod.Name))
                 {
                     _settingsDic[nod.Name] = nod.InnerText; // overwrite same name node
                 }
                 else
                 {
                     _settingsDic.Add(nod.Name, nod.InnerText);
                 }
             }
         }
     }
 }
コード例 #19
0
ファイル: ProviderUtils.cs プロジェクト: Lewy-H/NBrightBuy
 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;
 }
コード例 #20
0
ファイル: ShippingProvider.cs プロジェクト: Lewy-H/NBrightBuy
        public override NBrightInfo CalculateShipping(NBrightInfo cartInfo)
        {
            var shipData = new ShippingData(Shippingkey);
            var shipoption = cartInfo.GetXmlProperty("genxml/extrainfo/genxml/radiobuttonlist/rblshippingoptions");
            Double rangeValue = 0;
            if (shipData.CalculationUnit == "1")
                rangeValue = cartInfo.GetXmlPropertyDouble("genxml/totalweight");
            else
                rangeValue = cartInfo.GetXmlPropertyDouble("genxml/appliedsubtotal");
            var countrycode = "";
            var regioncode = "";
            var regionkey = "";
            var total = cartInfo.GetXmlPropertyDouble("genxml/appliedsubtotal");
            switch (shipoption)
            {
                case "1":
                    countrycode = cartInfo.GetXmlProperty("genxml/billaddress/genxml/dropdownlist/country");
                    regionkey = cartInfo.GetXmlProperty("genxml/billaddress/genxml/dropdownlist/region");
                    break;
                case "2":
                    countrycode = cartInfo.GetXmlProperty("genxml/shipaddress/genxml/dropdownlist/country");
                    regionkey = cartInfo.GetXmlProperty("genxml/shipaddress/genxml/dropdownlist/region");
                    break;
            }

            if (regionkey != "")
            {
                var rl = regionkey.Split(':');
                if (rl.Count() == 2) regioncode = rl[1];
            }

            var shippingcost = shipData.CalculateShipping(countrycode, regioncode, rangeValue, total);
            var shippingdealercost = shippingcost;
            cartInfo.SetXmlPropertyDouble("genxml/shippingcost", shippingcost);
            cartInfo.SetXmlPropertyDouble("genxml/shippingdealercost", shippingdealercost);

            return cartInfo;
        }
コード例 #21
0
        public static NBrightInfo GetProviderSettings(String ctrlkey)
        {
            var info = (NBrightInfo)Utils.GetCache("NBrightPayPalPaymentProvider" + PortalSettings.Current.PortalId.ToString(""));
            if (info == null)
            {
                var modCtrl = new NBrightBuyController();

                info = modCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "NBrightPayPalPAYMENT", ctrlkey);

                if (info == null)
                {
                    info = new NBrightInfo(true);
                    info.GUIDKey = ctrlkey;
                    info.TypeCode = "NBrightPayPalPAYMENT";
                    info.ModuleId = -1;
                    info.PortalId = PortalSettings.Current.PortalId;
                }

                Utils.SetCache("NBrightPayPalPaymentProvider" + PortalSettings.Current.PortalId.ToString(""), info);
            }

            return info;
        }
コード例 #22
0
ファイル: ShippingData.cs プロジェクト: Lewy-H/NBrightBuy
 public String UpdateRule(RepeaterItem rpItem, Boolean debugMode = false)
 {
     var strXml = GenXmlFunctions.GetGenXml(rpItem);
     // load into NBrigthInfo class, so it's easier to get at xml values.
     var objInfoIn = new NBrightInfo();
     objInfoIn.XMLData = strXml;
     UpdateRule(objInfoIn, debugMode);
     return ""; // if everything is OK, don't send a message back.
 }
コード例 #23
0
 public abstract String GetTemplate(NBrightInfo cartInfo);
コード例 #24
0
 public override string GetDeliveryLabelUrl(NBrightInfo cartInfo)
 {
     throw new NotImplementedException();
 }
コード例 #25
0
 public override NBrightInfo CalculateShipping(NBrightInfo cartInfo)
 {
     throw new NotImplementedException();
 }
コード例 #26
0
 public override NBrightInfo AfterSendEmail(NBrightInfo nbrightInfo, string emailsubjectrexkey)
 {
     return(nbrightInfo);
 }
コード例 #27
0
        public override NBrightInfo CalculateShipping(NBrightInfo cartInfo)
        {
            var    shipData   = new ShippingData(Shippingkey);
            var    shipoption = cartInfo.GetXmlProperty("genxml/extrainfo/genxml/radiobuttonlist/rblshippingoptions");
            Double rangeValue = 0;

            if (shipData.CalculationUnit == "1")
            {
                rangeValue = cartInfo.GetXmlPropertyDouble("genxml/totalweight");
            }
            else
            {
                rangeValue = cartInfo.GetXmlPropertyDouble("genxml/appliedsubtotal");
            }

            var countrycode = "";
            var regioncode  = "";
            var regionkey   = "";
            var postCode    = "";
            var total       = cartInfo.GetXmlPropertyDouble("genxml/appliedsubtotal");

            if (shipData.FreeshiplimitOnTotal == "True")
            {
                total = cartInfo.GetXmlPropertyDouble("genxml/carttotalvalue");
            }

            switch (shipoption)
            {
            case "1":
                countrycode = cartInfo.GetXmlProperty("genxml/billaddress/genxml/dropdownlist/country");
                regionkey   = cartInfo.GetXmlProperty("genxml/billaddress/genxml/dropdownlist/region");
                postCode    = cartInfo.GetXmlProperty("genxml/billaddress/genxml/textbox/postalcode");
                break;

            case "2":
                countrycode = cartInfo.GetXmlProperty("genxml/shipaddress/genxml/dropdownlist/country");
                regionkey   = cartInfo.GetXmlProperty("genxml/shipaddress/genxml/dropdownlist/region");
                postCode    = cartInfo.GetXmlProperty("genxml/shipaddress/genxml/textbox/postalcode");
                break;
            }

            var shippingcost = shipData.CalculateShippingByPC(postCode, rangeValue, total);

            if (shippingcost == -1)
            {
                if (regionkey != "")
                {
                    var rl = regionkey.Split(':');
                    if (rl.Count() == 2)
                    {
                        regioncode = rl[1];
                    }
                }
                shippingcost = shipData.CalculateShipping(countrycode, regioncode, rangeValue, total);
            }
            var shippingdealercost = shippingcost;

            cartInfo.SetXmlPropertyDouble("genxml/shippingcost", shippingcost);
            cartInfo.SetXmlPropertyDouble("genxml/shippingdealercost", shippingdealercost);

            return(cartInfo);
        }
コード例 #28
0
 public override NBrightInfo BeforeOrderStatusChange(NBrightInfo nbrightInfo)
 {
     return(nbrightInfo);
 }
コード例 #29
0
 public override NBrightInfo AfterOrderStatusChange(NBrightInfo nbrightInfo)
 {
     return(nbrightInfo);
 }
コード例 #30
0
 public override NBrightInfo AfterCategorySave(NBrightInfo nbrightInfo)
 {
     UrlRulesCaching.Remove(PortalSettings.Current.PortalId, nbrightInfo.ItemID, nbrightInfo.Lang);
     //NBrightBuyUtils.RemoveModCachePortalWide(PortalSettings.Current.PortalId);
     return(nbrightInfo);
 }
コード例 #31
0
 public override NBrightInfo AfterSavePurchaseData(NBrightInfo nbrightInfo)
 {
     return(nbrightInfo);
 }
コード例 #32
0
 public override NBrightInfo AfterCartSave(NBrightInfo nbrightInfo)
 {
     return(nbrightInfo);
 }
コード例 #33
0
 public override NBrightInfo ValidateCartItemAfter(NBrightInfo cartItemInfo)
 {
     return(cartItemInfo);
 }
コード例 #34
0
 public override NBrightInfo ValidateCartItemBefore(NBrightInfo cartItemInfo)
 {
     return(cartItemInfo);
 }
コード例 #35
0
ファイル: ShippingData.cs プロジェクト: Lewy-H/NBrightBuy
 public void UpdateRule(Repeater rpData)
 {
     foreach (RepeaterItem i in rpData.Items)
     {
         var strXml = GenXmlFunctions.GetGenXml(i);
         var nbi = new NBrightInfo(true);
         nbi.XMLData = strXml;
         if (nbi.GetXmlPropertyBool("genxml/hidden/isdirty"))
         {
             UpdateRule(i);
         }
     }
 }
コード例 #36
0
 public override NBrightInfo BeforePaymentFail(NBrightInfo nbrightInfo)
 {
     return(nbrightInfo);
 }
コード例 #37
0
 public virtual NBrightInfo EventBeforeUpdate(Repeater rpData, NBrightInfo objInfo)
 {
     return(objInfo);
 }
コード例 #38
0
 public virtual NBrightInfo EventBeforeRender(NBrightInfo objInfo)
 {
     return(objInfo);
 }
コード例 #39
0
 public override bool IsValid(NBrightInfo cartInfo)
 {
     throw new NotImplementedException();
 }
コード例 #40
0
        public override string DoWork(int portalId)
        {
            try
            {
                var objCtrl = new NBrightBuyController();
                var rtnmsg  = "";
                // check if we have NBS in this portal by looking for default settings.
                var nbssetting = objCtrl.GetByGuidKey(portalId, -1, "SETTINGS", "NBrightBuySettings");
                if (nbssetting != null)
                {
                    var pluginData = new PluginData(portalId);     // get plugin data to see if this scheduler is active on this portal
                    var plugin     = pluginData.GetPluginByCtrl("cartreview");
                    if (plugin != null && plugin.GetXmlPropertyBool("genxml/checkbox/active"))
                    {
                        var doscheduler = false;
                        // The NBS scheduler is normally set to run hourly, therefore if we only want a process to run daily we need the logic in this function.
                        // To do this we keep a last run flag on the sceduler settings
                        var setting = objCtrl.GetByGuidKey(portalId, -1, "NBrightCartReview", "NBrightCartReviewScheduler");
                        if (setting == null)
                        {
                            setting          = new NBrightInfo(true);
                            setting.ItemID   = -1;
                            setting.PortalId = portalId;
                            setting.TypeCode = "NBrightCartReview";
                            setting.GUIDKey  = "NBrightCartReviewScheduler";
                            setting.ModuleId = -1;
                            setting.XMLData  = "<genxml></genxml>";
                            doscheduler      = true;
                        }

                        if (plugin.GetXmlPropertyBool("genxml/checkbox/testmode") == true)
                        {
                            doscheduler = true;
                        }
                        else
                        {
                            // check last run date (Only running once a day in this case)
                            var lastrun = setting.GetXmlProperty("genxml/lastrun");
                            if (Utils.IsDate(lastrun) && (Convert.ToDateTime(lastrun).AddDays(1) < DateTime.Now))
                            {
                                doscheduler = true;
                            }
                        }


                        if (doscheduler)
                        {
                            var daysforzero   = plugin.GetXmlPropertyInt("genxml/textbox/daysforzero");
                            var daysfornormal = plugin.GetXmlPropertyInt("genxml/textbox/daysfornormal");

                            PurgeZeroCarts(portalId, daysforzero);
                            PurgeCarts(portalId, daysfornormal);

                            setting.SetXmlProperty("genxml/lastrun", DateTime.Now.ToString("s"), TypeCode.DateTime);
                            objCtrl.Update(setting);
                            rtnmsg = " - NBrightCartReview  " + portalId + " OK ";
                        }
                    }
                }

                return(rtnmsg);
            }
            catch (Exception ex)
            {
                return(" - NBrightCartReview FAIL: " + ex.ToString() + " : ");
            }
        }
コード例 #41
0
 public override string GetDeliveryLabelUrl(NBrightInfo cartInfo)
 {
     return("");
 }
コード例 #42
0
 public override NBrightInfo CalculateVoucherAmount(int portalId, int userId, NBrightInfo cartInfo, string discountcode)
 {
     throw new NotImplementedException();
 }
コード例 #43
0
 public override string GetTemplate(NBrightInfo cartInfo)
 {
     throw new NotImplementedException();
 }
コード例 #44
0
 public override NBrightInfo UpdatePercentUsage(int portalId, int userId, NBrightInfo purchaseInfo)
 {
     throw new NotImplementedException();
 }
コード例 #45
0
ファイル: PluginUtils.cs プロジェクト: wenyumou/OpenStore
        /// <summary>
        /// Search filesystem for any new plugins that have been added. Removed any deleted ones.
        /// </summary>
        public static void UpdateSystemPlugins()
        {
            // Add new plugins
            var updated             = false;
            var deleted             = false;
            var pluginfoldermappath = System.Web.Hosting.HostingEnvironment.MapPath(StoreSettings.NBrightBuyPath() + "/Plugins");

            if (pluginfoldermappath != null && Directory.Exists(pluginfoldermappath))
            {
                var objCtrl = new NBrightBuyController();
                var flist   = Directory.GetFiles(pluginfoldermappath, "*.xml");
                foreach (var f in flist)
                {
                    if (f.EndsWith(".xml"))
                    {
                        var datain = File.ReadAllText(f);
                        try
                        {
                            var nbi = new NBrightInfo();
                            nbi.XMLData = datain;
                            // check if we are injecting multiple
                            var nodlist = nbi.XMLDoc.SelectNodes("genxml");
                            if (nodlist != null && nodlist.Count > 0)
                            {
                                foreach (XmlNode nod in nodlist)
                                {
                                    var nbi2 = new NBrightInfo();
                                    nbi2.XMLData      = nod.OuterXml;
                                    nbi2.ItemID       = -1;
                                    nbi2.GUIDKey      = nbi.GetXmlProperty("genxml/textbox/ctrl");
                                    nbi2.PortalId     = 99999;
                                    nbi2.Lang         = "";
                                    nbi2.ParentItemId = 0;
                                    nbi2.ModuleId     = -1;
                                    nbi2.XrefItemId   = 0;
                                    nbi2.UserId       = 0;
                                    nbi2.TypeCode     = "PLUGIN";

                                    // check if record exists (should NOT) but lets replace if it does.
                                    var existingrecord = objCtrl.GetByGuidKey(-1, -1, "PLUGIN", nbi2.GUIDKey);
                                    if (existingrecord != null)
                                    {
                                        nbi2.ItemID = existingrecord.ItemID;
                                        if (nbi2.GetXmlPropertyBool("genxml/delete"))
                                        {
                                            var sysrecord = objCtrl.GetByGuidKey(99999, -1, "PLUGIN", nbi2.GUIDKey);
                                            objCtrl.Delete(existingrecord.ItemID);
                                            objCtrl.Delete(sysrecord.ItemID);
                                            File.Delete(f);
                                            deleted = true;
                                        }
                                        else
                                        {
                                            objCtrl.Update(nbi2);
                                            updated = true;
                                        }
                                    }
                                    else
                                    {
                                        objCtrl.Update(nbi2);
                                        updated = true;
                                    }
                                }
                            }
                            if (updated)
                            {
                                File.Delete(f);
                                //load entity typecode to DB idx settings.
                                NBrightBuyUtils.RegisterEnityTypeToDataBase();
                            }
                        }
                        catch (Exception)
                        {
                            // data might not be XML complient (ignore)
                        }
                    }
                }
            }

            if (updated || deleted)
            {
                if (updated)
                {
                    CopySystemPluginsToPortal();
                }
                if (deleted)
                {
                    DotNetNuke.Common.Utilities.DataCache.ClearCache();
                }
                ClearPluginCache(PortalSettings.Current.PortalId);
            }
        }
コード例 #46
0
        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();
            }
        }
コード例 #47
0
 public virtual void EventAfterUpdate(Repeater rpData, NBrightInfo objInfo)
 {
 }
コード例 #48
0
ファイル: ProfileData.cs プロジェクト: fujinguyen/NBrightBuy
        /// <summary>
        /// Save Data to DNN profile
        /// </summary>
        /// <param name="profile"></param>
        private void UpdateDnnProfile(NBrightInfo profile)
        {
            var flag = false;
            var prop1 = DnnUtils.GetUserProfileProperties(_uData.Info.UserId.ToString(""));
            var prop2 = DnnUtils.GetUserProfileProperties(_uData.Info.UserId.ToString(""));
            foreach (var p in prop1)
            {
                var n = profile.XMLDoc.SelectSingleNode("genxml/textbox/" + p.Key.ToLower());
                if (n != null)
                {
                    prop2[p.Key] = n.InnerText;
                    flag = true;
                }
                n = profile.XMLDoc.SelectSingleNode("genxml/dropdownlist/" + p.Key.ToLower());
                if (n != null)
                {
                    prop2[p.Key] = n.InnerText;
                    flag = true;
                }
                n = profile.XMLDoc.SelectSingleNode("genxml/radiobuttonlist/" + p.Key.ToLower());
                if (n != null)
                {
                    prop2[p.Key] = n.InnerText;
                    flag = true;
                }
            }
            if (flag) DnnUtils.SetUserProfileProperties(_uData.Info.UserId.ToString(""), prop2);

            // update email
            var email = profile.GetXmlProperty("genxml/textbox/email");
            if (email != "" && email != _uData.GetEmail()) _uData.UpdateEmail(email);
        }
コード例 #49
0
ファイル: EventInterface.cs プロジェクト: Lewy-H/NBrightBuy
 public abstract NBrightInfo ValidateCartItemBefore(NBrightInfo cartItemInfo);
コード例 #50
0
 public override double CalculateItemTax(NBrightInfo cartItemInfo)
 {
     throw new NotImplementedException();
 }
コード例 #51
0
ファイル: ShippingData.cs プロジェクト: Lewy-H/NBrightBuy
 public String UpdateRule(NBrightInfo ruleInfo, Boolean debugMode = false)
 {
     var addIndex = ruleInfo.GetXmlProperty("genxml/hidden/index");
     if (!Utils.IsNumeric(addIndex)) addIndex = "-1"; // assume new .
     var ruleIndex = Convert.ToInt32(addIndex);
     if (debugMode) ruleInfo.XMLDoc.Save(PortalSettings.Current.HomeDirectoryMapPath + "debug_ruleadd.xml");
     if (ruleIndex >= 0)
         {
             UpdateRule(ruleInfo.XMLData, ruleIndex);
         }
         else
         {
             _shippingList.Add(ruleInfo);
         }
     return ""; // if everything is OK, don't send a message back.
 }
コード例 #52
0
        private void DoImport(NBrightInfo nbi)
        {
            var fname = StoreSettings.Current.FolderUploadsMapPath + "\\" + nbi.GetXmlProperty("genxml/hidden/hiddatafile");

            if (System.IO.File.Exists(fname))
            {
                var xmlFile = new XmlDocument();
                xmlFile.Load(fname);

                if (GenXmlFunctions.GetField(rpData, "importproducts") == "True")
                {
                    ImportRecord(xmlFile, "PRD");
                    ImportRecord(xmlFile, "PRDLANG");

                    // import any entitytype provider data
                    // This is data created by plugins into the NBS data tables.
                    var pluginData = new PluginData(PortalSettings.Current.PortalId);
                    var provList   = pluginData.GetEntityTypeProviders();
                    foreach (var prov in provList)
                    {
                        var entityprov = EntityTypeInterface.Instance(prov.Key);
                        if (entityprov != null)
                        {
                            ImportRecord(xmlFile, entityprov.GetEntityTypeCode());
                            ImportRecord(xmlFile, entityprov.GetEntityTypeCodeLang());
                        }
                    }

                    ImportRecord(xmlFile, "PRDXREF");
                    ImportRecord(xmlFile, "USERPRDXREF");
                }

                if (GenXmlFunctions.GetField(rpData, "importcategories") == "True")
                {
                    ImportRecord(xmlFile, "CATEGORY");
                    ImportRecord(xmlFile, "CATEGORYLANG");
                }

                if (GenXmlFunctions.GetField(rpData, "importcategories") == "True" && GenXmlFunctions.GetField(rpData, "importproducts") == "True")
                {
                    ImportRecord(xmlFile, "CATCASCADE");
                    ImportRecord(xmlFile, "CATXREF");
                }

                if (GenXmlFunctions.GetField(rpData, "importproperties") == "True")
                {
                    ImportRecord(xmlFile, "GROUP");
                    ImportRecord(xmlFile, "GROUPLANG");
                }

                if (GenXmlFunctions.GetField(rpData, "importsettings") == "True")
                {
                    ImportRecord(xmlFile, "SETTINGS");
                }

                if (GenXmlFunctions.GetField(rpData, "importorders") == "True")
                {
                    ImportRecord(xmlFile, "ORDER");
                }

                RelinkNewIds();
            }
        }
コード例 #53
0
ファイル: ShippingData.cs プロジェクト: Lewy-H/NBrightBuy
        private void PopulateData(String shippingkey)
        {
            var modCtrl = new NBrightBuyController();
            Info = modCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "SHIPPING", shippingkey);
            if (Info == null)
            {
                Info = new NBrightInfo(true);
                Info.GUIDKey = shippingkey;
                Info.TypeCode = "SHIPPING";
                Info.ModuleId = -1;
                Info.PortalId = PortalSettings.Current.PortalId;
            }
            _shippingList = GetRuleList();

            // build range Data
            _rangeData = new List<RangeItem>();
            foreach (var i in _shippingList)
            {
                var rangeList = i.GetXmlProperty("genxml/textbox/shiprange");
                var rl = rangeList.Split(new string[] {"\n", "\r\n"}, StringSplitOptions.RemoveEmptyEntries);
                foreach (var s in rl)
                {
                    var ri = s.Split('=');
                    if (ri.Count() == 2  && Utils.IsNumeric(ri[1]))
                    {
                        var riV = ri[0].Split('-');
                        if (riV.Count() == 2 && Utils.IsNumeric(riV[0]) && Utils.IsNumeric(riV[1]))
                        {
                            var rItem = new RangeItem();
                            rItem.RefCsv = "," + i.GetXmlProperty("genxml/textbox/shipref") + ",";
                            rItem.RangeLow = Convert.ToDouble(riV[0],CultureInfo.GetCultureInfo("en-US"));
                            rItem.Cost = Convert.ToDouble(ri[1], CultureInfo.GetCultureInfo("en-US"));
                            rItem.RangeHigh = Convert.ToDouble(riV[1],CultureInfo.GetCultureInfo("en-US"));
                            _rangeData.Add(rItem);
                        }
                    }
                }
            }
        }
コード例 #54
0
 public override string GetTemplate(NBrightInfo cartInfo)
 {
     return("");
 }
コード例 #55
0
        private String GetProductListData(Dictionary<String, String> settings,bool paging = true)
        {
            var strOut = "";

            if (!settings.ContainsKey("header")) settings.Add("header", "");
            if (!settings.ContainsKey("body")) settings.Add("body", "");
            if (!settings.ContainsKey("footer")) settings.Add("footer", "");
            if (!settings.ContainsKey("filter")) settings.Add("filter", "");
            if (!settings.ContainsKey("orderby")) settings.Add("orderby", "");
            if (!settings.ContainsKey("returnlimit")) settings.Add("returnlimit", "0");
            if (!settings.ContainsKey("pagenumber")) settings.Add("pagenumber", "0");
            if (!settings.ContainsKey("pagesize")) settings.Add("pagesize", "0");
            if (!settings.ContainsKey("searchtext")) settings.Add("searchtext", "");
            if (!settings.ContainsKey("searchcategory")) settings.Add("searchcategory", "");
            if (!settings.ContainsKey("cascade")) settings.Add("cascade", "False");

            var header = settings["header"];
            var body = settings["body"];
            var footer = settings["footer"];
            var filter = settings["filter"];
            var orderby = settings["orderby"];
            var returnLimit = Convert.ToInt32(settings["returnlimit"]);
            var pageNumber = Convert.ToInt32(settings["pagenumber"]);
            var pageSize = Convert.ToInt32(settings["pagesize"]);
            var cascade = Convert.ToBoolean(settings["cascade"]);

            var searchText = settings["searchtext"];
            var searchCategory = settings["searchcategory"];

            if (searchText != "") filter += " and (NB3.[ProductName] like '%" + searchText + "%' or NB3.[ProductRef] like '%" + searchText + "%' or NB3.[Summary] like '%" + searchText + "%' ) ";

            if (Utils.IsNumeric(searchCategory))
            {
                if (orderby == "{bycategoryproduct}") orderby += searchCategory;
                var objQual = DataProvider.Instance().ObjectQualifier;
                var dbOwner = DataProvider.Instance().DatabaseOwner;
                if (!cascade)
                    filter += " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where typecode = 'CATXREF' and XrefItemId = " + searchCategory + ") ";
                else
                    filter += " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where (typecode = 'CATXREF' and XrefItemId = " + searchCategory + ") or (typecode = 'CATCASCADE' and XrefItemId = " + searchCategory + ")) ";
            }
            else
            {
                if (orderby == "{bycategoryproduct}") orderby = " order by NB3.productname ";
            }

            var recordCount = 0;

            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();

            var headerTempl = templCtrl.GetTemplateData(header, _lang, true, true, true, StoreSettings.Current.Settings());
            var bodyTempl = templCtrl.GetTemplateData(body, _lang, true, true, true, StoreSettings.Current.Settings());
            var footerTempl = templCtrl.GetTemplateData(footer, _lang, true, true, true, StoreSettings.Current.Settings());

            // replace any settings tokens (This is used to place the form data into the SQL)
            headerTempl = Utils.ReplaceSettingTokens(headerTempl, settings);
            headerTempl = Utils.ReplaceUrlTokens(headerTempl);
            bodyTempl = Utils.ReplaceSettingTokens(bodyTempl, settings);
            bodyTempl = Utils.ReplaceUrlTokens(bodyTempl);
            footerTempl = Utils.ReplaceSettingTokens(footerTempl, settings);
            footerTempl = Utils.ReplaceUrlTokens(footerTempl);

            var obj = new NBrightInfo(true);
            strOut = GenXmlFunctions.RenderRepeater(obj, headerTempl);

            if (paging) // get record count for paging
            {
                if (pageNumber == 0) pageNumber = 1;
                if (pageSize == 0) pageSize = StoreSettings.Current.GetInt("pagesize");
                recordCount = objCtrl.GetListCount(PortalSettings.Current.PortalId, -1, "PRD", filter,"PRDLANG",_lang);
            }

            var objList = objCtrl.GetDataList(PortalSettings.Current.PortalId, -1, "PRD", "PRDLANG", _lang, filter, orderby, StoreSettings.Current.DebugMode,"",returnLimit,pageNumber,pageSize,recordCount);
            strOut += GenXmlFunctions.RenderRepeater(objList, bodyTempl);

            strOut += GenXmlFunctions.RenderRepeater(obj, footerTempl);

            // add paging if needed
            if (paging)
            {
                var pg = new NBrightCore.controls.PagingCtrl();
                strOut += pg.RenderPager(recordCount, pageSize, pageNumber);
            }

            return strOut;
        }
コード例 #56
0
        public override NBrightInfo CalculateVoucherAmount(int portalId, int userId, NBrightInfo cartInfo, string discountcode)
        {
            cartInfo.SetXmlPropertyDouble("genxml/discountstatus", "");
            cartInfo.SetXmlPropertyDouble("genxml/voucherdiscount", "0"); // reset discount amount
            Double discountcodeamt = 0;

            if (userId > 0)
            {
                var clientData = new ClientData(portalId, userId);
                if (clientData.DiscountCodes.Count > 0)
                {
                    var subtotal = cartInfo.GetXmlPropertyDouble("genxml/subtotal");
                    // do client voucher discount on total cart
                    foreach (var d in clientData.VoucherCodes)
                    {
                        var validutil     = d.GetXmlProperty("genxml/textbox/validuntil");
                        var validutildate = DateTime.Today;
                        if (Utils.IsDate(validutil))
                        {
                            validutildate = Convert.ToDateTime(validutil);
                        }
                        if (d.GetXmlProperty("genxml/textbox/coderef").ToLower() == discountcode.ToLower() && validutildate >= DateTime.Today)
                        {
                            var amount = d.GetXmlPropertyDouble("genxml/textbox/amount");
                            if (amount > 0)
                            {
                                if (subtotal >= amount)
                                {
                                    discountcodeamt = amount;
                                }
                                else
                                {
                                    discountcodeamt = subtotal;
                                }
                                cartInfo.SetXmlPropertyDouble("genxml/discountstatus", "valid");
                            }
                            else
                            {
                                cartInfo.SetXmlPropertyDouble("genxml/discountstatus", "invalid");
                            }
                        }
                        if (discountcodeamt > 0)
                        {
                            break;
                        }
                    }
                }
            }

            if (discountcodeamt == 0) // if no client level, calc any portal level percentage discount
            {
                var objCtrl = new NBrightBuyController();
                var d       = objCtrl.GetByGuidKey(portalId, -1, "DISCOUNTCODE", discountcode);
                if (d != null)
                {
                    var validutil     = d.GetXmlProperty("genxml/textbox/validuntil");
                    var validutildate = DateTime.Today;
                    if (Utils.IsDate(validutil))
                    {
                        validutildate = Convert.ToDateTime(validutil);
                    }
                    if (validutildate >= DateTime.Today && d.GetXmlProperty("genxml/radiobuttonlist/amounttype") == "1")
                    {
                        var minamountlimit  = d.GetXmlPropertyDouble("genxml/textbox/minamountlimit");
                        var amount          = d.GetXmlPropertyDouble("genxml/textbox/amount");
                        var usage           = d.GetXmlPropertyDouble("genxml/textbox/usage");
                        var usagelimit      = d.GetXmlPropertyDouble("genxml/textbox/usagelimit");
                        var appliedsubtotal = cartInfo.GetXmlPropertyDouble("genxml/appliedsubtotal");
                        if (amount > 0 && (usagelimit == 0 || usagelimit > usage) && (appliedsubtotal >= minamountlimit))
                        {
                            discountcodeamt = amount;
                            cartInfo.SetXmlPropertyDouble("genxml/discountstatus", "valid");
                        }
                        else
                        {
                            cartInfo.SetXmlPropertyDouble("genxml/discountstatus", "invalid");
                        }
                    }
                }
            }

            cartInfo.SetXmlPropertyDouble("genxml/voucherdiscount", discountcodeamt); // reset discount amount

            return(cartInfo);
        }
コード例 #57
0
        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;
        }
コード例 #58
0
        private void ImportRecord(XmlDocument xmlFile, String typeCode, Boolean updaterecordsbyref = true)
        {
            var nodList = xmlFile.SelectNodes("root/item[./typecode='" + typeCode + "']");

            if (nodList != null)
            {
                foreach (XmlNode nod in nodList)
                {
                    var nbi = new NBrightInfo();
                    nbi.FromXmlItem(nod.OuterXml);
                    var olditemid = nbi.ItemID;

                    // check to see if we have a new record or updating a existing one, use the ref field to find out.
                    nbi.ItemID = -1;
                    if (nbi.PortalId >= 0)
                    {
                        nbi.PortalId = PortalId;                    // shared products have -1 portalid
                    }
                    if (typeCode == "PRD" && updaterecordsbyref)
                    {
                        var itemref = nbi.GetXmlProperty("genxml/textbox/txtproductref");
                        if (itemref != "")
                        {
                            var l = ModCtrl.GetList(nbi.PortalId, -1, "PRD", " and NB1.XmlData.value('(genxml/textbox/txtproductref)[1]','nvarchar(max)') = '" + itemref.Replace("'", "''") + "' ");
                            if (l.Count > 0)
                            {
                                nbi.ItemID = l[0].ItemID;
                            }
                        }
                    }
                    if (typeCode == "PRDLANG")
                    {
                        if (_recordXref.ContainsKey(nbi.ParentItemId))
                        {
                            var l = ModCtrl.GetList(nbi.PortalId, -1, "PRDLANG", " and NB1.parentitemid = '" + _recordXref[nbi.ParentItemId].ToString("") + "' and NB1.Lang = '" + nbi.Lang + "'");
                            if (l.Count > 0)
                            {
                                nbi.ItemID = l[0].ItemID;
                            }
                            nbi.ParentItemId = _recordXref[nbi.ParentItemId];
                        }
                    }



                    // import any entitytype provider data
                    // This is data created by plugins into the NBS data tables.
                    var pluginData = new PluginData(PortalSettings.Current.PortalId);
                    var provList   = pluginData.GetEntityTypeProviders();
                    foreach (var prov in provList)
                    {
                        var entityprov = EntityTypeInterface.Instance(prov.Key);
                        if (entityprov != null)
                        {
                            if (typeCode == entityprov.GetEntityTypeCode() && updaterecordsbyref)
                            {
                                var itemref = nbi.GetXmlProperty("genxml/textbox/txtproductref");
                                if (itemref != "")
                                {
                                    var l = ModCtrl.GetList(nbi.PortalId, -1, entityprov.GetEntityTypeCode(), " and NB3.ProductRef = '" + itemref.Replace("'", "''") + "' ");
                                    if (l.Count > 0)
                                    {
                                        nbi.ItemID = l[0].ItemID;
                                    }
                                }
                            }
                            if (typeCode == entityprov.GetEntityTypeCodeLang())
                            {
                                if (_recordXref.ContainsKey(nbi.ParentItemId))
                                {
                                    var l = ModCtrl.GetList(nbi.PortalId, -1, entityprov.GetEntityTypeCodeLang(), " and NB1.parentitemid = '" + _recordXref[nbi.ParentItemId].ToString("") + "' and NB1.Lang = '" + nbi.Lang + "'");
                                    if (l.Count > 0)
                                    {
                                        nbi.ItemID = l[0].ItemID;
                                    }
                                    nbi.ParentItemId = _recordXref[nbi.ParentItemId];
                                }
                            }
                        }
                    }


                    if ((typeCode == "PRDXREF" || typeCode == "CATXREF" || typeCode == "CATCASCADE"))
                    {
                        if (_recordXref.ContainsKey(nbi.XrefItemId))
                        {
                            nbi.XrefItemId = _recordXref[nbi.XrefItemId];
                        }
                        if (_recordXref.ContainsKey(nbi.ParentItemId))
                        {
                            nbi.ParentItemId = _recordXref[nbi.ParentItemId];
                        }

                        var l = ModCtrl.GetList(nbi.PortalId, -1, typeCode, " AND nb1.XrefItemId = " + nbi.XrefItemId + " AND nb1.ParentItemId=" + nbi.ParentItemId);
                        if (l.Count > 0)
                        {
                            return;
                        }
                    }

                    if (typeCode == "USERPRDXREF")
                    {
                        var u = UserController.GetUserByName(nbi.PortalId, nbi.TextData);
                        if (u != null)
                        {
                            if (_recordXref.ContainsKey(nbi.ParentItemId))
                            {
                                nbi.ParentItemId = _recordXref[nbi.ParentItemId];
                            }
                            if (_recordXref.ContainsKey(nbi.XrefItemId))
                            {
                                nbi.UserId = u.UserID;
                            }

                            var l = ModCtrl.GetList(nbi.PortalId, -1, "USERPRDXREF", " AND nb1.UserId = " + nbi.UserId + " AND nb1.ParentItemId=" + nbi.ParentItemId);
                            if (l.Count > 0)
                            {
                                return;
                            }
                        }
                    }


                    if (typeCode == "CATEGORY" && updaterecordsbyref)
                    {
                        var itemref = nbi.GetXmlProperty("genxml/textbox/txtcategoryref");
                        if (itemref != "")
                        {
                            var l = ModCtrl.GetList(nbi.PortalId, -1, "CATEGORY", " and [XMLData].value('(genxml/textbox/txtcategoryref)[1]','nvarchar(max)') = '" + itemref.Replace("'", "''") + "' ");
                            if (l.Count > 0)
                            {
                                nbi.ItemID = l[0].ItemID;
                            }
                        }
                    }
                    if (typeCode == "CATEGORYLANG")
                    {
                        if (_recordXref.ContainsKey(nbi.ParentItemId))
                        {
                            var l = ModCtrl.GetList(nbi.PortalId, -1, "CATEGORYLANG", " and NB1.parentitemid = '" + _recordXref[nbi.ParentItemId].ToString("") + "' and NB1.Lang = '" + nbi.Lang + "'");
                            if (l.Count > 0)
                            {
                                nbi.ItemID = l[0].ItemID;
                            }
                            nbi.ParentItemId = _recordXref[nbi.ParentItemId];
                        }
                    }
                    if (typeCode == "GROUP" && updaterecordsbyref)
                    {
                        var itemref = nbi.GetXmlProperty("genxml/textbox/groupref");
                        if (itemref != "")
                        {
                            var l = ModCtrl.GetList(nbi.PortalId, -1, "GROUP", " and [XMLData].value('(genxml/textbox/groupref)[1]','nvarchar(max)') = '" + itemref.Replace("'", "''") + "' ");
                            if (l.Count > 0)
                            {
                                nbi.ItemID = l[0].ItemID;
                            }
                        }
                    }
                    if (typeCode == "GROUPLANG")
                    {
                        if (_recordXref.ContainsKey(nbi.ParentItemId))
                        {
                            var l = ModCtrl.GetList(nbi.PortalId, -1, "GROUPLANG", " and NB1.parentitemid = '" + _recordXref[nbi.ParentItemId].ToString("") + "' and NB1.Lang = '" + nbi.Lang + "'");
                            if (l.Count > 0)
                            {
                                nbi.ItemID = l[0].ItemID;
                            }
                            nbi.ParentItemId = _recordXref[nbi.ParentItemId];
                        }
                    }
                    if (typeCode == "SETTINGS") // the setting exported are only the portal settings, not module.  So always update and don;t create new.
                    {
                        var l = ModCtrl.GetList(nbi.PortalId, 0, "SETTINGS", " and NB1.GUIDKey = 'NBrightBuySettings' ");
                        if (l.Count > 0)
                        {
                            nbi.ItemID = l[0].ItemID;
                        }
                    }
                    //NOTE: if ORDERS are imported, we expect those to ALWAYS be new records, we don't want to delete any validate orders in this import.

                    // NOTE: we expect the records to be done in typecode order so we know parent and xref itemids.

                    var newitemid = ModCtrl.Update(nbi);
                    if (newitemid > 0)
                    {
                        _recordXref.Add(olditemid, newitemid);
                    }
                    if (typeCode == "PRD" && !_productList.ContainsKey(newitemid))
                    {
                        _productList.Add(newitemid, typeCode);
                    }

                    // Add any provider data types
                    foreach (var prov in provList)
                    {
                        var entityprov = EntityTypeInterface.Instance(prov.Key);
                        if (entityprov != null)
                        {
                            if (typeCode == entityprov.GetEntityTypeCode())
                            {
                                _productList.Add(newitemid, typeCode);
                            }
                        }
                    }
                }
            }
        }
コード例 #59
0
 public override NBrightInfo AfterPaymentFail(NBrightInfo nbrightInfo)
 {
     return(nbrightInfo);
 }
コード例 #60
0
 public override NBrightInfo UpdateVoucherAmount(int portalId, int userId, NBrightInfo purchaseInfo)
 {
     throw new NotImplementedException();
 }