private String ReportSelection(HttpContext context)

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

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

                return(strOut);
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Пример #2
0
        private String DeleteData(HttpContext context)
        {
            var objCtrl = new NBrightBuyController();

            //get uploaded params
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);
            var itemid   = ajaxInfo.GetXmlProperty("genxml/hidden/itemid");

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

                    // run the promo before delete, so we remove any promo data that may exist.
                    if (typecode == "CATEGORYPROMO")
                    {
                        PromoUtils.RemoveGroupProductPromo(PortalSettings.Current.PortalId, nbi.ItemID);
                    }
                    if (typecode == "MULTIBUYPROMO")
                    {
                        PromoUtils.RemoveMultiBuyProductPromo(PortalSettings.Current.PortalId, nbi.ItemID);
                    }

                    // delete DB record
                    objCtrl.Delete(nbi.ItemID);
                }

                NBrightBuyUtils.RemoveModCache(-2);
            }
            return("");
        }
Пример #3
0
        private String SaveData(HttpContext context)
        {
            var objCtrl = new NBrightBuyController();

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

            SetContextLangauge(ajaxInfo);     // Ajax breaks context with DNN, so reset the context language to match the client.

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

            if (lang == "")
            {
                lang = ajaxInfo.GetXmlProperty("genxml/hidden/lang");
            }
            if (lang == "")
            {
                lang = _lang;
            }

            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/code");
                    objCtrl.Update(nbi);

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

                    DataCache.ClearCache();     // clear ALL cache.

                    // run the promo now.
                    if (typecode == "CATEGORYPROMO")
                    {
                        PromoUtils.CalcGroupPromoItem(nbi);
                    }
                    if (typecode == "MULTIBUYPROMO")
                    {
                        PromoUtils.CalcMultiBuyPromoItem(nbi);
                    }
                }
            }
            return("");
        }
