/// <summary>
        /// Collects data trough this meta node and its children
        /// </summary>
        /// <param name="data">PropertyCollectionDictionary to fill in</param>
        /// <returns>
        /// New or updated Dictionary
        /// </returns>
        public virtual PropertyCollectionDictionary collect(PropertyCollectionDictionary data = null)
        {
            if (data == null)
            {
                data = new PropertyCollectionDictionary();
            }

            AppendDataFields(data[path]);

            delivery.deliveryInstance del = context as delivery.deliveryInstance;
            del.collectOperationStart(context, this, data);

            foreach (metaDocumentSet pg in documentSets)
            {
                pg.collect(data);
            }

            foreach (metaDocument pg in documents)
            {
                pg.collect(data);
            }

            foreach (metaPage pg in pages)
            {
                pg.collect(data);
            }

            return(data);
        }
        /// <summary>
        /// Compiles the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="indata">The indata.</param>
        /// <returns></returns>
        public virtual docScriptCompiled compile(docScript source, PropertyCollectionDictionary indata = null)
        {
            docScriptCompiled output = new docScriptCompiled(source);

            script = source;
            logStartPhase("Compiling docScriptInstructions ", "total instructions (" + source.Count + ") -- total datasets (" + indata.Count() + ")");
            index = 0;
            foreach (docScriptInstruction instruction in source)
            {
                try
                {
                    if (doVerboseLog)
                    {
                        log(index.ToString("D4") + " " + instruction.type.ToString());
                    }

                    output.compile(instruction, this, indata, data, source.flags);

                    index++;
                }
                catch (Exception ex)
                {
                    if (errorPolicy.doThrow())
                    {
                        throw ex;
                    }
                    executionError("Internal exception during instruction compilation", instruction, ex);
                }
            }

            logEndPhase();

            return(output);
        }
Пример #3
0
        /// <summary>
        /// Collects internal data of this container.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <returns></returns>
        public virtual PropertyCollectionDictionary collect(PropertyCollectionDictionary data = null)
        {
            if (data == null)
            {
                data = new PropertyCollectionDictionary();
            }

            AppendDataFields(data[path]);

            delivery.deliveryInstance del = context as delivery.deliveryInstance;
            del.collectOperationStart(context, this, data);

            return(data);
        }
Пример #4
0
        /// <summary>
        /// Collects data trough this meta node and its children
        /// </summary>
        /// <param name="data">PropertyCollectionDictionary to fill in</param>
        /// <returns>
        /// New or updated Dictionary
        /// </returns>
        public virtual PropertyCollectionDictionary collect(PropertyCollectionDictionary data = null)
        {
            if (data == null)
            {
                data = new PropertyCollectionDictionary();
            }

            AppendDataFields(data[path]);

            //data.Add(path, pageData);

            delivery.deliveryInstance del = context as delivery.deliveryInstance;
            del.collectOperationStart(context, this, data);

            foreach (MetaContainerNestedBase pg in blocks)
            {
                pg.collect(data);
            }

            return(data);
        }
Пример #5
0
 public PropertyCollectionDictionary collectOperationStart(IRenderExecutionContext context, IMetaContentNested composer, PropertyCollectionDictionary dict)
 {
     return(dict);
     //  throw new NotImplementedException();
 }
        /// <summary>
        /// Collects data trough this meta node and its children
        /// </summary>
        /// <param name="data">PropertyCollectionDictionary to fill in</param>
        /// <returns>
        /// New or updated Dictionary
        /// </returns>
        public override PropertyCollectionDictionary collect(PropertyCollectionDictionary data = null)
        {
            data = base.collect(data);

            return(data);
        }
        /// <summary>
        /// Adds the specified ins.
        /// </summary>
        /// <param name="ins">The ins.</param>
        /// <returns></returns>
        public docScriptInstructionCompiled compile(docScriptInstruction ins, IRenderExecutionContext log, PropertyCollectionDictionary __indata, PropertyCollection __extraData, docScriptFlags flags)
        {
            docScriptInstructionCompiled instructionCompiled = new docScriptInstructionCompiled(ins, flags);

            try
            {
                PropertyCollectionDictionary indata    = __indata;
                PropertyCollection           extraData = __extraData;

                if (ins.type == appendType.x_scopeIn)
                {
                    currentDataPath = ins.getProperString(d.dsa_path);
                }
                else if (ins.type == appendType.x_scopeOut)
                {
                    currentDataPath = currentDataPath.getPathVersion(1, "\\", true);
                }

                PropertyCollection dataItem = null;
                if (indata != null)
                {
                    var tmp = indata[currentDataPath];
#pragma warning disable CS0184 // The given expression is never of the provided ('DictionaryEntry') type
                    if (tmp is DictionaryEntry)
#pragma warning restore CS0184 // The given expression is never of the provided ('DictionaryEntry') type
                    {
                        //DictionaryEntry entry = (DictionaryEntry)tmp;
                        //dataItem = entry.Value as PropertyCollection;
                    }
                    else
                    {
                        dataItem = tmp as PropertyCollection;
                    }
                }

                /// Compiling data into template
                instructionCompiled.compileTemplate(dataItem, extraData);

                if (instructionCompiled.isCompileFailed)
                {
                    string msg = scriptInstructions.Count().ToString("D4") + " " + ins.type.ToString() + " failed on: " + instructionCompiled.missingData.toCsvInLine();
                    if (flags.HasFlag(docScriptFlags.ignoreCompilationFails))
                    {
                        log.log(msg);
                    }
                    else
                    {
                        log.compileError(msg, instructionCompiled);
                    }

                    if (flags.HasFlag(docScriptFlags.allowFailedInstructions))
                    {
                        scriptInstructions.Add(instructionCompiled);
                    }
                    scriptInstructionsFailed.Add(instructionCompiled);
                }
                else
                {
                    scriptInstructions.Add(instructionCompiled);

                    if (instructionCompiled.isCompilable)
                    {
                        // log.log("--- compiled Strings(" + instructionCompiled.keyListForStrings.Count + ") and StringCollections(" + instructionCompiled.keyListForStringCollections.Count + ")");
                    }
                }

                missingData.AddRange(instructionCompiled.missingData);
            }
            catch (Exception ex)
            {
            }
            return(instructionCompiled);
        }
        /// <summary>
        /// inserts empty data field for each composer passed
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="composer">The composer.</param>
        /// <param name="dict">The dictionary.</param>
        /// <returns></returns>
        public PropertyCollectionDictionary collectOperationStart(IRenderExecutionContext context, IMetaContentNested composer, PropertyCollectionDictionary dict)
        {
            if (isDataFieldMode)
            {
                dict[composer.path].add(output_datafield, "");
            }
            else
            {
            }

            return(dict);
        }
