protected void Page_PreRender(object sender, EventArgs e)
    {
        if (!Visible)
        {
            return;
        }

        _category = "";

        try
        {
            Guid customerId           = new Guid(Request["customerid"]);
            var  roleActionList       = RoleActionService.GetRoleActions();
            var  customerRoleKeysList = RoleActionService.GetCustomerRoleKeysByCustomerId(customerId);

            foreach (RoleActionKey key in customerRoleKeysList)
            {
                var role = roleActionList.Find(r => r.Key == key);
                if (role != null)
                {
                    role.Enabled = true;
                }
            }

            rprAccessSettigs.DataSource = roleActionList;
            rprAccessSettigs.DataBind();
        }
        catch (Exception ex)
        {
            Debug.LogError(ex);
        }
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            lBase.Text = string.Format("<base href='{0}'/>",
                                       Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath +
                                       (!Request.ApplicationPath.EndsWith("/") ? "/" : string.Empty)
                                       + "admin/");


            MenuAdmin.CurrentCustomer = CustomerContext.CurrentCustomer;

            newAdminMessage = AdminMessagesService.GetNotViewedAdminMessagesCount();
            newReviewsCount = StatisticService.GetLastReviewsCount();

            adminMessages.CssClass = "top-part-right icon-mail " + (newAdminMessage > 0 ? "icon-selected" : "");
            adminMessages.Text     = newAdminMessage > 0 ? newAdminMessage.ToString() : "";
            adminMessages.Visible  = AdvantshopConfigService.GetLocalization() == "ru-RU";

            adminReviews.CssClass = "top-part-right icon-bubble " + (newReviewsCount > 0 ? "icon-selected" : "");
            adminReviews.Text     = newReviewsCount > 0 ? newReviewsCount.ToString() : "";

            var _customer = CustomerContext.CurrentCustomer;

            if (_customer.CustomerRole == Role.Moderator)
            {
                var  actions = RoleActionService.GetCustomerRoleActionsByCustomerId(_customer.Id);
                bool visible = actions.Any(a => a.Key == RoleActionKey.DisplayAdminMainPageStatistics && a.Enabled);

                StoreLanguage.Visible     = visible;
                LastAdminMessages.Visible = visible;
                adminMessages.Visible     = visible;

                adminReviews.Visible = actions.Any(a => a.Key == RoleActionKey.DisplayComments && a.Enabled);
            }
        }
Esempio n. 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SaasTab.Visible = SaasDataService.IsSaasEnabled;
        Page.Title      = SettingsMain.ShopName;

        Customer _customer = CustomerSession.CurrentCustomer;

        if (_customer.CustomerRole == Role.Moderator)
        {
            var actions = RoleActionService.GetCustomerRoleActionsByCustomerId(_customer.Id);

            if (actions.Any(a => a.Key == RoleActionKey.DisplayOrders && a.Enabled))
            {
                OrderTab.Visible          = true;
                GoogleCharts2.Visible     = true;
                FinanceStatistics.Visible = true;
            }
            else
            {
                OrderTab.Visible          = false;
                GoogleCharts2.Visible     = false;
                FinanceStatistics.Visible = false;
            }

            ReviewsBlock1.Visible = actions.Any(a => a.Key == RoleActionKey.DisplayComments && a.Enabled);
            tblDashBoard.Visible  = actions.Any(a => (a.Key == RoleActionKey.DisplayOrders || a.Key == RoleActionKey.DisplayCatalog || a.Key == RoleActionKey.DisplayComments) && a.Enabled);
            NotepadTab.Visible    = false;
        }

        if (OrderTab.Visible)
        {
            TabContainer.OnClientActiveTabChanged = "chartOrder";
        }
    }
