Esempio n. 1
0
        private String SaveData(HttpContext context)
        {
            var objCtrl = new NBrightBuyController();

            //get uploaded params
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);

            var itemid   = ajaxInfo.GetXmlProperty("genxml/hidden/itemid");
            var editlang = ajaxInfo.GetXmlProperty("genxml/hidden/editlang");

            if (editlang == "")
            {
                editlang = Utils.GetCurrentCulture();
            }

            if (Utils.IsNumeric(itemid))
            {
                // get DB record
                var nbi = objCtrl.Get(Convert.ToInt32(itemid));
                if (nbi != null)
                {
                    var typecode = nbi.TypeCode;

                    // get data passed back by ajax
                    var strIn = HttpUtility.UrlDecode(Utils.RequestParam(context, "inputxml"));
                    // update record with ajax data
                    nbi.UpdateAjax(strIn);
                    nbi.GUIDKey = nbi.GetXmlProperty("genxml/textbox/ref");
                    objCtrl.Update(nbi);

                    // do langauge record
                    var nbi2 = objCtrl.GetDataLang(Convert.ToInt32(itemid), editlang);
                    nbi2.UpdateAjax(strIn);
                    objCtrl.Update(nbi2);

                    DataCache.ClearCache(); // clear ALL cache.
                }
            }
            return("");
        }
        private String AddNew(String moduleid, String typeCode)
        {
            if (!Utils.IsNumeric(moduleid))
            {
                moduleid = "-2";                             // -2 for razor
            }
            var objCtrl = new NBrightBuyController();
            var nbi     = new NBrightInfo(true);

            nbi.PortalId = PortalSettings.Current.PortalId;
            nbi.TypeCode = typeCode;
            nbi.ModuleId = Convert.ToInt32(moduleid);
            nbi.ItemID   = -1;
            if (typeCode == "DISCOUNTCODE")
            {
                nbi.SetXmlProperty("genxml/textbox/code", Utils.GetUniqueKey().ToUpper());
                nbi.GUIDKey = nbi.GetXmlProperty("genxml/textbox/code");
            }
            var itemId = objCtrl.Update(nbi);

            nbi.ItemID = itemId;

            foreach (var lang in DnnUtils.GetCultureCodeList(PortalSettings.Current.PortalId))
            {
                var nbi2 = new NBrightInfo(true);
                nbi2.PortalId     = PortalSettings.Current.PortalId;
                nbi2.TypeCode     = typeCode + "LANG";
                nbi2.ModuleId     = Convert.ToInt32(moduleid);
                nbi2.ItemID       = -1;
                nbi2.Lang         = lang;
                nbi2.ParentItemId = itemId;
                nbi2.GUIDKey      = "";
                nbi2.ItemID       = objCtrl.Update(nbi2);
            }

            NBrightBuyUtils.RemoveModCache(nbi.ModuleId);

            return(nbi.ItemID.ToString(""));
        }
Esempio n. 3
0
        private static void FlagProductMultiBuy(int portalid, int productId, string promoname, int promoid, String promoType, DateTime dteF, DateTime dteU)
        {
            var cultureList = DnnUtils.GetCultureCodeList(portalid);
            var objCtrl     = new NBrightBuyController();
            var prdData     = objCtrl.GetData(productId);

            var nodList = prdData.XMLDoc.SelectNodes("genxml/models/genxml");

            if (nodList != null)
            {
                var currentpromoid = prdData.GetXmlPropertyInt("genxml/hidden/promoid");
                if (currentpromoid == 0 || currentpromoid == promoid)
                {
                    prdData.SetXmlProperty("genxml/hidden/promotype", promoType);
                    prdData.SetXmlProperty("genxml/hidden/promoname", promoname);
                    prdData.SetXmlProperty("genxml/hidden/promoid", promoid.ToString());
                    prdData.SetXmlProperty("genxml/hidden/promocalcdate", DateTime.Now.ToString("O"));
                    prdData.SetXmlProperty("genxml/hidden/datefrom", dteF.ToString("O"));
                    prdData.SetXmlProperty("genxml/hidden/dateuntil", dteU.ToString("O"));

                    objCtrl.Update(prdData);
                    if (promoType == "PROMOMULTIBUY")
                    {
                        foreach (var lang in cultureList)
                        {
                            var p           = objCtrl.GetDataLang(promoid, lang);
                            var prdDataLang = objCtrl.GetDataLang(productId, lang);
                            if (prdDataLang != null)
                            {
                                prdDataLang.SetXmlProperty("genxml/hidden/promodesc", p.GetXmlProperty("genxml/textbox/description"));
                                objCtrl.Update(prdDataLang);
                            }
                        }
                    }
                }
            }
        }
        private void Update()
        {
            var modCtrl = new NBrightBuyController();
            var strXml  = GenXmlFunctions.GetGenXml(rpDataH);

            _info.XMLData = strXml;
            _info.SetXmlProperty("genxml/debugmsg", "");
            modCtrl.Update(_info);

            var resxDic     = GenXmlFunctions.GetGenXmlResx(rpDataH);
            var genTempl    = (GenXmlTemplate)rpDataH.ItemTemplate;
            var resxfolders = genTempl.GetResxFolders();
            var resxUpdate  = NBrightBuyUtils.UpdateResxFields(resxDic, resxfolders, StoreSettings.Current.EditLanguage, true);

            //remove current setting from cache for reload
            Utils.RemoveCache("NBrightPayPalPaymentProvider" + PortalSettings.Current.PortalId.ToString(""));
        }
Esempio n. 5
0
        /// <summary>
        /// This function needs to process and returned message from the bank.
        /// This processing may vary widely between banks.
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            var modCtrl = new NBrightBuyController();
            var info    = modCtrl.GetPluginSinglePageData("OSPayPlugpayment", "OSPayPlugPAYMENT", Utils.GetCurrentCulture());

            try
            {
                var orderid = Utils.RequestQueryStringParam(context, "oid");
                if (Utils.IsNumeric(orderid))
                {
                    var orderData  = new OrderData(Convert.ToInt32(orderid));
                    var paymentkey = orderData.PurchaseInfo.GetXmlProperty("genxml/paymentkey");
                    if (paymentkey != "")
                    {
                        var payPlugData = new PayPlugLimpet(orderData);
                        var paymentData = payPlugData.RetrievePayment(paymentkey);
                        if (paymentData != null && paymentData.ContainsKey("is_paid"))
                        {
                            if (paymentData["is_paid"])
                            {
                                orderData.PaymentOk();
                            }
                            else
                            {
                                orderData.PaymentFail();
                            }
                        }
                    }
                }

                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.Write("OK");
                HttpContext.Current.Response.ContentType  = "text/plain";
                HttpContext.Current.Response.CacheControl = "no-cache";
                HttpContext.Current.Response.Expires      = -1;
                HttpContext.Current.Response.End();
            }
            catch (Exception ex)
            {
                if (!ex.ToString().StartsWith("System.Threading.ThreadAbortException")) // we expect a thread abort from the End response.
                {
                    info.SetXmlProperty("genxml/debugmsg", "OS_PayPlug ERROR: " + ex.ToString());
                    modCtrl.Update(info);
                }
            }
        }
Esempio n. 6
0
        private void MoveRecord(int movetocatid, int movecatid)
        {
            if (movecatid > 0)
            {
                var movData = CategoryUtils.GetCategoryData(movetocatid, EditLangCurrent);
                var selData = CategoryUtils.GetCategoryData(movecatid, EditLangCurrent);
                if (movData.Exists && selData.Exists)
                {
                    var fromParentItemid = selData.DataRecord.ParentItemId;
                    var toParentItemid   = movData.DataRecord.ParentItemId;
                    var reindex          = toParentItemid != fromParentItemid;
                    var objGrpCtrl       = new GrpCatController(EditLangCurrent);
                    var movGrp           = objGrpCtrl.GetGrpCategory(movData.Info.ItemID);
                    if (!movGrp.Parents.Contains(selData.Info.ItemID)) // cannot move a category into itself (i.e. move parent into sub-category)
                    {
                        selData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlparentcatid", toParentItemid.ToString(""));
                        selData.DataRecord.ParentItemId = toParentItemid;
                        selData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlgrouptype", movData.DataRecord.GetXmlProperty("genxml/dropdownlist/ddlgrouptype"));
                        var strneworder = movData.DataRecord.GetXmlPropertyDouble("genxml/hidden/recordsortorder");
                        var selorder    = selData.DataRecord.GetXmlPropertyDouble("genxml/hidden/recordsortorder");
                        var neworder    = Convert.ToDouble(strneworder, CultureInfo.GetCultureInfo("en-US"));
                        if (strneworder < selorder)
                        {
                            neworder = neworder - 0.5;
                        }
                        else
                        {
                            neworder = neworder + 0.5;
                        }
                        selData.DataRecord.SetXmlProperty("genxml/hidden/recordsortorder", neworder.ToString(""), TypeCode.Double);
                        var objCtrl = new NBrightBuyController();
                        objCtrl.Update(selData.DataRecord);

                        FixRecordSortOrder(toParentItemid.ToString(""), EditLangCurrent); //reindex all siblings (this is so we get a int on the recordsortorder)
                        FixRecordGroupType(selData.Info.ItemID.ToString(""), selData.DataRecord.GetXmlProperty("genxml/dropdownlist/ddlgrouptype"), EditLangCurrent);

                        if (reindex)
                        {
                            objGrpCtrl.ReIndexCascade(fromParentItemid);    // reindex from parent and parents.
                            objGrpCtrl.ReIndexCascade(selData.Info.ItemID); // reindex select and parents
                        }
                        NBrightBuyUtils.RemoveModCachePortalWide(PortalSettings.Current.PortalId);
                    }
                }
            }
        }
Esempio n. 7
0
        public static void PluginSave(HttpContext context)
        {
            if (NBrightBuyUtils.CheckRights())
            {
                var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);
                var itemid   = ajaxInfo.GetXmlProperty("genxml/hidden/itemid");
                if (Utils.IsNumeric(itemid))
                {
                    var objCtrl      = new NBrightBuyController();
                    var info         = objCtrl.GetData(Convert.ToInt32(itemid));
                    var pluginRecord = new PluginRecord(info);
                    var modelXml     = Utils.UnCode(ajaxInfo.GetXmlProperty("genxml/hidden/xmlupdatemodeldata"));

                    ajaxInfo.RemoveXmlNode("genxml/hidden/xmlupdatemodeldata");
                    pluginRecord.Info().XMLData = ajaxInfo.XMLData;

                    // check for unique ctrl ref
                    var ctrlref  = pluginRecord.Info().GetXmlProperty("genxml/textbox/ctrl");
                    var ctrltest = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "PLUGIN", ctrlref);
                    if (ctrltest != null)
                    {
                        if (ctrltest.ItemID != pluginRecord.Info().ItemID)
                        {
                            pluginRecord.Info().SetXmlProperty("genxml/textbox/ctrl", pluginRecord.Info().GetXmlProperty("genxml/textbox/ctrl") + Utils.GetUniqueKey());
                        }
                    }

                    // make sure index is in correct format, (FLOAT) for SQL
                    pluginRecord.Info().SetXmlProperty("genxml/hidden/index", (pluginRecord.Info().GetXmlPropertyInt("genxml/hidden/index").ToString()), TypeCode.Double);
                    pluginRecord.Info().RemoveXmlNode("genxml/hidden/itemid");
                    pluginRecord.Info().RemoveXmlNode("genxml/hidden/editlanguage");
                    pluginRecord.Info().RemoveXmlNode("genxml/hidden/uilang1");
                    pluginRecord.Info().GUIDKey = pluginRecord.Info().GetXmlProperty("genxml/textbox/ctrl");

                    pluginRecord.UpdateModels(modelXml, Utils.GetCurrentCulture());
                    objCtrl.Update(pluginRecord.Info());

                    // remove save GetData cache
                    DataCache.ClearCache();

                    //load entity typecode to DB idx settings.
                    NBrightBuyUtils.RegisterEnityTypeToDataBase();
                }
            }
        }
        public override NBrightInfo UpdatePercentUsage(int portalId, int userId, NBrightInfo purchaseInfo)
        {
            var discountcode = purchaseInfo.GetXmlProperty("genxml/extrainfo/genxml/textbox/promocode");

            if (!purchaseInfo.GetXmlPropertyBool("genxml/discountprocessed"))
            {
                if (userId > 0)
                {
                    if (discountcode == "")
                    {
                        return(purchaseInfo);
                    }
                    var clientData = new ClientData(portalId, userId);
                    if (clientData.DiscountCodes.Count > 0)
                    {
                        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");
                    }
                }

                var objCtrl = new NBrightBuyController();
                var dis     = objCtrl.GetByGuidKey(portalId, -1, "DISCOUNTCODE", discountcode);
                if (dis != null)
                {
                    var usage = dis.GetXmlPropertyDouble("genxml/textbox/usage");
                    dis.SetXmlPropertyDouble("genxml/textbox/usage", (usage + 1));
                    objCtrl.Update(dis);
                    purchaseInfo.SetXmlProperty("genxml/discountprocessed", "True");
                }
            }

            return(purchaseInfo);
        }
        private string AddReport(HttpContext context)
        {
            var objCtrl = new NBrightBuyController();
            var obj     = new NBrightInfo(true);

            obj.TypeCode = "NBSREPORT";
            obj.SetXmlProperty("genxml/lang/genxml/textbox/name", "New Report");
            obj.PortalId = PortalSettings.Current.PortalId;
            obj.ModuleId = -1;
            obj.ItemID   = -1;
            objCtrl.Update(obj);

            var cachekey = "GetReportListData*" + PortalSettings.Current.PortalId.ToString("");

            Utils.RemoveCache(cachekey);

            return("");
        }
