/// <summary>
        /// Exports help file into current state project folder
        /// </summary>
        /// <param name="filename">help.txt</param>
        /// <param name="open">true</param>
        /// <param name="onlyThisConsole">if set to <c>true</c> [only this console].</param>
        /// <remarks>
        /// Writes a txt file with content equal to the result of help command
        /// </remarks>
        /// <seealso cref="aceOperationSetExecutorBase" />
        public void aceOperation_helpExportHelp(
            [Description("help.txt")] String filename = "help.txt",
            [Description("true")] Boolean open        = true,
            [Description("If true it will generate user manual only for this console")] Boolean onlyThisConsole = false)
        {
            builderForMarkdown mdBuilder = new builderForMarkdown();

            if (onlyThisConsole)
            {
                var cst = commandTreeTools.BuildCommandTree(this, false);
                cst.ReportCommandTree(mdBuilder, false, 0, aceCommandConsoleHelpOptions.full);
                helpContent = mdBuilder.getLastLine();
            }
            else
            {
                commandSetTree.ReportCommandTree(mdBuilder, false, 0, aceCommandConsoleHelpOptions.full);
                helpContent = mdBuilder.GetContent();
            }

            String p = workspace.folder.pathFor(filename);

            if (p.saveToFile(helpContent))
            {
                response.log("Help file saved to: " + p);
            }
            if (open)
            {
                externalTool.notepadpp.run(p);
            }
        }
Пример #2
0
        //public static ITextRender getRenderFor(reportAPI api)
        //{
        //}

        public static ITextRender getRenderFor(reportAPI api)
        {
            ITextRender output = null;

            switch (api)
            {
            case reportAPI.imbXmlHtml:
                output = new builderForHtml();
                break;

            //case reportAPI.EEPlus:
            //    output = new builderForTableDocument();
            //    break;
            case reportAPI.textBuilder:
                output = new builderForText();
                break;

            default:
                output = new builderForMarkdown();
                break;
            }
            output.settings.api = api;

            return(output);
        }
        /// <summary>
        /// Writes a summary report into ITextRender
        /// </summary>
        /// <param name="ex">The ex.</param>
        /// <param name="sb">The sb.</param>
        /// <param name="summaryTitle">The summary title.</param>
        /// <returns></returns>
        public static String reportSummary(this Exception ex, ITextRender sb = null, String summaryTitle = "")
        {
            if (sb == null)
            {
                sb = new builderForMarkdown();
            }
            if (String.IsNullOrEmpty(summaryTitle))
            {
                summaryTitle = "Exception" + ex.GetType().Name;
            }

            //sb.open(htmlTagName.div, htmlClassForReport.noteContainer, htmlIdForReport.innerException);

            sb.AppendPair(summaryTitle + " message: ", ex.Message, true, "");

            sb.Append(summaryTitle + " stack: ", appendType.heading_3, true);
            //, htmlTagName.p, , "", false);

            ex.StackTrace.cleanStackTrace(sb);

            callerInfo ci = new callerInfo();

            sb.AppendLine(ex.Source);

            sb.AppendLine(ex.StackTrace);

            // sb.close();

            return(sb.ToString());
        }
Пример #4
0
        public void SaveReport(String filepath)
        {
            builderForMarkdown textRender = new builderForMarkdown();

            Report(textRender);

            File.WriteAllText(filepath, textRender.GetContent());
        }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="aceGeneralException"/> class.
        /// </summary>
        /// <param name="__message">The message.</param>
        /// <param name="__innerException">The inner exception.</param>
        public aceGeneralException(String __message = "", Exception __innerException = null, Object __callerInstane = null, String __title = "", Int32 stacks = 0) : base(__message, __innerException)
        {
            Int32 stackSkip = 1 + stacks;


            while (__innerException != null)
            {
                __innerException = __innerException.InnerException as aceGeneralException;
                stackSkip++;
            }


            _stackTrace = new StackTrace(true);
            //_stackFrame = _stackTrace.GetFrame(0);
            _stackFrame = getFirstFrameWithSource(_stackTrace, stackSkip);
            _message    = __message;
            title       = __title;

            if (_stackTrace == null)
            {
                _stackTraceText = Environment.StackTrace;
            }
            else
            {
                _stackTraceText = _stackTrace.ToString();
            }

            callInfo = callerInfo.getCallerInfo(_stackFrame, true);
            info     = callInfo.AppendDataFields(info);
            info     = callInfo.AppendDataFieldsOfMethod(info);


            if (InnerException != null)
            {
                if (imbSciStringExtensions.isNullOrEmptyString(__message))
                {
                    _message += Environment.NewLine + InnerException.Message;
                }
                if (imbSciStringExtensions.isNullOrEmptyString(title))
                {
                    title = "Exception: " + InnerException.GetType().Name + " in " + callInfo.className;
                }
            }
            var ex = InnerException;

            imbSCI.Core.reporting.render.builders.builderForMarkdown md = new builderForMarkdown();
            Int32 c = 1;

            while (ex != null)
            {
                ex.reportSummary(md, "Inner exception [" + c + "]");
                ex = ex.InnerException;
                c++;
            }
            _message = _message.addLine(md.ContentToString());

            HelpLink = Directory.GetCurrentDirectory() + "\\diagnostics\\index.html";
        }
