コード例 #1
0
        public static XElement BuildStatus(ProjectStatus status)
        {
            PageDocument.StatusColor color;

            switch (status)
            {
            case ProjectStatus.Active:
                color = PageDocument.StatusColor.Green;
                break;

            case ProjectStatus.Normal:
                color = PageDocument.StatusColor.Blue;
                break;

            case ProjectStatus.Legacy:
                color = PageDocument.StatusColor.Red;
                break;

            default:
                color = PageDocument.StatusColor.Grey;
                break;
            }

            return(PageDocument.BuildStatus(status.ToString(), color, false));
        }
コード例 #2
0
        public void AddPageTest()
        {
            IPagesStorageProviderV30 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV30>();

            mocks.ReplayAll();

            Host.Instance = new Host();

            Collectors.IndexDirectoryProvider = new DummyIndexDirectoryProvider();
            ProviderLoader.SetUp <IIndexDirectoryProviderV30>(typeof(DummyIndexDirectoryProvider), "");


            string pageTitle   = "This page is the title of the page";
            string pageContent = "This is the content of the page";

            PageContent page = new PageContent(new PageInfo("pagefullname", pagesStorageProvider, DateTime.Now), pageTitle,
                                               "user-test", DateTime.Now, "comment to last editing", pageContent, null, "Description of the page");

            Assert.IsTrue(SearchClass.IndexPage(page));

            List <SearchResult> results = SearchClass.Search(new SearchField[] { SearchField.Title }, "page", SearchOptions.AtLeastOneWord);

            Assert.AreEqual(1, results.Count, "Wrong result length");

            Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type");

            PageDocument documentPage = results[0].Document as PageDocument;

            Assert.AreEqual("This <b class=\"searchkeyword\">page</b> is the title of the <b class=\"searchkeyword\">page</b>", documentPage.HighlightedTitle, "Wrong title");
            Assert.AreEqual("This is the content of the <b class=\"searchkeyword\">page</b>", documentPage.HighlightedContent, "Wrong content");
        }
コード例 #3
0
        public void FormatAppointmentsTest()
        {
            PageDocument report = TestHelper.GetReport("Calendar-Format.rdlx");

            TestingRenderingExtension renderer = new TestingRenderingExtension();

            report.Render(renderer, null);

            // calendar1
            ICalendar calendar = (ICalendar)renderer.GetReportItem("Calendar1");

            Assert.IsNotNull(calendar);
            Assert.IsNotNull(calendar.Appointments);
            Assert.AreEqual(15, calendar.Appointments.Count);

            // there are expressions to get
            //		format		'=IIF((Convert.ToDateTime(Fields!StartTime.Value).Day - Convert.ToDateTime(Fields!EndTime.Value).Day) = 0, "D", "d")'
            //		background	'=IIF((Convert.ToDateTime(Fields!StartTime.Value).Day - Convert.ToDateTime(Fields!EndTime.Value).Day) = 0, "LightGreen", "Coral")'
            foreach (Appointment appointment in calendar.Appointments)
            {
                if (appointment.StartDate.Day - appointment.EndDate.Day == 0)
                {
                    Assert.AreEqual("D", appointment.Format);
                    Assert.AreEqual(Color.LightGreen, appointment.Backcolor);
                }
                else
                {
                    Assert.AreEqual("d", appointment.Format);
                    Assert.AreEqual(Color.Coral, appointment.Backcolor);
                }
            }
        }