Esempio n. 4
0
    protected void btnChangeCommonInfo_Click(object sender, EventArgs e)
    {
        int groupId;

        Int32.TryParse(ddlCustomerGroup.SelectedValue, out groupId);

        customer.FirstName         = HttpUtility.HtmlEncode(txtFirstName.Text);
        customer.LastName          = txtLastName.Text;
        customer.Phone             = txtWWW.Text;
        customer.SubscribedForNews = chkSubscribed4News.Checked;
        customer.EMail             = lblEmail.Text;
        customer.CustomerGroupId   = groupId;

        if (customer.CustomerRole != Role.Administrator)
        {
            var prevCustomerRole = customer.CustomerRole;
            customer.CustomerRole = (Role)Convert.ToInt32(ddlCustomerRole.SelectedValue);

            if (prevCustomerRole == Role.Moderator && customer.CustomerRole == Role.Moderator)
            {
                CustomerRoleActionsAdmin.SaveRole();
            }
            else if (prevCustomerRole == Role.Moderator && customer.CustomerRole == Role.User)
            {
                RoleActionService.DeleteCustomerRoleActions(customer.Id);
            }
        }

        CustomerService.UpdateCustomer(customer);
        ShowRoleAccess = customer.CustomerRole == Role.Moderator;
        CustomerRoleActionsAdmin.Visible = ShowRoleAccess;
    }
Esempio n. 5
0
    public void Page_PreRender(object sender, EventArgs e)
    {
        Customer _customer = CustomerSession.CurrentCustomer;

        if (_customer.CustomerRole == Role.Moderator)
        {
            var actions = RoleActionService.GetCustomerRoleActionsByCustomerId(_customer.Id);
            OnLineUsers.Visible = actions.Any(a => a.Key == RoleActionKey.DisplayOrders && a.Enabled);
        }

        OnLineUsers.Visible &= SettingsMain.EnableUserOnline;

        if (!FileHelpers.IsCombineCssJsExsist(true))
        {
            CacheManager.RemoveByPattern("squishit_");
        }

        headStyle.Text = Bundle.Css()
                         .Add("~/admin/css/jquery.tooltip.css")
                         .Add("~/admin/css/AdminStyle.css")
                         .Add("~/admin/css/catalogDataTreeStyles.css")
                         .Add("~/admin/css/exportFeedStyles.css")
                         .Add("~/admin/css/jqueryslidemenu.css")
                         .Add("~/css/jq/jquery.autocomplete.css")
                         .Add("~/css/advcss/modal.css")
                         .Add("~/js/plugins/progress/css/progress.css")
                         .Add("~/js/plugins/jpicker/css/jpicker.css")
                         .WithMinifier(MinifierFactory.Get <CSSBundle, YuiCompressor>())
                         .Render("~/admin/css/combined_#.css");

        // combine java
        headScript.Text = Bundle.JavaScript()
                          .Add("~/js/localization/" + SettingsMain.Language + "/lang.js")
                          .Add("~/js/jq/jquery-1.7.1.min.js")
                          .Add("~/js/jq/jquery.autocomplete.js")
                          .Add("~/js/jq/jquery.metadata.js")
                          .Add("~/js/fix/PIEInit.js")
                          .Add("~/js/advjs/advModal.js")
                          .Add("~/js/advjs/advTabs.js")
                          .Add("~/js/advjs/advUtils.js")
                          .Add("~/admin/js/jquery.cookie.min.js")
                          .Add("~/admin/js/jquery.qtip.min.js")
                          .Add("~/admin/js/jquery.tooltip.min.js")
                          .Add("~/admin/js/slimbox2.js")
                          .Add("~/admin/js/jquery.history.js")
                          .Add("~/admin/js/jquerytimer.js")
                          .Add("~/admin/js/jqueryslidemenu.js")
                          .Add("~/admin/js/admin.js")
                          .Add("~/admin/js/grid.js")
                          .Add("~/js/advantshop.js")
                          .Add("~/js/services/Utilities.js")
                          .Add("~/js/services/scriptsManager.js")
                          .Add("~/js/plugins/progress/progress.js")
                          .Add("~/js/plugins/jpicker/jpicker.js")
                          .WithMinifier(MinifierFactory.Get <JavaScriptBundle, YuiMinifier>())
                          .Render("~/admin/js/combined_#.js");
    }