Пример #6
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));
        }
Пример #7
0
 public override void eventDLCInitiated(directReporterBase __spider, crawlerDomainTask __task, modelSpiderSiteRecord __wRecord)
 {
     if (imbWEMManager.settings.directReportEngine.doDomainReport)
     {
         string             dlc_config = imbWEMManager.index.experimentEntry.sessionCrawlerFolder["sites"].pathFor("dlc_config_" + __wRecord.domainInfo.domainRootName.getFilename(".txt"));
         builderForMarkdown builder    = new builderForMarkdown();
         spiderTools.Describe(__task.evaluator, builder);
         builder.ToString().saveStringToFile(dlc_config);
     }
 }
Пример #8
0
        public ITextRender Report(ITextRender output = null)
        {
            if (output == null)
            {
                output = new builderForMarkdown();
            }

            var scores = items.Select(x => x.score);

            output.AppendHeading("Granularity");

            var   distinct = items.GetDistinctScores();
            Int32 dC       = distinct.Count();

            output.AppendPair("Distinct", dC);
            output.AppendPair("Entries", scores.Count());
            Double r = (Double)dC.GetRatio(scores.Count());

            output.AppendPair("Distinct / Entries", r);

            output.AppendHeading("Cumulative histogram");


            for (int i = 1; i < 11; i++)
            {
                Double l_min = (i - 1).GetRatio(10);
                Double l_max = i.GetRatio(10);
                var    bin   = scores.Where(x => (x > l_min) && (x < l_max));
                Double per   = bin.Count().GetRatio(scores.Count());
                output.AppendPair("Bin [" + i + "][" + l_max.ToString("F2") + "]", per.ToString("P2"));
            }

            output.AppendHeading("Descriptive statistics");

            DescriptiveStatistics desc = scores.GetStatistics(true);

            desc.Describe(output);



            output.AppendHeading("Document selection result");

            foreach (DocumentSelectResultEntry result in items)
            {
                output.AppendLine(result.score.ToString("F5") + "\t\t" + result.AssignedID);
            }

            output.AppendHorizontalLine();

            query.Describe(output);

            output.AppendHorizontalLine();

            return(output);
        }
        /// <summary>
        /// Gets the user manual for table saved.
        /// </summary>
        /// <param name="dataObject">The data object.</param>
        /// <param name="path">The path.</param>
        /// <param name="directInfo">The direct information.</param>
        /// <param name="skipUnDescribed">if set to <c>true</c> [skip un described].</param>
        /// <param name="showValue">if set to <c>true</c> [show value].</param>
        public static void GetUserManualForTableSaved(this DataTable dataObject, String path, String directInfo = "", Boolean skipUnDescribed = true, Boolean showValue = true)
        {
            builderForMarkdown mdb = new builderForMarkdown();

            dataObject.GetUserManualForTable(mdb, directInfo, skipUnDescribed);

            FileInfo fi = path.getWritableFile();

            String output = mdb.ToString(false);

            output.saveStringToFile(fi.FullName);
        }
        /// <summary>
        /// Prepares all rules for new case
        /// </summary>
        public override void prepareAll()
        {
            base.prepareAll();

            pageScoreRules.prepare();
            linkActiveRules.prepare();
            linkPassiveRules.prepare();

            pageClassificationRules.prepare();
            pageContentScoreRules.prepare();

            builderForMarkdown bl = new builderForMarkdown();

            this.Describe(bl);
            FullDescription = bl.ToString();
        }