Пример #4
0
        private String GetData(HttpContext context, bool clearCache = false)
        {
            var objCtrl = new NBrightBuyController();
            var strOut  = "";
            //get uploaded params
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);

            SetContextLangauge(ajaxInfo);     // Ajax breaks context with DNN, so reset the context language to match the client.

            var itemid         = ajaxInfo.GetXmlProperty("genxml/hidden/itemid");
            var typeCode       = ajaxInfo.GetXmlProperty("genxml/hidden/typecode");
            var newitem        = ajaxInfo.GetXmlProperty("genxml/hidden/newitem");
            var selecteditemid = ajaxInfo.GetXmlProperty("genxml/hidden/selecteditemid");
            var moduleid       = ajaxInfo.GetXmlProperty("genxml/hidden/moduleid");
            var editlang       = ajaxInfo.GetXmlProperty("genxml/hidden/editlang");

            if (editlang == "")
            {
                editlang = _lang;
            }

            if (!Utils.IsNumeric(moduleid))
            {
                moduleid = "-2";                                 // use moduleid -2 for razor
            }
            if (clearCache)
            {
                NBrightBuyUtils.RemoveModCache(Convert.ToInt32(moduleid));
            }

            if (newitem == "new")
            {
                selecteditemid = AddNew(moduleid, typeCode);
            }

            var templateControl = "/DesktopModules/NBright/NBrightBuy/Providers/PromoProvider";

            if (Utils.IsNumeric(selecteditemid))
            {
                // do edit field data if a itemid has been selected
                var obj = objCtrl.Get(Convert.ToInt32(selecteditemid), "", editlang);
                strOut = NBrightBuyUtils.RazorTemplRender(typeCode.ToLower() + "fields.cshtml", Convert.ToInt32(moduleid), _lang + itemid + editlang + selecteditemid, obj, templateControl, "config", _lang, StoreSettings.Current.Settings());
            }
            else
            {
                // Return list of items
                var l = objCtrl.GetList(PortalSettings.Current.PortalId, Convert.ToInt32(moduleid), typeCode, "", " order by [XMLData].value('(genxml/textbox/validuntil)[1]','nvarchar(50)'), ModifiedDate desc", 0, 0, 0, 0, editlang);
                strOut = NBrightBuyUtils.RazorTemplRenderList(typeCode.ToLower() + "list.cshtml", Convert.ToInt32(moduleid), _lang + editlang, l, templateControl, "config", _lang, StoreSettings.Current.Settings());
            }

            return(strOut);
        }
        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 lang   = ajaxInfo.GetXmlProperty("genxml/hidden/editlang");

            if (lang == "")
            {
                lang = ajaxInfo.GetXmlProperty("genxml/hidden/lang");
            }
            if (lang == "")
            {
                lang = _lang;
            }

            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);
                    if (nbi.GUIDKey == "")
                    {
                        nbi.GUIDKey = Utils.GetUniqueKey();
                    }
                    objCtrl.Update(nbi);

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

                    DataCache.ClearCache();     // clear ALL cache.
                }
            }
            return("");
        }
        private String SaveData(HttpContext context)
        {
            var objCtrl = new NBrightBuyController();

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


            var guidkey  = ajaxInfo.GetXmlProperty("genxml/hidden/guidkey");
            var typeCode = ajaxInfo.GetXmlProperty("genxml/hidden/typecode");
            var editlang = ajaxInfo.GetXmlProperty("genxml/hidden/editlang");

            if (editlang == "")
            {
                editlang = _lang;
            }


            // get data record with language
            var obj = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -2, typeCode, guidkey);

            if (obj != null)
            {
                // get DB record
                var nbi = objCtrl.Get(obj.ItemID);
                if (nbi != null)
                {
                    // get data passed back by ajax
                    var strIn = HttpUtility.UrlDecode(Utils.RequestParam(context, "inputxml"));
                    // update record with ajax data
                    nbi.UpdateAjax(strIn);
                    if (nbi.GUIDKey == "")
                    {
                        nbi.GUIDKey = typeCode;
                    }
                    objCtrl.Update(nbi);

                    // do langauge record
                    var nbi2 = objCtrl.GetDataLang(obj.ItemID, editlang);
                    nbi2.UpdateAjax(strIn);
                    objCtrl.Update(nbi2);

                    DataCache.ClearCache(); // clear ALL cache.
                }
            }
            return("");
        }
Пример #7
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);
            }
        }
        private String GetData(HttpContext context, bool clearCache = false)
        {
            var objCtrl = new NBrightBuyController();
            var strOut  = "";
            //get uploaded params
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);

            var guidkey  = ajaxInfo.GetXmlProperty("genxml/hidden/guidkey");
            var typeCode = ajaxInfo.GetXmlProperty("genxml/hidden/typecode");
            var moduleid = ajaxInfo.GetXmlProperty("genxml/hidden/moduleid");
            var editlang = ajaxInfo.GetXmlProperty("genxml/hidden/editlang");

            if (editlang == "")
            {
                editlang = _lang;
            }

            if (!Utils.IsNumeric(moduleid))
            {
                moduleid = "-2";                             // use moduleid -2 for razor
            }
            if (clearCache)
            {
                NBrightBuyUtils.RemoveModCache(Convert.ToInt32(moduleid));
            }

            var templateControl = "/DesktopModules/NBright/NBrightBuyOpenUrlRewriter";

            // get data record with language
            var obj = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, Convert.ToInt32(moduleid), typeCode, guidkey);

            if (obj == null)
            {
                var itemId = AddNew(moduleid, typeCode);
                obj = objCtrl.Get(itemId);
            }
            var objData = objCtrl.GetData(obj.ItemID, typeCode + "LANG", editlang);

            //strOut = NBrightBuyUtils.RazorTemplRender(typeCode.ToLower() + "fields.cshtml", Convert.ToInt32(moduleid), _lang + guidkey + editlang, objData, templateControl, "config", editlang, StoreSettings.Current.Settings());

            return(strOut);
        }
