public static DataTableForStatistics GetReportTableVersion(this DataTable source, bool disablePrimaryKey = true) { DataTableForStatistics output = source.GetClonedShema <DataTableForStatistics>(disablePrimaryKey); //output.AddRowNameColumn("Row name", true); // output.AddRowDescriptionColumn("Description", true); //// output.AddRowDescriptionColumn("Row info", true); // // <--- ovde ubaciti da atributi klase odredjuju stra prikazuje // output.AddExtraRow(templateFieldDataTable.col_group, 200); // output.AddExtraRow(PropertyEntryColumn.entry_unit, 200); // output.AddExtraRow(templateFieldDataTable.col_letter, 200); // output.AddExtraRow(templateFieldDataTable.col_desc, 200); // output.SetDefaults(); output.CopyRowsFrom(source); output.ApplyObjectTableTemplate(); return(output); }
/// <summary> /// Creates report table version for the <c>source</c> and saves the report on specified <c>folder</c> /// </summary> /// <param name="source">The source.</param> /// <param name="folder">The folder.</param> /// <param name="notation">The notation.</param> /// <param name="filenamePrefix">The filename prefix.</param> /// <param name="disablePrimaryKey">if set to <c>true</c> [disable primary key].</param> /// <param name="allowAsyncCall">if set to <c>true</c> [allow asynchronous call].</param> /// <returns></returns> /// <exception cref="ArgumentNullException">Folder is null! at GetReportAndSave() for [" + source.TableName + "] at filename [" + filenamePrefix + "]</exception> public static DataTableForStatistics GetReportAndSave(this DataTable source, folderNode folder, aceAuthorNotation notation = null, string filenamePrefix = "", bool disablePrimaryKey = true, Boolean allowAsyncCall = false) { if (notation == null) { notation = new aceAuthorNotation(); } if (allowAsyncCall) { if (imbSCI.Core.config.imbSCICoreConfig.settings.DataTableReports_AsyncExportCalls) { DataTableForStatisticsExportJob job = new DataTableForStatisticsExportJob(source, folder, notation, filenamePrefix, disablePrimaryKey); Thread t = new Thread(job.Do); t.Start(); return(null); // Task.Factory } } // if (source == null) return new DataTableForStatistics(); if (folder == null) { throw new ArgumentNullException("Folder is null! at GetReportAndSave() for [" + source.TableName + "] at filename [" + filenamePrefix + "]"); } if (source.Columns.Count > 0) { folderNode dataFolder = null; if (DataTableForStatistics.AUTOSAVE_CleanDataTable || DataTableForStatistics.AUTOSAVE_FieldsText || imbSCI.Core.config.imbSCICoreConfig.settings.DataTableReports_DoExportXMLData) { dataFolder = folder.Add(EXTRAFOLDER, "Excel report meta data", "Folder containing clean data export (single header row, CSV format) for easier use by other software platforms and/or column meta descriptions - additional information - in separate txt file for each Excel report created."); } if (imbSCI.Core.config.imbSCICoreConfig.settings.DataTableReports_DoExportXMLData) { try { String xmlCode = objectSerialization.ObjectToXML(source); xmlCode.saveStringToFile(dataFolder.pathFor(source.TableName.getFilename(".xml"), getWritableFileMode.overwrite, "XML Serialized DataTable [" + source.GetTitle() + "]", true)); } catch (Exception ex) { source.SetAdditionalInfoEntry("XML data", "Serialization failed: " + ex.Message); } } if (DataTableForStatistics.AUTOSAVE_CleanDataTable) { string cld = source.serializeDataTable(dataTableExportEnum.csv, PREFIX_CLEANDATATABLE + filenamePrefix.getFilename() + ".csv", dataFolder, notation); source.SetAdditionalInfoEntry("Clean data", cld); } if (DataTableForStatistics.AUTOSAVE_FieldsText) { string cli = dataFolder.pathFor(PREFIX_COLUMNINFO + filenamePrefix.getFilename() + ".txt"); source.GetUserManualForTableSaved(cli); source.SetAdditionalInfoEntry("Column info", cli); } if (tableReportCreation_insertFilePathToTableExtra) { } } DataTableForStatistics output = null; if (source is DataTableForStatistics) { output = source as DataTableForStatistics; } else { output = source.GetReportTableVersion(disablePrimaryKey); // output.SetDefaults(); //source.serializeDataTable(enums.dataTableExportEnum.excel, filenamePrefix + "_source", folder, notation); } output.Save(folder, notation, filenamePrefix); return(output); }