Exemplo n.º 1
0
        /// <summary>
        /// Generates the folder readme.
        /// </summary>
        /// <param name="folders">The folders.</param>
        /// <param name="folder">The folder.</param>
        /// <returns></returns>
        protected String generateFolderReadme(IEnumerable <folderNode> folders, folderNode folder = null)
        {
            builderForMarkdown builder = new builderForMarkdown();


            if (folder != null)
            {
                builder.AppendHeading("Folder structure", 2);
                builder.AppendLine();


                builder.AppendHeading(folder.name, 3);
                builder.AppendLine(" > " + folder.path);
                builder.AppendLine(" > " + folder.description);
                builder.AppendLine();


                builder.AppendHorizontalLine();
            }
            else
            {
                builder.AppendHeading("Folder structure", 2);
                builder.AppendLine();

                builder.AppendParagraph("Application directory structure");
                builder.AppendHorizontalLine();

                foreach (var fold in folders)
                {
                    //    builder.nextTabLevel();
                    builder.AppendHeading(fold.name, 3);
                    builder.AppendLine(" > " + fold.path);
                    builder.AppendLine(" > " + fold.description);
                    builder.AppendLine();
                    //  builder.prevTabLevel();
                }
            }



            builder.AppendLine();
            builder.AppendHorizontalLine();

            PropertyCollection pc = notation.buildPropertyCollection <PropertyCollection>(false, false, "cite");

            builder.AppendPairs(pc, false);


            builder.AppendLine();
            builder.AppendHorizontalLine();

            builder.AppendLine("File generated: ".add(DateTime.Now.ToLongDateString(), " ").add(DateTime.Now.ToLongTimeString()));
            builder.AppendLine("Application: <<".add(name, " ").add(">>", " "));


            return(builder.ContentToString(true));
        }
