/// <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); }