Пример #9
0
        //public void prepareOperation(IRenderExecutionContext context)
        //{
        //    String _pt = sourcepath.toPath("", context.data);
        //    template = openBase.openFileToString(_pt, true, false);
        //}

        public PropertyCollectionDictionary collectOperationStart(IRenderExecutionContext context, IMetaContentNested composer, PropertyCollectionDictionary dict)
        {
            var level = composer.elementLevel;

            if (level == sourceRender.levelOfNewFile)
            {
                string filename = dict[composer.path].getProperString("", templateFieldBasic.path_output);

                string parentPath = composer.path;
                if (composer.parent != null)
                {
                    parentPath = composer.parent.path;
                }

                string folderPath = context.data.getProperString(parentPath, templateFieldBasic.path_folder, templateFieldBasic.document_path, templateFieldBasic.documentset_path);

                // filename = context.directoryScope.FullName.add(filename, "\\");
                filepath fp = new filepath(filename);
                //String templateFilename = fp.filename.add(fp.extension, "."); //.toPathWithExtension("", format.getDefaultExtension());
                string templateFilename = fp.toPathWithExtension("", format.getDefaultExtension());

                // context.regFileOutput(templateFilename, folderPath, description);
                // dict[composer.path].Add(templateFieldBasic.path_output, filename);
            }
            else
            {
                // dict[composer.path].Add(templateFieldBasic.path_file, "");
            }

            //throw new NotImplementedException();
            return(dict);
        }
        /// <summary>
        /// Collects the operation start.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="composer">The composer.</param>
        /// <param name="dict">The dictionary.</param>
        /// <returns></returns>
        public PropertyCollectionDictionary collectOperationStart(IRenderExecutionContext context, IMetaContentNested composer, PropertyCollectionDictionary dict)
        {
            var level = composer.elementLevel;

            foreach (IDeliveryUnitItem item in unit.outputByLevel[level])
            {
                item.collectOperationStart(context, composer, dict);
            }

            foreach (IDeliveryUnitItem item in unit.itemByLevel[level])
            {
                if (item is deliveryUnitItemContentTemplated)
                {
                }
                else
                {
                    item.collectOperationStart(context, composer, dict);
                }
            }

            foreach (IDeliveryUnitItem item in unit.itemByLevel[level])
            {
                if (item is deliveryUnitItemContentTemplated)
                {
                    item.collectOperationStart(context, composer, dict);
                }
            }

            return(dict);
        }
        /// <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);
        }
        public PropertyCollectionDictionary collectOperationStart(IRenderExecutionContext context, IMetaContentNested composer, PropertyCollectionDictionary dict)
        {
            string pt = composer.name;

            dict[composer.path].Add(templateFieldBasic.path_folder, pt);
            if (composer.parent != null)
            {
                PropertyCollection pc         = dict[composer.parent.path];
                string             parentPath = pc.getProperString(templateFieldBasic.path_folder);
                string             fullpath   = parentPath.add(pt, "\\");
                dict[composer.path].add(templateFieldBasic.path_folder, fullpath);
            }

            //throw new NotImplementedException();
            return(dict);
        }
        /// <summary>
        /// Collects the operation start.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="composer">The composer.</param>
        /// <param name="dict">The dictionary.</param>
        /// <returns></returns>
        public PropertyCollectionDictionary collectOperationStart(IRenderExecutionContext context, IMetaContentNested composer, PropertyCollectionDictionary dict)
        {
            var level = composer.elementLevel;

            if (level == levelOfNewFile)
            {
                string filename = composer.name.getFilename().add(format.getDefaultExtension(), ".");

                string folder = "";

                if (composer.parent != null)
                {
                    folder = dict[composer.parent.path].getProperString(templateFieldBasic.path_folder);
                }

                //  filename = context.directoryScope.FullName.add(filename, "\\");

                string filepath = folder.add(filename, "\\");

                dict[composer.path].add(templateFieldBasic.path_dir, context.directoryRoot.FullName.add(folder, "\\"));
                dict[composer.path].add(templateFieldBasic.path_file, filename);
                dict[composer.path].add(templateFieldBasic.path_folder, folder);
                dict[composer.path].add(templateFieldBasic.path_output, filepath);

                context.regFileOutput(filename, composer.path, description);
            }
            else
            {
                dict[composer.path].add(templateFieldBasic.path_file, "");
            }

            return(dict);
            // throw new NotImplementedException();
        }