Esempio n. 6
0
        protected void btnChangeCommonInfo_Click(object sender, EventArgs e)
        {
            int groupId;

            Int32.TryParse(ddlCustomerGroup.SelectedValue, out groupId);
            lblError.Visible           = false;
            customer.FirstName         = HttpUtility.HtmlEncode(txtFirstName.Text);
            customer.LastName          = txtLastName.Text;
            customer.Phone             = txtWWW.Text;
            customer.CustomerGroupId   = groupId;
            customer.SubscribedForNews = chkSubscribed4News.Checked;

            if (customer.EMail != txtEmail.Text && CustomerService.ExistsEmail(txtEmail.Text))
            {
                lblError.Text    = Resource.Admin_CreateCustomer_CustomerErrorEmailExist;
                lblError.Visible = true;
                return;
            }

            customer.EMail = txtEmail.Text; customer.EMail = txtEmail.Text;

            var cardNumber = txtBonusCardNumber.Text.TryParseLong(true);

            if (BonusSystem.IsActive && txtBonusCardNumber.Text.IsNotEmpty())
            {
                if (BonusSystemService.GetCard(cardNumber) == null)
                {
                    lblError.Text    = Resource.Admin_ViewCustomer_WrongCardNumber;
                    lblError.Visible = true;
                    return;
                }
            }

            customer.BonusCardNumber = cardNumber;

            var prevCustomerRole = customer.CustomerRole;

            customer.CustomerRole = (Role)SQLDataHelper.GetInt(ddlCustomerRole.SelectedValue);

            if (customer.CustomerRole == Role.Moderator)
            {
                CustomerRoleActionsAdmin.SaveRole();
            }
            else if (prevCustomerRole == Role.Moderator && (customer.CustomerRole != Role.Moderator))
            {
                RoleActionService.DeleteCustomerRoleActions(customer.Id);
            }

            CustomerService.UpdateCustomer(customer);
            ShowRoleAccess = customer.CustomerRole == Role.Moderator;
            CustomerRoleActionsAdmin.Visible = ShowRoleAccess;
        }
Esempio n. 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Customer _customer = CustomerSession.CurrentCustomer;

        if (_customer.CustomerRole == Role.Moderator)
        {
            var actions = RoleActionService.GetCustomerRoleActionsByCustomerId(_customer.Id);

            OrderStatusStatistics.Visible = actions.Any(a => a.Key == RoleActionKey.DisplayOrders && a.Enabled);
            OrderStatistics.Visible       = actions.Any(a => a.Key == RoleActionKey.DisplayOrders && a.Enabled);
            CustomersStatistics1.Visible  = actions.Any(a => a.Key == RoleActionKey.DisplayCustomers && a.Enabled);
            ProductsStatistics.Visible    = actions.Any(a => a.Key == RoleActionKey.DisplayCatalog && a.Enabled);
        }
    }
Esempio n. 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var _customer = CustomerContext.CurrentCustomer;

            if (_customer.CustomerRole == Role.Moderator)
            {
                var actions = RoleActionService.GetCustomerRoleActionsByCustomerId(_customer.Id);

                dashCatalog.Visible   = actions.Any(a => a.Key == RoleActionKey.DisplayCatalog && a.Enabled);
                dashOrder.Visible     = actions.Any(a => a.Key == RoleActionKey.DisplayOrders && a.Enabled);
                dashNews.Visible      = actions.Any(a => a.Key == RoleActionKey.DisplayNews && a.Enabled);
                dashImportCsv.Visible = actions.Any(a => a.Key == RoleActionKey.DisplayImportExport && a.Enabled);
                dashModules.Visible   = actions.Any(a => a.Key == RoleActionKey.DisplayModules && a.Enabled);
                dashDesign.Visible    = actions.Any(a => a.Key == RoleActionKey.DisplayDesignTransformer && a.Enabled);

                this.Visible = dashCatalog.Visible || dashOrder.Visible || dashNews.Visible || dashImportCsv.Visible || dashModules.Visible || dashDesign.Visible;
            }
        }
    public void SaveRole()
    {
        Guid customerId = new Guid(Request["customerid"]);

        foreach (RepeaterItem item in rprAccessSettigs.Items)
        {
            string roleActionKey = ((HiddenField)item.FindControl("hfRoleActionKey")).Value;
            bool   enabled       = Convert.ToBoolean(((CheckBox)item.FindControl("chkRoleAction")).Checked);

            RoleActionService.UpdateOrInsertCustomerRoleAction(customerId, roleActionKey, enabled);
        }

        var cacheName = CacheNames.GetRoleActionsCacheObjectName(customerId.ToString());

        if (CacheManager.Contains(cacheName))
        {
            CacheManager.Remove(cacheName);
        }
    }
