imbSCI.DataComplex Namespaces |
Extended and typed DataTables, DataTable to Excel reporting, various graph structures, translation tables, trend estimation structures, path DOM, reporting extensions, TF-IDF corpus and document data structures, data structures for reporting and other stuff in context of imbSCI framework
1using imbSCI.Core.attributes; 2using imbSCI.Core.enums; 3using imbSCI.Core.extensions.text; 4using imbSCI.Core.style.color; 5using imbSCI.DataComplex.data; 6using imbSCI.DataComplex.tables; 7using System; 8using System.Collections.Generic; 9using System.ComponentModel; 10using System.Data; 11using System.Drawing; 12using System.Text; 13 14namespace imbSCI.DataComplex 15{ 16 /// <summary>Example, demonstrating data annotation with reporting, using generic, DataTable based, collection</summary> 17 /// <seealso cref="imbSCI.DataComplex.data.TestMicroEnvironmentBase" /> 18 public class DataComplexExamples : TestMicroEnvironmentBase 19 { 20 /// <summary> 21 /// This is a dummy data class, used for data annotation & reporting demonstration 22 /// </summary> 23 [imb(imbAttributeName.reporting_categoryOrder, "Group 1,Group 2")] 24 [imb(imbAttributeName.basicColor, "#999999")] 25 public class DataEntryTest 26 { 27 public static Random rnd { get; set; } = new Random(); 28 29 /// <summary> 30 /// Constructor, setting some random values 31 /// </summary> 32 public DataEntryTest() 33 { 34 myProperty = imbStringGenerators.getRandomString(15); 35 myPropertyRatio = rnd.NextDouble(); 36 37 isInState = rnd.NextDouble() > 0.5; 38 BigNumber = Convert.ToInt32(rnd.NextDouble() * 200000); 39 } 40 41 /// <summary> </summary> 42 [Category("Group 2")] 43 [DisplayName("Random string")] // 44 [Description("Text property with random string generation attached")] // [imb(imbAttributeName.reporting_escapeoff)] 45 [imb(imbAttributeName.measure_letter, "l")] 46 [imb(imbAttributeName.reporting_columnWidth, "50")] // width can be specified as integer or string, no difference 47 public String myProperty { get; set; } = default(String); 48 49 /// <summary> Example of boolean property </summary> 50 [Category("Group 1")] 51 [DisplayName("Is In State")] 52 [imb(imbAttributeName.viewPriority, 200)] 53 [imb(imbAttributeName.measure_letter, "T")] 54 [imb(imbAttributeName.basicColor, "#0066FF")] // you can use string hex (RGB or ARGB, both in 256 or 8 bit form) 55 [imb(imbAttributeName.reporting_columnWidth, 10)] // width can be specified as integer or string, no difference 56 [Description("Example of boolean property")] 57 public Boolean isInState { get; set; } = true; 58 59 /// <summary> Example of integer property </summary> 60 [Category("Group 1")] 61 [DisplayName("Big number")] 62 [imb(imbAttributeName.measure_letter, "C")] 63 [imb(imbAttributeName.measure_setUnit, "n")] 64 [imb(imbAttributeName.menuPriority, 100)] // <-- menuPriorty is meant for menu declarations, but works here too 65 [imb(imbAttributeName.basicColor, ColorWorks.ColorRed)] // This will not be applied, as "isInState" property already defined color for the group 66 [imb(imbAttributeName.reporting_valueformat, "#,###")] // format is specified according to String.Format format 67 [imb(imbAttributeName.measure_important, dataPointImportance.important)] // this will set "bold" for values in the report 68 [Description("Some important big number, having set importance flag and number format")] 69 public Int32 BigNumber { get; set; } = 150000; 70 71 /// <summary> Example of integer property </summary> 72 [Category("Group 3")] 73 [DisplayName("Some number")] 74 [imb(imbAttributeName.basicColor, ColorWorks.ColorRed)] // <- therefore, you can use constants from imbSCI.Core.style.color.ColorWorks 75 [imb(imbAttributeName.reporting_valueformat, "#,###")] // format is specified according to String.Format format 76 [Description("Group 3 member")] 77 public Int32 SomeNumber { get; set; } = 15000; 78 79 /// <summary> Ratio </summary> 80 [Category("Group 3")] 81 [DisplayName("myPropertyRatio")] 82 [imb(imbAttributeName.measure_letter, "R")] 83 [imb(imbAttributeName.measure_setUnit, "%")] 84 [imb(imbAttributeName.viewPriority, 200)] 85 [imb(imbAttributeName.reporting_valueformat, "P2")] // you can use Standard Numeric Formats 86 [imb(imbAttributeName.basicColor, "#FFFFFF")] // <- this color will prevail the one defined at SomeNumber, because myPropertyRatio has higher priority in the group 87 [Description("Ratio")] // [imb(imbAttributeName.measure_important)][imb(imbAttributeName.reporting_valueformat, "")][imb(imbAttributeName.reporting_escapeoff)] 88 public Double myPropertyRatio { get; set; } = default(Double); 89 } 90 91 /// <summary> 92 /// Creates generic DataTable collection, adds 5 rows and generates Excel and CSV file 93 /// </summary> 94 public void ExampleOne_DataTableDataAnnotation() 95 { 96 // creating typed DataTable collection, holding DataEntryTest class 97 DataTableTypeExtended<DataEntryTest> dataTableTypeExtended = new DataTableTypeExtended<DataEntryTest>(nameof(DataEntryTest), nameof(ExampleOne_DataTableDataAnnotation)); 98 99 // adding five rows 100 dataTableTypeExtended.AddRow(new DataEntryTest()); 101 dataTableTypeExtended.AddRow(new DataEntryTest()); 102 dataTableTypeExtended.AddRow(new DataEntryTest()); 103 dataTableTypeExtended.AddRow(new DataEntryTest()); 104 dataTableTypeExtended.AddRow(new DataEntryTest()); 105 106 // Generating and exporting report into Excel file 107 DataTableForStatistics report = dataTableTypeExtended.GetReportAndSave(folderResults); 108 } 109 } 110}