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 Graphics graphics; // public MeasurementService (Graphics graphics) // { // if ( graphics == null) { // throw new ArgumentNullException("graphics"); // } // this.graphics = graphics; // } public static Size MeasureReportItem(Graphics graphics, IReportItem item) { BaseTextItem textItem = item as BaseTextItem; if (textItem != null) { string str = String.Empty; BaseDataItem dataItem = item as BaseDataItem; if (dataItem != null) { str = dataItem.DBValue; } else { BaseTextItem it = item as BaseTextItem; if (it != null) { str = it.Text; } } SizeF sf = graphics.MeasureString(str.TrimEnd(), textItem.Font, textItem.Size.Width); return(sf.ToSize()); } return(item.Size); }
public override void Fill(IDataItem item) { if (current != null) { BaseDataItem baseDataItem = item as BaseDataItem; if (baseDataItem != null) { PropertyDescriptor p = this.listProperties.Find(baseDataItem.ColumnName, true); if (p != null) { baseDataItem.DBValue = p.GetValue(this.Current).ToString(); } else { baseDataItem.DBValue = string.Format(CultureInfo.InvariantCulture, "<{0}> missing!", baseDataItem.ColumnName); } return; } //image processing from IList BaseImageItem baseImageItem = item as BaseImageItem; if (baseImageItem != null) { PropertyDescriptor p = this.listProperties.Find(baseImageItem.ColumnName, true); if (p != null) { baseImageItem.Image = p.GetValue(this.Current) as System.Drawing.Image; } return; } } }
public void DataNavigator_Return_ErrMessage_If_ColumnName_NotExist () { IDataManager dm = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.contributorCollection as System.Collections.IList,new ReportSettings()); IDataNavigator dataNav = dm.GetNavigator; BaseDataItem item = new BaseDataItem(); item.ColumnName = "ColumnNotExist"; var items = new ReportItemCollection(); items.Add(item); dataNav.Fill(items); string str = "<" + item.ColumnName +">"; Assert.That(item.DBValue.Contains(str)); }
private void InsertGroupHeader() { ICSharpCode.Reports.Core.BaseDataItem dataItem = new ICSharpCode.Reports.Core.BaseDataItem(); dataItem.ColumnName = base.ReportModel.ReportSettings.GroupColumnsCollection[0].ColumnName; dataItem.DataType = base.ReportModel.ReportSettings.GroupColumnsCollection[0].DataTypeName; dataItem.Location = new Point (10,5); dataItem.Size = new Size (150,20); dataItem.Text = base.ReportModel.ReportSettings.GroupColumnsCollection[0].ColumnName; ICSharpCode.Reports.Core.BaseGroupedRow groupHeader = new ICSharpCode.Reports.Core.BaseGroupedRow(); groupHeader.Location = new Point(5,10); groupHeader.Size = new Size (300,30); groupHeader.Items.Add(dataItem); base.ReportModel.DetailSection.Items.Add(groupHeader); }
protected ICSharpCode.Reports.Core.GroupHeader CreateGroupHeader(Point headerLocation) { ICSharpCode.Reports.Core.BaseDataItem dataItem = new ICSharpCode.Reports.Core.BaseDataItem(); dataItem.ColumnName = ReportModel.ReportSettings.GroupColumnsCollection[0].ColumnName; dataItem.DataType = ReportModel.ReportSettings.GroupColumnsCollection[0].DataTypeName; dataItem.Location = new Point(GlobalValues.ControlMargins.Left, GlobalValues.ControlMargins.Top); dataItem.Size = new Size(150, 20); dataItem.Text = ReportModel.ReportSettings.GroupColumnsCollection[0].ColumnName; ICSharpCode.Reports.Core.GroupHeader groupHeader = new ICSharpCode.Reports.Core.GroupHeader(); groupHeader.Location = headerLocation; groupHeader.Size = new Size(300, dataItem.Size.Height + GlobalValues.ControlMargins.Top + GlobalValues.ControlMargins.Bottom); groupHeader.Items.Add(dataItem); return(groupHeader); }
internal static ReportItemCollection DataItemsFromDataSet(DataSet dataSet) { if (dataSet == null) { throw new ArgumentNullException("dataSet"); } if (dataSet.Tables.Count > 1) { string s = String.Format(System.Globalization.CultureInfo.InvariantCulture, "AutoBuildFromDataSet : at this time no more than one table is allowed <{0}>", dataSet.Tables.Count); ICSharpCode.Core.MessageService.ShowError(s); } ReportItemCollection itemCol = new ReportItemCollection(); foreach (DataTable tbl in dataSet.Tables) { foreach (DataColumn col in tbl.Columns) { if (col.DataType == typeof(System.Byte[])) { ICSharpCode.Reports.Core.BaseImageItem rItem = new ICSharpCode.Reports.Core.BaseImageItem(); rItem.ColumnName = col.ColumnName; rItem.BaseTableName = tbl.TableName; rItem.Name = col.ColumnName; rItem.ScaleImageToSize = false; itemCol.Add(rItem); } else { ICSharpCode.Reports.Core.BaseDataItem rItem = new ICSharpCode.Reports.Core.BaseDataItem(); rItem.ColumnName = col.ColumnName; rItem.DBValue = col.ColumnName; rItem.BaseTableName = tbl.TableName; rItem.DataType = col.DataType.ToString(); rItem.Name = col.ColumnName; rItem.Text = "=[" + col.ColumnName + "]"; itemCol.Add(rItem); } } } return(itemCol); }
public static ReportModel CreateModel(string reportName, bool createGrouping) { 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); if (createGrouping) { structure.Grouping = "group"; } 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); }
// only checked columns are use in the report private ReportItemCollection CreateItemsCollection(DataGridViewColumn[] displayCols) { ReportItemCollection items = new ReportItemCollection(); foreach (DataGridViewColumn cc in displayCols) { DataGridViewColumnHeaderCheckBoxCell hc = (DataGridViewColumnHeaderCheckBoxCell)cc.HeaderCell; if (hc.Checked) { AbstractColumn ac = this.abstractColumns.Find(cc.HeaderText); ICSharpCode.Reports.Core.BaseDataItem br = new ICSharpCode.Reports.Core.BaseDataItem(); br.Name = ac.ColumnName; br.ColumnName = ac.ColumnName; br.DataType = ac.DataTypeName; br.DBValue = ac.ColumnName; items.Add(br); } } return(items); }
protected static ColumnCollection CollectFieldsFromModel(ReportModel model) { if (model == null) { throw new ArgumentNullException("model"); } ColumnCollection col = new ColumnCollection(); foreach (BaseSection section in model.SectionCollection) { for (int i = 0; i < section.Items.Count; i++) { IReportItem item = section.Items[i]; BaseDataItem baseItem = item as BaseDataItem; if (baseItem != null) { col.Add(new AbstractColumn(baseItem.ColumnName)); } } } return(col); }
internal static ReportItemCollection ReportItemCollection (DataSet dataSet) { if (dataSet == null) { throw new ArgumentNullException("dataSet"); } if (dataSet.Tables.Count > 1) { string s = String.Format(System.Globalization.CultureInfo.InvariantCulture, "AutoBuildFromDataSet : at this time no more than one table is allowed <{0}>",dataSet.Tables.Count); ICSharpCode.Core.MessageService.ShowError(s); } ReportItemCollection itemCol = new ReportItemCollection(); foreach (DataTable tbl in dataSet.Tables) { foreach (DataColumn col in tbl.Columns) { if (col.DataType == typeof(System.Byte[])) { ICSharpCode.Reports.Core.BaseImageItem rItem = new ICSharpCode.Reports.Core.BaseImageItem(); rItem.ColumnName = col.ColumnName; rItem.BaseTableName = tbl.TableName; rItem.Name = col.ColumnName; rItem.ScaleImageToSize = false; itemCol.Add (rItem); } else { ICSharpCode.Reports.Core.BaseDataItem rItem = new ICSharpCode.Reports.Core.BaseDataItem(); rItem.ColumnName = col.ColumnName; rItem.DBValue = col.ColumnName; rItem.BaseTableName = tbl.TableName; rItem.DataType = col.DataType.ToString(); rItem.Name = col.ColumnName; rItem.Text = "=[" + col.ColumnName + "]"; itemCol.Add (rItem); } } } return itemCol; }
public override void Fill(IReportItem item) { base.Fill(item); DataRow row = this.Current as DataRow; if (row != null) { BaseDataItem baseDataItem = item as BaseDataItem; if (baseDataItem != null) { baseDataItem.DBValue = row[baseDataItem.ColumnName].ToString(); return; } BaseImageItem bi = item as BaseImageItem; if (bi != null) { using (System.IO.MemoryStream memStream = new System.IO.MemoryStream()){ Byte[] val = row[bi.ColumnName] as Byte[]; if (val != null) { if ((val[78] == 66) && (val[79] == 77)) { memStream.Write(val, 78, val.Length - 78); } else { memStream.Write(val, 0, val.Length); } System.Drawing.Image image = System.Drawing.Image.FromStream(memStream); bi.Image = image; } } } } }
// only checked columns are use in the report private ReportItemCollection CreateItemsCollection (DataGridViewColumn[] displayCols) { ReportItemCollection items = new ReportItemCollection(); foreach (DataGridViewColumn cc in displayCols) { DataGridViewColumnHeaderCheckBoxCell hc= (DataGridViewColumnHeaderCheckBoxCell)cc.HeaderCell; if (hc.Checked) { AbstractColumn ac = this.abstractColumns.Find(cc.HeaderText); ICSharpCode.Reports.Core.BaseDataItem br = new ICSharpCode.Reports.Core.BaseDataItem(); br.Name = ac.ColumnName; br.ColumnName = ac.ColumnName; br.DataType = ac.DataTypeName; br.DBValue = ac.ColumnName; items.Add(br); } } return items; }
public void Expression_In_Text_Evaluate() { ReportSettings rs = new ReportSettings(); IDataManager dm = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.table,rs); DataNavigator dataNav = dm.GetNavigator; BaseDataItem bdi = new BaseDataItem(){ Name ="MyDataItem", ColumnName = "last", Text ="=Substring(Fields!last,0,3)", Expression ="=Substring(Fields!last,0,3)" }; var ri = new ReportItemCollection(); ri.Add(bdi); while (dataNav.MoveNext()) { dataNav.Fill(ri); DataRow r = dataNav.Current as DataRow; string actual = r["last"].ToString(); Assert.That(actual.Substring(0,3), Is.EqualTo(bdi.DBValue)); } }
protected ICSharpCode.Reports.Core.BaseGroupedRow CreateGroupHeader(Point headerLocation) { ICSharpCode.Reports.Core.BaseDataItem dataItem = new ICSharpCode.Reports.Core.BaseDataItem(); dataItem.ColumnName = ReportModel.ReportSettings.GroupColumnsCollection[0].ColumnName; dataItem.DataType = ReportModel.ReportSettings.GroupColumnsCollection[0].DataTypeName; dataItem.Location = new Point (GlobalValues.ControlMargins.Left,GlobalValues.ControlMargins.Top); dataItem.Size = new Size (150,20); dataItem.Text = ReportModel.ReportSettings.GroupColumnsCollection[0].ColumnName; ICSharpCode.Reports.Core.BaseGroupedRow groupHeader = new ICSharpCode.Reports.Core.BaseGroupedRow(); groupHeader.Location = headerLocation; groupHeader.Size = new Size (300,dataItem.Size.Height + GlobalValues.ControlMargins.Top + GlobalValues.ControlMargins.Bottom); groupHeader.Items.Add(dataItem); return groupHeader; }
object ExtractDBValue(DataRow row,BaseDataItem item) { if (EvaluationHelper.CanEvaluate(item.Expression)) { return ExtractFromExpression(item.Expression, row); } else { return DBValueFromRow(row, item.ColumnName); } }