Esempio n. 10
0
        public static bool Check(Customer customer, string currentPage)
        {
            if (customer.CustomerRole != Role.Moderator || currentPage.Contains("default.aspx") || currentPage.Contains("filemanager.ashx"))
            {
                return(true);
            }

            var page = currentPage.Contains("productsonmain.aspx")
                           ? currentPage.Split(new[] { '/' }).Last()
                           : currentPage.Split(new[] { '?' }).First().Split(new[] { '/' }).Last();

            if (dictionary.ContainsKey(page))
            {
                RoleActionKey key = dictionary[page];
                return
                    (RoleActionService.GetCustomerRoleActionsByCustomerId(customer.Id)
                     .Any(a => a.Key == key && a.Enabled));
            }

            return(false);
        }
Esempio n. 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SetMeta(SettingsMain.ShopName);

            var _customer = CustomerContext.CurrentCustomer;

            if (_customer.CustomerRole == Role.Moderator)
            {
                var  actions = RoleActionService.GetCustomerRoleActionsByCustomerId(_customer.Id);
                bool showMainPageStatistics = actions.Any(a => a.Key == RoleActionKey.DisplayAdminMainPageStatistics && a.Enabled);

                IndicatorsStatistic.Visible     = showMainPageStatistics;
                SearchStatistic.Visible         = showMainPageStatistics;
                PlanProgressChart.Visible       = showMainPageStatistics;
                GoogleAnaliticStatistic.Visible = showMainPageStatistics;
                ordersStatuses.Visible          = showMainPageStatistics;


                bool showOrderDashBoard = actions.Any(a => a.Key == RoleActionKey.DisplayOrders && a.Enabled);

                BigOrdersChart.Visible = showOrderDashBoard;
                LastOrders.Visible     = showOrderDashBoard;
            }
        }