Пример #9
0
        private string RunReport(HttpContext context)
        {
            var strOut = "- No Data Returned -";
            var strSql = "";

            try
            {
                var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);
                //var itemid = ajaxInfo.GetXmlPropertyInt("genxml/hidden/itemid");
                var razortemplate = ajaxInfo.GetXmlProperty("genxml/hidden/razortemplate");
                var portalid      = PortalSettings.Current.PortalId.ToString("");

                var editlang = ajaxInfo.GetXmlProperty("genxml/hidden/editlang");
                if (editlang == "")
                {
                    editlang = Utils.GetCurrentCulture();
                }
                var selecteditemid = ajaxInfo.GetXmlPropertyInt("genxml/hidden/selecteditemid");

                if (selecteditemid > 0)
                {
                    var objCtrl = new NBrightBuyController();
                    var obj     = objCtrl.Get(selecteditemid);
                    if (obj != null)
                    {
                        var inline = obj.GetXmlPropertyBool("genxml/checkbox/inline");
                        strSql = obj.GetXmlProperty("genxml/textbox/sql");
                        // replace any settings tokens (This is used to place the form data into the SQL)
                        strSql = Utils.ReplaceSettingTokens(strSql, ajaxInfo.ToDictionary());
                        strSql = Utils.ReplaceUrlTokens((strSql));

                        strSql = GenXmlFunctions.StripSqlCommands(strSql); // don't allow anything to update through here.

                        // add FOR XML if not there, this function will only output XML results.
                        if (!strSql.ToLower().Contains("for xml"))
                        {
                            strSql += " FOR XML PATH ('item'), ROOT ('root')";
                        }

                        var strXmlResults = objCtrl.GetSqlxml(strSql);
                        if (strXmlResults != "")
                        {
                            var xdoc       = XDocument.Parse(strXmlResults);
                            var headerInfo = new NBrightInfo(false);
                            headerInfo.XMLData = "<item></item>";
                            var elementsList = xdoc.XPathSelectElements("root/item[1]/*");
                            var xmlList      = new List <NBrightInfo>();

                            if (obj.GetXmlProperty("genxml/radiobuttonlist/reportformat") == "csv")
                            {
                                var lp = 1;
                                foreach (XElement xmlitem in elementsList)
                                {
                                    headerInfo.SetXmlProperty("item/header" + lp, xmlitem.Name.ToString());
                                    lp += 1;
                                }
                                xmlList.Add(headerInfo);
                            }

                            foreach (XElement xmlitem in xdoc.XPathSelectElements("root/item"))
                            {
                                var nbi = new NBrightInfo(false);
                                nbi.XMLData = xmlitem.ToString();
                                xmlList.Add(nbi);
                            }

                            var templateControl = "/DesktopModules/NBright/OS_Reports";

                            if (obj.GetXmlProperty("genxml/radiobuttonlist/reportformat") == "html")
                            {
                                if (inline)
                                {
                                    razortemplate = "reporthtmlinline.cshtml";
                                }
                                else
                                {
                                    razortemplate = "reporthtml.cshtml";
                                }
                            }
                            if (obj.GetXmlProperty("genxml/radiobuttonlist/reportformat") == "csv")
                            {
                                inline        = false;
                                razortemplate = "reportcsv.cshtml";
                            }
                            //project
                            if (obj.GetXmlProperty("genxml/radiobuttonlist/reportformat") == "barchart")
                            {
                                inline        = true;
                                razortemplate = "reportbar.cshtml";
                            }

                            strOut = NBrightBuyUtils.RazorTemplRenderList(razortemplate, -1, "", xmlList, templateControl, "config", editlang, StoreSettings.Current.Settings());

                            if (!inline)
                            {
                                var outfile = StoreSettings.Current.FolderTempMapPath + "\\" + selecteditemid + "." + obj.GetXmlProperty("genxml/radiobuttonlist/reportformat");
                                Utils.SaveFile(outfile, strOut);
                                strOut = "<br/><h1>Completed: <a target='_blank' href='" + StoreSettings.Current.FolderTemp + "/" + selecteditemid + "."
                                         + obj.GetXmlProperty("genxml/radiobuttonlist/reportformat") + "?key=" + Utils.GetUniqueKey() + "' >View</a></h1>";
                            }
                        }
                        return(strOut);
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.ToString() + " <hr/> " + strSql);
            }
            return(strOut);
        }