Пример #11
0
        /// <summary>
        /// Pravi stack trace izvestaj
        /// </summary>
        /// <param name="stackTrace"></param>
        /// <param name="sb"></param>
        /// <returns></returns>
        internal static String cleanStackTrace(this String stackTrace, ITextRender sb)
        {
            if (sb == null)
            {
                sb = new builderForMarkdown();
            }
            if (String.IsNullOrEmpty(stackTrace))
            {
                return("");
            }


            Match m = regex_ourStack.Match(stackTrace);

            if (m != null)
            {
                string cs = m.Value.toStringSafe().Trim("{}".ToCharArray());
                cs.imbRemoveDouble();

                List <string> parts = imbSciStringExtensions.SplitOnce(cs, " in ");

                if (parts.Count > 1)
                {
                    sb.AppendPair("Location: ", parts.imbFirstSafe());


                    String filePart = parts.toCsvInLine();

                    parts = imbSciStringExtensions.SplitOnce(filePart, ":line ");

                    sb.AppendPair("File: ", parts.imbFirstSafe());

                    //sb.Append("File :", htmlTagName.span, htmlClassForReport.itemName);

                    sb.AppendLink(parts.imbFirstSafe(), parts.imbFirstSafe(), "Source file", appendLinkType.link);

                    sb.AppendPair("Line: ", parts.imbLastSafe()); //, htmlTagName.span, htmlClassForReport.itemName.ToString(), htmlClassForReport.filePath.ToString(), true, htmlTagName.p);


                    sb.close();
                }
            }

            return(sb.ToString());
        }
Пример #12
0
        /// <summary>
        /// Gets the description lines for data defined in this instance
        /// </summary>
        /// <param name="builder">The builder.</param>
        /// <returns></returns>
        public String GetDescription(ITextRender builder = null)
        {
            if (builder == null)
            {
                builder = new builderForMarkdown();
            }

            var l        = builder.Length;
            var notation = this;

            if (!notation.author.isNullOrEmpty())
            {
                builder.AppendPair("Author", notation.author, true, ": ");
            }
            if (!notation.Email.isNullOrEmpty())
            {
                builder.AppendPair("E-mail", notation.Email, true, ": ");
            }
            if (!notation.web.isNullOrEmpty())
            {
                builder.AppendPair("Web", notation.web, true, ": ");
            }
            if (!notation.copyright.isNullOrEmpty())
            {
                builder.AppendPair("Copyright", notation.copyright, true, ": ");
            }
            if (!notation.license.isNullOrEmpty())
            {
                builder.AppendPair("License", notation.license, true, ": ");
            }
            if (!notation.software.isNullOrEmpty())
            {
                builder.AppendPair("Software", notation.software, true, ": ");
            }
            if (!notation.organization.isNullOrEmpty())
            {
                builder.AppendPair("Organization", notation.organization, true, ": ");
            }
            if (!notation.comment.isNullOrEmpty())
            {
                builder.AppendPair("Comment", notation.comment, true, ": ");
            }

            return(builder.GetContent(l));
        }
Пример #13
0
        /// <summary>
        /// Gets the caller information report.
        /// </summary>
        /// <param name="output">The output.</param>
        /// <returns></returns>
        public static String getCallerInfoReport(this callerInfo output)
        {
            builderForMarkdown sb = new builderForMarkdown();

            sb.Append("Caller info report:", appendType.heading_3, true);

            sb.nextTabLevel();
            // sb.AppendLine("Caller method: " + labelFormat);

            sb.AppendPair("Call in code: ", output.sufix);


            sb.AppendPair("Method name: ", output.className);

            sb.AppendPair("Source file: ", output.Filepath);

            sb.Append("Source call line: ", appendType.bold, true);

            sb.Append(output.sourceCodeLine, appendType.source, true);

            sb.Append("Source call line segment: ", appendType.regular, true);
            sb.Append(output.sourceCodeInvokePart, appendType.source, true);

            sb.Append("Caller method local variables:", appendType.heading_4);
            sb.nextTabLevel();

            output.localVariables.ForEach(
                x => sb.Append(
                    String.Format("{0}:{1} {2}", x.LocalIndex, x.LocalType.Name, x.toStringSafe()), appendType.quotation)
                );
            sb.prevTabLevel();

            sb.AppendPair("Caller source line properties:", output.sourceCodeParameterCalls.toCsvInLine());

            sb.prevTabLevel();

            sb.prevTabLevel();

            return(sb.ToString());
        }
