Esempio n. 1
0
        /// <summary>
        /// Compiles the links in the template.
        /// </summary>
        /// <param name="template">The template.</param>
        /// <param name="context">The context.</param>
        /// <param name="format">The format.</param>
        /// <param name="levels">The levels.</param>
        /// <returns></returns>
        /// <exception cref="aceReportException">null</exception>
        public static string CompileLinksInTemplate(this string template, deliveryInstance context, reportOutputFormatName format, List <reportElementLevel> levels)
        {
            var mc = linkInTemplate.Matches(template);

            try
            {
                foreach (Match m in mc)
                {
                    string elementPath  = m.Groups[1].Value;
                    string elementMatch = m.Groups[0].Value;

                    metaDocumentRootSet root = context.scope.root as metaDocumentRootSet;

                    IMetaContentNested target = root.regPathGet(elementPath); //// as IMetaContentNested; //.resolve(imbSCI.Cores.reporting.style.enums.metaModelTargetEnum.scopeRelativePath, elementPath, null).First();

                    //IMetaContentNested target = context.scope.resolve(imbSCI.Cores.reporting.style.enums.metaModelTargetEnum.scopeRelativePath, elementPath, null).First();

                    string path = target.CompileLinkForElemenet(context, format, levels);
                    template = template.Replace(elementMatch, path);
                }
            }
            catch (Exception ex)
            {
                string msg = "CompileLinksInTemplate failed for [" + context.scope.path + "] : " + ex.Message;
                throw new aceReportException(context, msg, aceReportExceptionType.compileScriptError, null);
            }
            return(template);
        }
        protected void executePrepare(metaDocumentRootSet report, string runstamp, PropertyCollection __data = null)
        {
            //  aceLog.consoleControl.setAsOutput(this, "Delivery");

            folderPrepare(runstamp);

            report.context = this;
            theme          = unit.theme;

            AppendLine();
            AppendLine();

            logStartPhase("Delivery init", "initialization of Delivery instance");

            if (__data == null)
            {
                __data = new PropertyCollection();
            }
            __data = AppendDataFields(__data);
            __data = unit.AppendDataFields(__data);
            if (__data != null)
            {
                data.AppendData(__data, existingDataMode.overwriteExisting);
            }

            scope          = report;
            report.context = this;

            logStartPhase("Prepare phase", "#1 phase of deliveryInstance");

            data.add(templateFieldBasic.root_relpath, "");
            data.add(templateFieldBasic.report_folder, report.name);

            var vls = Enum.GetValues(typeof(templateFieldSubcontent));

            foreach (object vl in vls)
            {
                data.Add(vl, "");
            }

            // unit.blockBuilder.BuildDynamicNavigationTemplates(this, data);
            //            unit.blockBuilder.BuildNavigationTemplates(this, data);

            unit.executePrepare();

            foreach (IDeliveryUnitItem item in unit.items)
            {
                item.prepareOperation(this);
            }

            unit.updateTemplates(this);

            foreach (IDeliveryUnitItem item in unit.outputContent)
            {
                item.prepareOperation(this);
            }

            unit.describe(this);
        }
