示例#1
0
        public ActionResult GetReport(DtoReportOptions dtoOptions)
        {
            if (string.IsNullOrWhiteSpace(dtoOptions.SourceString) ||
                (dtoOptions.OptCalcOccurAll | dtoOptions.OptCalcOccurExtLinks | dtoOptions.OptCalcOccurMeta | dtoOptions.OptFilterStopWords) == false)
            {
                ViewBag.Message = "Some parameters is not set!";
                return(PartialView("_ErrorPartial"));
            }

            SeoTextProcessor processor = new SeoTextProcessor();
            Report           report    = new Report();

            ReportOptions options = new ReportOptions()
            {
                SourceString = dtoOptions.SourceString
                ,
                OptCalcOccurAll = dtoOptions.OptCalcOccurAll
                ,
                OptCalcOccurExtLinks = dtoOptions.OptCalcOccurExtLinks
                ,
                OptCalcOccurMeta = dtoOptions.OptCalcOccurMeta
                ,
                OptFilterStopWords = dtoOptions.OptFilterStopWords
            };

            try
            {
                bool initResult = processor.Init(options);
                if (!initResult)
                {
                    ViewBag.Message = "Error while initing input data! Check parameters and try again.";
                    return(PartialView("_ErrorPartial"));
                }

                report = processor.Process();
                if (report.Error)
                {
                    ViewBag.Message = report.ResultDescription;
                    return(PartialView("_ErrorPartial"));
                }

                if (Session["SeoReport"] == null)
                {
                    Session.Add("SeoReport", report);
                }
                else
                {
                    Session["SeoReport"] = report;
                }
                return(PartialView("_ReportPartial", report));
            }
            catch (Exception ex)
            {
                return(PartialView("_ErrorPartial", ex));
            }
        }
示例#2
0
        public void TestDoProcessUrl()
        {
            Options.SourceString = "https://www.w3schools.com/xml/xpath_syntax.asp";
            SeoTextProcessor prc = new SeoTextProcessor();

            prc.Init(this.Options);

            Report report = prc.Process();

            Assert.IsNotNull(report);
        }
示例#3
0
        public void TestDoProcessText()
        {
            Options.SourceString = "asdf sdaf sdf sdf dsf sdfsf";
            SeoTextProcessor prc = new SeoTextProcessor();

            prc.Init(this.Options);

            Report report = prc.Process();

            Assert.IsNotNull(report);
        }