コード例 #4
0
        private XElement RenderLinks()
        {
            var content = new List <object>();

            var title = new XElement("p", new XElement("code", new XElement("u", "ʟɪɴᴋs")));

            content.Add(title);

            if (GetType() == typeof(LibraryProjectPage))
            {
                var nuget = new XElement(
                    "p",
                    new XElement(
                        "a",
                        new XAttribute("href", $"{Config.NuGetUrl}/packages/{ProjectName}/"),
                        PageDocument.BuildImage($"{Config.NuGetUrl}/favicon.ico"),
                        "$nbsp$NuGet package"));

                content.Add(nuget);
            }

            var build = new XElement(
                "p",
                new XElement(
                    "a",
                    new XAttribute("href", $"{Config.CCNetUrl}/server/{Type.ServerName()}/project/{ProjectName}/ViewProjectReport.aspx"),
                    PageDocument.BuildImage($"{Config.CCNetUrl}/favicon.ico"),
                    "$nbsp$Build project"));

            content.Add(build);

            return(PageDocument.BuildBody(content));
        }
コード例 #5
0
        public void AppointmentWithBadFormattedDates()
        {
            PageDocument report = TestHelper.GetReport("Calendar-BadDates.rdlx");

            TestingRenderingExtension renderer = new TestingRenderingExtension();

            report.Render(renderer, null);

            // StartTime(string),EndTime(string),Value(string)
            // "2007-1205","2007-12-07","Appt#1 Text ..."
            // "2007-12-05","2007-1207","Appt#2 Text ..."
            // "2007-12-05","2007-12-07","Appt#3 Text ..."

            // calendar1
            ICalendar calendar = (ICalendar)renderer.GetReportItem("Calendar1");

            Assert.IsNotNull(calendar);
            Assert.IsNotNull(calendar.Appointments);
            Assert.AreEqual(2, calendar.Appointments.Count);
            // second row
            Appointment app1 = calendar.Appointments[0];

            Assert.AreEqual(new DateTime(2007, 12, 5), app1.StartDate.Date);
            Assert.AreEqual(new DateTime(2007, 12, 5), app1.EndDate.Date);
            Assert.AreEqual("Appt#2 Text ...", app1.Value);
            // third row
            Appointment app2 = calendar.Appointments[1];

            Assert.AreEqual(new DateTime(2007, 12, 5), app2.StartDate.Date);
            Assert.AreEqual(new DateTime(2007, 12, 7), app2.EndDate.Date);
            Assert.AreEqual("Appt#3 Text ...", app2.Value);
        }
コード例 #6
0
        public void DefaultAppearanceAppointmentTest()
        {
            PageDocument report = TestHelper.GetReport("Calendar.rdlx");

            TestingRenderingExtension renderer = new TestingRenderingExtension();

            report.Render(renderer, null);

            // calendar1
            ICalendar calendar = (ICalendar)renderer.GetReportItem("Calendar1");

            Assert.IsNotNull(calendar);
            Assert.IsNotNull(calendar.Appointments);

            foreach (Appointment appointment in calendar.Appointments)
            {
                Assert.AreEqual(Color.LightYellow, appointment.Backcolor);
                Assert.AreEqual(Color.DarkGray, appointment.BorderColor);
                Assert.AreEqual("Arial", appointment.FontFamily);
                Assert.AreEqual(new Length("8pt"), appointment.FontSize);
                Assert.AreEqual(FontStyle.Normal, appointment.FontStyle);
                Assert.AreEqual(FontWeight.Normal, appointment.FontWeight);
                Assert.AreEqual(FontDecoration.None, appointment.FontDecoration);
                Assert.AreEqual(Color.Black, appointment.FontColor);
                Assert.AreEqual(TextAlign.General, appointment.TextAlign);
                Assert.AreEqual(string.Empty, appointment.Format);
                Assert.AreEqual(ImageSource.External, appointment.ImageSource);
                Assert.AreEqual(string.Empty, appointment.ImageValue);
                Assert.AreEqual(string.Empty, appointment.MimeType);
            }
        }