Пример #14
0
        /// <summary>
        /// Primary method for exception description
        /// </summary>
        /// <param name="ex"></param>
        /// <param name="sb"></param>
        public static String describe(this Exception ex, ITextRender sb = null, String title = "")
        {
            if (sb == null)
            {
                sb = new builderForMarkdown();
            }

            if (String.IsNullOrEmpty(title))
            {
                title = "Exception " + ex.GetType().Name;
            }
            //sb.nextTabLevel();
            try
            {
                sb.AppendHeading(title + " : " + ex.GetType().Name);
                sb.AppendPair("Message: ", ex.Message, true);
                sb.AppendPair("Target site: ", ex.TargetSite.ToString(), true);
                sb.AppendPair("Source: ", ex.Source, true);


                ex.StackTrace.cleanStackTrace(sb);

                //  sb.AppendLine("", -1);

                var exi = ex.getLastInner();
                if (ex != exi)
                {
                    exi.describe(sb, "Last inner exception");
                }
            }
            catch (Exception ex2)
            {
                sb.AppendLine("EX2: " + ex2.Message);
                //throw ex2;
            }

            //r sb.prevTabLevel();
            return(sb.ToString());
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="templateBlocksForHtml"/> class.
 /// </summary>
 public templateBlocksForHtml()
 {
     outputRender = new builderForMarkdown();
 }
Пример #16
0
        /// <summary>
        /// Generates the folder readme.
        /// </summary>
        /// <param name="notation">The notation.</param>
        /// <param name="builder">The builder.</param>
        /// <param name="directoryStructureDepthLimit">The directory structure depth limit - i.e. until what subdirectory depth is described in the readme file.</param>
        /// <returns></returns>
        internal string generateFolderReadme(aceAuthorNotation notation, ITextRender builder = null, Int32 directoryStructureDepthLimit = 3)
        {
            if (builder == null)
            {
                builder = new builderForMarkdown();
            }
            String prefix = "";

            String mypath = path;

            if (parent != null)
            {
                mypath = mypath.removeStartsWith(parent.path);
                prefix = path;
            }

            builder.AppendHeading("Directory information", 2);

            builder.AppendHeading(caption, 3);
            builder.AppendLine(" > " + mypath);
            builder.AppendLine(" > " + description);

            builder.AppendHorizontalLine();

            foreach (String st in AdditionalDescriptionLines)
            {
                builder.AppendLine(st);
            }

            if (AdditionalDescriptionLines.Any())
            {
                builder.AppendHorizontalLine();
            }

            if (AdditionalFileEntries.Any())
            {
                builder.AppendHeading("Files in this directory:", 2);
                String format = "D" + AdditionalFileEntries.Count().ToString().Length.ToString();
                Int32  flc    = 1;

                List <String> sortedKeys = AdditionalFileEntries.Keys.ToList();
                sortedKeys.Sort(String.CompareOrdinal);

                foreach (String key in sortedKeys)
                {
                    builder.AppendLine(flc.ToString(format) + " : " + AdditionalFileEntries[key].description);
                    flc++;
                }
            }

            //builder.AppendHeading("Folder treeview", 2);

            //builder.Append(this.tree)

            builder.AppendHorizontalLine();

            builder.AppendHeading("Subdirectories of: " + prefix, 2);

            var folderNodes = this.getAllChildrenInType <folderNode>(null, false, true, 0, directoryStructureDepthLimit);

            foreach (var fold in folderNodes)
            {
                Int32 levelDistance = fold.level - level;

                String insert = " -- ".Repeat(levelDistance);

                if (levelDistance > directoryStructureDepthLimit)
                {
                    if (fold.count() > 0)
                    {
                        builder.AppendCite(insert + "> directory " + fold.caption + " with [" + fold.count() + "] sub directories ...");
                    }
                }
                else
                {
                    builder.AppendLine(String.Format("{0,-60} : {1,-100}", insert + "> " + fold.caption, fold.path.removeStartsWith(prefix)));
                    if (!fold.description.isNullOrEmpty())
                    {
                        builder.AppendLine(insert + "| " + fold.description);
                    }
                }
                //builder.AppendLine();
                //  builder.prevTabLevel();
            }

            //  AdditionalFileEntries.Sort(String.CompareOrdinal);

            if (notation != null)
            {
                builder.AppendHorizontalLine();
                notation.GetDescription(builder);
            }

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

            builder.AppendLine(imbSciStringExtensions.add(imbSciStringExtensions.add("File generated: ", DateTime.Now.ToLongDateString(), " "), DateTime.Now.ToLongTimeString()));

            return(builder.ContentToString(true));
        }
        //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);
        }
        /// <summary>
        /// Podesava vrednosti celog objekta - bez nasledjenih
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <param name="instanceName">Name of the instance.</param>
        /// <param name="parentName">Name of the parent.</param>
        /// <param name="loger">The loger.</param>
        public static void editSettings(Object settings, String instanceName = "", String parentName = "", ILogBuilder loger = null)
        {
            Type settingsType = settings.GetType();

            PropertyInfo[] props = settingsType.GetProperties();

            List <PropertyInfo> propList = new List <PropertyInfo>();

            foreach (PropertyInfo pro in props)
            {
                if (pro.CanWrite)
                {
                    if (pro.PropertyType.IsEnum)
                    {
                        propList.Add(pro);
                    }
                    else if (pro.PropertyType.IsPrimitive)
                    {
                        propList.Add(pro);
                    }
                    else if (pro.PropertyType == typeof(String))
                    {
                        propList.Add(pro);
                    }
                    else
                    {
                        if (pro.DeclaringType == settingsType)
                        {
                            if (pro.Name != "Item")
                            {
                                propList.Add(pro);
                            }
                            else
                            {
                            }
                        }
                    }
                }
            }

            props = propList.ToArray();

            String titleLine = "";

            if (String.IsNullOrEmpty(instanceName))
            {
                titleLine = "Variables [" + props.Length + "] in an instance of [" + settingsType.Name + "].";
            }
            else
            {
                if (String.IsNullOrEmpty(parentName))
                {
                    titleLine = "Variables [" + props.Length + "] in [" + parentName + "->" + instanceName + "] of [" + settingsType.Name + "].";
                }
                else
                {
                    titleLine = "Variables [" + props.Length + "] in [" + instanceName + "] of [" + settingsType.Name + "].";
                }
            }
            Console.WriteLine(titleLine);

            Console.WriteLine();

            builderForMarkdown input_builderForMarkdown = (builderForMarkdown)loger;

            if (input_builderForMarkdown != null)
            {
                input_builderForMarkdown.rootTabLevel();

                input_builderForMarkdown.AppendHeading(titleLine, 1);

                input_builderForMarkdown.AppendTableRow(acePaletteVariationRole.header, "Caption", "Property", "Value", "New value", "Description");
            }

            foreach (PropertyInfo prop in props)
            {
                List <String>        msgOut = new List <string>();
                DescriptionAttribute descAttribute;
                DisplayNameAttribute displayNameAttribute;

                String description = "";
                String displayName = "";

                Object[] propAttributes = prop.GetCustomAttributes(false);

                foreach (Object propAtt in propAttributes)
                {
                    descAttribute = propAtt as DescriptionAttribute;
                    if (descAttribute != null)
                    {
                        description = descAttribute.Description;
                    }

                    displayNameAttribute = propAtt as DisplayNameAttribute;
                    if (displayNameAttribute != null)
                    {
                        displayName = displayNameAttribute.DisplayName;
                    }
                }

                Object propValue = null;

                propValue = prop.GetValue(settings, null);
                Object propNewValue = new Object();

                Console.WriteLine();

                Console.WriteLine("" + displayName + " (" + prop.Name + ") = " + propValue.ToString());
                Console.WriteLine("--  " + description);

                String oldValue = propValue.ToString();

                propNewValue = null;

                if (prop.PropertyType.IsEnum)
                {
                    propNewValue = askForOption("Select value from list below", propValue);
                }
                else
                {
                    switch (prop.PropertyType.Name.ToLower())
                    {
                    case "string":
                        propNewValue = askForStringInline("Insert new value", propValue as String);
                        break;

                    case "decimal":
                        String  tmpString = askForStringInline("Insert new value", propValue.ToString());
                        Decimal decimalResult;
                        if (Decimal.TryParse(tmpString, out decimalResult))
                        {
                            propNewValue = decimalResult;
                        }
                        else
                        {
                            Console.WriteLine("Invalid input - default value set: " + propValue.ToString());
                            propNewValue = propValue;
                        }
                        break;

                    case "int32":
                        String tmpStringInt = askForStringInline("Insert new value", propValue.ToString());
                        Int32  intResult;
                        if (Int32.TryParse(tmpStringInt, out intResult))
                        {
                            propNewValue = intResult;
                        }
                        else
                        {
                            Console.WriteLine("Invalid input - default value set: " + propValue.ToString());
                            propNewValue = propValue;
                        }
                        break;

                    case "bool":
                    case "boolean":
                        propNewValue = askYesNo("Select new value", (Boolean)propValue);
                        break;
                    }
                }
                if (propNewValue != null)
                {
                    prop.SetValue(settings, propNewValue, new object[0]);
                    Console.WriteLine("Value set: " + propNewValue.ToString());
                }
                else
                {
                    Console.WriteLine("Skipping parameter: " + prop.Name + ":" + prop.PropertyType.Name);
                }

                input_builderForMarkdown.AppendTableRow(acePaletteVariationRole.none, displayName, prop.Name, oldValue, propNewValue.ToString(), description);

                Console.WriteLine();
            }
        }
Пример #19
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);
        }