Esempio n. 12
0
        private void LoadOrder()
        {
            order = OrderService.GetOrder(OrderId);
            if (order == null)
            {
                Response.Redirect("OrderSearch.aspx");
            }

            lnkExportToExcel.NavigateUrl = "HttpHandlers/ExportOrderExcel.ashx?OrderID=" + order.OrderID;
            lnkEditOrder.NavigateUrl     = "EditOrder.aspx?OrderID=" + order.OrderID;

            OrderNumber         = order.Number;
            lblOrderId.Text     = order.OrderID.ToString();
            lblOrderDate.Text   = AdvantShop.Localization.Culture.ConvertDate(order.OrderDate);
            lblOrderNumber.Text = order.Number;

            IsPaid = order.PaymentDate != null && order.PaymentDate != DateTime.MinValue;

            if (order.OrderCurrency != null)
            {
                CurrencyValue = order.OrderCurrency.CurrencyValue;
                CurrencyCode  = order.OrderCurrency.CurrencyCode;
            }

            if (order.OrderCustomer != null)
            {
                var customer = CustomerService.GetCustomer(order.OrderCustomer.CustomerID);
                if (customer != null && customer.Id != Guid.Empty)
                {
                    lnkCustomerName.Text         = order.OrderCustomer.FirstName + @" " + order.OrderCustomer.LastName;
                    lnkCustomerName.NavigateUrl  = @"viewcustomer.aspx?customerid=" + order.OrderCustomer.CustomerID;
                    lnkCustomerEmail.Text        = order.OrderCustomer.Email;
                    lnkCustomerEmail.NavigateUrl = "mailto:" + order.OrderCustomer.Email;
                }
                else
                {
                    lblCustomerEmail.Text = order.OrderCustomer.Email;
                    lblCustomerName.Text  = order.OrderCustomer.FirstName + @" " + order.OrderCustomer.LastName;
                }

                lblCustomerPhone.Text = order.OrderCustomer.MobilePhone;
            }

            if (order.ShippingContact != null)
            {
                lblShippingCountry.Text = order.ShippingContact.Country;
                lblShippingCity.Text    = order.ShippingContact.City;
                lblShippingRegion.Text  = order.ShippingContact.Zone;
                lblShippingZipCode.Text = order.ShippingContact.Zip;
                lblShippingAddress.Text = order.ShippingContact.Address;

                if (!string.IsNullOrEmpty(order.ShippingContact.Country) && !string.IsNullOrEmpty(order.ShippingContact.City) &&
                    !string.IsNullOrEmpty(order.ShippingContact.Zone) && !string.IsNullOrEmpty(order.ShippingContact.Address))
                {
                    lnkShippingAddressOnMap.NavigateUrl = (SettingsOrderConfirmation.PrintOrder_MapType == "googlemap"
                                                                ? "https://maps.google.com/maps?ie=UTF8&z=15&q="
                                                                : "http://maps.yandex.ru/?text=") +
                                                          HttpUtility.UrlEncode(order.ShippingContact.Country + "," + order.ShippingContact.Zone + "," +
                                                                                order.ShippingContact.City + "," + order.ShippingContact.Address);
                }
                else
                {
                    lnkShippingAddressOnMap.Visible = false;
                }
            }

            if (order.BillingContact != null)
            {
                lblBuyerCountry.Text = order.BillingContact.Country;
                lblBuyerRegion.Text  = order.BillingContact.Zone;
                lblBuyerCity.Text    = order.BillingContact.City;
                lblBuyerZip.Text     = order.BillingContact.Zip;
                lblBuyerAddress.Text = order.BillingContact.Address;

                if (!string.IsNullOrEmpty(order.BillingContact.Country) && !string.IsNullOrEmpty(order.BillingContact.City) &&
                    !string.IsNullOrEmpty(order.BillingContact.Zone) && !string.IsNullOrEmpty(order.BillingContact.Address))
                {
                    lnkBuyerAddressOnMap.NavigateUrl = (SettingsOrderConfirmation.PrintOrder_MapType == "googlemap"
                                                            ? "https://maps.google.com/maps?ie=UTF8&z=15&q="
                                                            : "http://maps.yandex.ru/?text=") +
                                                       HttpUtility.UrlEncode(order.BillingContact.Country + "," + order.BillingContact.Zone + "," +
                                                                             order.BillingContact.City + "," + order.BillingContact.Address);
                }
                else
                {
                    lnkBuyerAddressOnMap.Visible = false;
                }
            }

            lblShippingMethodName.Text = order.ArchivedShippingName + (order.OrderPickPoint != null ? "<br />" + order.OrderPickPoint.PickPointAddress : "");
            lblPaymentMethodName.Text  = order.PaymentMethodName;

            var statusesList = OrderService.GetOrderStatuses();

            if (statusesList != null && statusesList.Any(status => status.StatusID == order.OrderStatus.StatusID))
            {
                ddlViewOrderStatus.DataSource = statusesList;
                ddlViewOrderStatus.DataBind();
                ddlViewOrderStatus.SelectedValue = order.OrderStatus.StatusID.ToString();
            }
            else
            {
                ddlViewOrderStatus.Items.Add(new ListItem(order.OrderStatus.StatusName, order.OrderStatus.StatusID.ToString()));
                ddlViewOrderStatus.SelectedValue = order.OrderStatus.StatusID.ToString();
            }
            ddlViewOrderStatus.Attributes["data-orderid"] = order.OrderID.ToString();

            pnlOrderNumber.Attributes["style"] = "border-left-color: #" + order.OrderStatus.Color;

            if (order.OrderCertificates == null || order.OrderCertificates.Count == 0)
            {
                lvOrderItems.DataSource = order.OrderItems;
                lvOrderItems.DataBind();
                lvOrderCertificates.Visible = false;
            }
            else
            {
                lvOrderCertificates.DataSource = order.OrderCertificates;
                lvOrderCertificates.DataBind();
                lvOrderItems.Visible = false;
            }

            lblUserComment.Text = string.IsNullOrEmpty(order.CustomerComment)
                                        ? Resource.Admin_OrderSearch_NoComment
                                        : order.CustomerComment;

            txtAdminOrderComment.Text = string.Format("{0}", order.AdminOrderComment);
            txtStatusComment.Text     = string.Format("{0}", order.StatusComment);

            txtStatusComment.Attributes["data-orderid"]     = order.OrderID.ToString();
            txtAdminOrderComment.Attributes["data-orderid"] = order.OrderID.ToString();

            var shipping = ShippingMethodService.GetShippingMethod(order.ShippingMethodId);

            if (shipping != null)
            {
                OrderPickPoint = order.OrderPickPoint;

                liMultiship.Visible = shipping.Type == ShippingType.Multiship;

                liSendBillingLink.Visible = order.OrderCustomer != null && order.ShippingMethod != null && !order.Payed;

                ShippingTypeIsCdek = shipping.Type == ShippingType.Cdek;

                ShippingTypeIsCheckout = lblCheckoutAdressNotice.Visible = shipping.Type == ShippingType.CheckoutRu;

                if (CustomerContext.CurrentCustomer.CustomerRole == Role.Moderator)
                {
                    var  actions             = RoleActionService.GetCustomerRoleActionsByCustomerId(CustomerContext.CurrentCustomer.Id);
                    bool showSendPaymentLink =
                        actions.Any(a => a.Key == RoleActionKey.DisplaySendPaymentLink && a.Enabled);

                    liSendBillingLink.Visible &= showSendPaymentLink;
                }
            }

            if (BonusSystem.IsActive)
            {
                var purchase = BonusSystemService.GetPurchase(order.Number, order.OrderID);
                if (purchase != null)
                {
                    bonusCardBlock.Visible  = true;
                    lblBonusCardNumber.Text = purchase.CardNumber;
                    lblBonusCardAmount.Text = purchase.NewBonusAmount.ToString();
                }
            }

            if (Settings1C.Enabled)
            {
                divUseIn1C.Visible = true;
                chkUseIn1C.Checked = order.UseIn1C;
                chkUseIn1C.Attributes["data-orderid"] = order.OrderID.ToString();

                var status1C = OrderService.GetStatus1C(order.OrderID);
                if (status1C != null)
                {
                    divStatus1C.Visible = true;
                    lbl1CStatus.Text    = status1C.Status1C;
                }
            }
            else
            {
                divUseIn1C.Visible = false;
            }

            LoadTotal(order);
        }
