Ejemplo n.º 1
0
        protected void grid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DeleteRedirectSeo")
            {
                RedirectSeoService.DeleteRedirectSeo(SQLDataHelper.GetInt(e.CommandArgument));
            }
            if (e.CommandName == "AddRedirectSeo")
            {
                GridViewRow footer             = grid.FooterRow;
                var         txtNexRedirectFrom = ((TextBox)footer.FindControl("txtNexRedirectFrom")).Text.Trim().ToLower();
                var         txtNewRedirectTo   = ((TextBox)footer.FindControl("txtNewRedirectTo")).Text.Trim().ToLower();
                var         txtNewProductArtNo = ((TextBox)footer.FindControl("txtNewProductArtNo")).Text.Trim();

                if (string.IsNullOrEmpty(txtNexRedirectFrom) || (string.IsNullOrEmpty(txtNewRedirectTo) && string.IsNullOrEmpty(txtNewProductArtNo)))
                {
                    grid.FooterStyle.BackColor = System.Drawing.Color.FromName("#ffcccc");
                    return;
                }

                var redirectSeo = new RedirectSeo
                {
                    RedirectFrom = txtNexRedirectFrom,
                    RedirectTo   = txtNewRedirectTo,
                    ProductArtNo = txtNewProductArtNo
                };

                RedirectSeoService.AddRedirectSeo(redirectSeo);
                grid.ShowFooter = false;
            }
            if (e.CommandName == "CancelAdd")
            {
                grid.FooterStyle.BackColor = System.Drawing.Color.FromName("#ccffcc");
                grid.ShowFooter            = false;
            }
        }
Ejemplo n.º 2
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (grid.UpdatedRow != null)
            {
                var redirectSeo = new RedirectSeo
                {
                    ID           = SQLDataHelper.GetInt(grid.UpdatedRow["ID"]),
                    RedirectFrom = grid.UpdatedRow["RedirectFrom"].Trim().ToLower(),
                    RedirectTo   = grid.UpdatedRow["RedirectTo"].Trim().ToLower(),
                    ProductArtNo = grid.UpdatedRow["ProductArtNo"]
                };
                RedirectSeoService.UpdateRedirectSeo(redirectSeo);
            }

            DataTable data = _paging.PageItems;

            while (data.Rows.Count < 1 && _paging.CurrentPageIndex > 1)
            {
                _paging.CurrentPageIndex--;
                data = _paging.PageItems;
            }

            var clmn = new DataColumn("IsSelected", typeof(bool))
            {
                DefaultValue = _inverseSelection
            };

            data.Columns.Add(clmn);
            if ((_selectionFilter != null) && (_selectionFilter.Values != null))
            {
                for (int i = 0; i <= data.Rows.Count - 1; i++)
                {
                    int intIndex = i;
                    if (Array.Exists(_selectionFilter.Values, c => c == data.Rows[intIndex]["ID"].ToString()))
                    {
                        data.Rows[i]["IsSelected"] = !_inverseSelection;
                    }
                }
            }

            if (data.Rows.Count < 1)
            {
                goToPage.Visible = false;
            }

            grid.DataSource = data;
            grid.DataBind();


            pageNumberer.PageCount = _paging.PageCount;
            lblFound.Text          = _paging.TotalRowsCount.ToString();
        }
Ejemplo n.º 3
0
    protected void btnAddResirects_Click(object sender, EventArgs e)
    {
        string[] lines = redirects.Value.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

        foreach (var line in lines)
        {
            string[] words = line.Split(" \t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (words.Length == 2)
            {
                var redirect = new RedirectSeo
                {
                    RedirectFrom = (words[0][0] != '/') ? "/" + words[0] : words[0],
                    RedirectTo   = (words[1][0] != '/') ? "/" + words[1] : words[1]
                };

                RedirectSeoService.AddRedirectSeo(redirect);
            }
        }
    }
Ejemplo n.º 4
0
        protected void btnImport_Click(object sender, EventArgs e)
        {
            if (!fuImportFile.HasFile)
            {
                return;
            }

            var filePath     = FoldersHelper.GetPathAbsolut(FolderType.PriceTemp);
            var fileName     = "redirectsImport.csv";
            var fullFileName = filePath + fileName.FileNamePlusDate();

            FileHelpers.CreateDirectory(filePath);

            fuImportFile.SaveAs(fullFileName);

            using (var csvReader = new CsvHelper.CsvReader(new StreamReader(fullFileName), new CsvConfiguration()
            {
                Delimiter = ";"
            }))
            {
                while (csvReader.Read())
                {
                    var currentRecord = new RedirectSeo
                    {
                        RedirectFrom = csvReader.GetField <string>("RedirectFrom"),
                        RedirectTo   = csvReader.GetField <string>("RedirectTo"),
                        ProductArtNo = csvReader.GetField <string>("ProductArtNo")
                    };

                    var redirect = RedirectSeoService.GetRedirectsSeoByRedirectFrom(currentRecord.RedirectFrom);

                    if (redirect == null)
                    {
                        RedirectSeoService.AddRedirectSeo(currentRecord);
                    }
                    else
                    {
                        currentRecord.ID = redirect.ID;
                        RedirectSeoService.UpdateRedirectSeo(currentRecord);
                    }
                }
            }
        }