コード例 #7
0
        public void CalendarDrillthroughWithParametersActionTest()
        {
            PageDocument report = TestHelper.GetReport("Calendar-DrillthroughWithParameters.rdlx");

            TestingRenderingExtension renderer = new TestingRenderingExtension();

            report.Render(renderer, null);

            ICalendar calendar;

            // calendar1 (default values)
            calendar = (ICalendar)renderer.GetReportItem("Calendar1");
            Assert.IsNotNull(calendar);
            foreach (Appointment appointment in calendar.Appointments)
            {
                Assert.IsNotNull(appointment.Action);
                Assert.AreEqual(ActionType.DrillThrough, appointment.Action.ActionType);
                Assert.IsNotNull(appointment.Action.Drillthrough);
                Assert.AreEqual(appointment.Value, appointment.Action.Drillthrough.ReportName);
                Assert.AreEqual(2, appointment.Action.Drillthrough.NumberOfParameters);

                foreach (DrillthroughParameter parameter in appointment.Action.Drillthrough.Parameters)
                {
                    Assert.AreEqual(true, parameter.Omit);
                    Assert.AreEqual("param", parameter.Name);
                    Assert.AreEqual(appointment.Value, parameter.Value);
                }
            }
        }
コード例 #8
0
        public void CalendarHyperlinkActionRenderingTest()
        {
            PageDocument report = TestHelper.GetReport("Calendar-Hyperlink.rdlx");

            ActionRenderingExtension renderer = new ActionRenderingExtension();

            report.Render(renderer, null);

            Assert.IsNotNull(renderer.CalendarLayoutArea);
            Assert.IsNotNull(renderer.CalendarLayoutArea.InteractivityAreas);

            //StartTime(string),EndTime(string),Value(string)
            //2007-12-05,2007-12-07,"www.google.com" - appeared as one interactive area
            //2007-12-06,2007-12-07,"www.rambler.ru" - appeared as one interactive area
            //2007-12-07,2007-12-07,"www.ya.ru" - appeared as one interactive area
            //2008-02-05,2008-03-07,"www.yahoo.com" - appeared as seven interactive areas

            Assert.AreEqual(11, renderer.CalendarLayoutArea.InteractivityAreas.Count);

            /*foreach (KeyValuePair<IImageMapArea, IAction> area in renderer.CalendarLayoutArea.InteractivityAreas)
             * {
             *      Assert.IsTrue(area.Key.Shape == ImageMapShape.Rectangle);
             *      Assert.IsNotNull(area.Key.Coordinates);
             *      Assert.AreEqual(4, area.Key.Coordinates.Length);
             *      Assert.IsNotNull(area.Value);
             *      Assert.IsTrue(area.Value.ActionType == ActionType.HyperLink);
             *      Assert.IsFalse(string.IsNullOrEmpty(area.Value.HyperLink));
             * }*/
        }
コード例 #9
0
        public void CalendarRenderWithNoDataBound()
        {
            PageDocument report = TestHelper.GetReport("Calendar-NoData.rdlx");

            TestingRenderingExtension rendererExt = new TestingRenderingExtension();

            report.Render(rendererExt, null);

            CalendarDataRegion calendar = rendererExt.GetReportItem("Calendar1") as CalendarDataRegion;

            Assert.IsNotNull(calendar);

            CalendarData         calendarData = new CalendarData(calendar);
            CalendarContentRange content      = new CalendarContentRange(calendar, calendarData.GetFirstMonth(), calendarData.GetLastMonth());

            // recalibrate graphics to twips
            RectangleF rect = new RectangleF(0, 0, 4000f, 4000f);

            CalendarDesigner.ScaleToTwipsGraphicsAndBound(GetGraphics(), ref rect);

            // create gdi canvas wrapper to use in renderer
            IDrawingCanvas canvas = GraphicsCanvasFactory.Create(GetGraphics());

            // render calendar to canvas
            CalendarRenderer.Instance.Render(content, canvas, rect);
        }