Esempio n. 13
0
        private static void OnBeginRequest(object sender, EventArgs e)
        {
            var    app           = (HttpApplication)sender;
            string strCurrentUrl = app.Request.RawUrl.ToLower().Trim();

            app.StaticFile304();
            // Debug go first
            if (UrlService.IsDebugUrl(strCurrentUrl))
            {
                // Nothing here
                // just return
                return;
            }

            // Check cn
            if (AppServiceStartAction.state != DataBaseService.PingDbState.NoError)
            {
                // Nothing here
                // just return
                return;
            }

            // Check original pictures
            if (strCurrentUrl.Contains("/pictures/product/original/"))
            {
                app.Context.RewritePath("~/err404.aspx");
                return;
            }

            // Check price_temp folder
            if (strCurrentUrl.Contains("/price_temp/"))
            {
                var actions = RoleActionService.GetCustomerRoleActionsByCustomerId(CustomerContext.CurrentCustomer.Id);

                if (!(CustomerContext.CurrentCustomer.IsAdmin || TrialService.IsTrialEnabled ||
                      CustomerContext.CurrentCustomer.IsVirtual ||
                      (CustomerContext.CurrentCustomer.IsModerator && actions.Any(item => item.Key == RoleActionKey.DisplayOrders || item.Key == RoleActionKey.DisplayImportExport)))
                    )
                {
                    app.Context.RewritePath("~/err404.aspx");
                    return;
                }
            }

            // Social
            string social = UrlService.Social.Find(strCurrentUrl.Contains);

            if (social != null)
            {
                app.Response.RedirectPermanent("~/social/catalogsocial.aspx?type=" + social.Split('-').Last());
            }

            // Check exportfeed
            //if (strCurrentUrl.Contains("exportfeed.aspx") || strCurrentUrl.Contains("exportfeeddet.aspx"))
            //    return;

            // Payment return url
            if (strCurrentUrl.Contains("/paymentreturnurl/"))
            {
                app.Context.RewritePath("~/PaymentReturnUrl.aspx?PaymentMethodID=" + app.Request.Path.Split(new[] { "/paymentreturnurl/" }, StringSplitOptions.None).LastOrDefault()
                                        + (string.IsNullOrWhiteSpace(app.Request.Url.Query) ? string.Empty : "&" + app.Request.Url.Query.Trim('?')));
                return;
            }
            if (strCurrentUrl.Contains("/paymentnotification/"))
            {
                app.Context.RewritePath("~/HttpHandlers/PaymentNotification.ashx?PaymentMethodID=" + app.Request.Path.Split(new[] { "/paymentnotification/" }, StringSplitOptions.None).LastOrDefault()
                                        + (string.IsNullOrWhiteSpace(app.Request.Url.Query) ? string.Empty : "&" + app.Request.Url.Query.Trim('?')));
                return;
            }

            // Seek in url table
            foreach (var key in UrlService.UrlTable.Keys.Where(strCurrentUrl.Split('?')[0].EndsWith))
            {
                app.Context.RewritePath(UrlService.UrlTable[key] + (string.IsNullOrWhiteSpace(app.Request.Url.Query)
                                                                            ? string.Empty
                                                                            : (UrlService.UrlTable[key].Contains("?") ? "&" : "?") + app.Request.Url.Query.Trim('?')));
                return;
            }

            //// Storage
            //string storage = UrlService.Storages.Find(strCurrentUrl.Contains);
            //if (storage != null)
            //{
            //    var index = strCurrentUrl.IndexOf(storage, StringComparison.Ordinal);
            //    string tail = app.Request.RawUrl.Substring(index + storage.Length);
            //    string pathNew = string.Format("~{0}{1}", storage, tail);
            //    app.Context.RewritePath(pathNew);
            //    return;
            //}

            string path = strCurrentUrl;

            if (app.Request.ApplicationPath != "/")
            {
                if (app.Request.ApplicationPath != null)
                {
                    path = path.Replace(app.Request.ApplicationPath.ToLower(), "");
                }
            }

            // sometimes Path.GetExtension thows exeption "Illegal characters in path"
            try
            {
                string extention = Path.GetExtension(path.Split('?')[0]);
                if (UrlService.ExtentionNotToRedirect.Contains(extention))
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                Debug.LogError(ex, false);
            }

            //301 redirect if need
            if (SettingsSEO.Enabled301Redirects && !path.Contains("/admin/"))
            {
                string newUrl = UrlService.GetRedirect301(path.TrimStart('/').Trim('?'), app.Request.Url.AbsoluteUri);
                if (newUrl.IsNotEmpty())
                {
                    app.Response.RedirectPermanent(newUrl);
                    return;
                }
            }

            var modules = AttachedModules.GetModules <IModuleUrlRewrite>();

            foreach (var moduleType in modules)
            {
                var    moduleObject = (IModuleUrlRewrite)Activator.CreateInstance(moduleType, null);
                string newUrl       = path;
                if (moduleObject.RewritePath(path, ref newUrl))
                {
                    app.Context.RewritePath(newUrl);
                    return;
                }
            }

            var param = UrlService.ParseRequest(path);

            if (param != null)
            {
                UrlService.RedirectTo(app, param);
            }
            else if (path.IsNotEmpty() && path != "/" && !path.Contains(".") && !path.Contains("?"))
            {
                Debug.LogError(new HttpException(404, "Can't get url: " + app.Context.Request.RawUrl + "path: '" + path + "'"));
                app.Context.RewritePath("~/err404.aspx");
            }
        }