/// <summary> /// Saves the data. /// </summary> /// <param name="instance">The instance.</param> /// <param name="descriptiveCopy">The descriptive copy.</param> public void saveData(DataTable instance, dataTableExportEnum descriptiveCopy = dataTableExportEnum.csv) { String filename = folder[aceCCFolders.metadata].pathFor(getFilename(instance.TableName, "table")); instance.saveObjectToXML(filename); if (descriptiveCopy != dataTableExportEnum.none) { instance.serializeDataTable(descriptiveCopy, instance.TableName, folder[aceCCFolders.metadata], console.application.appAboutInfo); } }
public void saveData(DataSet instance, dataTableExportEnum descriptiveCopy = dataTableExportEnum.csv) { String filename = folder[aceCCFolders.metadata].pathFor(instance.FilenameForDataset()); instance.saveObjectToXML(filename.ensureEndsWith(".xml")); if (descriptiveCopy != dataTableExportEnum.none) { instance.serializeDataSet(instance.FilenameForDataset(), folder[aceCCFolders.metadata], descriptiveCopy, console.application.appAboutInfo); } }
/// <summary> /// Gets the format by filename extension. /// </summary> /// <param name="filepath">The filepath.</param> /// <returns></returns> public static dataTableExportEnum getExportFormatByExtension(this string filepath) { string filename = Path.GetFileName(filepath); dataTableExportEnum format = dataTableExportEnum.csv; if (filename.EndsWith("json", StringComparison.Ordinal)) { format = dataTableExportEnum.json; } if (filename.EndsWith("csv", StringComparison.Ordinal)) { format = dataTableExportEnum.csv; } if (filename.EndsWith("excell", StringComparison.Ordinal)) { format = dataTableExportEnum.excel; } if (filename.EndsWith("excel", StringComparison.Ordinal)) { format = dataTableExportEnum.excel; } if (filename.EndsWith("xls", StringComparison.Ordinal)) { format = dataTableExportEnum.excel; } if (filename.EndsWith("xlsx", StringComparison.Ordinal)) { format = dataTableExportEnum.excel; } if (filename.EndsWith("md", StringComparison.Ordinal)) { format = dataTableExportEnum.markdown; } if (filename.EndsWith("xml", StringComparison.Ordinal)) { format = dataTableExportEnum.xml; } return(format); }
public static dataTableExportEnum checkFormatByFilename(this dataTableExportEnum format, string filename) { if ((format == dataTableExportEnum.none) || (46 == (int)format)) { if (filename.EndsWith("json", StringComparison.Ordinal)) { format = dataTableExportEnum.json; } if (filename.EndsWith("csv", StringComparison.Ordinal)) { format = dataTableExportEnum.csv; } if (filename.EndsWith("excell", StringComparison.Ordinal)) { format = dataTableExportEnum.excel; } if (filename.EndsWith("excel", StringComparison.Ordinal)) { format = dataTableExportEnum.excel; } if (filename.EndsWith("xls", StringComparison.Ordinal)) { format = dataTableExportEnum.excel; } if (filename.EndsWith("xlsx", StringComparison.Ordinal)) { format = dataTableExportEnum.excel; } if (filename.EndsWith("md", StringComparison.Ordinal)) { format = dataTableExportEnum.markdown; } if (filename.EndsWith("xml", StringComparison.Ordinal)) { format = dataTableExportEnum.xml; } } return(format); }
/// <summary> /// Serializes the data table into choosed format and returns file path /// </summary> /// <param name="source">The source.</param> /// <param name="format">The format.</param> /// <param name="filename">The filename, without extension.</param> /// <param name="directory">The directory to save into.</param> /// <returns></returns> public static string serializeDataTable(this DataTable source, dataTableExportEnum format, string filename, folderNode directory, params object[] resources) { dataTableIOFlags IOFlags = resources.GetIOFlags(); if (source == null) { return(""); } if (source.Columns.Count == 0) { throw new dataException("Source table [0 columns]: ", null, source, "Export to excell : table is not applicable"); } if (source.Rows.Count == 0) { return(""); } format = checkFormatByFilename(format, filename); string output = filename; FileInfo fileInfo = null; aceAuthorNotation authorNotation = resources.getFirstOfType <aceAuthorNotation>(false, false, true); if (authorNotation == null) { authorNotation = new aceAuthorNotation(); } if (directory == null) { directory = new DirectoryInfo(Directory.GetCurrentDirectory()); } string cleanfilename = source.FilenameForTable(filename); filename = directory.pathFor(cleanfilename, getWritableFileMode.overwrite, "Exported DataTable [" + source.GetTitle() + "][" + source.GetDescription() + "]. "); switch (format) { case dataTableExportEnum.csv: output = source.toCSV(true); output = output.saveStringToFile(imbSciStringExtensions.ensureEndsWith(filename, ".csv")).FullName; break; case dataTableExportEnum.excel: //fileInfo = new FileInfo(filename.ensureEndsWith(".xlsx")); filename = imbSciStringExtensions.ensureEndsWith(filename, ".xlsx"); fileInfo = filename.getWritableFile(getWritableFileMode.overwrite); //if (File.Exists(fileInfo.FullName)) File.Delete(fileInfo.FullName); try { using (ExcelPackage pck = new ExcelPackage(fileInfo)) { DataTableForStatistics dt_stat = null; if (source is DataTableForStatistics) { dt_stat = source as DataTableForStatistics; } else { dt_stat = source.GetReportTableVersion(true); } ExcelWorksheet ws = pck.Workbook.Worksheets.Add(source.GetTitle()); dt_stat.RenderToWorksheet(ws); /* * pck.Workbook.Properties.Title = source.GetTitle(); * pck.Workbook.Properties.Comments = authorNotation.comment; * pck.Workbook.Properties.Category = "DataTable export"; * pck.Workbook.Properties.Author = authorNotation.author; * pck.Workbook.Properties.Company = authorNotation.organization; * pck.Workbook.Properties.Application = authorNotation.software; * //pck.Workbook.Properties.Keywords = meta.keywords.content.toCsvInLine(); * pck.Workbook.Properties.Created = DateTime.Now; * pck.Workbook.Properties.Subject = source.GetDescription(); * * ws.Cells["A1"].LoadFromDataTable(source, true); * ExcelRow row = ws.Row(1); //.Height = 100; * row.Height = 100; * row.Style.WrapText = true; * * row.Style.Fill.PatternType = ExcelFillStyle.Solid; * row.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.WhiteSmoke); * * Int32 rc = ws.Dimension.Rows - 1; * * for (int i = 0; i < rc; i++) * { * var ex_row = ws.Row(i+1); * var in_row = source.Rows[i]; * if (dt_stat != null) * { * if (dt_stat.extraRows.Contains(in_row)) * { * if (dt_stat.extraRows.IndexOf(in_row)%2 > 0) * { * ex_row.Style.Fill.PatternType = ExcelFillStyle.Solid; * ex_row.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.LightGray); * } else * { * ex_row.Style.Fill.PatternType = ExcelFillStyle.Solid; * ex_row.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.WhiteSmoke); * } * } * } * * ex_row.Style.WrapText = true; * // row.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.WhiteSmoke); * } */ pck.Save(); } } catch (Exception ex) { throw new dataException("Excell: " + ex.Message, ex, source, "Export to excell"); } output = fileInfo.FullName; break; case dataTableExportEnum.json: output = objectSerialization.SerializeJson(source); // JsonConvert.SerializeObject(source, Newtonsoft.Json.Formatting.Indented); fileInfo = output.saveStringToFile(imbSciStringExtensions.ensureEndsWith(filename, ".json")); //.FullName; output = fileInfo.FullName; break; case dataTableExportEnum.markdown: output = source.markdownTable(); fileInfo = output.saveStringToFile(imbSciStringExtensions.ensureEndsWith(filename, ".md")); output = fileInfo.FullName; break; case dataTableExportEnum.xml: filename = imbSciStringExtensions.ensureEndsWith(filename, ".xml"); source.WriteXml(filename, false); output = openBase.openFileToString(filename, true, false); break; default: break; } return(output); }
public static string serializeDataSet(this DataSet source, string filename, folderNode directory, dataTableExportEnum format, params object[] resources) { dataTableIOFlags IOFlags = resources.GetIOFlags(); string output = filename; FileInfo fileInfo = null; format = checkFormatByFilename(format, filename); aceAuthorNotation authorNotation = resources.getFirstOfType <aceAuthorNotation>(false, false, true); if (authorNotation == null) { authorNotation = new aceAuthorNotation(); } if (directory == null) { directory = new DirectoryInfo(Directory.GetCurrentDirectory()); } string cleanfilename = source.FilenameForDataset(filename); filename = directory.pathFor(cleanfilename, getWritableFileMode.overwrite, "Exported DataSet [" + source.DataSetName + "] with [" + source.Tables.Count + "] tables. " + source.GetDesc()); DirectoryInfo dix = null; switch (format) { case dataTableExportEnum.csv: dix = directory.Add(cleanfilename, source.DataSetName, "Folder with CSV exports of DataSet [" + source.DataSetName + "] with [" + source.Tables.Count + "] tables. " + source.GetDesc()); foreach (DataTable table in source.Tables) { table.serializeDataTable(format, table.FilenameForTable(), dix); } output = dix.FullName; break; case dataTableExportEnum.excel: //fileInfo = new FileInfo(filename.ensureEndsWith(".xlsx")); filename = imbSciStringExtensions.ensureEndsWith(filename, ".xlsx"); fileInfo = filename.getWritableFile(getWritableFileMode.overwrite); //if (File.Exists(fileInfo.FullName)) File.Delete(fileInfo.FullName); try { using (ExcelPackage pck = new ExcelPackage(fileInfo)) { pck.Workbook.Properties.Title = source.GetTitle(); pck.Workbook.Properties.Comments = authorNotation.comment; pck.Workbook.Properties.Category = "DataTable export"; pck.Workbook.Properties.Author = authorNotation.author; pck.Workbook.Properties.Company = authorNotation.organization; pck.Workbook.Properties.Application = authorNotation.software; //pck.Workbook.Properties.Keywords = meta.keywords.content.toCsvInLine(); pck.Workbook.Properties.Created = DateTime.Now; pck.Workbook.Properties.Subject = source.GetDesc(); int c = 0; foreach (DataTable table in source.Tables) { string title = table.GetTitle(); if (title.Length > 20) { title = title.toWidthMaximum(15, ""); } title = title + c.ToString("D3"); c++; while (pck.Workbook.Worksheets.Any(x => x.Name == title)) { title = title + c.ToString("D3"); c++; } if (title == dataTableRenderingSetup.TABLE_DEFAULTNAME) { title = "Table" + source.Tables.Count.ToString("D3"); } ExcelWorksheet ws = pck.Workbook.Worksheets.Add(title); DataTableForStatistics dt_stat = table as DataTableForStatistics; if (table is DataTableForStatistics) { dt_stat = table as DataTableForStatistics; } else { dt_stat = table.GetReportTableVersion(true); } table.SetTitle(title); table.TableName = title; //DataTableForStatistics dt_stat = table as DataTableForStatistics; dt_stat.RenderToWorksheet(ws); /* * * ws.Cells["A1"].LoadFromDataTable(table, true); * * ExcelRow row = ws.Row(1); //.Height = 100; * row.Height = 100; * row.Style.WrapText = true; * * row.Style.Fill.PatternType = ExcelFillStyle.Solid; * row.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.WhiteSmoke); * * Int32 rc = ws.Dimension.Rows - 1; * * for (int i = 0; i < rc; i++) * { * var ex_row = ws.Row(i + 1); * var in_row = table.Rows[i]; * if (dt_stat != null) * { * if (dt_stat.extraRows.Contains(in_row)) * { * if (dt_stat.extraRows.IndexOf(in_row) % 2 > 0) * { * ex_row.Style.Fill.PatternType = ExcelFillStyle.Solid; * ex_row.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.LightGray); * } * else * { * ex_row.Style.Fill.PatternType = ExcelFillStyle.Solid; * ex_row.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.WhiteSmoke); * } * } * } * * ex_row.Style.WrapText = true; * // row.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.WhiteSmoke); * } */ } pck.Save(); } } catch (Exception ex) { throw new dataException("Excell: " + ex.Message, ex, source, "Export to excell"); } output = fileInfo.FullName; break; case dataTableExportEnum.json: dix = directory.Add(cleanfilename, source.DataSetName, "Folder with JSON exports of DataSet [" + source.DataSetName + "] with [" + source.Tables.Count + "] tables. " + source.GetDesc()); output = objectSerialization.SerializeJson <DataSet>(source); fileInfo = output.saveStringToFile(imbSciStringExtensions.ensureEndsWith(filename, ".json")); //.FullName; output = fileInfo.FullName; break; case dataTableExportEnum.markdown: dix = directory.Add(cleanfilename, source.DataSetName, "Folder with Markdown exports of DataSet [" + source.DataSetName + "] with [" + source.Tables.Count + "] tables. " + source.GetDesc()); foreach (DataTable table in source.Tables) { table.serializeDataTable(format, table.FilenameForTable(), dix); } output = dix.FullName; break; case dataTableExportEnum.xml: dix = directory.Add(cleanfilename, source.DataSetName, "Folder with XML exports of DataSet [" + source.DataSetName + "] with [" + source.Tables.Count + "] tables. " + source.GetDesc()); foreach (DataTable table in source.Tables) { table.serializeDataTable(format, table.FilenameForTable(), dix); } output = dix.FullName; break; default: break; } return(output); }
/// <summary> /// Deserializes the data table. /// </summary> /// <param name="filename">The filename or filepath.</param> /// <param name="format">The format to read from</param> /// <param name="directory">The directory (if filename was supplied and not full filepath)</param> /// <param name="table">The table.</param> /// <param name="resources">Supports: IObjectWithNameAndDescription</param> /// <returns></returns> /// <exception cref="dataException"> /// File path not accessable: " + filepath - null - null - deserializeDataTable /// or /// Deserialization error - imbDataTableExtensions->deserialize /// </exception> /// <exception cref="NotImplementedException"></exception> public static DataTable deserializeDataTable(this string filename, dataTableExportEnum format, folderNode directory = null, DataTable table = null, params object[] resources) { dataTableIOFlags iOFlags = resources.GetIOFlags(); string output = ""; string filepath = ""; FileInfo fileInfo = null; if (Path.IsPathRooted(filename)) { filepath = filename; } else { if (directory == null) { directory = new DirectoryInfo(Directory.GetCurrentDirectory()); } filepath = directory.pathFor(filename, getWritableFileMode.existing, table.GetDescription()); } if (!File.Exists(filepath)) { throw new dataException("File path not accessable: " + filepath, null, null, "deserializeDataTable"); } fileInfo = new FileInfo(filepath); if (table == null) { table = new DataTable(); } IObjectWithNameAndDescription ownerWithName = resources.getFirstOfType <IObjectWithNameAndDescription>(false, null, true); if (ownerWithName == null) { table.TableName = Path.GetFileNameWithoutExtension(filepath); } else { table.TableName = ownerWithName.name; table.ExtendedProperties.Add(templateFieldDataTable.data_tabledesc, ownerWithName.description); } switch (format) { case dataTableExportEnum.csv: // <---------------- postoji vec u ekstenzijama CSV resenje StreamReader sr = new StreamReader(fileInfo.FullName); throw new NotImplementedException(); //var csvr = new CsvReader(sr); // csvr.ReadHeader(); // csvr.Configuration.WillThrowOnMissingField = false; // foreach (string column in csvr.FieldHeaders) // { // var DataColumn = table.Columns.Add(column.Replace("__", "_")); // } //while (csvr.Read()) //{ // var row = table.NewRow(); // foreach (DataColumn column in table.Columns) // { // string vl = csvr.GetField(column.DataType, column.ColumnName).toStringSafe(); // vl = vl.Replace(".", ""); // vl = vl.Replace(",", "."); // row[column.ColumnName] = vl; // } // table.Rows.Add(row); //} /* * IEnumerable<DataRow> rows = csvr.GetRecords<DataRow>(); * foreach (DataRow dr in rows) * { * DataRow tdr = table.NewRow(); * foreach (DataColumn dc in table.Columns) * { * tdr[dc] = dr[dc.ColumnName]; * } * table.Rows.Add(tdr); * }*/ break; case dataTableExportEnum.excel: try { using (ExcelPackage pck = new ExcelPackage(fileInfo)) { var dts = pck.ToDataSet(iOFlags.HasFlag(dataTableIOFlags.firstRowColumnNames)); table = dts.Tables.imbFirstSafe() as DataTable; } } catch (Exception ex) { throw new dataException("Deserialization error", ex, table, "imbDataTableExtensions->deserialize"); } /* * * // <--- OVO POSTOJI DOLE U KOMANDI toDataSet * using (ExcelPackage pck = new ExcelPackage(fileInfo)) * { * ExcelWorksheet ws = pck.Workbook.Worksheets[0]; * //ws.GetValue(0,) * Int32 c = 1; * Int32 r = 1; * Boolean headersOk = false; * List<String> headers = new List<string>(); * String head = ws.GetValue(r, c).toStringSafe(); * * for (int i = 1; i < ws.Dimension.Columns; i++) * { * DataColumn dc = new DataColumn(c.toOrdinalLetter(false)); * head = ws.GetValue(r, c).toStringSafe(); * if (head.isWord()) * { * headers.Add(head); * } * * dc.ExtendedProperties.Add(templateFieldDataTable.col_id, i); * dc.ExtendedProperties.Add(templateFieldDataTable.col_name, i.toOrdinalLetter()); * table.Columns.Add(dc); * c++; * } * * if (headers.Count() >= ws.Dimension.Columns) headersOk = true; * * if (headersOk) * { * c = 0; * foreach (DataColumn dc in table.Columns) * { * dc.Caption = headers[c]; * c++; * } * r++; * } * * for (int i = r; i < ws.Dimension.Rows; i++) * { * DataRow dr = table.NewRow(); * foreach (DataColumn dc in table.Columns) * { * dr[dc] = ws.GetValue(i, dc.Ordinal); * } * table.Rows.Add(dr); * r++; * } * } */ output = fileInfo.FullName; break; case dataTableExportEnum.json: string json = openBase.openFileToString(filepath, true); table = objectSerialization.DeserializeJson <DataTable>(json); break; case dataTableExportEnum.markdown: throw new NotImplementedException(); break; case dataTableExportEnum.xml: string xml = openBase.openFileToString(filepath, true); table.ReadXml(xml); break; default: break; } table.NormalizeColumnNames(); return(table); }
/// <summary> /// Compiles complex appends. Returns <c>appendType</c> if it is no match for this <c>runner</c>. /// </summary> /// <param name="ins">The ins.</param> /// <remarks>OK for multimpleruns</remarks> /// <returns><c>appendType.none</c> if executed, other <c>appendType</c> if no match for this run method</returns> protected appendType runComplexInstruction(IRenderExecutionContext context, docScriptInstruction ins) { ITextRender render = outputRender; //builder.documentBuilder; switch (ins.type) { //// ****************************** External executable case appendType.exe: IExeAppend exe = (IExeAppend)ins[d.dsa_value]; exe.execute(context, render); break; /////////////////////// --------------------------------- case appendType.button: string btn_caption = (string)ins[d.dsa_title]; //.getProperString(d.dsa_title); string btn_url = (string)ins[d.dsa_url]; //.getProperString(d.dsa_url); bootstrap_color btn_color = (bootstrap_color)ins[d.dsa_styleTarget]; // ins.getProperEnum<bootstrap_color>(bootstrap_color.info, d.dsa_styleTarget); bootstrap_size btn_size = (bootstrap_size)ins[d.dsa_stylerSettings]; // ins.getProperEnum<bootstrap_size>(bootstrap_size.md, d.dsa_stylerSettings); render.AppendDirect(render.converter.GetButton(btn_caption, btn_url, btn_color.ToString(), btn_size.ToString())); break; case appendType.attachment: string att_caption = (string)ins[d.dsa_title]; //.getProperString(d.dsa_title); string att_url = (string)ins[d.dsa_url]; //.getProperString(d.dsa_url); string filename = ins[d.dsa_title].toStringSafe().getFilename(); att_url = att_url.or(filename); bootstrap_color att_color = (bootstrap_color)ins[d.dsa_styleTarget]; //.getProperEnum<bootstrap_color>(bootstrap_color.primary, d.dsa_styleTarget); bootstrap_size att_size = (bootstrap_size)ins[d.dsa_stylerSettings]; // ins.getProperEnum<bootstrap_size>(bootstrap_size.sm, d.dsa_stylerSettings); string output = ""; if (ins.containsKey(d.dsa_content)) { DataTable dt = ins[d.dsa_content] as DataTable; //.getProperObject<DataTable>(d.dsa_content); if (dt != null) { dataTableExportEnum format = (dataTableExportEnum)ins[d.dsa_format]; //>(dataTableExportEnum.excel, d.dsa_format); if (imbSciStringExtensions.isNullOrEmpty(att_url)) { att_url = dt.TableName.getFilename().getCleanPropertyName().Replace(" ", "").ToLower(); } att_url = dt.serializeDataTable(format, att_url, context.directoryScope); } else { output = ins[d.dsa_content] as string; } } if (ins.containsAllOfTypes(typeof(FileInfo))) { FileInfo fi = ins.getProperObject <FileInfo>(); att_url = fi.Name; fi.CopyTo(att_url); } att_url = att_url.removeStartsWith(context.directoryScope.FullName).Trim('\\').removeStartsWith("/"); string bootstrapButton = render.converter.GetButton(att_caption, att_url, att_color.toString(), att_size.toString()); render.AppendDirect(bootstrapButton); break; case appendType.i_chart: List <object> parameters = (List <object>)ins[d.dsa_value]; //.getProperObject<List<Object>>(d.dsa_value); string chstr = charts.chartTools.buildChart((chartTypeEnum)parameters[0], (chartFeatures)parameters[1], (DataTable)parameters[2], (chartSizeEnum)parameters[3], ins.getProperEnum <chartTypeEnum>(chartTypeEnum.none, d.dsa_format)); render.AppendDirect(chstr); break; case appendType.direct: render.AppendDirect((string)ins[d.dsa_contentLine]); break; case appendType.toFile: string toFile_outputpath = ins.getProperString(d.dsa_path); toFile_outputpath = context.directoryScope.FullName.add(toFile_outputpath, "\\"); render.AppendToFile(toFile_outputpath, ins.getProperString(d.dsa_contentLine)); break; case appendType.fromFile: string fromFile_sourcepath = ins[d.dsa_path].toStringSafe(); bool fromFile_isLocalSource = (bool)ins[d.dsa_on]; templateFieldSubcontent fromFile_key = (templateFieldSubcontent)ins[d.dsa_key]; if (fromFile_isLocalSource) { fromFile_sourcepath = context.directoryScope.FullName.add(fromFile_sourcepath, "\\"); } if (File.Exists(fromFile_sourcepath)) { render.AppendFromFile(fromFile_sourcepath, fromFile_key, fromFile_isLocalSource); } else { render.AppendLabel("File " + fromFile_sourcepath + " not found", true, bootstrap_style.style_warning); } break; case appendType.file: string file_sourcepath = ins.getProperString(d.dsa_path); string file_outputpath = ins.getProperString(d.dsa_name); bool file_isDataTemplate = (bool)ins.getProperField(d.dsa_on); bool file_isLocalSource = (bool)ins.getProperField(d.dsa_relative); file_outputpath = context.directoryScope.FullName.add(file_outputpath, "\\"); if (file_isLocalSource) { fromFile_sourcepath = context.directoryScope.FullName.add(file_sourcepath, "\\"); } string templateNeedle = ins.getProperString("none", d.dsa_styleTarget); if (templateNeedle != "none") { deliveryUnit dUnit = (deliveryUnit)context.dUnit; deliveryUnitItemContentTemplated templateItem = dUnit.findDeliveryUnitItemWithTemplate(templateNeedle); string __filecontent = openBase.openFileToString(file_sourcepath, true, false); templateItem.saveOutput(context, __filecontent, context.data, file_outputpath, file_isDataTemplate); } else { render.AppendFile(file_sourcepath, file_outputpath, file_isDataTemplate); } break; case appendType.image: diagramModel model = ins.getProperObject <diagramModel>(d.dsa_value); diagramOutputEngineEnum engine = ins.getProperEnum <diagramOutputEngineEnum>(diagramOutputEngineEnum.mermaid, d.dsa_format); if (model != null) { deliveryUnit dUnit = (deliveryUnit)context.dUnit; diagramOutputBase diaOutput = null; if (outputRender is builderForMarkdown) { diaOutput = engine.getOutputEngine(); } if (diaOutput == null) { diaOutput = new diagramMermaidOutput(); } string diaString = diaOutput.getOutput(model, dUnit.theme.palletes); render.AppendDirect(diaString); } else { render.AppendImage(ins.getProperString(d.dsa_path), ins.getProperString(d.dsa_contentLine), ins.getProperString(d.dsa_name)); } break; case appendType.math: render.AppendMath(ins.getProperString(d.dsa_contentLine), ins.getProperString(d.dsa_format)); break; case appendType.label: render.AppendLabel(ins.getProperString(d.dsa_contentLine), !ins.isHorizontal, ins.getProperString(d.dsa_styleTarget)); break; case appendType.panel: render.AppendPanel(ins.getProperString(d.dsa_contentLine), ins.getProperString(d.dsa_title), ins.getProperString(d.dsa_description), ins.getProperString(d.dsa_styleTarget)); break; case appendType.frame: render.AppendFrame(ins.getProperString(d.dsa_contentLine), ins.getProperInt32(-1, d.dsa_w), ins.getProperInt32(-1, d.dsa_h), ins.getProperString(d.dsa_title), ins.getProperString(d.dsa_description), (IEnumerable <string>)ins.getProperField(d.dsa_content)); break; case appendType.placeholder: render.AppendPlaceholder(ins.getProperField(d.dsa_name), ins.isHorizontal); break; case appendType.list: render.AppendList((IEnumerable <object>)ins.getProperField(d.dsa_content), (bool)ins.getProperField(d.dsa_on)); break; case appendType.footnote: throw new NotImplementedException("No implementation for: " + ins.type.ToString()); break; case appendType.c_line: render.AppendHorizontalLine(); break; case appendType.c_data: object dataSource = ins.getProperField(d.dsa_dataPairs, d.dsa_dataList, d.dsa_value); string _head = ins.getProperString("", d.dsa_title, d.dsa_name); string _foot = ins.getProperString("", d.dsa_footer, d.dsa_description); if (dataSource is PropertyCollection) { PropertyCollection pairs = dataSource as PropertyCollection; string sep = ins.getProperString(d.dsa_separator); if (imbSciStringExtensions.isNullOrEmpty(_foot)) { _foot = pairs.getAndRemoveProperString(d.dsa_footer, d.dsa_description); } if (imbSciStringExtensions.isNullOrEmpty(_head)) { _head = pairs.getAndRemoveProperString(d.dsa_title, d.dsa_description); } if (!imbSciStringExtensions.isNullOrEmpty(_foot)) { pairs.Add(d.dsa_footer.ToString(), _foot); } if (!imbSciStringExtensions.isNullOrEmpty(_head)) { pairs.Add(d.dsa_title.ToString(), _head); // list.Insert(0, _head); } render.AppendPairs(pairs, ins.isHorizontal, sep); // pair } else if (dataSource is IList <object> ) { IList <object> list = dataSource as IList <object>; if (!imbSciStringExtensions.isNullOrEmpty(_foot)) { list.Add(_foot); } if (!imbSciStringExtensions.isNullOrEmpty(_head)) { list.Insert(0, _head); } render.AppendList(list, false); } break; case appendType.c_pair: render.AppendPair(ins.getProperString(d.dsa_key, d.dsa_name, d.dsa_title), ins.getProperField(d.dsa_value, d.dsa_contentLine, d.dsa_dataField, d.dsa_content), true, ins.getProperString(" ", d.dsa_separator) ); break; case appendType.c_table: try { DataTable dt2 = (DataTable)ins[d.dsa_dataTable]; // .getProperObject<DataTable>(d.dsa_dataTable); if (dt2.Rows.Count == 0) { } dt2.ExtendedProperties.add(templateFieldDataTable.data_tablename, ins[d.dsa_title], true); dt2.ExtendedProperties.add(templateFieldDataTable.data_tabledesc, ins[d.dsa_description], true); dt2 = dt2.CompileTable(context as deliveryInstance, reportOutputFormatName.htmlViaMD, levelsOfNewDirectory); // <------------- privremeni hack render.AppendTable(dt2, true); } catch (Exception ex) { } break; case appendType.c_link: render.AppendLink(ins.getProperString(d.dsa_url, d.dsa_value), ins.getProperString(d.dsa_name, d.dsa_contentLine, d.dsa_key), ins.getProperString(d.dsa_title, d.dsa_description, d.dsa_footer), ins.getProperEnum <appendLinkType>(appendLinkType.link)); break; case appendType.section: render.AppendSection( ins.getProperString(d.dsa_contentLine), ins.getProperString(d.dsa_title, d.dsa_name), ins.getProperString(d.dsa_description), ins.getProperField(d.dsa_content) as IEnumerable <string>); break; case appendType.c_section: render.AppendSection( ins.getProperString(d.dsa_contentLine), ins.getProperString(d.dsa_title, d.dsa_name), ins.getProperString(d.dsa_description), ins.getProperField(d.dsa_content) as IEnumerable <string>); break; case appendType.c_open: render.open(ins.getProperString("section", d.dsa_contentLine, d.dsa_name, d.dsa_key), ins.getProperString(d.dsa_title), ins.getProperString(d.dsa_description)); break; case appendType.c_close: render.close(ins.getProperString("none", d.dsa_contentLine, d.dsa_name, d.dsa_key)); break; case appendType.source: string sourcecode = ""; List <string> scode = ins.getProperObject <List <string> >(d.dsa_content); sourcecode = scode.toCsvInLine(Environment.NewLine); string sc_name = ins.getProperString("code", d.dsa_name); string sc_desc = ins.getProperString("", d.dsa_description, d.dsa_footer); string sc_title = ins.getProperString("", d.dsa_title); string sc_typename = ins.getProperString("html", d.dsa_class_attribute); render.open(sc_name, sc_title, sc_desc); render.AppendCode(sourcecode, sc_typename); render.close(); //render.close(ins.getProperString("none", d.dsa_contentLine, d.dsa_name, d.dsa_key)); break; default: //executionError(String.Format("Instruction ({0}) not supported by runComplexInstruction() method", ins.type.ToString()), ins); return(ins.type); break; } return(appendType.none); }