コード例 #10
0
        public void AddPageTest()
        {
            IPagesStorageProviderV60 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV60>();

            Expect.Call(pagesStorageProvider.CurrentWiki).Return("wiki1").Repeat.Any();

            mocks.ReplayAll();

            Collectors.InitCollectors();
            Collectors.AddProvider(typeof(FSIndexDirectoryProvider), System.Reflection.Assembly.GetAssembly(typeof(FSIndexDirectoryProvider)), "", typeof(IIndexDirectoryProviderV60));
            Host.Instance = new Host();
            Host.Instance.OverridePublicDirectory(testDir);

            ProviderLoader.SetUp <IIndexDirectoryProviderV60>(typeof(FSIndexDirectoryProvider), "");

            string pageTitle   = "This is the title of the page";
            string pageContent = "This is the content of the page";

            PageContent page = new PageContent("pagefullname", pagesStorageProvider, DateTime.Now, pageTitle,
                                               "user-test", DateTime.Now, "comment to last editing", pageContent, null, "Description of the page");


            Assert.IsTrue(SearchClass.IndexPage(page));

            List <SearchResult> results = SearchClass.Search("wiki1", new SearchField[] { SearchField.Title }, "page", SearchOptions.AtLeastOneWord);

            Assert.AreEqual(1, results.Count, "Wrong result length");

            Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type");

            PageDocument documentPage = results[0].Document as PageDocument;

            Assert.AreEqual("This is the title of the <b class=\"searchkeyword\">page</b>", documentPage.HighlightedTitle, "Wrong title");
            Assert.AreEqual("This is the content of the <b class=\"searchkeyword\">page</b>", documentPage.HighlightedContent, "Wrong content");
        }