Esempio n. 10
0
        public static PaymentResponse GetOrderPaymentResponse(OrderData orderData, string origin)
        {
            var info   = ProviderUtils.GetProviderSettings();
            var apiKey = info.GetXmlProperty("genxml/textbox/key");

            IPaymentClient paymentClient = new PaymentClient(apiKey);
            var            task          = Task.Run(async() => await paymentClient.GetPaymentAsync(orderData.PaymentPassKey));

            task.Wait();
            PaymentResponse paymentClientResult = task.Result;

            if (string.IsNullOrEmpty(orderData.GetInfo().GetXmlNode("genxml/paymentreturn")))
            {
                orderData.GetInfo().AddSingleNode("paymentreturn", "", "genxml");
            }

            var xmlDoc  = orderData.GetInfo().XMLDoc;
            var newNode = xmlDoc.CreateNode(XmlNodeType.Element, "data", "");
            var dtAttr  = newNode.Attributes.Append(xmlDoc.CreateAttribute("timestamp"));

            dtAttr.Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            newNode.Attributes.Append(dtAttr);

            var xml = $@"<data timestamp=""{DateTime.Now:yyyy-MM-dd HH:mm:ss}"" origin=""{origin}"">
    <created>{paymentClientResult.CreatedAt:yyyy-MM-dd HH:mm:ss}</created>
    <cancelled>{paymentClientResult.CreatedAt:yyyy-MM-dd HH:mm:ss}</cancelled>
    <expired>{paymentClientResult.CreatedAt:yyyy-MM-dd HH:mm:ss}</expired>
    <failed>{paymentClientResult.CreatedAt:yyyy-MM-dd HH:mm:ss}</failed>
    <paied>{paymentClientResult.CreatedAt:yyyy-MM-dd HH:mm:ss}</paied>
    <description>{paymentClientResult.Description}</description>
    <method>{paymentClientResult.Method}</method>
    <amount>{paymentClientResult.Amount.Value}</amount>
    <currency>{paymentClientResult.Amount.Currency}</currency>
    <status>{paymentClientResult.Status}</status>
</data>";

            orderData.GetInfo().AddXmlNode(xml, "data", "genxml/paymentreturn");
            var modCtrl = new NBrightBuyController();

            modCtrl.Update(orderData.GetInfo());

            return(paymentClientResult);
        }
Esempio n. 11
0
        private void AddNewImage(int itemId, String imageurl, String imagepath)
        {
            var objCtrl    = new NBrightBuyController();
            var dataRecord = objCtrl.Get(itemId);

            if (dataRecord != null)
            {
                var strXml = "<genxml><imgs><genxml><hidden><imagepath>" + imagepath + "</imagepath><imageurl>" + imageurl + "</imageurl></hidden></genxml></imgs></genxml>";
                if (dataRecord.XMLDoc.SelectSingleNode("genxml/imgs") == null)
                {
                    dataRecord.AddXmlNode(strXml, "genxml/imgs", "genxml");
                }
                else
                {
                    dataRecord.AddXmlNode(strXml, "genxml/imgs/genxml", "genxml/imgs");
                }
                objCtrl.Update(dataRecord);
            }
        }
Esempio n. 12
0
        private String SaveSettings(HttpContext context)
        {
            try
            {
                var objCtrl = new NBrightBuyController();

                //get uploaded params
                var ajaxInfo = NBrightBuyUtils.GetAjaxInfo(context);

                var moduleid = ajaxInfo.GetXmlProperty("genxml/hidden/moduleid");
                if (Utils.IsNumeric(moduleid))
                {
                    // get DB record
                    var nbi = NBrightBuyUtils.GetSettings(PortalSettings.Current.PortalId, Convert.ToInt32(moduleid));
                    if (nbi.ModuleId == 0) // new setting record
                    {
                        nbi = CreateSettingsInfo(moduleid, nbi);
                    }
                    // get data passed back by ajax
                    var strIn = HttpUtility.UrlDecode(Utils.RequestParam(context, "inputxml"));
                    // update record with ajax data
                    nbi.UpdateAjax(strIn);


                    if (nbi.GetXmlProperty("genxml/hidden/modref") == "")
                    {
                        nbi.SetXmlProperty("genxml/hidden/modref", Utils.GetUniqueKey(10));
                    }
                    if (nbi.TextData == "")
                    {
                        nbi.TextData = "NBrightBuy";
                    }
                    objCtrl.Update(nbi);
                    NBrightBuyUtils.RemoveModCachePortalWide(PortalSettings.Current.PortalId); // make sure all new settings are used.
                }
                return("");
            }
            catch (Exception ex)
            {
                Logging.LogException(ex);
                return(ex.ToString());
            }
        }
Esempio n. 13
0
        private void Update()
        {
            var modCtrl = new NBrightBuyController();
            var strXml  = GenXmlFunctions.GetGenXml(rpDataH, "", StoreSettings.Current.FolderImagesMapPath);

            _info.XMLData = strXml;
            modCtrl.Update(_info);

            var resxDic     = GenXmlFunctions.GetGenXmlResx(rpDataH);
            var genTempl    = (GenXmlTemplate)rpDataH.ItemTemplate;
            var resxfolders = genTempl.GetResxFolders();
            var resxUpdate  = NBrightBuyUtils.UpdateResxFields(resxDic, resxfolders, StoreSettings.Current.EditLanguage, true);

            // NOTE: For some reason this action restarts the application, not sure why, but it's a side effect that helps display the new resx change. So I'm leaving it for now!
            //  This restart doesn;t happen with the update of the settings page???

            //remove current setting from cache for reload
            Utils.RemoveCache("ManualPaymentProvider" + PortalSettings.Current.PortalId.ToString(""));
        }
Esempio n. 14
0
        /// <summary>
        /// Save cart
        /// </summary>
        public void Save(Boolean debugMode = false)
        {
            var strXML = "<list>";
            var lp     = 0;

            foreach (var info in _shippingList)
            {
                info.SetXmlProperty("genxml/hidden/index", lp.ToString("D"));
                strXML += info.XMLData;
                lp     += 1;
            }
            strXML += "</list>";
            Info.RemoveXmlNode("genxml/list");
            Info.AddXmlNode(strXML, "list", "genxml");
            if (Info != null)
            {
                var modCtrl = new NBrightBuyController();
                Info.ItemID = modCtrl.Update(Info);
            }
        }
