Exemple #1
0
        public void ProcessRequest(HttpContext context)
        {
            #region "Initialize"

            var strOut = "** No Action **";

            var paramCmd       = Utils.RequestQueryStringParam(context, "cmd");
            var itemId         = Utils.RequestQueryStringParam(context, "itemid");
            var ctlType        = Utils.RequestQueryStringParam(context, "ctltype");
            var idXref         = Utils.RequestQueryStringParam(context, "idxref");
            var xpathpdf       = Utils.RequestQueryStringParam(context, "pdf");
            var xpathref       = Utils.RequestQueryStringParam(context, "pdfref");
            var lang           = Utils.RequestQueryStringParam(context, "lang");
            var language       = Utils.RequestQueryStringParam(context, "language");
            var moduleId       = Utils.RequestQueryStringParam(context, "mid");
            var moduleKey      = Utils.RequestQueryStringParam(context, "mkey");
            var parentid       = Utils.RequestQueryStringParam(context, "parentid");
            var entryid        = Utils.RequestQueryStringParam(context, "entryid");
            var entryxid       = Utils.RequestQueryStringParam(context, "entryxid");
            var catid          = Utils.RequestQueryStringParam(context, "catid");
            var catxid         = Utils.RequestQueryStringParam(context, "catxid");
            var templatePrefix = Utils.RequestQueryStringParam(context, "tprefix");
            var value          = Utils.RequestQueryStringParam(context, "value");
            var itemListName   = Utils.RequestQueryStringParam(context, "listname");
            if (itemListName == "")
            {
                itemListName = "ItemList";
            }
            if (itemListName == "*")
            {
                itemListName = "ItemList";
            }

            #region "setup language"

            // because we are using a webservice the system current thread culture might not be set correctly,
            _uilang = NBrightBuyUtils.SetContextLangauge(context);
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);
            _editlang = NBrightBuyUtils.GetEditLang(ajaxInfo, _uilang);

            #endregion

            Logging.Debug($"XmlConnector called with: paramCmd='{paramCmd}', itemId='{itemId}', itemListName='{itemListName}'");

            #endregion

            try
            {
                #region "Do processing of command"

                if (paramCmd.StartsWith("client."))
                {
                    strOut = ClientFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("orderadmin_"))
                {
                    strOut = OrderFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("payment_"))
                {
                    strOut = PaymentFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("product_"))
                {
                    ProductFunctions.EntityTypeCode = "PRD";
                    strOut = ProductFunctions.ProcessCommand(paramCmd, context, _editlang);
                }
                else if (paramCmd.StartsWith("category_"))
                {
                    CategoryFunctions.EntityTypeCode = "CATEGORY";
                    strOut = CategoryFunctions.ProcessCommand(paramCmd, context, _editlang);
                }
                else if (paramCmd.StartsWith("property_"))
                {
                    PropertyFunctions.EntityTypeCode = "CATEGORY";
                    strOut = PropertyFunctions.ProcessCommand(paramCmd, context, _editlang);
                }
                else if (paramCmd.StartsWith("itemlist_"))
                {
                    strOut = ItemListsFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("addressadmin_"))
                {
                    strOut = AddressAdminFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("plugins_"))
                {
                    strOut = PluginFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("cart_"))
                {
                    strOut = CartFunctions.ProcessCommand(paramCmd, context);
                }
                else
                {
                    switch (paramCmd)
                    {
                    case "test":
                        strOut = "<root>" + UserController.Instance.GetCurrentUserInfo().Username + "</root>";
                        break;

                    case "setdata":
                        break;

                    case "deldata":
                        break;

                    case "getdata":
                        strOut = GetReturnData(context);
                        break;

                    case "fileupload":
                        if (NBrightBuyUtils.CheckRights())
                        {
                            strOut = FileUpload(context);
                        }
                        break;

                    case "fileclientupload":
                        if (StoreSettings.Current.GetBool("allowupload"))
                        {
                            strOut = FileUpload(context, itemId);
                        }
                        break;

                    case "docdownload":

                        var fname   = Utils.RequestQueryStringParam(context, "filename");
                        var filekey = Utils.RequestQueryStringParam(context, "key");
                        if (filekey != "")
                        {
                            var uData = new UserData();
                            if (uData.HasPurchasedDocByKey(filekey))
                            {
                                fname = uData.GetPurchasedFileName(filekey);
                            }
                            fname = StoreSettings.Current.FolderDocuments + "/" + fname;
                        }
                        if (fname != "")
                        {
                            strOut = fname;     // return this is error.
                            var downloadname = Utils.RequestQueryStringParam(context, "downloadname");
                            var fpath        = HttpContext.Current.Server.MapPath(fname);
                            if (downloadname == "")
                            {
                                downloadname = Path.GetFileName(fname);
                            }
                            try
                            {
                                Utils.ForceDocDownload(fpath, downloadname, context.Response);
                            }
                            catch (Exception ex)
                            {
                                // ignore, robots can cause error on thread abort.
                                //Exceptions.LogException(ex);
                                Logging.Debug($"XmlConnector.ProcessRequest exception for {paramCmd} which is ignored because bots tend to cause these on thread abort: {ex.Message}.");
                            }
                        }
                        break;

                    case "printproduct":
                        break;

                    case "renderpostdata":
                        strOut = RenderPostData(context);
                        break;

                    case "getsettings":
                        strOut = GetSettings(context);
                        break;

                    case "savesettings":
                        if (NBrightBuyUtils.CheckRights())
                        {
                            strOut = SaveSettings(context);
                        }
                        break;

                    case "updateprofile":
                        strOut = UpdateProfile(context);
                        break;

                    case "dosearch":
                        strOut = DoSearch(context);
                        break;

                    case "resetsearch":
                        strOut = ResetSearch(context);
                        break;

                    case "orderby":
                        strOut = DoOrderBy(context);
                        break;

                    case "renderthemefolders":
                        strOut = RenderThemeFolders(context);
                        break;
                    }
                }

                if (strOut == "** No Action **")
                {
                    var pluginData = new PluginData(PortalSettings.Current.PortalId);
                    var provList   = pluginData.GetAjaxProviders();
                    foreach (var d in provList)
                    {
                        if (paramCmd.ToLower().StartsWith(d.Key.ToLower() + "_") || paramCmd.ToLower().StartsWith("cmd" + d.Key.ToLower() + "_"))
                        {
                            var ajaxprov = AjaxInterface.Instance(d.Key);
                            if (ajaxprov != null)
                            {
                                strOut = ajaxprov.ProcessCommand(paramCmd, context, _editlang);
                            }
                        }
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                strOut = ex.ToString();
                Logging.LogException(ex);
                //Exceptions.LogException(ex);
            }


            #region "return results"

            //send back xml as plain text
            context.Response.Clear();
            context.Response.ContentType = "text/plain";
            context.Response.Write(strOut);
            context.Response.End();

            #endregion
        }
Exemple #2
0
        public void ProcessRequest(HttpContext context)
        {
            #region "Initialize"

            var strOut = "** No Action **";

            var paramCmd       = Utils.RequestQueryStringParam(context, "cmd");
            var itemId         = Utils.RequestQueryStringParam(context, "itemid");
            var ctlType        = Utils.RequestQueryStringParam(context, "ctltype");
            var idXref         = Utils.RequestQueryStringParam(context, "idxref");
            var xpathpdf       = Utils.RequestQueryStringParam(context, "pdf");
            var xpathref       = Utils.RequestQueryStringParam(context, "pdfref");
            var lang           = Utils.RequestQueryStringParam(context, "lang");
            var language       = Utils.RequestQueryStringParam(context, "language");
            var moduleId       = Utils.RequestQueryStringParam(context, "mid");
            var moduleKey      = Utils.RequestQueryStringParam(context, "mkey");
            var parentid       = Utils.RequestQueryStringParam(context, "parentid");
            var entryid        = Utils.RequestQueryStringParam(context, "entryid");
            var entryxid       = Utils.RequestQueryStringParam(context, "entryxid");
            var catid          = Utils.RequestQueryStringParam(context, "catid");
            var catxid         = Utils.RequestQueryStringParam(context, "catxid");
            var templatePrefix = Utils.RequestQueryStringParam(context, "tprefix");
            var value          = Utils.RequestQueryStringParam(context, "value");
            var itemListName   = Utils.RequestQueryStringParam(context, "listname");
            if (itemListName == "")
            {
                itemListName = "ItemList";
            }
            if (itemListName == "*")
            {
                itemListName = "ItemList";
            }

            #region "setup language"

            // because we are using a webservice the system current thread culture might not be set correctly,
            NBrightBuyUtils.SetContextLangauge(context);
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);
            _editlang = NBrightBuyUtils.GetEditLang(ajaxInfo, Utils.GetCurrentCulture());

            #endregion

            Logging.Debug($"XmlConnector called with: paramCmd='{paramCmd}', itemId='{itemId}', itemListName='{itemListName}'");

            #endregion

            try
            {
                #region "Do processing of command"

                if (paramCmd.StartsWith("client."))
                {
                    strOut = ClientFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("orderadmin_"))
                {
                    strOut = OrderFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("payment_"))
                {
                    strOut = PaymentFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("product_"))
                {
                    var productFunctions = new ProductFunctions();
                    strOut = productFunctions.ProcessCommand(paramCmd, context, _editlang);
                }
                else if (paramCmd.StartsWith("category_"))
                {
                    var categoryFunctions = new CategoryFunctions();
                    strOut = categoryFunctions.ProcessCommand(paramCmd, context, _editlang);
                }
                else if (paramCmd.StartsWith("property_"))
                {
                    var propertyFunctions = new PropertyFunctions();
                    strOut = propertyFunctions.ProcessCommand(paramCmd, context, _editlang);
                }
                else if (paramCmd.StartsWith("itemlist_"))
                {
                    strOut = ItemListsFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("addressadmin_"))
                {
                    strOut = AddressAdminFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("plugins_"))
                {
                    strOut = PluginFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("cart_"))
                {
                    strOut = CartFunctions.ProcessCommand(paramCmd, context);
                }
                else
                {
                    switch (paramCmd)
                    {
                    case "test":
                        strOut = "<root>" + UserController.Instance.GetCurrentUserInfo().Username + "</root>";
                        break;

                    case "setdata":
                        break;

                    case "deldata":
                        break;

                    case "getdata":
                        strOut = GetReturnData(context);
                        break;

                    case "fileupload":
                        if (NBrightBuyUtils.CheckRights())
                        {
                            strOut = FileUpload(context);
                        }
                        break;

                    case "fileclientupload":
                        if (StoreSettings.Current.GetBool("allowupload"))
                        {
                            strOut = FileUpload(context, itemId);
                        }
                        break;

                    case "docdownload":
                        strOut = DownloadSystemFile(paramCmd, context);
                        break;

                    case "printproduct":
                        break;

                    case "renderpostdata":
                        strOut = RenderPostData(context);
                        break;

                    case "getsettings":
                        strOut = GetSettings(context);
                        break;

                    case "savesettings":
                        if (NBrightBuyUtils.CheckRights())
                        {
                            strOut = SaveSettings(context);
                        }
                        break;

                    case "updateprofile":
                        strOut = UpdateProfile(context);
                        break;

                    case "dosearch":
                        strOut = DoSearch(context);
                        break;

                    case "resetsearch":
                        strOut = ResetSearch(context);
                        break;

                    case "orderby":
                        strOut = DoOrderBy(context);
                        break;

                    case "renderthemefolders":
                        strOut = RenderThemeFolders(context);
                        break;
                    }
                }

                if (strOut == "** No Action **")
                {
                    var ajaxprovider = ajaxInfo.GetXmlProperty("genxml/hidden/ajaxprovider");
                    if (ajaxprovider == "")
                    {
                        ajaxprovider = Utils.RequestQueryStringParam(context, "ajaxprovider");
                    }

                    var pluginData = new PluginData(PortalSettings.Current.PortalId);
                    var provList   = pluginData.GetAjaxProviders();
                    if (ajaxprovider != "")
                    {
                        strOut = "Ajax Provider not found: " + ajaxprovider;
                        if (provList.ContainsKey(ajaxprovider))
                        {
                            var ajaxprov = AjaxInterface.Instance(ajaxprovider);
                            if (ajaxprov != null)
                            {
                                strOut = ajaxprov.ProcessCommand(paramCmd, context, _editlang);
                            }
                        }
                    }
                    else
                    {
                        foreach (var d in provList)
                        {
                            if (paramCmd.ToLower().StartsWith(d.Key.ToLower() + "_") || paramCmd.ToLower().StartsWith("cmd" + d.Key.ToLower() + "_"))
                            {
                                var ajaxprov = AjaxInterface.Instance(d.Key);
                                if (ajaxprov != null)
                                {
                                    strOut = ajaxprov.ProcessCommand(paramCmd, context, _editlang);
                                }
                            }
                        }
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                strOut = ex.ToString();
                Logging.LogException(ex);
                //Exceptions.LogException(ex);
            }


            #region "return results"

            //send back xml as plain text
            context.Response.Clear();
            context.Response.ContentType = "text/plain";
            context.Response.Write(strOut);
            context.Response.End();

            #endregion
        }