Пример #10
0
        private String GetData(HttpContext context, bool clearCache = false)
        {
            var objCtrl = new NBrightBuyController();
            var strOut  = "";
            //get uploaded params
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);

            var itemid         = ajaxInfo.GetXmlProperty("genxml/hidden/itemid");
            var typeCode       = ajaxInfo.GetXmlProperty("genxml/hidden/typecode");
            var newitem        = ajaxInfo.GetXmlProperty("genxml/hidden/newitem");
            var selecteditemid = ajaxInfo.GetXmlProperty("genxml/hidden/selecteditemid");
            var moduleid       = ajaxInfo.GetXmlProperty("genxml/hidden/moduleid");
            var editlang       = ajaxInfo.GetXmlProperty("genxml/hidden/editlang");

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

            var rundisplay = ajaxInfo.GetXmlPropertyBool("genxml/hidden/rundisplay");

            if (!Utils.IsNumeric(moduleid))
            {
                moduleid = "-2";                             // use moduleid -2 for razor
            }
            if (clearCache)
            {
                NBrightBuyUtils.RemoveModCache(Convert.ToInt32(moduleid));
            }

            if (newitem == "new")
            {
                selecteditemid = AddNew(moduleid, typeCode);
            }

            var templateControl = "/DesktopModules/NBright/OS_Reports";

            if (Utils.IsNumeric(selecteditemid))
            {
                // do edit field data if a itemid has been selected
                var obj = objCtrl.Get(Convert.ToInt32(selecteditemid), "", editlang);
                if (rundisplay)
                {
                    strOut = NBrightBuyUtils.RazorTemplRender("run.cshtml", Convert.ToInt32(moduleid), itemid + editlang + selecteditemid, obj, templateControl, "config", editlang, StoreSettings.Current.Settings());
                }
                else
                {
                    strOut = NBrightBuyUtils.RazorTemplRender("datafields.cshtml", Convert.ToInt32(moduleid), itemid + editlang + selecteditemid, obj, templateControl, "config", editlang, StoreSettings.Current.Settings());
                }
            }
            else
            {
                var pagenumber = ajaxInfo.GetXmlPropertyInt("genxml/hidden/pagenumber");
                var pagesize   = ajaxInfo.GetXmlPropertyInt("genxml/hidden/pagesize");

                if (pagenumber == 0)
                {
                    pagenumber = 1;
                }
                if (pagesize == 0)
                {
                    pagesize = 20;
                }

                var filter     = "";
                var searchText = ajaxInfo.GetXmlProperty("genxml/hidden/searchtext");
                if (searchText != "")
                {
                    filter += " and ( ";
                    filter += " (([xmldata].value('(genxml/textbox/ref)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))";
                    filter += " or (([xmldata].value('(genxml/lang/genxml/textbox/ref2)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))";
                    filter += " ) ";
                }

                // get only entity type required
                var recordcount = objCtrl.GetListCount(PortalSettings.Current.PortalId, -1, typeCode, filter);


                // Return list of items
                var l = objCtrl.GetDataList(PortalSettings.Current.PortalId, Convert.ToInt32(moduleid), typeCode, typeCode + "LANG", editlang, filter, " order by [XMLData].value('(genxml/textbox/ref)[1]','nvarchar(50)')", true, "", 0, pagenumber, pagesize, recordcount);
                strOut = NBrightBuyUtils.RazorTemplRenderList("datalist.cshtml", Convert.ToInt32(moduleid), "", l, templateControl, "config", editlang, StoreSettings.Current.Settings());

                if (recordcount > pagesize)
                {
                    var pg = new NBrightCore.controls.PagingCtrl();
                    strOut += pg.RenderPager(recordcount, pagesize, pagenumber);
                }
            }

            return(strOut);
        }