Esempio n. 3
0
 /// <summary>
 /// Defines deliveryInstance unit and calls construction
 /// </summary>
 /// <param name="aReport">a report.</param>
 /// <returns></returns>
 public abstract deliveryInstance executeRenderReport(metaDocumentRootSet aReport, analyticJobRecord aRecord);
        /// <summary>
        /// Executes the and save.
        /// </summary>
        /// <param name="report">The report.</param>
        /// <param name="runstamp">The runstamp.</param>
        /// <param name="__data">The data.</param>
        protected void execute(metaDocumentRootSet report, string runstamp, PropertyCollection __data = null)
        {
            dataDictionary = new PropertyCollectionDictionary();

            if (!unit.scriptFlags.HasFlag(docScriptFlags.disableGlobalCollection))
            {
                logStartPhase("Collect data", "#2 phase of data collecting");
                dataDictionary = report.collect(dataDictionary);
                logEndPhase();
            }
            else
            {
                log("Global data collection disabled by unit.scriptFlags");
            }

            logStartPhase("Script composing", "#3 phase of data composing");

            script       = new docScript("Script - unit[" + unit.name + "] - runstamp: " + runstamp);
            script.flags = unit.scriptFlags;

            script = report.compose(script);
            if (doBuildDeliveryMeta)
            {
                string scMeta = script.ToString(docScriptInstructionTextFormatEnum.meta);
                scMeta.saveStringToFile(directoryRoot.FullName.add("deliveryMeta.md", "\\"), getWritableFileMode.autoRenameExistingOnOtherDate, Encoding.UTF8);

                string csMeta = script.ToString(docScriptInstructionTextFormatEnum.cs_compose);
                csMeta.saveStringToFile(directoryRoot.FullName.add("deliveryMeta.cs", "\\"), getWritableFileMode.autoRenameExistingOnOtherDate, Encoding.UTF8);
            }

            logEndPhase();

            setup(unit.theme, data, renders.getTextRenders());

            logStartPhase("Script compilation", "#4 applying data to content");

            compiled = compile(script, dataDictionary);

            repo = new reportOutputRepository(directoryRoot, script.name);

            logStartPhase("Execute docScriptInstructions ", "5# executing scripttotal instructions (" + script.Count() + ")");

            index = 0;
            int tIndex = 1000;

            int mediumTimerLimit = 10;
            int mediumTimerIndex = 0;

            foreach (docScriptInstructionCompiled instruction in compiled)
            {
                try
                {
                    appendTypeKind kind = instruction.type.getAppendTypeKind();

                    if (doVerboseLog)
                    {
                        log(index.ToString("D4") + " " + instruction.ToString(docScriptInstructionTextFormatEnum.meta));
                    }

                    //afinal = appendType.none;

                    appendType final = executeOnce(instruction, kind);

                    if (final != appendType.none)
                    {
                        final = runStyleInstruction(instruction);
                    }

                    if (final == appendType.none)
                    {
                    }
                    else
                    {
                        var scopeLevel = scope.elementLevel;

                        foreach (var it in unit.outputByLevel[scopeLevel])
                        {
                            deliveryUnitItemSimpleRenderOutput output = it as deliveryUnitItemSimpleRenderOutput;

                            if (output != null)
                            {
                                output.executeScriptInstruction(this, instruction);
                                final = appendType.none;
                                //  builder = output.builder;
                            }
                        }
                    }

                    if (executionStopFlagCheck())
                    {
                        log("Execution is stopped by executionStopFlag!");
                        break;
                    }

                    index++;
                }
                catch (Exception ex)
                {
                    string msg = Environment.NewLine + "Report script execution [" + index + "/" + compiled.Count() + "] error. Instruction: [" + instruction.ToString(docScriptInstructionTextFormatEnum.cs_compose) + "]";
                    msg = msg.addLine("-- scoped meta object: path:[" + scope.path + "] -- [" + scope.name + "] -- [" + scope.GetType().Name + "]");
                    msg = msg.addLine("-- directory: [" + directoryScope.FullName + "]");
                    msg = msg.addLine("-- exception: [" + ex.GetType().Name + "] => [" + ex.Message + "]");

                    var axe = new aceReportException(msg + "Report instruction [" + instruction.type.ToString() + "] exception");
                    //if (axe.callInfo != null)
                    //{
                    //    msg = msg.addLine("-- source of ex: [" + axe.callInfo.sourceCodeLine + "]");
                    //    msg = msg.addLine("-- source file:  [" + axe.callInfo.Filepath + "]");
                    //    msg = msg.addLine("-- source line:  [" + axe.callInfo.line + "]");
                    //    msg = msg.addLine("-- source class:  [" + axe.callInfo.className + "]");
                    //}

                    log(msg + Environment.NewLine);
                    string path = "errorReport_" + index.ToString() + ".txt";
                    path = directoryScope.FullName.add(path, "\\");
                    msg.saveStringToFile(path, getWritableFileMode.autoRenameExistingOnOtherDate, Encoding.UTF8);

                    if (errorPolicy.doThrow())
                    {
                        throw axe;
                    }
                    executionError("Internal exception during an instruction execution", instruction, ex);
                }

                #region ----------------------------------

                if (compiled.Count() > 1000)
                {
                    if (tIndex > 0)
                    {
                        tIndex--;
                    }
                    else
                    {
                        mediumTimerIndex++;
                        double ratio = ((double)index) / ((double)compiled.Count());
                        aceLog.log("Report generation at [" + ratio.ToString("P") + "] done");
                        tIndex = 1000;
                    }
                }
                if (mediumTimerIndex > mediumTimerLimit)
                {
                    var memBefore = GC.GetTotalMemory(false);
                    GC.Collect();
                    var memBefore2 = memBefore - GC.GetTotalMemory(false);
                    aceLog.log("-- garbage collector invoked - memory released: " + memBefore2.getMByteCountFormated());
                    // aceLog.saveAllLogs(true);
                    mediumTimerIndex = 0;
                }

                #endregion ----------------------------------
            }

            GC.Collect();
            GC.WaitForFullGCComplete();

            logEndPhase();

            AppendPairs(data, false, " -> ");

            log("Completed");

            foreach (IDeliveryUnitItem item in unit.items)
            {
                item.reportFinishedOperation(this);
            }

            // aceLog.consoleControl.removeFromOutput(this);
        }
 /// <summary>
 /// Calls prepare and then <see cref="execute(metaDocumentRootSet, string, PropertyCollection)"/>
 /// </summary>
 /// <param name="report">The report.</param>
 /// <param name="runstamp">The runstamp.</param>
 /// <param name="__data">The data.</param>
 public void executeAndSave(metaDocumentRootSet report, string runstamp, PropertyCollection __data = null)
 {
     executePrepare(report, runstamp, __data);
     execute(report, runstamp, __data);
 }