public static ReportModel CreateModel (string reportName,bool createGrouping) { ReportStructure reportStructure = CreateReportStructure(reportName); AvailableFieldsCollection abstractColumns = new AvailableFieldsCollection(); AbstractColumn a1 = new AbstractColumn("Field1",typeof(System.String)); reportStructure.AvailableFieldsCollection.Add(a1); ICSharpCode.Reports.Core.BaseDataItem bri = new ICSharpCode.Reports.Core.BaseDataItem(); bri.Name ="Field1"; reportStructure.ReportItemCollection.Add(bri); if (createGrouping) { reportStructure.Grouping = "group"; } ReportModel m = reportStructure.CreateAndFillReportModel(); IReportGenerator generator = new GeneratePushDataReport(m,reportStructure); generator.GenerateReport(); ReportLoader rl = new ReportLoader(); object root = rl.Load(generator.XmlReport.DocumentElement); ReportModel model = root as ReportModel; if (model != null) { model.ReportSettings.FileName = GlobalValues.PlainFileName; FilePathConverter.AdjustReportName(model); } else { throw new InvalidReportModelException(); } return model; }
public static ReportModel CreateModel (string reportName) { ReportStructure structure = CreateReportStructure(reportName); AvailableFieldsCollection abstractColumns = new AvailableFieldsCollection(); AbstractColumn a1 = new AbstractColumn("Field1",typeof(System.String)); structure.AvailableFieldsCollection.Add(a1); ICSharpCode.Reports.Core.BaseDataItem bri = new ICSharpCode.Reports.Core.BaseDataItem(); bri.Name ="Field1"; structure.ReportItemCollection.Add(bri); ReportModel m = structure.CreateAndFillReportModel(); ICSharpCode.Core.Properties customizer = new ICSharpCode.Core.Properties(); customizer.Set("Generator", structure); customizer.Set("ReportLayout",GlobalEnums.ReportLayout.ListLayout); IReportGenerator generator = new GeneratePushDataReport(m,customizer); generator.GenerateReport(); ReportLoader rl = new ReportLoader(); object root = rl.Load(generator.XmlReport.DocumentElement); ReportModel model = root as ReportModel; if (model != null) { model.ReportSettings.FileName = GlobalValues.PlainFileName; FilePathConverter.AdjustReportName(model); } else { throw new InvalidReportModelException(); } return model; }
private AvailableFieldsCollection AvailableFieldsCollectionFromTable (DataTable table) { AvailableFieldsCollection av = new AvailableFieldsCollection(); AbstractColumn ac = null; foreach (DataColumn dc in resultDataSet.Tables[0].Columns) { Console.WriteLine("{0} - {1}",dc.ColumnName,dc.DataType); ac = new AbstractColumn(dc.ColumnName,dc.DataType); av.Add(ac); } return av; }
private IndexList BuildSortIndex(Collection <AbstractColumn> col) { IndexList arrayList = new IndexList(); for (int rowIndex = 0; rowIndex < this.table.Rows.Count; rowIndex++) { DataRow rowItem = this.table.Rows[rowIndex]; object[] values = new object[col.Count]; for (int criteriaIndex = 0; criteriaIndex < col.Count; criteriaIndex++) { AbstractColumn c = (AbstractColumn)col[criteriaIndex]; object value = rowItem[c.ColumnName]; if (value != null && value != DBNull.Value) { if (!(value is IComparable)) { throw new InvalidOperationException(value.ToString()); } values[criteriaIndex] = value; } else { values[criteriaIndex] = DBNull.Value; } } arrayList.Add(new SortComparer(col, rowIndex, values)); } if (arrayList[0].ObjectArray.GetLength(0) == 1) { List <BaseComparer> lbc = BaseListStrategy.GenericSorter(arrayList); arrayList.Clear(); arrayList.AddRange(lbc); } else { arrayList.Sort(); } return(arrayList); }
private void SetSortColumns (AbstractColumn column) { SortColumn sortColumn = column as SortColumn; if (sortColumn != null) { var sortColumnNode = new SortColumnNode (sortColumn.ColumnName,sortColumnMenuPath); if (sortColumn.SortDirection == ListSortDirection.Ascending) { sortColumnNode.ImageIndex = ascendingIcon; } else { sortColumnNode.ImageIndex = descendingIcon; } this.nodeSorting.Nodes.Add(sortColumnNode); } }
private void SetAvailableFields (AbstractColumn af) { ColumnNode node = new ColumnNode(af.ColumnName,columnIcon); node.Tag = this.nodeAvailableFields; node.SelectedImageIndex = columnIcon; this.nodeAvailableFields.Nodes.Add(node); }