コード例 #11
0
        // GET api/values/5
        public string Get(string id)
        {
            var fileName = "BarCode.rdlx";

            try
            {
                //GrapeCity.ActiveReports.Viewer.Win.Viewer arvMain = new GrapeCity.ActiveReports.Viewer.Win.Viewer();

                var reportFile = new FileInfo(HttpContext.Current.Server.MapPath("~/") + fileName);

                PageReport report = new PageReport(reportFile);

                var doc = new PageDocument(report);


                doc.Parameters["ReportParameter1"].CurrentValue = id;

                doc.Print(false, false, false);

                return("value = " + id);
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
コード例 #12
0
        public static XElement BuildBoolean(bool value)
        {
            var color = value
                                ? PageDocument.StatusColor.Green
                                : PageDocument.StatusColor.Grey;

            return(PageDocument.BuildStatus(value.ToString(), color, true));
        }
コード例 #13
0
 /// <summary>
 /// Preview the Layer report and set the target device for the layer to the report.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnPreview_Click(object sender, EventArgs e)
 {
     _pageReport.Load(new FileInfo("Layer.rdlx"));
     _reportRuntime = new PageDocument(_pageReport);
     _reportRuntime.PageReport.Report.Layers[1].TargetDevice = _targetDevices;
     reportViewer.LoadDocument(_reportRuntime);
     btnPdfExport.Enabled = true;
 }
コード例 #14
0
 private XElement RenderDetails()
 {
     return(PageDocument.BuildSection(
                PageDocument.BuildBody(
                    PageDocument.BuildColumn("300px", RenderStats()),
                    PageDocument.BuildColumn("200px", RenderLinks()),
                    PageDocument.BuildColumn(null, RenderHistory()))));
 }
コード例 #15
0
 private XElement RenderNameAndDescription()
 {
     return(new XElement(
                "td",
                PageDocument.BuildPageLink(m_page),
                new XElement("br"),
                new XElement("sup").XValue(Description)));
 }
コード例 #16
0
        public virtual PageDocument RenderPage()
        {
            var page = new PageDocument();

            page.Root.Add(RenderProperties());

            return(page);
        }
コード例 #17
0
        private void ShowLabels()
        {
            PageDocument pageDocument = null;

            pageDocument = ActiveReportsTools <int> .GetDocument(StaticMethods.GetPath(@"Etiketten\AdressEtikett.rdlx"));

            pageDocument.LocateDataSource += pageDocument_LocateDataSource;
            viewer1.LoadDocument(pageDocument);
        }
コード例 #18
0
        public static XElement BuildOwner(string userUid)
        {
            if (String.IsNullOrEmpty(userUid))
            {
                return(PageDocument.BuildStatus("none", PageDocument.StatusColor.Grey, false));
            }

            return(PageDocument.BuildUserLink(userUid));
        }
コード例 #19
0
ファイル: ContentSystem_Conf.cs プロジェクト: hdgardner/ECF
        public static void Initialize(TestContext testContext)
        {
            PageDocument.Init(new SqlPageDocumentStorageProvider(), new SqlTemporaryStorageProvider());

            if (!System.IO.Directory.Exists(ResultsPath))
            {
                System.IO.Directory.CreateDirectory(ResultsPath);
            }
        }
コード例 #20
0
        private XElement RenderAbout()
        {
            if (About == null)
            {
                About = PageDocument.BuildBody(new XElement("p", "..."));
            }

            return(PageDocument.BuildSection(About));
        }
コード例 #21
0
        public void UnindexPageTest()
        {
            IPagesStorageProviderV40 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV40>();

            Expect.Call(pagesStorageProvider.CurrentWiki).Return("wiki1").Repeat.Any();

            mocks.ReplayAll();

            Collectors.InitCollectors();
            Collectors.AddProvider(typeof(AzureIndexDirectoryProvider), System.Reflection.Assembly.GetAssembly(typeof(AzureIndexDirectoryProvider)), ConfigurationManager.AppSettings["AzureConnString"], typeof(IIndexDirectoryProviderV40));
            Host.Instance = new Host();
            Host.Instance.OverridePublicDirectory(testDir);

            ProviderLoader.SetUp <IIndexDirectoryProviderV40>(typeof(AzureIndexDirectoryProvider), ConfigurationManager.AppSettings["AzureConnString"]);

            string      pageTitle1   = "This is the title";
            string      pageContent1 = "This is the content of the page";
            PageContent page1        = new PageContent("pagefullname1", pagesStorageProvider, DateTime.Now, pageTitle1,
                                                       "user-test", DateTime.Now, "comment to last editing", pageContent1, null, "Description of the page");
            string      pageTitle2   = "This is the title of the second page";
            string      pageContent2 = "This is the content of the second page";
            PageContent page2        = new PageContent("pagefullname2", pagesStorageProvider, DateTime.Now, pageTitle2,
                                                       "user-test", DateTime.Now, "comment to last editing", pageContent2, null, "Description of the page");

            Lucene.Net.Store.Directory directory = new RAMDirectory();
            Assert.IsTrue(SearchClass.IndexPage(page1));
            Assert.IsTrue(SearchClass.IndexPage(page2));

            List <SearchResult> results = SearchClass.Search("wiki1", new SearchField[] { SearchField.Title, SearchField.Content }, "page", SearchOptions.AtLeastOneWord);

            Assert.AreEqual(2, results.Count, "Wrong result length");

            Assert.AreEqual(DocumentType.Page, results[1].DocumentType, "Wrong document type");
            PageDocument doc1 = results[1].Document as PageDocument;

            Assert.AreEqual(string.Empty, doc1.HighlightedTitle, "Wrong title");
            Assert.AreEqual("This is the content of the <b class=\"searchkeyword\">page</b>", doc1.HighlightedContent, "Wrong content");

            Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type");
            PageDocument doc2 = results[0].Document as PageDocument;

            Assert.AreEqual("This is the title of the second <b class=\"searchkeyword\">page</b>", doc2.HighlightedTitle, "Wrong title");
            Assert.AreEqual("This is the content of the second <b class=\"searchkeyword\">page</b>", doc2.HighlightedContent, "Wrong content");

            Assert.IsTrue(SearchClass.UnindexPage(page1));

            results = SearchClass.Search("wiki1", new SearchField[] { SearchField.Title, SearchField.Content }, "page", SearchOptions.AtLeastOneWord);

            Assert.AreEqual(1, results.Count, "Wrong result length");

            Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type");
            PageDocument doc3 = results[0].Document as PageDocument;

            Assert.AreEqual("This is the title of the second <b class=\"searchkeyword\">page</b>", doc3.HighlightedTitle, "Wrong title");
            Assert.AreEqual("This is the content of the second <b class=\"searchkeyword\">page</b>", doc3.HighlightedContent, "Wrong content");
        }
コード例 #22
0
        private void PDFDigitalSignature_Load(object sender, EventArgs e)
        {
            //Set the default for in the 'Signature Format' combo box.
            cmbVisibilityType.SelectedIndex = 3;
            var pageReport = new PageReport();

            _pageDocument = pageReport.Document;
            pageReport.Load(new FileInfo("..//..//..//..//Report//Catalog.rdlx"));
            arvMain.LoadDocument(_pageDocument);
        }
コード例 #23
0
 private XElement RenderNameColumn()
 {
     return(new XElement(
                "td",
                PageDocument.BuildPageLink(
                    m_page,
                    BranchName == null
                                         ? ProjectName
                                         : $"~ {BranchName} ~ {ProjectName}")));
 }
コード例 #24
0
 private XElement RenderMore()
 {
     return(PageDocument.BuildInfo(
                PageDocument.BuildBody(
                    new XElement(
                        "p",
                        "Знаешь об этом компоненте что-то еще? Пожалуйста напиши! (в произвольной форме, после заголовка About)",
                        new XElement("br"),
                        "Например цели создания, какие функции выполняет, может быть какие-то неочевидные особенности или решения по дизайну или структуре классов, и$nbsp$т.$nbsp$п."))));
 }
コード例 #25
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var reportFile = new FileInfo(@"..\..\..\..\Report\Svg.rdlx");
            var report     = new PageReport(reportFile);
            var document   = new PageDocument(report);

            viewer1.LoadDocument(document);
        }
コード例 #26
0
 public static object[] BuildExplain(string anchor, XElement element)
 {
     return(new object[]
     {
         element,
         "$nbsp$",
         new XElement(
             "sup",
             PageDocument.BuildPageLink("Свойства проекта", anchor, "explain?"))
     });
 }
コード例 #27
0
ファイル: SiteExportTab.ascx.cs プロジェクト: hdgardner/ECF
        /// <summary>
        /// Does the export.
        /// </summary>
        private void DoExport(Guid appId)
        {
            AppContext.Current.ApplicationId = appId;

            try
            {
                string result = String.Empty;

                if (SiteId != Guid.Empty)
                {
                    // export site

                    StringBuilder filePath = new StringBuilder(Server.MapPath(ManagementHelper.GetImportExportFolderPath("site")));
                    filePath.AppendFormat("\\SiteExport_{0}_{1}_{2}.xml", SiteName.Replace(' ', '-'), DateTime.Now.ToString("yyyyMMdd_HHmmss"), System.Environment.MachineName);
                    FileStream fs = new FileStream(filePath.ToString(), FileMode.Create, FileAccess.ReadWrite);

                    try
                    {
                        PageDocument.Init(new SqlPageDocumentStorageProvider(), new SqlTemporaryStorageProvider());
                        _ImportExport = new Mediachase.Cms.ImportExport.ImportExportHelper();
                        _ImportExport.ImportExportProgressMessage += new SiteImportExportProgressMessageHandler(ImportExport_ImportExportProgressMessage);
                        _ImportExport.ExportSite(SiteId, fs);
                    }
                    catch (SiteImportExportException ex)
                    {
                        throw ex;
                    }
                    finally
                    {
                        if (fs != null)
                        {
                            fs.Close();
                        }

                        // refresh files grid
                        //FilesControl.DataBind();
                        //FilesPanel.Update();
                    }
                }
                else
                {
                    throw new Exception("SiteId is empty!");
                }
            }
            catch (Exception ex)
            {
                ProgressControl1.AddProgressMessageText(ex.Message, true, -1);
            }
            finally
            {
            }
        }
コード例 #28
0
        public void UnindexPageTest()
        {
            IPagesStorageProviderV30 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV30>();

            mocks.ReplayAll();

            Host.Instance = new Host();

            Collectors.IndexDirectoryProvider = new DummyIndexDirectoryProvider();
            ProviderLoader.SetUp <IIndexDirectoryProviderV30>(typeof(DummyIndexDirectoryProvider), "");

            string      pageTitle1   = "This is the title";
            string      pageContent1 = "This is the content of the page";
            PageContent page1        = new PageContent(new PageInfo("pagefullname1", pagesStorageProvider, DateTime.Now), pageTitle1,
                                                       "user-test", DateTime.Now, "comment to last editing", pageContent1, null, "Description of the page");
            string      pageTitle2   = "This is the title of the second page";
            string      pageContent2 = "This is the content of the second page";
            PageContent page2        = new PageContent(new PageInfo("pagefullname2", pagesStorageProvider, DateTime.Now), pageTitle2,
                                                       "user-test", DateTime.Now, "comment to last editing", pageContent2, null, "Description of the page");

            Lucene.Net.Store.Directory directory = new RAMDirectory();
            Assert.IsTrue(SearchClass.IndexPage(page1));
            Assert.IsTrue(SearchClass.IndexPage(page2));

            List <SearchResult> results = SearchClass.Search(new SearchField[] { SearchField.Title, SearchField.Content }, "page", SearchOptions.AtLeastOneWord);

            Assert.AreEqual(2, results.Count, "Wrong result length");

            Assert.AreEqual(DocumentType.Page, results[1].DocumentType, "Wrong document type");
            PageDocument doc1 = results[1].Document as PageDocument;

            Assert.AreEqual(string.Empty, doc1.HighlightedTitle, "Wrong title");
            Assert.AreEqual("This is the content of the <b class=\"searchkeyword\">page</b>", doc1.HighlightedContent, "Wrong content");

            Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type");
            PageDocument doc2 = results[0].Document as PageDocument;

            Assert.AreEqual("This is the title of the second <b class=\"searchkeyword\">page</b>", doc2.HighlightedTitle, "Wrong title");
            Assert.AreEqual("This is the content of the second <b class=\"searchkeyword\">page</b>", doc2.HighlightedContent, "Wrong content");

            Assert.IsTrue(SearchClass.UnindexPage(page1));

            results = SearchClass.Search(new SearchField[] { SearchField.Title, SearchField.Content }, "page", SearchOptions.AtLeastOneWord);

            Assert.AreEqual(1, results.Count, "Wrong result length");

            Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type");
            PageDocument doc3 = results[0].Document as PageDocument;

            Assert.AreEqual("This is the title of the second <b class=\"searchkeyword\">page</b>", doc3.HighlightedTitle, "Wrong title");
            Assert.AreEqual("This is the content of the second <b class=\"searchkeyword\">page</b>", doc3.HighlightedContent, "Wrong content");
        }
コード例 #29
0
        private string NormalizeForComparison(string content)
        {
            var doc    = new PageDocument(content);
            var macros = doc.Root.XElements("//ac:structured-macro").ToList();

            foreach (var macro in macros)
            {
                macro.XAttribute("ac:macro-id").RemoveIfExists();
                macro.XAttribute("ac:schema-version").RemoveIfExists();
            }

            return(doc.Render());
        }
コード例 #30
0
        private string NormalizeForComparison(string content)
        {
            var doc    = new PageDocument(content);
            var macros = doc.Root.XElements("//ac:structured-macro").ToList();

            foreach (var macro in macros)
            {
                macro.XAttribute("ac:macro-id").RemoveIfExists();
                macro.XAttribute("ac:schema-version").RemoveIfExists();
            }

            return(doc.Render()
                   .CleanWhitespaces()
                   .Replace("<table class=\"wrapped\"><colgroup><col /><col /></colgroup>", "<table>"));
        }