Пример #11
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);
                }
            }
        }
        private String GetData(HttpContext context, bool clearCache = false)
        {
            var objCtrl = new NBrightBuyController();
            var strOut  = "";
            //get uploaded params
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);

            var itemid         = ajaxInfo.GetXmlProperty("genxml/hidden/itemid");
            var typeCode       = ajaxInfo.GetXmlProperty("genxml/hidden/typecode");
            var newitem        = ajaxInfo.GetXmlProperty("genxml/hidden/newitem");
            var selecteditemid = ajaxInfo.GetXmlProperty("genxml/hidden/selecteditemid");
            var moduleid       = ajaxInfo.GetXmlProperty("genxml/hidden/moduleid");
            var editlang       = ajaxInfo.GetXmlProperty("genxml/hidden/editlang");

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

            if (!Utils.IsNumeric(moduleid))
            {
                moduleid = "-2";                             // use moduleid -2 for razor
            }
            if (clearCache)
            {
                NBrightBuyUtils.RemoveModCache(Convert.ToInt32(moduleid));
            }

            if (newitem == "new")
            {
                selecteditemid = AddNew(moduleid, typeCode);
            }

            var templateControl = "/DesktopModules/NBright/OS_CartReview";

            if (Utils.IsNumeric(selecteditemid))
            {
                // do edit field data if a itemid has been selected
                var obj     = objCtrl.Get(Convert.ToInt32(selecteditemid), "", editlang);
                var cartobj = new CartData(PortalSettings.Current.PortalId, "", obj.ItemID.ToString(""));
                strOut = NBrightBuyUtils.RazorTemplRender("datafields.cshtml", Convert.ToInt32(moduleid), itemid + editlang + selecteditemid, cartobj, templateControl, "config", editlang, StoreSettings.Current.Settings());
            }
            else
            {
                var filter     = "";
                var searchText = ajaxInfo.GetXmlProperty("genxml/hidden/searchtext");
                if (searchText != "")
                {
                    filter += " and (    (([xmldata].value('(genxml/billaddress/genxml/textbox/firstname)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))";
                    filter += " or (([xmldata].value('(genxml/billaddress/genxml/textbox/lastname)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))";
                    filter += " or (([xmldata].value('(genxml/billaddress/genxml/textbox/unit)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))";
                    filter += " or (([xmldata].value('(genxml/billaddress/genxml/textbox/street)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))";
                    filter += " or (([xmldata].value('(genxml/billaddress/genxml/textbox/postalcode)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))";
                    filter += " or (([xmldata].value('(genxml/billaddress/genxml/textbox/email)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))";
                    filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/firstname)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))";
                    filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/lastname)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))";
                    filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/unit)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))";
                    filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/street)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))";
                    filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/postalcode)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))";
                    filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/email)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))";
                    filter += " or (([xmldata].value('(genxml/productrefs)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))";
                    filter += " or (([xmldata].value('(genxml/ordernumber)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))  ) ";
                }

                var pagenumber = ajaxInfo.GetXmlPropertyInt("genxml/hidden/pagenumber");
                var pagesize   = ajaxInfo.GetXmlPropertyInt("genxml/hidden/pagesize");

                if (pagenumber == 0)
                {
                    pagenumber = 1;
                }
                if (pagesize == 0)
                {
                    pagesize = 20;
                }

                // get only entity type required
                var recordcount = objCtrl.GetListCount(PortalSettings.Current.PortalId, -1, typeCode, filter);

                // Return list of items
                var l = objCtrl.GetList(PortalSettings.Current.PortalId, Convert.ToInt32(moduleid), typeCode, filter, " order by NB1.ModifiedDate DESC ", 0, pagenumber, pagesize, recordcount, editlang);
                strOut = NBrightBuyUtils.RazorTemplRenderList("datalist.cshtml", Convert.ToInt32(moduleid), editlang + pagenumber, l, templateControl, "config", editlang, StoreSettings.Current.Settings());

                if (recordcount > pagesize)
                {
                    var pg = new NBrightCore.controls.PagingCtrl();
                    strOut += pg.RenderPager(recordcount, pagesize, pagenumber);
                }
            }

            return(strOut);
        }
        private String GetData(HttpContext context, bool clearCache = false)

        {
            var objCtrl = new NBrightBuyController();
            var strOut  = "";
            //get uploaded params
            var ajaxInfo       = NBrightBuyUtils.GetAjaxFields(context);
            var itemid         = ajaxInfo.GetXmlProperty("genxml/hidden/itemid");
            var typeCode       = ajaxInfo.GetXmlProperty("genxml/hidden/typecode");
            var newitem        = ajaxInfo.GetXmlProperty("genxml/hidden/newitem");
            var selecteditemid = ajaxInfo.GetXmlProperty("genxml/hidden/selecteditemid");
            var moduleid       = ajaxInfo.GetXmlProperty("genxml/hidden/moduleid");
            var editlang       = ajaxInfo.GetXmlProperty("genxml/hidden/editlang");
            var selectlang     = ajaxInfo.GetXmlProperty("genxml/hidden/selectlang");
            var rundisplay     = ajaxInfo.GetXmlPropertyBool("genxml/hidden/rundisplay");

            if (selectlang != "")
            {
                editlang = selectlang;
            }

            if (itemid == "")
            {
                itemid = selecteditemid;
            }

            if (editlang == "")
            {
                editlang = _lang;
            }

            if (!Utils.IsNumeric(moduleid))
            {
                moduleid = "-2";                             // use moduleid -2 for razor
            }
            if (clearCache)
            {
                NBrightBuyUtils.RemoveModCache(Convert.ToInt32(moduleid));
            }

            if (newitem == "new")
            {
                itemid = AddNew(moduleid, typeCode);
            }

            var templateControl = "/DesktopModules/NBright/NBrightBuyReport";

            if (Utils.IsNumeric(itemid))
            {
                // do edit field data if a itemid has been selected
                var obj = objCtrl.Get(Convert.ToInt32(itemid), "", editlang);
                if (rundisplay)
                {
                    strOut = NBrightBuyUtils.RazorTemplRender(typeCode.ToLower() + "run.cshtml", Convert.ToInt32(moduleid), _lang + itemid + editlang, obj, templateControl, "config", _lang, StoreSettings.Current.Settings());
                }
                else
                {
                    strOut = NBrightBuyUtils.RazorTemplRender(typeCode.ToLower() + "fields.cshtml", Convert.ToInt32(moduleid), _lang + itemid + editlang, obj, templateControl, "config", _lang, StoreSettings.Current.Settings());
                }
            }
            else
            {
                // Return list of items
                var l = objCtrl.GetDataList(PortalSettings.Current.PortalId, Convert.ToInt32(moduleid), typeCode, typeCode + "LANG", Utils.GetCurrentCulture(), "", " order by ModifiedDate desc", false, "", 100, 0, 0, 0);
                strOut = NBrightBuyUtils.RazorTemplRenderList(typeCode.ToLower() + "list.cshtml", Convert.ToInt32(moduleid), _lang + editlang, l, templateControl, "config", _lang, StoreSettings.Current.Settings());
            }
            return(strOut);
        }