Esempio n. 15
0
        public static String PluginAddNew(HttpContext context)
        {
            try
            {
                if (NBrightBuyUtils.CheckRights())
                {
                    var ajaxInfo = NBrightBuyUtils.GetAjaxInfo(context);

                    var strOut      = "";
                    var themeFolder = ajaxInfo.GetXmlProperty("genxml/hidden/themefolder");
                    if (themeFolder == "")
                    {
                        themeFolder = "config";
                    }
                    var razortemplate = ajaxInfo.GetXmlProperty("genxml/hidden/razortemplate");

                    var passSettings = NBrightBuyUtils.GetPassSettings(ajaxInfo);

                    var info = new NBrightInfo(true);
                    info.ItemID   = -1;
                    info.PortalId = PortalSettings.Current.PortalId;
                    info.Lang     = Utils.GetCurrentCulture();
                    info.SetXmlProperty("genxml/hidden/index", "99");
                    info.TypeCode = "PLUGIN";
                    info.GUIDKey  = Utils.GetUniqueKey(12);
                    var objCtrl = new NBrightBuyController();
                    info.ItemID = objCtrl.Update(info);
                    var pluginRecord = new PluginRecord(info);

                    strOut = NBrightBuyUtils.RazorTemplRender(razortemplate, 0, "", pluginRecord, TemplateRelPath, themeFolder, Utils.GetCurrentCulture(), passSettings);
                    return(strOut);
                }
                return("");
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Esempio n. 16
0
        private static void EndProductSalePrice(int portalId, int productId, int promoid)
        {
            var objCtrl = new NBrightBuyController();
            var prdData = objCtrl.GetData(productId);

            var nodList = prdData.XMLDoc.SelectNodes("genxml/models/genxml");

            if (nodList != null)
            {
                var currentpromoid = prdData.GetXmlPropertyInt("genxml/hidden/promoid");
                if (currentpromoid == promoid)
                {
                    var lp = 1;
                    foreach (XmlNode nod in nodList)
                    {
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", 0);
                        lp += 1;
                    }
                    objCtrl.Update(prdData);
                    RemoveProductPromoData(portalId, productId, promoid);
                }
            }
        }
Esempio n. 17
0
        private void PageLoad()
        {
            try
            {
                var obj = NBrightBuyUtils.GetSettings(PortalId, ModuleId);
                obj.ModuleId = base.ModuleId; // need to pass the moduleid here, becuase it doesn;t exists in url for settings and on new settings it needs it.

                // check the moduleref is unique, if not the module have been copied, so create new moduleref
                var objCtrl   = new NBrightBuyController();
                var moduleKey = obj.GetXmlProperty("genxml/hidden/modref");
                if (!String.IsNullOrEmpty(moduleKey))
                {
                    var modl = objCtrl.GetDataListCount(PortalId, -1, "SETTINGS", " and [XMLData].value('(genxml/hidden/modref)[1]','nvarchar(max)') = '" + moduleKey + "'", "", "", false, false);
                    if (modl > 1)
                    {
                        // we have multiple refs, reset this one.
                        obj.SetXmlProperty("genxml/hidden/modref", Utils.GetUniqueKey(10));
                        objCtrl.Update(obj);
                    }
                }


                if (String.IsNullOrEmpty(SettingsTemplate))
                {
                    SettingsTemplate = ModuleConfiguration.DesktopModule.ModuleName + "settings.cshtml";                                         // default to name of module
                }
                var strOut = NBrightBuyUtils.RazorTemplRender(SettingsTemplate, ModuleId, "", obj, ControlPath, "config", Utils.GetCurrentCulture(), StoreSettings.Current.Settings());
                var lit    = new Literal();
                lit.Text = strOut;
                phData.Controls.Add(lit);
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Esempio n. 18
0
        /// <summary>
        /// This function needs to process and returned message from the bank.
        /// Thsi processing may vary widely between banks.
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            var modCtrl = new NBrightBuyController();
            var info    = ProviderUtils.GetProviderSettings("NBrightBuySipsApipayment");

            try
            {
                var debugMode = info.GetXmlPropertyBool("genxml/checkbox/debugmode");
                var rtnMsg    = "version=2" + Environment.NewLine + "cdr=1";

                // ------------------------------------------------------------------------
                // In this case the payment provider passes back data via form POST.
                // Get the data we need.
                string returnmessage = "";
                int    NBrightBuySipsApiStoreOrderID = 0;
                string NBrightBuySipsApiCartID       = "";
                string NBrightBuySipsApiClientLang   = "";

                if ((context.Request.Form.Get("DATA") != null))
                {
                    returnmessage = "message=" + context.Request.Form.Get("DATA");

                    if (!string.IsNullOrEmpty(returnmessage))
                    {
                        // ------------------------------------------------------------------------
                        var settings = ProviderUtils.GetProviderSettings("NBrightBuySipsApipayment");

                        var controlMapPath = HttpContext.Current.Server.MapPath("/DesktopModules/NBright/NBrightBuySipsApi");
                        var pathfile       = "pathfile=" + PortalSettings.Current.HomeDirectoryMapPath.TrimEnd('\\') + "\\" + settings.GetXmlProperty("genxml/textbox/paramfolder") + "\\pathfile";

                        var exepath  = controlMapPath.TrimEnd('\\') + "\\sipsbin\\response.exe";
                        var sipsdata = ProviderUtils.CallSipsExec(exepath, pathfile + " " + returnmessage);

                        if (debugMode)
                        {
                            info.SetXmlProperty("genxml/debugmsg", sipsdata);
                            modCtrl.Update(info);
                        }

                        var tableau = sipsdata.Split('!');

                        string code      = tableau[1];
                        string error_msg = tableau[2];

                        if (string.IsNullOrEmpty(code) | code == "-1")
                        {
                            info.SetXmlProperty("genxml/debugmsg", error_msg);
                            modCtrl.Update(info);
                        }
                        else
                        {
                            // L'execution s'est bien deroulee
                            // recuperation des donnees de la reponse

                            string merchant_id         = tableau[3];
                            string merchant_country    = tableau[4];
                            string amount              = tableau[5];
                            string transaction_id      = tableau[6];
                            string payment_means       = tableau[7];
                            string transmission_date   = tableau[8];
                            string payment_time        = tableau[9];
                            string payment_date        = tableau[10];
                            string response_code       = tableau[11];
                            string payment_certificate = tableau[12];
                            string authorisation_id    = tableau[13];
                            string currency_code       = tableau[14];
                            string card_number         = tableau[15];
                            string cvv_flag            = tableau[16];
                            string cvv_response_code   = tableau[17];
                            string bank_response_code  = tableau[18];
                            string complementary_code  = tableau[19];
                            string complementary_info  = tableau[20];
                            string return_context      = tableau[21];
                            string caddie              = tableau[22];
                            string receipt_complement  = tableau[23];
                            string merchant_language   = tableau[24];
                            string language            = tableau[25];
                            string customer_id         = tableau[26];
                            string order_id            = tableau[27];
                            string customer_email      = tableau[28];
                            string customer_ip_address = tableau[29];
                            string capture_day         = tableau[30];
                            string capture_mode        = tableau[31];
                            string data = tableau[32];

                            // Sauvegarde des champs de la reponse
                            string Lmsg = null;

                            Lmsg  = merchant_id + ",";
                            Lmsg += merchant_country + ",";
                            Lmsg += amount + ",";
                            Lmsg += transaction_id + ",";
                            Lmsg += transmission_date + ",";
                            Lmsg += payment_means + ",";
                            Lmsg += payment_time + ",";
                            Lmsg += payment_date + ",";
                            Lmsg += response_code + ",";
                            Lmsg += payment_certificate + ",";
                            Lmsg += authorisation_id + ",";
                            Lmsg += currency_code + ",";
                            Lmsg += card_number + ",";
                            Lmsg += cvv_flag + ",";
                            Lmsg += cvv_response_code + ",";
                            Lmsg += bank_response_code + ",";
                            Lmsg += complementary_code + ",";
                            Lmsg += complementary_info + ",";
                            Lmsg += return_context + ",";
                            Lmsg += caddie + ",";
                            Lmsg += receipt_complement + ",";
                            Lmsg += merchant_language + ",";
                            Lmsg += language + ",";
                            Lmsg += customer_id + ",";
                            Lmsg += order_id + ",";
                            Lmsg += customer_email + ",";
                            Lmsg += customer_ip_address + ",";
                            Lmsg += capture_day + ",";
                            Lmsg += capture_mode + ",";
                            Lmsg += data + ",";

                            //update database stuff
                            if (Utils.IsNumeric(order_id))
                            {
                                var orderData = new OrderData(Convert.ToInt32(order_id));
                                orderData.AddAuditMessage(Lmsg, "payment", "sipsapi", info.GetXmlProperty("genxml/checkbox/debugmode"));
                                // Status return "00" is payment successful
                                if (response_code == "00")
                                {
                                    //set order status to Payed
                                    orderData.PaymentOk();
                                }
                                else
                                {
                                    orderData.PaymentFail();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (!ex.ToString().StartsWith("System.Threading.ThreadAbortException"))  // we expect a thread abort from the End response.
                {
                    info.SetXmlProperty("genxml/debugmsg", "NBrightBuySipsApi ERROR: " + ex.ToString());
                    modCtrl.Update(info);
                }
            }
        }
Esempio n. 19
0
        /// <summary>
        /// This function needs to process and returned message from the bank.
        /// This processing may vary widely between banks.
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            var modCtrl = new NBrightBuyController();
            var info    = ProviderUtils.GetProviderSettings();

            try
            {
                var debugMode = info.GetXmlPropertyBool("genxml/checkbox/debugmode");

                var    orderid    = context.Request.Form.Get("vads_order_id");
                string clientlang = context.Request.Form.Get("vads_order_info");

                var rtnMsg     = "SECURITY WARNING";
                var sig1       = context.Request.Form.Get("signature");
                var strMacCalc = ProviderUtils.GetSignatureReturnData(info.GetXmlProperty("genxml/textbox/certificate"), context.Request);
                var sig2       = ProviderUtils.GetSignature(strMacCalc);

                var debugMsg = "START CALL notify.ashx " + DateTime.Now.ToString("s") + " </br>";
                if (debugMode)
                {
                    foreach (var f in context.Request.Form.AllKeys)
                    {
                        debugMsg += f + ": " + context.Request.Form.Get(f) + "</br>";
                    }
                    debugMsg += "NBrightSystemPay DEBUG: " + DateTime.Now.ToString("s") + " </br>";
                    debugMsg += sig1 + " </br>";
                    debugMsg += sig2 + " </br>";
                    info.SetXmlProperty("genxml/debugmsg", debugMsg);
                    modCtrl.Update(info);
                }
                else
                {
                    if (info.GetXmlProperty("genxml/debugmsg") != "")
                    {
                        info.SetXmlProperty("genxml/debugmsg", "");
                        modCtrl.Update(info);
                    }
                }

                if (sig1 == sig2)
                {
                    // ------------------------------------------------------------------------
                    rtnMsg = "";
                    int nBrightSystemPayStoreOrderId = 0;

                    if (Utils.IsNumeric(orderid))
                    {
                        nBrightSystemPayStoreOrderId = Convert.ToInt32(orderid);
                    }

                    if (debugMode)
                    {
                        debugMsg += "OrderId: " + nBrightSystemPayStoreOrderId + " vads_order_id: " + orderid + " </br>";
                    }

                    if (nBrightSystemPayStoreOrderId > 0)
                    {
                        var orderData = new OrderData(nBrightSystemPayStoreOrderId);

                        string nBrightSystemPayStatusCode = ProviderUtils.GetStatusCode(orderData, context.Request);

                        if (debugMode)
                        {
                            debugMsg += "NBrightSystemPayStatusCode: " + nBrightSystemPayStatusCode + " </br>";
                        }

                        // Status return "00" is payment successful
                        if (nBrightSystemPayStatusCode == "00")
                        {
                            //set order status to Payed
                            orderData.PaymentOk();
                        }
                        else
                        {
                            orderData.PaymentFail();
                        }

                        orderData.Save();
                    }

                    if (debugMode)
                    {
                        debugMsg += "Return Message: " + rtnMsg;
                        info.SetXmlProperty("genxml/debugmsg", debugMsg);
                        modCtrl.Update(info);
                    }
                }

                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.Write(rtnMsg);
                HttpContext.Current.Response.ContentType  = "text/plain";
                HttpContext.Current.Response.CacheControl = "no-cache";
                HttpContext.Current.Response.Expires      = -1;
                HttpContext.Current.Response.End();
            }
            catch (Exception ex)
            {
                if (!ex.ToString().StartsWith("System.Threading.ThreadAbortException")) // we expect a thread abort from the End response.
                {
                    info.SetXmlProperty("genxml/debugmsg", "NBrightSystemPay ERROR: " + ex.ToString());
                    modCtrl.Update(info);
                }
            }
        }
Esempio n. 20
0
        /// <summary>
        /// This function needs to process and returned message from the bank.
        /// This processing may vary widely between banks.
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            var modCtrl = new NBrightBuyController();
            var info    = modCtrl.GetPluginSinglePageData("OSPayPalpayment", "OSPayPalPAYMENT", Utils.GetCurrentCulture());

            try
            {
                var ipn       = new PayPalIpnParameters(context.Request);
                var debugMode = info.GetXmlPropertyBool("genxml/checkbox/debug.mode");
                var debugMsg  = "START CALL" + DateTime.Now.ToString("s") + " </br>";
                var rtnMsg    = "version=2" + Environment.NewLine + "cdr=1";

                // ------------------------------------------------------------------------
                // In this case the payment provider passes back data via form POST.
                // Get the data we need.
                string returnmessage        = "";
                int    OSPayPalStoreOrderID = 0;
                string OSPayPalCartID       = "";
                string OSPayPalClientLang   = "";


                if (Utils.IsNumeric(ipn.item_number))
                {
                    var validateUrl = info.GetXmlProperty("genxml/textbox/paymenturl") + "?" + ipn.PostString;

                    // check the record exists
                    debugMsg += "OrderId: " + ipn.item_number + " </br>";
                    var nbi = modCtrl.Get(Convert.ToInt32(ipn.item_number), "ORDER");
                    if (nbi != null)
                    {
                        var orderData = new OrderData(nbi.ItemID);
                        debugMsg += "validateUrl: " + validateUrl + " </br>";
                        if (ProviderUtils.VerifyPayment(ipn, validateUrl))
                        {
                            //set order status to Payed
                            debugMsg += "PaymentOK </br>";
                            orderData.PaymentOk();
                        }
                        else
                        {
                            if (ipn.IsValid)
                            {
                                debugMsg += "NOT VALIDATED BY PAYPAL </br>";
                                //set order status to Not verified
                                orderData.PaymentOk("050");
                            }
                            else
                            {
                                if (orderData.OrderStatus == "020" || orderData.OrderStatus == "010" || orderData.OrderStatus == "030")
                                {
                                    debugMsg += "PAYMENT FAIL </br>";
                                    orderData.PaymentFail();
                                }
                                else
                                {
                                    debugMsg += "INVALID UPDATE ACTION</br>";
                                }
                            }
                        }
                    }
                    else
                    {
                        debugMsg += "ORDER does not exists";
                    }
                    if (debugMode)
                    {
                        info.SetXmlProperty("genxml/debugmsg", debugMsg);
                        modCtrl.Update(info);
                    }
                }

                if (debugMode)
                {
                    debugMsg += "Return Message: " + rtnMsg;
                    info.SetXmlProperty("genxml/debugmsg", debugMsg);
                    modCtrl.Update(info);
                }


                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.Write(rtnMsg);
                HttpContext.Current.Response.ContentType  = "text/plain";
                HttpContext.Current.Response.CacheControl = "no-cache";
                HttpContext.Current.Response.Expires      = -1;
                HttpContext.Current.Response.End();
            }
            catch (Exception ex)
            {
                if (!ex.ToString().StartsWith("System.Threading.ThreadAbortException")) // we expect a thread abort from the End response.
                {
                    info.SetXmlProperty("genxml/debugmsg", "OS_PayPal ERROR: " + ex.ToString());
                    modCtrl.Update(info);
                }
            }
        }
Esempio n. 21
0
        private void DoImport(NBrightInfo nbi)
        {
            var fname = StoreSettings.Current.FolderTempMapPath + "\\" + nbi.GetXmlProperty("genxml/hidden/hiddatafile");

            if (System.IO.File.Exists(fname))
            {
                var xmlFile = new XmlDocument();
                try
                {
                    xmlFile.Load(fname);
                }
                catch (Exception e)
                {
                    Exceptions.LogException(e);
                    NBrightBuyUtils.SetNotfiyMessage(ModuleId, "xmlloadfail", NotifyCode.fail, ControlPath + "/App_LocalResources/Import.ascx.resx");
                    return;
                }

                // Ref old cat id , id new cat
                ////////////////////////////////////////////////////////////////////////////
                Dictionary <string, int> categoryListIDGiud   = new Dictionary <string, int>();
                Dictionary <int, int>    categoryListIDFather = new Dictionary <int, int>();
                ///////////////////////////////////////////////////////////////////////////

                var objCtrl = new NBrightBuyController();

                // get all valid languages
                var langList = DnnUtils.GetCultureCodeList(PortalId);
                foreach (var lang in langList)
                {
                    //Import Categories

                    #region "categories"

                    var nodList = xmlFile.SelectNodes("root/categories/" + lang + "/NB_Store_CategoriesInfo");
                    if (nodList != null)
                    {
                        var categoryid = -1;
                        foreach (XmlNode nod in nodList)
                        {
                            try
                            {
                                //if category Id exist replage guidKey
                                var guidKeyNod = nod.SelectSingleNode("CategoryID").InnerText;
                                if (guidKeyNod != null)
                                {
                                    var guidKey = guidKeyNod;
                                    categoryid = -1;
                                    // see if category already exists (update if so)
                                    var nbiImport = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "CATEGORY", guidKey);
                                    if (nbiImport != null)
                                    {
                                        categoryid = nbiImport.ItemID;
                                    }
                                    var CategoryData = new CategoryData(categoryid, lang);

                                    // clear down existing XML data
                                    var i = new NBrightInfo(true);
                                    i.PortalId = PortalSettings.Current.PortalId;
                                    CategoryData.DataRecord.XMLData     = i.XMLData;
                                    CategoryData.DataLangRecord.XMLData = i.XMLData;

                                    // assign guidkey to legacy productid (guidKey)
                                    CategoryData.DataRecord.GUIDKey = guidKey;
                                    CategoryData.DataRecord.SetXmlProperty("genxml/textbox/txtcategoryref", guidKey);

                                    // do mapping of XML data
                                    // DATA FIELDS
                                    var cD_CategoryID          = nod.SelectSingleNode("CategoryID").InnerText;
                                    var cD_PortalID            = nod.SelectSingleNode("PortalID").InnerText;
                                    var cD_Archived            = nod.SelectSingleNode("Archived").InnerText;
                                    var cD_Hide                = nod.SelectSingleNode("Hide").InnerText;
                                    var cD_CreatedByUser       = nod.SelectSingleNode("CreatedByUser").InnerText;
                                    var cD_CreatedDate         = nod.SelectSingleNode("CreatedDate").InnerText;
                                    var cD_ParentCategoryID    = nod.SelectSingleNode("ParentCategoryID").InnerText;
                                    var cD_ListOrder           = nod.SelectSingleNode("ListOrder").InnerText;
                                    var cD_Lang                = nod.SelectSingleNode("Lang").InnerText;
                                    var cD_ProductCount        = nod.SelectSingleNode("ProductCount").InnerText;
                                    var cD_ProductTemplate     = nod.SelectSingleNode("ProductTemplate").InnerText;
                                    var cD_ListItemTemplate    = nod.SelectSingleNode("ListItemTemplate").InnerText;
                                    var cD_ListAltItemTemplate = nod.SelectSingleNode("ListAltItemTemplate").InnerText;
                                    var cD_ImageURL            = nod.SelectSingleNode("ImageURL").InnerText;

                                    // DATA LANG FIELDS
                                    var cL_CategoryName    = nod.SelectSingleNode("CategoryName").InnerText;
                                    var cL_ParentName      = nod.SelectSingleNode("ParentName").InnerText;
                                    var cL_CategoryDesc    = nod.SelectSingleNode("CategoryDesc").InnerText;
                                    var cL_Message         = nod.SelectSingleNode("Message").InnerText;
                                    var cL_SEOPageTitle    = nod.SelectSingleNode("SEOPageTitle").InnerText;
                                    var cL_SEOName         = nod.SelectSingleNode("SEOName").InnerText;
                                    var cL_MetaDescription = nod.SelectSingleNode("MetaDescription").InnerText;
                                    var cL_MetaKeywords    = nod.SelectSingleNode("MetaKeywords").InnerText;

                                    // Populate DATA CATEGORY
                                    CategoryData.DataRecord.SetXmlProperty("genxml/hidden/recordsortorder", cD_ListOrder);
                                    CategoryData.DataRecord.SetXmlProperty("genxml/checkbox/chkishidden", cD_Hide);
                                    CategoryData.DataRecord.SetXmlProperty("genxml/checkbox/chkdisable", "False");
                                    CategoryData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlgrouptype", "cat");

                                    if (cD_ParentCategoryID != null && cD_ParentCategoryID != "0")
                                    {
                                        CategoryData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlparentcatid", cD_ParentCategoryID);
                                    }

                                    // Populate DATA CATEGORY LANG


                                    if (cL_CategoryName != null && cL_CategoryName != "")
                                    {
                                        CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtcategoryname", cL_CategoryName);
                                    }
                                    if (cL_CategoryDesc != null && cL_CategoryDesc != "")
                                    {
                                        CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtcategorydesc", cL_CategoryDesc);
                                    }
                                    if (cL_MetaDescription != null && cL_MetaDescription != "")
                                    {
                                        CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtmetadescription", cL_MetaDescription);
                                    }
                                    if (cL_MetaKeywords != null && cL_MetaKeywords != "")
                                    {
                                        CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtmetakeywords", cL_MetaKeywords);
                                    }
                                    if (cL_SEOPageTitle != null && cL_SEOPageTitle != "")
                                    {
                                        CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtseopagetitle", cL_SEOPageTitle);
                                    }
                                    if (cL_SEOName != null && cL_SEOName != "")
                                    {
                                        CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtseoname", cL_SEOName);
                                    }
                                    if (cL_Message != null && cL_Message != "")
                                    {
                                        CategoryData.DataLangRecord.SetXmlProperty("genxml/edt/message", cL_Message);
                                    }

                                    categoryListIDGiud.Add(CategoryData.CategoryRef, CategoryData.CategoryId);
                                    if (cD_ParentCategoryID != null && cD_ParentCategoryID != "" && cD_ParentCategoryID != "0")
                                    {
                                        categoryListIDFather.Add(CategoryData.CategoryId, Convert.ToInt32(cD_ParentCategoryID));
                                    }


                                    CategoryData.Save();
                                }
                            }
                            catch (Exception e)
                            {
                                var logMessage = "CATEGORY: CategoryId: " + categoryid.ToString() + " : " + e.ToString();
                                LogOutput.LogWrite(logMessage);
                            }
                        }

                        //loop on The dictionary
                        foreach (var catl in categoryListIDFather)
                        {
                            //Key
                            var tempNewID = catl.Key;
                            //Value
                            var tempOldFather = catl.Value;

                            var tempNewFather = categoryListIDGiud[tempOldFather.ToString()];

                            var CategoryData = new CategoryData(tempNewID, lang);
                            CategoryData.ParentItemId = tempNewFather;
                            CategoryData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlparentcatid", tempNewFather.ToString());
                            CategoryData.Save();
                        }
                    }

                    #endregion

                    // Import Products

                    #region "data"

                    nodList = xmlFile.SelectNodes("root/products/" + lang + "/P");
                    if (nodList != null)
                    {
                        var productid = -1;
                        var prodname  = "";
                        foreach (XmlNode nod in nodList)
                        {
                            try
                            {
                                var guidKeyNod = nod.SelectSingleNode("NB_Store_ProductsInfo/ProductID");
                                if (guidKeyNod != null)
                                {
                                    var guidKey = guidKeyNod.InnerText;
                                    productid = -1;
                                    // See if e already have a product imported, if so we want to update (maybe multiple languages, or a 2nd migrate)
                                    var nbiImport = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "PRD", guidKey);
                                    if (nbiImport != null)
                                    {
                                        productid = nbiImport.ItemID;
                                    }
                                    var productData = new ProductData(productid, lang);

                                    productid = productData.Info.ItemID; // set productid, so we have the id if it goes wrong.
                                    prodname  = productData.ProductName;

                                    // clear down existing XML data
                                    var i = new NBrightInfo(true);
                                    productData.DataRecord.XMLData     = i.XMLData;
                                    productData.DataLangRecord.XMLData = i.XMLData;

                                    // assign guidkey to legacy productid (guidKey)
                                    productData.DataRecord.GUIDKey = guidKey;
                                    productData.DataRecord.SetXmlProperty("genxml/importref", guidKey);

                                    // do mapping of XML data
                                    // DATA FIELDS
                                    var pD_ProductID     = nod.SelectSingleNode("NB_Store_ProductsInfo/ProductID").InnerText;
                                    var pD_PortalID      = nod.SelectSingleNode("NB_Store_ProductsInfo/PortalID").InnerText;
                                    var pD_TaxCategoryID = nod.SelectSingleNode("NB_Store_ProductsInfo/TaxCategoryID").InnerText;
                                    var pD_Featured      = nod.SelectSingleNode("NB_Store_ProductsInfo/Featured").InnerText;
                                    var pD_Archived      = nod.SelectSingleNode("NB_Store_ProductsInfo/Archived").InnerText;
                                    var pD_CreatedByUser = nod.SelectSingleNode("NB_Store_ProductsInfo/CreatedByUser").InnerText;
                                    var pD_CreatedDate   = nod.SelectSingleNode("NB_Store_ProductsInfo/CreatedDate").InnerText;
                                    var pD_IsDeleted     = nod.SelectSingleNode("NB_Store_ProductsInfo/IsDeleted").InnerText;
                                    var pD_ProductRef    = nod.SelectSingleNode("NB_Store_ProductsInfo/ProductRef").InnerText;
                                    var pD_Lang          = nod.SelectSingleNode("NB_Store_ProductsInfo/Lang").InnerText;
                                    var pD_Manufacturer  = nod.SelectSingleNode("NB_Store_ProductsInfo/Manufacturer").InnerText;
                                    var pD_ModifiedDate  = nod.SelectSingleNode("NB_Store_ProductsInfo/ModifiedDate").InnerText;
                                    var pD_IsHidden      = nod.SelectSingleNode("NB_Store_ProductsInfo/IsHidden").InnerText;
                                    // DATA LANG FIELDS
                                    var pL_ProductName = nod.SelectSingleNode("NB_Store_ProductsInfo/ProductName").InnerText;
                                    var pL_Summary     = nod.SelectSingleNode("NB_Store_ProductsInfo/Summary").InnerText;
                                    var pL_Description = nod.SelectSingleNode("NB_Store_ProductsInfo/Description").InnerText;
                                    var pL_SEOName     = nod.SelectSingleNode("NB_Store_ProductsInfo/SEOName").InnerText;
                                    var pL_TagWords    = nod.SelectSingleNode("NB_Store_ProductsInfo/TagWords").InnerText;
                                    var pL_Desc        = nod.SelectSingleNode("NB_Store_ProductsInfo/Description").InnerText;

                                    if (pD_ProductRef != null)
                                    {
                                        productData.DataRecord.SetXmlProperty("genxml/textbox/txtproductref", pD_ProductRef);
                                    }
                                    if (pD_Manufacturer != null)
                                    {
                                        productData.DataRecord.SetXmlProperty("genxml/textbox/customorder", pD_Manufacturer);
                                    }

                                    // langauge main fields
                                    if (pL_ProductName != null)
                                    {
                                        productData.DataLangRecord.SetXmlProperty("genxml/textbox/txtproductname", pL_ProductName);
                                    }
                                    if (pL_Summary != null)
                                    {
                                        productData.DataLangRecord.SetXmlProperty("genxml/textbox/txtsummary", pL_Summary);
                                    }
                                    if (pL_SEOName != null)
                                    {
                                        productData.DataLangRecord.SetXmlProperty("genxml/textbox/txtseoname", pL_SEOName);
                                    }
                                    if (pL_SEOName != null)
                                    {
                                        productData.DataLangRecord.SetXmlProperty("genxml/textbox/txtseopagetitle", pL_SEOName);
                                    }
                                    if (pL_TagWords != null)
                                    {
                                        productData.DataLangRecord.SetXmlProperty("genxml/textbox/txttagwords", pL_TagWords);
                                    }

                                    //edt

                                    if (pL_Desc != null)
                                    {
                                        productData.DataLangRecord.SetXmlProperty("genxml/edt", "");
                                        productData.DataLangRecord.SetXmlProperty("genxml/edt/description", pL_Desc);
                                    }


                                    ////////////////////////////// CUSTOM FIELDS /////////////////////////////////////
                                    ////////////////////////////// CUSTOM FIELDS /////////////////////////////////////
                                    ////////////////////////////// CUSTOM FIELDS /////////////////////////////////////
                                    #region "Custom Fields"

                                    // Custom Fields the Custom fields in Nbstore are stored in XmlData xml file area.

                                    if (nod.SelectSingleNode("NB_Store_ProductsInfo/XMLData").FirstChild != null) // verify if there are custom fileds
                                    {
                                        var InputCustomFieldsXml = new XmlDocument();
                                        InputCustomFieldsXml.Load(new StringReader(nod.SelectSingleNode("NB_Store_ProductsInfo/XMLData").InnerText));
                                        var nodListCustom = InputCustomFieldsXml.SelectSingleNode("genxml");
                                        var custominfo    = new NBrightInfo();
                                        custominfo.XMLData = nodListCustom.OuterXml;

                                        // ***************************
                                        // process custom fields here.
                                        // ***************************
                                    }

                                    #endregion
                                    ////////////////////////////// END CUSTOM FIELDS /////////////////////////////////////
                                    ////////////////////////////// END CUSTOM FIELDS /////////////////////////////////////
                                    ////////////////////////////// END CUSTOM FIELDS /////////////////////////////////////


                                    // Models
                                    var nodListModels = nod.SelectNodes("M/NB_Store_ModelInfo");
                                    foreach (XmlNode nodMod in nodListModels)
                                    {
                                        //load single node module strucuture
                                        var ModelID = nodMod.SelectSingleNode("ModelID").InnerText;

                                        var ProductID    = nodMod.SelectSingleNode("ProductID").InnerText;
                                        var ListOrder    = nodMod.SelectSingleNode("ListOrder").InnerText;
                                        var UnitCost     = nodMod.SelectSingleNode("UnitCost").InnerText;
                                        var Barcode      = nodMod.SelectSingleNode("Barcode").InnerText;
                                        var ModelRef     = nodMod.SelectSingleNode("ModelRef").InnerText;
                                        var Lang         = nodMod.SelectSingleNode("Lang").InnerText;
                                        var ModelName    = nodMod.SelectSingleNode("ModelName").InnerText;
                                        var QtyRemaining = nodMod.SelectSingleNode("QtyRemaining").InnerText;
                                        var QtyTrans     = nodMod.SelectSingleNode("QtyTrans").InnerText;
                                        var QtyTransDate = nodMod.SelectSingleNode("QtyTransDate").InnerText;
                                        var ProductName  = nodMod.SelectSingleNode("ProductName").InnerText;
                                        var PortalID     = nodMod.SelectSingleNode("PortalID").InnerText;
                                        var Weight       = nodMod.SelectSingleNode("Weight").InnerText;
                                        var Height       = nodMod.SelectSingleNode("Height").InnerText;
                                        var Length       = nodMod.SelectSingleNode("Length").InnerText;
                                        var Width        = nodMod.SelectSingleNode("Width").InnerText;
                                        var Deleted      = nodMod.SelectSingleNode("Deleted").InnerText;
                                        var QtyStockSet  = nodMod.SelectSingleNode("QtyStockSet").InnerText;
                                        var DealerCost   = nodMod.SelectSingleNode("DealerCost").InnerText;
                                        var PurchaseCost = nodMod.SelectSingleNode("PurchaseCost").InnerText;
                                        var XMLData      = nodMod.SelectSingleNode("XMLData").InnerText;
                                        var Extra        = nodMod.SelectSingleNode("Extra").InnerText;
                                        var DealerOnly   = nodMod.SelectSingleNode("DealerOnly").InnerText;
                                        var Allow        = nodMod.SelectSingleNode("Allow").InnerText;


                                        ////////////////////////////// FINE CUSTOM FIELDS /////////////////////////////////////
                                        ////////////////////////////// FINE CUSTOM FIELDS /////////////////////////////////////
                                        ////////////////////////////// FINE CUSTOM FIELDS /////////////////////////////////////



                                        //il dentro al tag model cè un genxml che identifica il modello
                                        // MODELLI CAMPI DATA
                                        ////////////////////////////// MODELS /////////////////////////////////////
                                        ////////////////////////////// MODELS /////////////////////////////////////
                                        ////////////////////////////// MODELS /////////////////////////////////////
                                        var newkey = Utils.GetUniqueKey();

                                        var strXmlModel = @"<genxml><models><genxml>
                                      <files />
                                      <hidden><modelid>" + newkey + "</modelid>" +
                                                          @"</hidden>
                                      <textbox>
                                        <availabledate datatype=""date"" />
                                        <txtqtyminstock>0</txtqtyminstock>
                                        <txtmodelref>" + ModelRef + @"</txtmodelref>
                                        <txtunitcost>" + UnitCost + @"</txtunitcost>
                                        <txtsaleprice>0.00</txtsaleprice>
                                        <txtbarcode>" + Barcode + @"</txtbarcode>
                                        <txtqtyremaining>" + QtyRemaining + @"</txtqtyremaining>
                                        <txtqtystockset>" + QtyStockSet + @"</txtqtystockset>
                                        <txtdealercost>" + DealerCost + @"</txtdealercost>
                                        <txtpurchasecost>" + PurchaseCost + @"</txtpurchasecost>
                                        <weight>" + Weight + @"</weight>
                                        <depth>" + Length + @"</depth>
                                        <width>" + Width + @"</width>
                                        <height>" + Height + @"</height>
                                        <unit />
                                        <delay />
                                      </textbox>
                                      <checkbox>
                                        <chkstockon>False</chkstockon>
                                        <chkishidden>False</chkishidden>
                                        <chkdeleted>False</chkdeleted>
                                        <chkdealeronly>False</chkdealeronly>
                                      </checkbox>
                                      <dropdownlist>
                                        <modelstatus>010</modelstatus>
                                      </dropdownlist>
                                      <checkboxlist />
                                      <radiobuttonlist />
                                    </genxml></models></genxml>";

                                        var strXmlModelLang = @"<genxml><models><genxml>
                                        <files />
                                        <hidden />
                                        <textbox>
                                            <txtmodelname>" + ModelName + "</txtmodelname>" +
                                                              "<txtextra>" + Extra + @"</txtextra>
                                        </textbox>
                                        <checkbox /><dropdownlist /><checkboxlist /><radiobuttonlist />
                                        </genxml></models></genxml>";

                                        if (productData.DataRecord.XMLDoc.SelectSingleNode("genxml/models") == null)
                                        {
                                            productData.DataRecord.AddXmlNode(strXmlModel, "genxml/models", "genxml");
                                            productData.DataLangRecord.AddXmlNode(strXmlModelLang, "genxml/models", "genxml");
                                        }
                                        else
                                        {
                                            productData.DataRecord.AddXmlNode(strXmlModel, "genxml/models/genxml", "genxml/models");
                                            productData.DataLangRecord.AddXmlNode(strXmlModelLang, "genxml/models/genxml", "genxml/models");
                                        }
                                    }

                                    ////////////////////////////// IMAGES /////////////////////////////////////
                                    ////////////////////////////// IMAGES /////////////////////////////////////
                                    ////////////////////////////// IMAGES /////////////////////////////////////
                                    ////////////////////////////// IMAGES /////////////////////////////////////
                                    // copy all the images from Portals\0\productimages to Portals\0\NBStore\images

                                    var nodListImages = nod.SelectNodes("I/NB_Store_ProductImageInfo");
                                    foreach (XmlNode nodImg in nodListImages)
                                    {
                                        var ImageID   = nodImg.SelectSingleNode("ImageID").InnerText;
                                        var Hidden    = nodImg.SelectSingleNode("Hidden").InnerText;
                                        var ImageUrl  = nodImg.SelectSingleNode("ImageURL").InnerText;
                                        var ImagePath = nodImg.SelectSingleNode("ImagePath").InnerText;

                                        productData.AddNewImage(ImageUrl, ImagePath);
                                    }
                                    ////////////////////////////// DOCS /////////////////////////////////////
                                    ////////////////////////////// DOCS /////////////////////////////////////
                                    ////////////////////////////// DOCS /////////////////////////////////////
                                    ////////////////////////////// DOCS /////////////////////////////////////
                                    // copy all the DOCS from Portals\0\productdocs to Portals\0\NBStore\docs

                                    var nodListDocs = nod.SelectNodes("D/NB_Store_ProductDocInfo");
                                    var lp          = 1;
                                    var objCtrlDoc  = new NBrightBuyController();

                                    foreach (XmlNode nodDoc in nodListDocs)
                                    {
                                        var DocID     = nodDoc.SelectSingleNode("DocID").InnerText;
                                        var ProductID = nodDoc.SelectSingleNode("ProductID").InnerText;
                                        var DocPath   = nodDoc.SelectSingleNode("DocPath").InnerText;
                                        var ListOrder = nodDoc.SelectSingleNode("ListOrder").InnerText;
                                        var Hidden    = nodDoc.SelectSingleNode("Hidden").InnerText;
                                        var FileName  = nodDoc.SelectSingleNode("FileName").InnerText;
                                        var FileExt   = nodDoc.SelectSingleNode("FileExt").InnerText;
                                        var Lang      = nodDoc.SelectSingleNode("Lang").InnerText;
                                        var DocDesc   = nodDoc.SelectSingleNode("DocDesc").InnerText;

                                        productData.AddNewDoc(DocPath, FileName);

                                        productData.DataRecord.SetXmlProperty("genxml/docs/genxml[" + lp.ToString() + "]/hidden/fileext", FileExt);
                                        DocPath = DocPath.Replace("productdocs", @"NBStore\docs");
                                        productData.DataRecord.SetXmlProperty("genxml/docs/genxml[" + lp.ToString() + "]/hidden/filepath", DocPath);

                                        objCtrlDoc.Update(productData.DataRecord);

                                        // if doesen't exisit the xml genxml strucuture inside the DataLangRecor I create it
                                        var strXml = "<genxml><docs><genxml><textbox/></genxml></docs></genxml>";
                                        if (productData.DataLangRecord.XMLDoc.SelectSingleNode("genxml/docs") == null)
                                        {
                                            productData.DataLangRecord.AddXmlNode(strXml, "genxml/docs", "genxml");
                                        }
                                        else
                                        {
                                            productData.DataLangRecord.AddXmlNode(strXml, "genxml/docs/genxml", "genxml/docs");
                                        }
                                        /////////////////////////////////////////////////
                                        productData.DataLangRecord.SetXmlProperty("genxml/docs/genxml[" + lp.ToString() + "]/textbox/txtdocdesc", DocDesc);
                                        productData.DataLangRecord.SetXmlProperty("genxml/docs/genxml[" + lp.ToString() + "]/textbox/txttitle", FileName);

                                        objCtrlDoc.Update(productData.DataLangRecord);


                                        lp += 1;
                                    }



                                    ////////////////////////////// CATEGORIES /////////////////////////////////////
                                    ////////////////////////////// CATEGORIES /////////////////////////////////////
                                    ////////////////////////////// CATEGORIES /////////////////////////////////////
                                    ////////////////////////////// CATEGORIES /////////////////////////////////////

                                    var nodListCat = nod.SelectNodes("C/NB_Store_ProductCategoryInfo");
                                    foreach (XmlNode nodCat in nodListCat)
                                    {
                                        var ProductID  = nodCat.SelectSingleNode("ProductID").InnerText;
                                        var CategoryID = nodCat.SelectSingleNode("CategoryID").InnerText;

                                        if (ProductID == guidKey)
                                        {
                                            if (categoryListIDGiud.ContainsKey(CategoryID))
                                            {
                                                var newCategoryId = categoryListIDGiud[CategoryID];
                                                productData.AddCategory(newCategoryId);
                                            }
                                        }
                                    }



                                    ////////////////////////////// SAVE PRODUCT /////////////////////////////////////
                                    productData.Save();
                                }
                            }
                            catch (Exception e)
                            {
                                var logMessage = "PRODUCTS: " + prodname + " ProductId: " + productid.ToString() + " : " + e.ToString();
                                LogOutput.LogWrite(logMessage);
                            }
                        }
                    }

                    ////////////////////////////// RELATED PRODUCTS /////////////////////////////////////
                    //recicle on all the xml import Product and reconnect the related product
                    foreach (var lang2 in langList)
                    {
                        if (nodList != null)
                        {
                            foreach (XmlNode nod in nodList)
                            {
                                var guidKeyNod = nod.SelectSingleNode("NB_Store_ProductsInfo/ProductID");
                                if (guidKeyNod != null)
                                {
                                    var guidKey   = guidKeyNod.InnerText;
                                    var productid = -1;
                                    try
                                    {
                                        // See if e already have a product imported, if so we want to update (maybe multiple languages, or a 2nd migrate)
                                        var nbiImport = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "PRD", guidKey);
                                        if (nbiImport != null)
                                        {
                                            productid = nbiImport.ItemID;
                                        }
                                        var productData = new ProductData(productid, lang2);

                                        ////////////////////////////// RELATED PRODUCTS /////////////////////////////////////
                                        ////////////////////////////// RELATED PRODUCTS /////////////////////////////////////
                                        var nodListRelated = nod.SelectNodes("R/NB_Store_ProductRelatedInfo");
                                        if (nodListRelated != null) //if there are related
                                        {
                                            foreach (XmlNode nodRel in nodListRelated)
                                            {
                                                // id in the related product import file
                                                var ImportRelatedProductID = nodRel.SelectSingleNode("RelatedProductID").InnerText;
                                                // extract Id of the new created product thet have the old id in the guidKey
                                                var tempID = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "PRD", ImportRelatedProductID);

                                                if (tempID != null)
                                                {
                                                    int IDRelatedprod = tempID.ItemID;
                                                    productData.AddRelatedProduct(IDRelatedprod);
                                                    productData.Save();
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        var logMessage = "RELATED PRODUCTS: ProductId: " + productid.ToString() + " : " + e.ToString();
                                        LogOutput.LogWrite(logMessage);
                                    }
                                }
                            }
                        }
                    }

                    LogOutput.LogWrite("END: " + DateTime.Now);

                    #endregion
                }

                NBrightBuyUtils.SetNotfiyMessage(ModuleId, "Import", NotifyCode.ok, ControlPath + "/App_LocalResources/Import.ascx.resx");
            }
        }
Esempio n. 22
0
        public static void RemoveProductPromoData(int portalid, int productId, int promoid)
        {
            var cultureList = DnnUtils.GetCultureCodeList(portalid);
            var objCtrl     = new NBrightBuyController();
            var prdData     = objCtrl.GetData(productId);

            // (legacy) remove fields for old promo
            var currentpromoid = prdData.GetXmlPropertyInt("genxml/hidden/promoid");

            if (currentpromoid != 0) //
            {
                prdData.RemoveXmlNode("genxml/hidden/promotype");
                prdData.RemoveXmlNode("genxml/hidden/promoname");
                prdData.RemoveXmlNode("genxml/hidden/promoid");
                prdData.RemoveXmlNode("genxml/hidden/promocalcdate");
                prdData.RemoveXmlNode("genxml/hidden/datefrom");
                prdData.RemoveXmlNode("genxml/hidden/dateuntil");
            }

            // remove any sale price amounts that may have been added by group promotion.
            var l = prdData.XMLDoc.SelectNodes("genxml/models/genxml");

            if (l != null)
            {
                var promoexist = false;
                var lp         = 1;
                foreach (XmlNode nod in l)
                {
                    var promodealersaleid = prdData.GetXmlPropertyInt("genxml/promo/dealersaleid" + lp);
                    var promosalepriceid  = prdData.GetXmlPropertyInt("genxml/promo/salepriceid" + lp);
                    var promodealercostid = prdData.GetXmlPropertyInt("genxml/promo/dealercostid" + lp);

                    if (promosalepriceid == promoid)
                    {
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", "0");
                        prdData.RemoveXmlNode("genxml/promo/salepriceid" + lp);
                        promosalepriceid = 0;
                    }
                    if (promodealercostid == promoid)
                    {
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealercost", "0");
                        prdData.RemoveXmlNode("genxml/promo/dealercostid" + lp);
                        promodealercostid = 0;
                    }
                    if (promodealersaleid == promoid)
                    {
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealersale", "0");
                        prdData.RemoveXmlNode("genxml/promo/dealersaleid" + lp);
                        promodealersaleid = 0;
                    }

                    if (promodealersaleid > 0 || promosalepriceid > 0 || promodealercostid > 0)
                    {
                        promoexist = true;
                    }

                    lp += 1;
                }

                if (!promoexist)
                {
                    prdData.RemoveXmlNode("genxml/hidden/promoflag");
                    prdData.RemoveXmlNode("genxml/promo");
                }

                // promo description only at product level, thi sis not correct for multiple price promoiton.
                // but this is a rare use case issue.
                foreach (var lang in cultureList)
                {
                    var prdDataLang = objCtrl.GetDataLang(productId, lang);
                    if (prdDataLang != null)
                    {
                        prdDataLang.RemoveXmlNode("genxml/hidden/promodesc");
                        objCtrl.Update(prdDataLang);
                    }
                }
            }

            objCtrl.Update(prdData);
        }
Esempio n. 23
0
        /// <summary>
        /// This function needs to process and returned message from the bank.
        /// This processing may vary widely between banks.
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            var modCtrl = new NBrightBuyController();
            var info    = modCtrl.GetPluginSinglePageData("OS_PayBoxpayment", "OS_PayBoxPAYMENT", Utils.GetCurrentCulture());

            try
            {
                var debugMode = info.GetXmlPropertyBool("genxml/checkbox/debugmode");
                var debugMsg  = "START CALL" + DateTime.Now.ToString("s") + " </br>";
                var rtnMsg    = "version=2" + Environment.NewLine + "cdr=1";

                // ------------------------------------------------------------------------
                // In this case the payment provider passes back data via form POST.
                // Get the data we need.
                string returnmessage         = "";
                int    OS_PayBoxStoreOrderID = 0;
                string OS_PayBoxCartID       = "";
                string OS_PayBoxClientLang   = "";

                var orderid = Utils.RequestQueryStringParam(context, "ref");
                debugMsg += "orderid: " + orderid + "</br>";

                if (Utils.IsNumeric(orderid))
                {
                    var authcode = Utils.RequestQueryStringParam(context, "auto");
                    var errcode  = Utils.RequestQueryStringParam(context, "rtnerr");
                    var call     = Utils.RequestQueryStringParam(context, "call");
                    var trans    = Utils.RequestQueryStringParam(context, "trans");

                    OS_PayBoxStoreOrderID = Convert.ToInt32(orderid);
                    // ------------------------------------------------------------------------

                    debugMsg += "OrderId: " + orderid + " </br>";
                    debugMsg += "errcode: " + errcode + " </br>";
                    debugMsg += "authcode: " + authcode + " </br>";
                    debugMsg += "trans: " + trans + " </br>";
                    debugMsg += "call: " + call + " </br>";

                    var orderData = new OrderData(OS_PayBoxStoreOrderID);
                    if (info.GetXmlPropertyBool("genxml/checkbox/pbxautoseule"))
                    {
                        orderData.PurchaseInfo.SetXmlProperty("genxml/payboxrtn", "");
                        orderData.PurchaseInfo.SetXmlProperty("genxml/payboxrtn/call", call);
                        orderData.PurchaseInfo.SetXmlProperty("genxml/payboxrtn/trans", trans);
                        orderData.SavePurchaseData();
                    }

                    if (authcode == "")
                    {
                        rtnMsg = "KO";
                    }
                    else
                    {
                        rtnMsg = "OK";
                    }

                    if (authcode == "")
                    {
                        orderData.PaymentFail();
                    }
                    else
                    {
                        if (errcode == "00000")
                        {
                            orderData.PaymentOk();
                        }
                        else if (errcode == "99999")
                        {
                            orderData.PaymentOk("050");
                        }
                        else
                        {
                            orderData.PaymentFail();
                        }
                    }

                    if (debugMode)
                    {
                        orderData.PurchaseInfo.SetXmlProperty("genxml/payboxrtn/debugmsg", debugMsg);
                        orderData.SavePurchaseData();
                    }
                }
                if (debugMode)
                {
                    debugMsg += "Return Message: " + rtnMsg;
                    info.SetXmlProperty("genxml/debugmsg", debugMsg);
                    modCtrl.Update(info);
                }


                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.Write(rtnMsg);
                HttpContext.Current.Response.ContentType  = "text/plain";
                HttpContext.Current.Response.CacheControl = "no-cache";
                HttpContext.Current.Response.Expires      = -1;
                HttpContext.Current.Response.End();
            }
            catch (Exception ex)
            {
                if (!ex.ToString().StartsWith("System.Threading.ThreadAbortException")) // we expect a thread abort from the End response.
                {
                    Logging.LogException(ex);
                }
            }
        }
Esempio n. 24
0
        public static string CalcMultiBuyPromoItem(NBrightInfo p)
        {
            var objCtrl        = new NBrightBuyController();
            var propgroupid    = p.GetXmlPropertyInt("genxml/dropdownlist/propbuy");
            var promoname      = p.GetXmlProperty("genxml/textbox/name");
            var validfrom      = p.GetXmlProperty("genxml/textbox/validfrom");
            var validuntil     = p.GetXmlProperty("genxml/textbox/validuntil");
            var disabled       = p.GetXmlPropertyBool("genxml/checkbox/disabled");
            var lastcalculated = p.GetXmlProperty("genxml/hidden/lastcalculated");

            if (!disabled)
            {
                var portalsettings = NBrightDNN.DnnUtils.GetPortalSettings(p.PortalId);
                var lang           = portalsettings.DefaultLanguage;

                var runcalc = true;
                if (Utils.IsDate(lastcalculated))
                {
                    if (Convert.ToDateTime(lastcalculated) >= p.ModifiedDate)
                    {
                        runcalc = false;                                                        // only run if changed
                    }
                    if (DateTime.Now.Date > Convert.ToDateTime(lastcalculated).Date.AddDays(1))
                    {
                        runcalc = true;                                                                         // every day just after midnight. (for site performace)
                    }
                }
                if (Utils.IsDate(validuntil))
                {
                    if (DateTime.Now.Date > Convert.ToDateTime(validuntil))
                    {
                        runcalc = true;                                                     // need to disable the promo if passed date
                    }
                }
                if ((runcalc) && Utils.IsDate(validfrom) && Utils.IsDate(validuntil))
                {
                    var          dteF = Convert.ToDateTime(validfrom).Date;
                    var          dteU = Convert.ToDateTime(validuntil).Date;
                    CategoryData gCat;

                    gCat = CategoryUtils.GetCategoryData(propgroupid, lang);
                    var prdList = gCat.GetAllArticles();

                    foreach (var prd in prdList)
                    {
                        if (DateTime.Now.Date >= dteF && DateTime.Now.Date <= dteU)
                        {
                            // CALC Promo
                            FlagProductMultiBuy(p.PortalId, prd.ParentItemId, promoname, p.ItemID, "PROMOMULTIBUY", dteF, dteU);
                        }
                        if (DateTime.Now.Date > dteU)
                        {
                            // END Promo
                            RemoveProductPromoData(p.PortalId, prd.ParentItemId, p.ItemID);
                            p.SetXmlProperty("genxml/checkbox/disabled", "True");
                            objCtrl.Update(p);
                        }
                        ProductUtils.RemoveProductDataCache(p.PortalId, prd.ParentItemId);
                        var productData = ProductUtils.GetProductData(prd.ParentItemId, lang);
                        productData.Save(); // recalc any new prices.
                    }

                    p.SetXmlProperty("genxml/hidden/lastcalculated", DateTime.Now.AddSeconds(10).ToString("O")); // Add 10 sec to time so we don't get exact clash with update time.
                    objCtrl.Update(p);
                }
            }
            return("OK");
        }
Esempio n. 25
0
        public static string CalcGroupPromoItem(NBrightInfo p)
        {
            var objCtrl        = new NBrightBuyController();
            var typeselect     = p.GetXmlProperty("genxml/radiobuttonlist/typeselect");
            var catgroupid     = p.GetXmlProperty("genxml/dropdownlist/catgroupid");
            var propgroupid    = p.GetXmlProperty("genxml/dropdownlist/propgroupid");
            var promoname      = p.GetXmlProperty("genxml/textbox/name");
            var amounttype     = p.GetXmlProperty("genxml/radiobuttonlist/amounttype");
            var amount         = p.GetXmlPropertyDouble("genxml/textbox/amount");
            var validfrom      = p.GetXmlProperty("genxml/textbox/validfrom");
            var validuntil     = p.GetXmlProperty("genxml/textbox/validuntil");
            var overwrite      = p.GetXmlPropertyBool("genxml/checkbox/overwrite");
            var disabled       = p.GetXmlPropertyBool("genxml/checkbox/disabled");
            var lastcalculated = p.GetXmlProperty("genxml/hidden/lastcalculated");
            var whichprice     = p.GetXmlPropertyInt("genxml/radiobuttonlist/whichprice");
            var runfreq        = p.GetXmlPropertyInt("genxml/radiobuttonlist/runfreq");

            if (!disabled)
            {
                var portalsettings = NBrightDNN.DnnUtils.GetPortalSettings(p.PortalId);
                var lang           = portalsettings.DefaultLanguage;

                var prdList = new List <NBrightInfo>();
                if (typeselect == "all")
                {
                    prdList = objCtrl.GetList(p.PortalId, -1, "PRD");
                }
                else
                {
                    CategoryData gCat;
                    var          groupid = catgroupid;
                    if (typeselect != "cat")
                    {
                        groupid = propgroupid;
                    }
                    gCat = CategoryUtils.GetCategoryData(groupid, lang);
                    if (gCat != null)
                    {
                        prdList = gCat.GetAllArticles();
                    }
                }

                var runcalc = true;
                if (runfreq == 1 || runfreq == 3) // run freq is date range
                {
                    if (runfreq == 3)
                    {
                        // run constantly, set end date to +100 year
                        validfrom  = DateTime.Now.AddYears(-1).ToString("s");
                        validuntil = DateTime.Now.AddYears(100).ToString("s");
                    }
                    // run date range
                    if (Utils.IsDate(lastcalculated))
                    {
                        if (Convert.ToDateTime(lastcalculated) >= p.ModifiedDate)
                        {
                            runcalc = false;                                                       // only run if changed
                        }
                        if (DateTime.Now.Date > Convert.ToDateTime(lastcalculated).Date.AddDays(1))
                        {
                            runcalc = true;                                                                         // every day just after midnight. (for site performace)
                        }
                    }
                    if (Utils.IsDate(validuntil))
                    {
                        if (DateTime.Now.Date > Convert.ToDateTime(validuntil))
                        {
                            runcalc = true;                                                     // need to disable the promo if passed date
                        }
                    }
                    if ((runcalc) && Utils.IsDate(validfrom) && Utils.IsDate(validuntil))
                    {
                        var dteF = Convert.ToDateTime(validfrom).Date;
                        var dteU = Convert.ToDateTime(validuntil).Date;

                        foreach (var prd in prdList)
                        {
                            var productid = prd.ParentItemId;
                            if (typeselect == "all")
                            {
                                productid = prd.ItemID;
                            }

                            if (DateTime.Now.Date >= dteF && DateTime.Now.Date <= dteU)
                            {
                                // CALC Promo
                                CalcProductSalePrice(p.PortalId, productid, amounttype, amount, p.ItemID, whichprice, overwrite);
                            }
                            if (DateTime.Now.Date > dteU)
                            {
                                // END Promo
                                RemoveProductPromoData(p.PortalId, productid, p.ItemID);
                            }
                            ProductUtils.RemoveProductDataCache(p.PortalId, productid);
                            var productData = ProductUtils.GetProductData(productid, lang);
                            productData.Save(); // recalc any new prices.
                        }
                        if (DateTime.Now.Date > dteU)
                        {
                            // END Promo
                            p.SetXmlProperty("genxml/checkbox/disabled", "True");
                        }
                    }
                }
                if (runfreq == 2) // run Once, do update and disable promo.
                {
                    foreach (var prd in prdList)
                    {
                        var productid = prd.ParentItemId;
                        if (typeselect == "all")
                        {
                            productid = prd.ItemID;
                        }
                        // CALC Promo
                        CalcProductSalePrice(p.PortalId, productid, amounttype, amount, p.ItemID, whichprice, overwrite);
                        ProductUtils.RemoveProductDataCache(p.PortalId, productid);
                        var productData = ProductUtils.GetProductData(productid, lang);
                        productData.Save(); // recalc any new prices.
                    }
                    p.SetXmlProperty("genxml/checkbox/disabled", "True");
                }
                if (runfreq == 4) // remove
                {
                    foreach (var prd in prdList)
                    {
                        var productid = prd.ParentItemId;
                        if (typeselect == "all")
                        {
                            productid = prd.ItemID;
                        }
                        RemoveProductPromoData(p.PortalId, productid, p.ItemID);
                        ProductUtils.RemoveProductDataCache(p.PortalId, productid);
                        var productData = ProductUtils.GetProductData(productid, lang);
                        productData.Save(); // recalc any new prices.
                    }

                    p.SetXmlProperty("genxml/checkbox/disabled", "True");
                }
                p.SetXmlProperty("genxml/hidden/lastcalculated", DateTime.Now.AddSeconds(10).ToString("O")); // Add 10 sec to time so we don't get exact clash with update time.
                objCtrl.Update(p);
            }
            return("OK");
        }
Esempio n. 26
0
        private static void CalcProductSalePrice(int portalid, int productId, string amounttype, double amount, int promoid, int whichprice, bool overwrite)
        {
            var cultureList = DnnUtils.GetCultureCodeList(portalid);
            var objCtrl     = new NBrightBuyController();
            var prdData     = objCtrl.GetData(productId);

            var nodList = prdData.XMLDoc.SelectNodes("genxml/models/genxml");

            if (nodList != null)
            {
                prdData.SetXmlProperty("genxml/hidden/promoflag", "True"); // set flag, so we can identify products with promo for product save event removal.
                if (prdData.GetXmlProperty("genxml/promo") == "")
                {
                    prdData.SetXmlProperty("genxml/promo", "");
                }
                var lp = 1;
                foreach (XmlNode nod in nodList)
                {
                    var currentpromoid = GetCurrentPromoId(prdData, whichprice, lp);
                    var nbi            = new NBrightInfo();
                    nbi.XMLData = nod.OuterXml;
                    var    disablesale      = nbi.GetXmlPropertyBool("genxml/checkbox/chkdisablesale");
                    var    disabledealer    = nbi.GetXmlPropertyBool("genxml/checkbox/chkdisabledealer");
                    var    unitcost         = nbi.GetXmlPropertyDouble("genxml/textbox/txtunitcost");
                    var    dealercost       = nbi.GetXmlPropertyDouble("genxml/textbox/txtdealercost");
                    Double newamt           = 0;
                    Double newdealersaleamt = 0;
                    Double newdealeramt     = 0;
                    if (amounttype == "1")
                    {
                        newamt           = unitcost - amount;
                        newdealersaleamt = dealercost - amount;
                    }
                    else
                    {
                        newamt           = unitcost - ((unitcost / 100) * amount);
                        newdealersaleamt = dealercost - ((dealercost / 100) * amount);
                    }
                    newdealeramt = newamt;
                    if (newamt < 0)
                    {
                        newamt = 0;
                    }
                    if (newdealersaleamt < 0)
                    {
                        newdealersaleamt = 0;
                    }

                    var currentprice = GetCurrentPromoPrice(prdData, whichprice, lp);
                    if (!overwrite)
                    {
                        if (currentprice == 0)
                        {
                            overwrite = true;
                        }
                        if (currentpromoid == promoid)
                        {
                            overwrite = true;
                        }
                    }
                    if (overwrite)
                    {
                        switch (whichprice)
                        {
                        case 1:
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", newamt);
                            prdData.SetXmlProperty("genxml/promo/salepriceid" + lp, promoid.ToString());
                            break;

                        case 2:
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealercost", newdealeramt);
                            prdData.SetXmlProperty("genxml/promo/dealercostid" + lp, promoid.ToString());
                            break;

                        case 3:
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealersale", newdealersaleamt);
                            prdData.SetXmlProperty("genxml/promo/dealersaleid" + lp, promoid.ToString());
                            break;

                        case 4:
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealersale", newdealersaleamt);
                            prdData.SetXmlProperty("genxml/promo/dealersaleid" + lp, promoid.ToString());
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", newamt);
                            prdData.SetXmlProperty("genxml/promo/salepriceid" + lp, promoid.ToString());
                            break;

                        default:
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", newamt);
                            prdData.SetXmlProperty("genxml/promo/salepriceid" + lp, promoid.ToString());
                            break;
                        }
                    }
                    if (disablesale)
                    {
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", 0);
                        prdData.RemoveXmlNode("genxml/promo/salepriceid" + lp);
                    }
                    if (disabledealer)
                    {
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealercost", 0);
                        prdData.RemoveXmlNode("genxml/promo/dealercostid" + lp);
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealersale", 0);
                        prdData.RemoveXmlNode("genxml/promo/dealersaleid" + lp);
                    }

                    lp += 1;
                }
                objCtrl.Update(prdData);

                foreach (var lang in cultureList)
                {
                    var promodesc = "";
                    var p         = objCtrl.GetDataLang(promoid, lang);
                    if (p != null)
                    {
                        promodesc = p.GetXmlProperty("genxml/textbox/description");
                    }
                    var prdDataLang = objCtrl.GetDataLang(productId, lang);
                    if (prdDataLang != null)
                    {
                        prdDataLang.SetXmlProperty("genxml/hidden/promodesc", promodesc);
                        objCtrl.Update(prdDataLang);
                    }
                }
            }
        }
Esempio n. 27
0
        private static void CalcProductSalePrice(int portalid, int productId, string amounttype, double amount, string promoname, int promoid, bool overwrite, DateTime dteF, DateTime dteU)
        {
            var cultureList = DnnUtils.GetCultureCodeList(portalid);
            var objCtrl     = new NBrightBuyController();
            var prdData     = objCtrl.GetData(productId);

            var nodList = prdData.XMLDoc.SelectNodes("genxml/models/genxml");

            if (nodList != null)
            {
                var currentpromoid = prdData.GetXmlPropertyInt("genxml/hidden/promoid");
                if (currentpromoid == 0 || currentpromoid == promoid || overwrite)
                {
                    prdData.SetXmlProperty("genxml/hidden/promotype", "PROMOGROUP");
                    prdData.SetXmlPropertyDouble("genxml/hidden/promoname", promoname);
                    prdData.SetXmlProperty("genxml/hidden/promoid", promoid.ToString());
                    prdData.SetXmlProperty("genxml/hidden/promocalcdate", DateTime.Now.ToString("O"));
                    prdData.SetXmlProperty("genxml/hidden/datefrom", dteF.ToString("O"));
                    prdData.SetXmlProperty("genxml/hidden/dateuntil", dteU.ToString("O"));

                    var lp = 1;
                    foreach (XmlNode nod in nodList)
                    {
                        var nbi = new NBrightInfo();
                        nbi.XMLData = nod.OuterXml;
                        var    unitcost = nbi.GetXmlPropertyDouble("genxml/textbox/txtunitcost");
                        Double newamt   = 0;
                        if (amounttype == "1")
                        {
                            newamt = unitcost - amount;
                        }
                        else
                        {
                            newamt = unitcost - ((unitcost / 100) * amount);
                        }

                        if (newamt < 0)
                        {
                            newamt = 0;
                        }

                        var currentprice = prdData.GetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice");

                        if (!overwrite)
                        {
                            if (currentprice == 0)
                            {
                                overwrite = true;
                            }
                            if (currentpromoid == promoid)
                            {
                                overwrite = true;
                            }
                        }
                        if (overwrite)
                        {
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", newamt);
                        }
                        lp += 1;
                    }
                    objCtrl.Update(prdData);

                    foreach (var lang in cultureList)
                    {
                        var p           = objCtrl.GetDataLang(promoid, lang);
                        var prdDataLang = objCtrl.GetDataLang(productId, lang);
                        if (prdDataLang != null)
                        {
                            prdDataLang.SetXmlProperty("genxml/hidden/promodesc", p.GetXmlProperty("genxml/textbox/description"));
                            objCtrl.Update(prdDataLang);
                        }
                    }
                }
            }
        }
Esempio n. 28
0
        public static string CalcGroupPromoItem(NBrightInfo p)
        {
            var objCtrl        = new NBrightBuyController();
            var typeselect     = p.GetXmlProperty("genxml/radiobuttonlist/typeselect");
            var catgroupid     = p.GetXmlProperty("genxml/dropdownlist/catgroupid");
            var propgroupid    = p.GetXmlProperty("genxml/dropdownlist/propgroupid");
            var promoname      = p.GetXmlProperty("genxml/textbox/name");
            var amounttype     = p.GetXmlProperty("genxml/radiobuttonlist/amounttype");
            var amount         = p.GetXmlPropertyDouble("genxml/textbox/amount");
            var validfrom      = p.GetXmlProperty("genxml/textbox/validfrom");
            var validuntil     = p.GetXmlProperty("genxml/textbox/validuntil");
            var overwrite      = p.GetXmlPropertyBool("genxml/checkbox/overwrite");
            var disabled       = p.GetXmlPropertyBool("genxml/checkbox/disabled");
            var lastcalculated = p.GetXmlProperty("genxml/hidden/lastcalculated");

            if (!disabled)
            {
                var runcalc = true;
                if (Utils.IsDate(lastcalculated))
                {
                    if (Convert.ToDateTime(lastcalculated) >= p.ModifiedDate)
                    {
                        runcalc = false;                                                           // only run if changed
                    }
                    if (DateTime.Now.Date > Convert.ToDateTime(lastcalculated).Date.AddDays(1))
                    {
                        runcalc = true;                                                                             // every day just after midnight. (for site performace)
                    }
                }
                if (Utils.IsDate(validuntil))
                {
                    if (DateTime.Now.Date > Convert.ToDateTime(validuntil))
                    {
                        runcalc = true;                                                         // need to disable the promo if passed date
                    }
                }
                if ((runcalc) && Utils.IsDate(validfrom) && Utils.IsDate(validuntil))
                {
                    var          dteF = Convert.ToDateTime(validfrom).Date;
                    var          dteU = Convert.ToDateTime(validuntil).Date;
                    CategoryData gCat;
                    var          groupid = catgroupid;
                    if (typeselect != "cat")
                    {
                        groupid = propgroupid;
                    }

                    gCat = CategoryUtils.GetCategoryData(groupid, Utils.GetCurrentCulture());
                    var prdList = gCat.GetAllArticles();

                    foreach (var prd in prdList)
                    {
                        if (DateTime.Now.Date >= dteF && DateTime.Now.Date <= dteU)
                        {
                            // CALC Promo
                            CalcProductSalePrice(p.PortalId, prd.ParentItemId, amounttype, amount, promoname, p.ItemID, overwrite, dteF, dteU);
                        }
                        if (DateTime.Now.Date > dteU)
                        {
                            // END Promo
                            RemoveProductPromoData(p.PortalId, prd.ParentItemId, p.ItemID);
                            p.SetXmlProperty("genxml/checkbox/disabled", "True");
                            objCtrl.Update(p);
                        }
                        ProductUtils.RemoveProductDataCache(p.PortalId, prd.ParentItemId);
                    }

                    p.SetXmlProperty("genxml/hidden/lastcalculated", DateTime.Now.AddSeconds(10).ToString("O"));     // Add 10 sec to time so we don't get exact clash with update time.
                    objCtrl.Update(p);
                }
            }
            return("OK");
        }
Esempio n. 29
0
        /// <summary>
        /// This function needs to process and returned message from the bank.
        /// This processing may vary widely between banks.
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            var modCtrl = new NBrightBuyController();
            var info    = ProviderUtils.GetProviderSettings("NBrightPayPalpayment");

            try
            {
                var ipn = new PayPalIpnParameters(context.Request.Form);

                var debugMode = info.GetXmlPropertyBool("genxml/checkbox/debug.mode");

                var debugMsg = "START CALL" + DateTime.Now.ToString("s") + " </br>";
                debugMsg += "returnmessage: " + context.Request.Form.Get("returnmessage") + "</br>";
                if (debugMode)
                {
                    info.SetXmlProperty("genxml/debugmsg", debugMsg);
                    modCtrl.Update(info);
                }

                debugMsg += "NBrightPayPal DEBUG: " + DateTime.Now.ToString("s") + " </br>" + context.Request.Form + "<br/>";

                if (Utils.IsNumeric(ipn.item_number))
                {
                    var validateUrl = info.GetXmlProperty("genxml/textbox/paymenturl") + "?" + ipn.PostString;

                    // check the record exists
                    debugMsg += "OrderId: " + ipn.item_number + " </br>";
                    var nbi = modCtrl.Get(Convert.ToInt32(ipn.item_number), "ORDER");
                    if (nbi != null)
                    {
                        var orderData = new OrderData(nbi.ItemID);
                        if (ProviderUtils.VerifyPayment(ipn, validateUrl))
                        {
                            if (debugMode)
                            {
                                info.SetXmlProperty("genxml/debugmsg", debugMsg);
                                modCtrl.Update(info);
                            }

                            //set order status to Payed
                            orderData.PaymentOk();
                        }
                        else
                        {
                            if (ipn.IsValid)
                            {
                                info.SetXmlProperty("genxml/debugmsg", "NOT VALIDATED BY PAYPAL");
                                //set order status to Not verified
                                orderData.PaymentOk("050");
                            }
                            else
                            {
                                info.SetXmlProperty("genxml/debugmsg", "PAYMENT FAIL");
                                orderData.PaymentFail();
                            }
                        }
                    }
                    else
                    {
                        debugMsg += "ORDER does not exists";
                    }
                    if (debugMode)
                    {
                        info.SetXmlProperty("genxml/debugmsg", debugMsg);
                        modCtrl.Update(info);
                    }
                }
            }
            catch (Exception ex)
            {
                if (!ex.ToString().StartsWith("System.Threading.ThreadAbortException")) // we expect a thread abort from the End response.
                {
                    info.SetXmlProperty("genxml/debugmsg", "NBrightPayPal ERROR: " + ex.ToString());
                    modCtrl.Update(info);
                }
            }
        }
Esempio n. 30
0
        /// <summary>
        /// This function needs to process and returned message from the bank.
        /// This processing may vary widely between banks.
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            var info = ProviderUtils.GetProviderSettings();

            var            objEventLog    = new EventLogController();
            PortalSettings portalsettings = new PortalSettings();

            try
            {
                var debugMode = info.GetXmlPropertyBool("genxml/checkbox/debugmode");
                var debugMsg  = "START CALL" + DateTime.Now.ToString("s") + " </br>";
                var rtnMsg    = "version=2" + Environment.NewLine + "cdr=1";

                var orderid = Utils.RequestQueryStringParam(context, "orderid");

                debugMsg += "orderid: " + orderid + "</br>";


                if (Utils.IsNumeric(orderid))
                {
                    var orderData = new OrderData(Convert.ToInt32(orderid));

                    PaymentResponse paymentClientResult = ProviderUtils.GetOrderPaymentResponse(orderData, "OS_MollieNotify.ProcessRequest");

                    objEventLog.AddLog("Mollie Webhook call for orderid: " + orderid, "Status: " + paymentClientResult.Status, portalsettings, -1, EventLogController.EventLogType.ADMIN_ALERT);

                    //Waiting for Payment 060
                    //Payment OK 040
                    //Incomplete 010
                    //Cancelled 030

                    switch (paymentClientResult.Status.ToString().ToLower())
                    {
                    case "paid":
                        orderData.PaymentOk("040", true);
                        rtnMsg = "OK";
                        break;

                    case "failed":
                        orderData.PaymentFail("010");
                        rtnMsg = "OK";
                        break;

                    case "canceled":
                        orderData.PaymentFail("030");
                        rtnMsg = "OK";
                        break;

                    case "expired":
                        orderData.PaymentFail("010");
                        rtnMsg = "OK";
                        break;

                    default:
                        orderData.PaymentFail("010");
                        rtnMsg = "OK";
                        break;
                    }
                }
                if (debugMode)
                {
                    debugMsg += "Return Message: " + rtnMsg;
                    info.SetXmlProperty("genxml/debugmsg", debugMsg);
                    var modCtrl = new NBrightBuyController();
                    modCtrl.Update(info);
                }

                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.Write(rtnMsg);
                HttpContext.Current.Response.ContentType  = "text/plain";
                HttpContext.Current.Response.CacheControl = "no-cache";
                HttpContext.Current.Response.Expires      = -1;
                HttpContext.Current.Response.End();
            }
            catch (Exception ex)
            {
                objEventLog.AddLog("Mollie Webhook call failed", ex.Message + " " + ex.InnerException, portalsettings, -1, EventLogController.EventLogType.ADMIN_ALERT);

                if (!ex.ToString().StartsWith("System.Threading.ThreadAbortException")) // we expect a thread abort from the End response.
                {
                    info.SetXmlProperty("genxml/debugmsg", "OS_Mollie ERROR: " + ex.ToString());
                    var modCtrl = new NBrightBuyController();
                    modCtrl.Update(info);
                }
            }
        }