Exemplo n.º 2
0
        public void reportIteration(dataUnitSpiderIteration dataUnit, modelSpiderSiteRecord wRecord, ISpiderEvaluatorBase evaluator)
        {
            iterationPerformanceRecord ip_record = new iterationPerformanceRecord(wRecord);

            wRecord.iterationTableRecord.Add(ip_record);


            folderNode fn; //siteRecords[wRecord].Add(dataUnit.iteration.ToString("D3"), wRecord.domainInfo.domainRootName + dataUnit.iteration.ToString("D3"), "Iteration " + dataUnit.iteration + " on domain: " + wRecord.domainInfo.domainName);


            if (imbWEMManager.settings.directReportEngine.doIterationReport)
            {
                if (imbWEMManager.settings.directReportEngine.doDomainReport)
                {
                    fn = getIterationFolder(dataUnit.iteration, wRecord);
                    if (REPORT_WRECORD_LOG)
                    {
                        wRecord.logBuilder.getLastLine().saveStringToFile(fn.pathFor("wrecord.txt"));
                    }



                    string fileprefix = wRecord.domainInfo.domainRootName.getCleanFilepath();


                    textByIteration url_loaded   = urlsLoaded[wRecord];   //.GetOrAdd(wRecord, new textByIteration());
                    textByIteration url_detected = urlsDetected[wRecord]; //, new textByIteration());
                                                                          //textByIteration terms_ext = termsExtracted[wRecord];
                                                                          //textByIteration sentence_ext = sentencesExtracted[wRecord];



                    if (REPORT_MODULES)
                    {
                        if (imbWEMManager.settings.directReportEngine.DR_ReportModules_XMLIteration)
                        {
                            if (wRecord.tRecord.instance is spiderModularEvaluatorBase)
                            {
                                wRecord.frontierDLC.reportIterationOut(wRecord, fn);
                            }
                        }
                    }

                    string its = dataUnit.iteration.ToString("D3");


                    //DataTable dt = wRecord.context.targets.GetDataTable();
                    //dt.SetTitle(fileprefix + "_targets");
                    //dt.serializeDataTable(aceCommonTypes.enums.dataTableExportEnum.csv, "", fn, notation);

                    //sentence_ext[dataUnit.iteration].AddRangeUnique(wRecord.context.targets.blocks.GetHashList());

                    //if (REPORT_ITERATION_TERMS)
                    //{
                    //    fileunit blocks = new fileunit(fn.pathFor(its + "_blc.txt"), false);


                    //    blocks.setContentLines(sentence_ext[dataUnit.iteration]);

                    //    blocks.Save();
                    //}

                    if (REPORT_TIMELINE)
                    {
                        objectSerialization.saveObjectToXML(ip_record, fn.pathFor("performance.xml"));
                    }



                    if (REPORT_ITERATION_URLS)
                    {
                        if (wRecord.iteration > 0)
                        {
                            builderForMarkdown now_loaded = new builderForMarkdown();

                            //fileunit now_loaded = new fileunit(fn.pathFor(its + "_loadedNow.txt"), false);
                            List <spiderTarget> targets_loaded = wRecord.context.targets.GetLoadedInIteration(wRecord.iteration - 1);

                            int tc = 0;
                            foreach (spiderTarget t in targets_loaded)
                            {
                                reportTarget(t, fn, tc);
                                now_loaded.AppendLine(t.url);
                                now_loaded.AppendHorizontalLine();
                                now_loaded.Append(t.marks.GetActiveResults());
                                now_loaded.AppendHorizontalLine();
                                now_loaded.Append(t.marks.GetPassiveResults());
                                now_loaded.AppendHorizontalLine();

                                var dt = t.marks.getHistory(t.url, wRecord.tRecord.instance.name);
                                dt.Save(fn, imbWEMManager.authorNotation, its + "_loadedNow");

                                now_loaded.AppendTable(dt, false);

                                tc++;
                            }

                            now_loaded.ToString().saveStringToFile(fn.pathFor(its + "_loadedNow.txt"));


                            spiderTaskResult loadResults = wRecord.spiderTaskResults[wRecord.iteration - 1];
                            loadResults.getDataTable().GetReportAndSave(fn, notation, "loadResults", true); // .serializeDataTable(aceCommonTypes.enums.dataTableExportEnum.excel, "loadResults", fn, notation);
                        }



                        fileunit detected = new fileunit(fn.pathFor(its + "_dt.txt"), false);
                        fileunit loaded   = new fileunit(fn.pathFor(its + "_ld.txt"), false);

                        fileunit relp = new fileunit(fn.pathFor(its + "_srb_ld.txt"), false);
                        relp.Append(wRecord.relevantPages, true);

                        foreach (spiderTarget t in wRecord.context.targets)
                        {
                            if (t.page != null)
                            {
                                //t.contentBlocks.ForEach(x => sentence_ext[dataUnit.iteration].AddUnique(x.textHash));

                                loaded.Append(t.url);
                                url_loaded[dataUnit.iteration].Add(t.url);
                            }
                            else
                            {
                                detected.Append(t.url);
                                url_detected[dataUnit.iteration].Add(t.url);
                            }
                        }


                        string lineFormat = "{0,5} {1,30} [s:{1,6}]" + Environment.NewLine;

                        fileunit active = new fileunit(fn.pathFor(its + "_act.txt"), false);
                        int      c      = 1;

                        foreach (var lnk in wRecord.web.webActiveLinks)
                        {
                            active.Append(string.Format(lineFormat, c, lnk.url, lnk.marks.score));
                            active.Append(lnk.marks.GetLayerAssociation());
                            c++;
                        }


                        detected.Save();
                        loaded.Save();
                        active.Save();
                    }
                }
            }



            wRecord.tRecord.instance.reportIteration(this, wRecord);
        }
        //public String makeFolderSignature()

        public void scopeOutOperation(IRenderExecutionContext context, IMetaContentNested oldScope)
        {
            if (context.directoryScope.FullName == context.directoryRoot.FullName)
            {
            }
            else
            {
                builderForMarkdown dirReadMe = new builderForMarkdown();

                dirReadMe.AppendHorizontalLine();

                dirReadMe.AppendHeading("Directory for [" + oldScope.name + "]", 3);

                dirReadMe.AppendLine("Report: {{{test_caption}}},  {{{sys_time}}}, {{{sys_date}}}");

                dirReadMe.AppendLine("> Open 'index.html' for report content");

                dirReadMe.AppendHorizontalLine();

                dirReadMe.AppendHeading("Report element description", 2);

                dirReadMe.AppendPair("Element class type", oldScope.GetType().Name, true, " \t\t = \t");
                dirReadMe.AppendPair("Element logical level", oldScope.elementLevel.ToString(), true, " \t\t = \t");
                dirReadMe.AppendPair("Element logical path", oldScope.path, true, " \t\t = \t"); //.elementLevel.ToString());
                dirReadMe.AppendPair("Element isRoot", oldScope.isThisRoot, true, " \t\t = \t"); //.elementLevel.ToString());

                dirReadMe.AppendHorizontalLine();

                dirReadMe.AppendHeading("Element data dump", 2);

                var pc = oldScope.AppendDataFields(null);
                dirReadMe.AppendPairs(pc, false, " \t\t = \t");

                dirReadMe.AppendHorizontalLine();

                dirReadMe.AppendHeading("Contextual data contextual dump", 2);

                var p2c = context.data;
                dirReadMe.AppendPairs(p2c, false, " \t\t = \t");

                dirReadMe.AppendHorizontalLine();

                dirReadMe.AppendLine("File created: {{{sys_time}}}, {{{sys_date}}}, {{{meta_year}}}");
                dirReadMe.AppendLine("By: {{{meta_softwareName}}}");
                dirReadMe.AppendLine("{{{meta_copyright}}}, {{{meta_author}}}, {{{meta_organization}}}");

                dirReadMe.AppendHorizontalLine();

                dirReadMe.AppendLine("File system path: " + context.directoryScope.FullName);
                dirReadMe.AppendLine("Report root path: " + context.directoryRoot.FullName);

                string content = dirReadMe.ContentToString(true, reportOutputFormatName.markdown);
                content = content.applyToContent(pc);
                content = content.applyToContent(p2c);

                string path = context.directoryScope.FullName.add("readme.md", "\\");

                content.saveStringToFile(path, getWritableFileMode.overwrite, Encoding.UTF8);

                // leaving the directory
                context.directoryScope = context.directoryScope.Parent;
            }
            setRelPath(context);
        }