/// <summary> /// Compiles the link for elemenet /// </summary> /// <param name="element">The element.</param> /// <param name="context">The context.</param> /// <param name="format">The format.</param> /// <param name="levels">The levels.</param> /// <returns></returns> public static string CompileLinkForElemenet(this IMetaContentNested element, deliveryInstance context, reportOutputFormatName format, List <reportElementLevel> levels) { string path = ""; var elLevel = element.getElementLevel(); switch (elLevel) { case reportElementLevel.servicepage: case reportElementLevel.page: path = element.GetOutputPath(context, format, levels, false); break; case reportElementLevel.document: metaDocument doc = element as metaDocument; path = doc.index.GetOutputPath(context, format, levels, false); break; case reportElementLevel.documentSet: metaDocumentSet docs = element as metaDocumentSet; path = docs.index.GetOutputPath(context, format, levels, false); break; } path = path.getWebPathBackslashFormat().applyToContent(false, context.data); return(path); }
public PropertyCollection BuildDynamicNavigationTemplates(deliveryInstance context, PropertyCollection data = null) { if (data == null) { data = new PropertyCollection(); } string reldir = context.directoryScope.FullName.removeStartsWith(context.directoryRoot.FullName); string selPath = reldir; // context.scope.path; IMetaContentNested mc = context.scope as IMetaContentNested; if (mc != null) { selPath = mc.path; } reportLinkCollection directory = context.linkRegistry.getLinkOneCollection(selPath, data.getProperString(templateFieldBasic.path_folder, templateFieldBasic.document_path, templateFieldBasic.documentset_path)); string str_localdirectory = ""; if (directory != null) { str_localdirectory = directory.makeHtmlInsert(); } data.add(reportOutputDomainEnum.localdirectory, str_localdirectory); return(data); }
#pragma warning disable CS1574 // XML comment has cref attribute 'aceReportException' that could not be resolved /// <summary> /// Regs the path. /// </summary> /// <param name="metaItem">The meta item.</param> /// <param name="theParentRegMoment">if set to <c>true</c> [the parent reg moment].</param> /// <exception cref="aceReportException"> /// null - null - regPath issue /// or /// null - null - regPath issue /// </exception> public void regPath(IMetaContentNested metaItem, bool theParentRegMoment) #pragma warning restore CS1574 // XML comment has cref attribute 'aceReportException' that could not be resolved { reportElementLevel level = metaItem.elementLevel; if (regPathCache[level].ContainsKey(metaItem.path)) { if (regPathCache[level].ContainsValue(metaItem)) { if (regPathCache[level][metaItem.path] == metaItem) { } else { metaItem.name = metaItem.name + "sub"; regPath(metaItem, theParentRegMoment); // throw new aceReportException(metaItem.path + " is reserved by other element! " + metaItem.name, null, null, "regPath issue"); } } else { metaItem.name = metaItem.name + "in"; regPath(metaItem, theParentRegMoment); } } else { regPathCache[level][metaItem.path] = metaItem; } }
/// <summary> /// Run <c>compose(script)</c> on all subitems from primary collection /// </summary> /// <param name="parent">The parent.</param> /// <param name="script">The script.</param> /// <returns></returns> internal static docScript subCompose(this IMetaContentNested parent, docScript script) { parent.sortChildren(); bool skip = true; foreach (IMetaComposeAndConstruct cont in parent) { skip = false; if (script.flags.HasFlag(docScriptFlags.ignoreNavigation)) { if (cont is INavigation) { skip = true; } } if (!skip) { docScript subScript = new docScript(script.context); var subscript = cont.compose(subScript); script.insertSub(subscript); } else { } } return(script); }
public void scopeOutOperation(IRenderExecutionContext context, IMetaContentNested oldScope) { // String filename = oldScope.name.getFilename(); var level = oldScope.elementLevel; string filename = "";//context.data.getProperString("", templateFieldBasic.path_file); // IMetaContent mc = (IMetaContent)oldScope; if (!context.data.ContainsKey(templateFieldNavigation.mainmenu)) { context.data.add(templateFieldNavigation.mainmenu, "", true); } filename = oldScope.GetOutputPath((deliveryInstance)context, format, levelsOfNewDirectory, true); //context.directoryScope.FullName.add(filename, "\\"); FileInfo fi = null; if (level == levelOfNewFile) { fi = outputRender.saveDocument(filename, getWritableFileMode.overwrite, format); if (fi != null) { // context.regFileOutput(fi.FullName, oldScope.path, description); //context.regFileOutput(fi.FullName, getFolderPathForLinkRegistry(context), description); } } else if (level == levelOfNewPage) { fi = outputRender.savePage(filename, format); } // scopeOutDirectoryCheck(context, level); }
/// <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); }
/// <summary> /// Adding internal link /// </summary> /// <param name="__target"></param> /// <param name="__parent"></param> /// <returns></returns> public metaLink AddLink(IMetaContentNested __target, string __description = "", int __priority = 100) { metaLink link = new metaLink(); link.target = __target; link.parent = parent; link.priority = __priority; link.description = __description; if (__target is metaPage) { metaPage targetPage = __target as metaPage; link.title = targetPage.header.name; if (link.description.isNullOrEmptyString()) { link.description = targetPage.header.description; } //link.description = targetPage. } link.name = link.target.name.imbTitleCamelOperation(true); link.type = appendLinkType.link; links.Add(link); return(link); }
/// <summary> /// Discovers the common parent or sets the one provided in arguments /// </summary> /// <param name="__parent">The parent.</param> /// <returns></returns> /// <exception cref="aceReportException">Can't discover the parent when the collection is empty!! - null - discoverCommonParent exception</exception> public IMetaContentNested discoverCommonParent(IMetaContentNested __parent = null) { if (__parent != null) { parent = __parent; return(parent); } if (parent != null) { return(parent); } if (Count > 0) { foreach (IMetaContentNested child in this) { if (child.parent != null) { parent = child.parent; return(parent); } } } if ((Count == 0) && (parent == null)) { throw new aceReportException("Can't discover the parent when the collection is empty!! " + "discoverCommonParent exception"); } return(null); }
/// <summary> /// Rebuilds navigation items -- this should be run before rendering the content /// </summary> /// <param name="__parent"></param> public void rebuild(IMetaContentNested __parent) { parent = __parent; if (parent.document != null) { var link = AddLink(parent.document, "Document page", -25); } if (parent.root != null) { var link = AddLink(parent.document, "Report page", -50); } if (parent.isThisDocument) { int index = parent.indexOf(__parent); if (parent.Count() > index) { AddLink(parent[index + 1] as IMetaContentNested, "Next page", -10); } if (index > 0) { AddLink(parent[index - 1] as IMetaContentNested, "Prev page", -5); } } if (parent is metaPage) { var link = AddLink(parent, "Back to parent", -15); //link.name = "Parent page"; } }
public static string GetIndexPath(this IMetaContentNested scoped, deliveryInstance context, reportOutputFormatName format, List <reportElementLevel> levels, bool makeAppApsolut = true) { string filename = ""; // context.data.getProperString("", templateFieldBasic.path_file); filename = context.GetDirectoryPath(scoped, levels, makeAppApsolut).add("index", "\\").add(format.getDefaultExtension(), "."); // Console.WriteLine("index: [" + filename + "]"); return(filename); }
/// <summary> /// Checks if the script is the script is initiated - if not it will create new one with name of parent /// </summary> /// <param name="creator">The creator.</param> /// <param name="script">The script.</param> /// <returns>Existing or newly created script</returns> public static docScript checkScript(this IMetaContentNested creator, docScript script) { if (script == null) { script = new docScript(creator.name); } return(script); }
/// <summary> /// Runs <c>construct</c> on all subitems from primary collection /// </summary> /// <param name="parent">The parent.</param> /// <param name="resources"></param> public static void subConstruct(this IMetaContentNested parent, object[] resources) { List <object> reslist = resources.getFlatList <object>(); foreach (IMetaComposeAndConstruct cont in parent) { cont.construct(resources); } }
/// <summary> /// Registers the specified kind. /// </summary> /// <param name="kind">The kind.</param> /// <param name="needle">The needle.</param> /// <param name="content">The content.</param> public virtual void register(reportRegistryEnum kind, string needle, IMetaContentNested content) { string token = makeToken(kind, needle); if (!byToken.ContainsKey(token)) { byToken.Add(token, content); } }
/// <summary> /// Registers the particular. /// </summary> /// <param name="particularID">The particular identifier.</param> /// <param name="needle">The needle.</param> /// <param name="content">The content.</param> public virtual void registerParticular(string particularID, string needle, IMetaContentNested content) { string token = makeToken(reportRegistryEnum.particular, particularID + needle); if (!byToken.ContainsKey(token)) { byToken.Add(token, content); } }
public virtual int indexOf(IObjectWithChildSelector child) { IMetaContentNested __child = child as IMetaContentNested; if (__child == null) { return(-1); } return(items.IndexOf(__child)); }
/// <summary> /// Method to register new page in collection - you must get new instance from parent object /// </summary> /// <param name="newChild"></param> /// <returns></returns> public int Add(IMetaContentNested newChild, IMetaContentNested __parent = null) { if (newChild == null) { // aceLog.loger.AppendLine("AddChild([null]) at [" + GetType().Name + "]"); throw new aceReportException("AddChild got [null] object " + "metaCollection got null"); return(-1); } if (__parent == null) { } else { discoverCommonParent(__parent); } if ((__parent == null) && (parent == null)) { discoverCommonParent(__parent); // <- this will throw exception if it was impossible to find out the parent } if (__parent != null) { newChild.parent = __parent; } if (parent != null) { newChild.parent = parent; } newChild.parent = parent; string nameProposal = newChild.name; int ci = 0; while (this.Any(x => x.name == nameProposal)) { ci++; nameProposal = makeItemUniqueName(newChild.name); if (ci > 50) { break; } } newChild.name = nameProposal; // newChild.id = items.Count; // Add(newPage); items.Add((T)newChild); //newChild.priority = Count; return(items.Count); }
/// <summary> /// Gets the directory path. /// </summary> /// <param name="context">The context.</param> /// <param name="scoped">The scoped.</param> /// <param name="levels">What levels of element are able to create new folder</param> /// <param name="makeAppApsolut">if set TRUE it will make path including absolute path to application runtime </param> /// <returns></returns> public static string GetDirectoryPath(this IRenderExecutionContext context, IMetaContentNested scoped, List <reportElementLevel> levels, bool makeAppApsolut = true) { string parentPath = ""; //if (scoped.parent != null) //{ // IMetaContent con = (IMetaContent)scoped.parent; // parentPath = con.path; //} //else //{ // //} List <IMetaContentNested> parents = new List <IMetaContentNested>(); IMetaContentNested head = (IMetaContentNested)scoped; string pDir = ""; do { if (levels.Contains(head.elementLevel)) { pDir = head.name.add(pDir, "\\"); parents.Add(head); } else { } head = head.parent; } while (head != null); string name = parentPath; //scoped.name.getFilename(); name = parentPath.add(name, "\\"); string dir = ""; if (makeAppApsolut) { dir = context.directoryRoot.FullName.Replace(Directory.GetCurrentDirectory(), "").removeStartsWith("\\"); dir = dir.add(pDir, "\\"); } else { dir = "".t(templateFieldBasic.root_relpath); dir = dir + pDir; } //dir = dir.add(pDir, "\\"); string output = dir.getCleanFilepath(); //Console.WriteLine("dir: [" + dir + "]"); return(output); //as String; }
/// <summary> /// Evaluates the specified test content. /// </summary> /// <param name="testContent">Content of the test.</param> /// <param name="defaultOrLastResult">if set to <c>true</c> [default or last result].</param> /// <returns></returns> /// <remarks> /// <para>Results of multiple <see cref="metaContentCriteriaTrigger"/> instances within the collection are combined with associated <see cref="metaContentTriggerOperator"/> logic operators.</para> /// </remarks> public bool evaluate(IMetaContentNested testContent) { bool defaultOrLastResult = true; foreach (metaContentCriteriaTrigger trig in items) { defaultOrLastResult = trig.evaluate(testContent, defaultOrLastResult); } return(defaultOrLastResult); }
public virtual IModelRecord GetByReport(IMetaContentNested report) { if (byReport.ContainsKey(report)) { return(byReport[report]); } else { return(null); } }
/// <summary> /// When scopes the in operation - applies template into context.data [if is in datafield mode] /// </summary> /// <param name="context">The context.</param> /// <param name="newScope">The new scope.</param> public void scopeInOperation(IRenderExecutionContext context, IMetaContentNested newScope) { if (isDataFieldMode) { if (!template.isNullOrEmpty()) { string output = template.applyToContent(false, context.data); context.data.add(output_datafield, output); } } }
/// <summary> /// Registers for record. /// </summary> /// <param name="record">The record.</param> /// <param name="content">The content.</param> public virtual void registerForRecord(IModelRecord record, IMetaContentNested content) { // String token = makeToken(record); byRecord.Add(record, content); //if (!byToken.ContainsKey(token)) //{ // byToken.Add(token, content); //} else //{ // aceLog.log("Duplicate token in the registry: " + token); //} }
public void scopeInOperation(IRenderExecutionContext context, IMetaContentNested newScope) { context.directoryScope = Directory.CreateDirectory(context.GetDirectoryPath(newScope, levels)); setRelPath(context); if (context is deliveryInstance) { deliveryInstance contextDeliveryInstance = (deliveryInstance)context; contextDeliveryInstance.unit.blockBuilder.BuildDynamicNavigationTemplates(contextDeliveryInstance, context.data); } }
/// <summary> /// Gets the link collection /// </summary> /// <param name="scoped">The scoped.</param> /// <param name="context">The context.</param> /// <param name="format">The format.</param> /// <param name="levels">The levels.</param> /// <param name="makeAppApsolut">if set to <c>true</c> [make application apsolut].</param> /// <returns></returns> public static reportLinkCollectionSet GetLinkCollection(this IMetaContentNested scoped, deliveryInstance context, reportOutputFormatName format, List <reportElementLevel> levels, bool makeAppApsolut = true) { reportLinkCollectionSet menu = new reportLinkCollectionSet(); reportElementLevel level = scoped.getElementLevel(); IMetaContentNested linkFrom = scoped; switch (level) { case reportElementLevel.document: //metaDocument document = (metaDocument)linkFrom; //menu.Add(document.documentTitle, document.GetLinkCollection(context, format)); //break; case reportElementLevel.page: linkFrom = scoped.document; if (linkFrom != null) { metaDocument document2 = (metaDocument)linkFrom; menu.Add(document2.documentTitle, document2.GetLinkCollection(context, format, levels, makeAppApsolut)); } else { if (scoped.parent != null) { return(GetLinkCollection(scoped.parent, context, format, levels, makeAppApsolut)); } } break; case reportElementLevel.documentSet: metaDocumentSet documentSet = (metaDocumentSet)linkFrom; menu.AddInGroup(documentSet.documentSetTitle, documentSet.GetServicePageLinkCollection(context, format, levels, makeAppApsolut)); menu.AddInGroup(documentSet.documentSetTitle, documentSet.GetDocumentSetsLinkCollection(context, format, levels, makeAppApsolut)); menu.currentItem.GetMainGroup().name = "Report sections"; foreach (metaDocument docum in linkFrom) { menu.Add(docum.documentTitle, docum.GetLinkCollection(context, format, levels, makeAppApsolut)); } break; } return(menu); }
/// <summary> /// Scopes the out operation. /// </summary> /// <param name="context">The context.</param> /// <param name="oldScope">The old scope.</param> public void scopeOutOperation(IRenderExecutionContext context, IMetaContentNested oldScope) { setRelPath(context); var level = oldScope.elementLevel; if (sourceRender.levelOfNewFile == level) { createNewFile(context, oldScope); } else if (sourceRender.levelOfNewPage == level) { } // sourceRender.scopeOutDirectoryCheck(context, level); }
public void rebuild(IMetaContentNested __parent) { parent = __parent; foreach (IMetaContentNested child in __parent) { AddLink(child, "", child.priority); } if (parent.parent is metaPage) { var link = AddLink(parent, "Back to parent", -50); //link.name = "Parent page"; } }
public IMetaContentNested regPathGet(string __elementPath) { string __path = ""; reportElementLevel level = __elementPath.GetReportElementPathAndLevel(out __path); if (regPathCache[level].ContainsKey(__path)) { IMetaContentNested result = regPathCache[level][__path] as IMetaContentNested; return(result); } if (logger != null) { logger.log("regPathGet with level[" + level.ToString() + "] failed on [" + __path + "]"); } return(this); }
/// <summary> /// X-scopeOut /// </summary> /// <param name="oldScope">The old scope.</param> /// <exception cref="NotImplementedException"> /// </exception> /// <exception cref="ArgumentOutOfRangeException"></exception> public override void x_scopeAutoSave(IMetaContentNested oldScope) { var level = oldScope.elementLevel; foreach (IDeliveryUnitItem item in unit.outputByLevel[level]) { item.scopeOutOperation(this, oldScope); // log("output[" + item.name + "] triggered by x_scopeAutoSave() @ level: " + level.ToString()); } foreach (IDeliveryUnitItem item in unit.itemByLevel[level]) { item.scopeOutOperation(this, oldScope); // log("item[" + item.name + "] triggered by x_scopeAutoSave() @ level: " + level.ToString()); } }
/// <summary> /// Composes the operation end. /// </summary> /// <param name="context">The context.</param> /// <param name="composer">The composer.</param> /// <param name="script">The script.</param> /// <returns></returns> public docScript composeOperationEnd(IRenderExecutionContext context, IMetaContentNested composer, docScript script) { var level = composer.elementLevel; foreach (IDeliveryUnitItem item in unit.outputByLevel[level]) { item.composeOperationEnd(context, composer, script); } foreach (IDeliveryUnitItem item in unit.itemByLevel[level]) { item.composeOperationEnd(context, composer, script); } return(script); }
/// <summary> /// Evaluates it self - returns raw result without applying <see cref="triggerOperator"/>. /// </summary> /// <param name="testContent">Content of the test.</param> /// <returns>Returns <c>true</c> on first criteria matched, otherwise returns <c>false</c></returns> public bool evaluateSelf(IMetaContentNested testContent) { bool output = false; if (testContent == null) { return(false); } if (type != null) { if (type.isCompatibileWith(testContent.GetType())) { return(true); } } if (level != reportElementLevel.none) { if (level == testContent.elementLevel) { return(true); } } if (element != null) { if (testContent == element) { return(true); } } if (!pathMatch.isNullOrEmptyString()) { IMetaContentNested match = testContent.getChildByPath(pathMatch) as IMetaContentNested; bool result = testContent.testScope(match, pathMatchRule); if (result) { return(true); } } return(output); }
/// <summary> /// Scope in /// </summary> /// <param name="newScope">The new scope.</param> public override void x_scopeAutoCreate(IMetaContentNested newScope) { IMetaContentNested metaScope = newScope as IMetaContentNested; scope = newScope; var level = scope.elementLevel; if (unit.scriptFlags.HasFlag(docScriptFlags.useDataDictionaryForLocalData)) { PropertyCollection pc = dataDictionary[scope.path]; data.AppendData(pc, existingDataMode.overwriteExisting); } if (unit.scriptFlags.HasFlag(docScriptFlags.enableLocalCollection)) { AppendDataFields(data); IAppendDataFields appScope = scope as IAppendDataFields; if (appScope != null) { appScope.AppendDataFields(data); } } foreach (IDeliveryUnitItem item in unit.outputByLevel[level]) { item.scopeInOperation(this, scope); if (reportingCoreManager.doVerboseLog) { aceLog.log("output[" + item.name + "] triggered by x_scopeAutoCreate() @ level: " + level.ToString()); } } foreach (IDeliveryUnitItem item in unit.itemByLevel[level]) { if (item is deliveryUnitDirectoryConstructor) { } item.scopeInOperation(this, scope); if (reportingCoreManager.doVerboseLog) { aceLog.log("item[" + item.name + "] triggered by x_scopeAutoCreate() @ level: " + level.ToString()); } } }