Пример #14
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);
                }
            }
        }
Пример #15
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("DnnCMolliepayment");

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

                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 = "DnnCMollie DEBUG: " + 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 DnnCMollieStoreOrderID = 0;
                //string DnnCMollieCartID = "";
                //string DnnCMollieClientLang = "";



                var testMode   = info.GetXmlPropertyBool("genxml/checkbox/testmode");
                var testApiKey = info.GetXmlProperty("genxml/textbox/testapikey");
                var liveApiKey = info.GetXmlProperty("genxml/textbox/liveapikey");

                var nbi           = new NBrightInfo();
                var paymentMethod = nbi.GetXmlProperty("genxml/textbox/paymentmethod");
                var paymentBank   = nbi.GetXmlProperty("genxml/textbox/paymentbank");
                var apiKey        = testApiKey;

                if (!testMode)
                {
                    apiKey = liveApiKey;
                }

                string molliePaymentId = context.Request.Form["id"];
                int    oId             = -1;

                int.TryParse(context.Request.Form["orderid"], out oId);
                if (oId <= 0)
                {
                    int.TryParse(context.Request.Form["ordid"], out oId);
                }

                MollieClient mollieClient = new MollieClient();
                mollieClient.setApiKey(apiKey);
                PaymentStatus paymentStatus = mollieClient.GetStatus(molliePaymentId);

                var orderid = paymentStatus.metadata;
                var nbInfo  = modCtrl.Get(Convert.ToInt32(orderid), "ORDER");
                if (nbi != null)
                {
                    var orderData = new OrderData(nbInfo.ItemID);

                    switch (paymentStatus.status.Value)
                    {
                    case Status.paid:
                        orderData.PaymentOk();
                        break;

                    case Status.cancelled:
                        //set order status to Cancelled
                        orderData.PaymentOk("030");
                        break;

                    case Status.failed:
                        //set order status to payment failed
                        orderData.PaymentFail();
                        break;

                    case Status.open:
                        //set order status to Waiting for payment
                        orderData.PaymentOk("060");
                        break;

                    case Status.pending:
                        //set order status to Waiting for payment
                        orderData.PaymentOk("060");
                        break;

                    case Status.expired:
                        //set order status to Incomplete
                        orderData.PaymentOk("010");
                        break;
                    }

                    var rtnStr = paymentStatus.status.Value + "<br/> id = " + molliePaymentId;
                    rtnStr += "<br/> orderId = " + orderid;
                    rtnStr += "<br/> status = " + orderData.OrderStatus;

                    File.WriteAllText(PortalSettings.Current.HomeDirectoryMapPath + "\\debug_DnnC_IPN_return.html", rtnStr.ToString());
                }
            }
            catch { }
        } //end
