public void ReplaceButton_Click(object sender, EventArgs e)
        {
            string searchQuery = SearchQuery.Text;
            string replaceText = ReplaceTextBox.Text;

            if (!string.IsNullOrEmpty(searchQuery) && !string.IsNullOrEmpty(replaceText))
            {
                List<PageData> results = FindPagesContainSearchQuery(searchQuery);

                foreach (PageData result in results)
                {
                    SitePageData writablePage = (SitePageData)result.CreateWritableClone();
                    XhtmlStringConverter converter = new XhtmlStringConverter();

                    if (writablePage["MainBody"] != null) {
                    string mainBody = writablePage["MainBody"].ToString();
                    mainBody = mainBody.Replace(searchQuery, replaceText);
                    writablePage["MainBody"] = (XhtmlString) converter.ConvertFromString(mainBody);
                }
                    string name = writablePage.Name;
                    name = name.Replace(searchQuery, replaceText);
                    writablePage.Name = name;

                    string descr = writablePage.MetaDescription;

                    if (descr != null) {
                    descr = descr.Replace(searchQuery, replaceText);
                    writablePage.MetaDescription = descr;
                    }

                    DataFactory.Instance.Save(writablePage, DataAccess.SaveAction.Publish, Security.AccessLevel.Create);
                }
            }
            ResultsLiteral.Text = string.Format("Replaced {0} with {1}", searchQuery, replaceText);
        }
Ejemplo n.º 2
0
        public void ReplaceButton_Click(object sender, EventArgs e)
        {
            string searchQuery = SearchQuery.Text;
            string replaceText = ReplaceTextBox.Text;

            if (!string.IsNullOrEmpty(searchQuery) && !string.IsNullOrEmpty(replaceText))
            {
                List <PageData> results = FindPagesContainSearchQuery(searchQuery);

                foreach (PageData result in results)
                {
                    SitePageData         writablePage = (SitePageData)result.CreateWritableClone();
                    XhtmlStringConverter converter    = new XhtmlStringConverter();

                    if (writablePage["MainBody"] != null)
                    {
                        string mainBody = writablePage["MainBody"].ToString();
                        mainBody = mainBody.Replace(searchQuery, replaceText);
                        writablePage["MainBody"] = (XhtmlString)converter.ConvertFromString(mainBody);
                    }
                    string name = writablePage.Name;
                    name = name.Replace(searchQuery, replaceText);
                    writablePage.Name = name;

                    string descr = writablePage.MetaDescription;

                    if (descr != null)
                    {
                        descr = descr.Replace(searchQuery, replaceText);
                        writablePage.MetaDescription = descr;
                    }

                    DataFactory.Instance.Save(writablePage, DataAccess.SaveAction.Publish, Security.AccessLevel.Create);
                }
            }
            ResultsLiteral.Text = string.Format("Replaced {0} with {1}", searchQuery, replaceText);
        }