Пример #16
0
        public static String ProductAdminDetail(HttpContext context)
        {
            try
            {
                if (NBrightBuyUtils.CheckManagerRights())
                {
                    var settings       = NBrightBuyUtils.GetAjaxDictionary(context);
                    var strOut         = "";
                    var selecteditemid = settings["selecteditemid"];
                    if (Utils.IsNumeric(selecteditemid))
                    {
                        if (!settings.ContainsKey("themefolder"))
                        {
                            settings.Add("themefolder", "");
                        }
                        if (!settings.ContainsKey("razortemplate"))
                        {
                            settings.Add("razortemplate", "");
                        }
                        if (!settings.ContainsKey("portalid"))
                        {
                            settings.Add("portalid", PortalSettings.Current.PortalId.ToString(""));                                    // aways make sure we have portalid in settings
                        }
                        if (!settings.ContainsKey("selecteditemid"))
                        {
                            settings.Add("selecteditemid", "");
                        }

                        var themeFolder = settings["themefolder"];

                        var razortemplate = settings["razortemplate"];
                        var portalId      = Convert.ToInt32(settings["portalid"]);

                        var passSettings = settings;
                        foreach (var s in StoreSettings.Current.Settings()) // copy store setting, otherwise we get a byRef assignement
                        {
                            if (passSettings.ContainsKey(s.Key))
                            {
                                passSettings[s.Key] = s.Value;
                            }
                            else
                            {
                                passSettings.Add(s.Key, s.Value);
                            }
                        }

                        if (!Utils.IsNumeric(selecteditemid))
                        {
                            return("");
                        }

                        if (themeFolder == "")
                        {
                            themeFolder = StoreSettings.Current.ThemeFolder;
                            if (settings.ContainsKey("themefolder"))
                            {
                                themeFolder = settings["themefolder"];
                            }
                        }

                        var objCtrl = new NBrightBuyController();
                        var info    = objCtrl.Get(Convert.ToInt32(selecteditemid), "PRD", Utils.GetCurrentCulture());

                        strOut = NBrightBuyUtils.RazorTemplRender(razortemplate, 0, "", info, "/DesktopModules/NBright/NBrightBuy", themeFolder, Utils.GetCurrentCulture(), passSettings);
                    }
                    return(strOut);
                }
                return("");
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }