public void Should_Create_TreeItems_With_Exports_For_Folders() { var report = new MyReportBase(); var designContext = TestHelper.CreateDesignerContext(); var northwind = TestHelper.NorthwindDataSource; var fakeDefinition1 = new DesignTimeDataSourceDefinition(northwind.DataSourceName, @"TestFolder", string.Empty); var fakeDefinition2 = new DesignTimeDataSourceDefinition(northwind.DataSourceName, @"FakeFolder", string.Empty); var fakeDefinition3 = new DesignTimeDataSourceDefinition(northwind.DataSourceName, @"TestFolder\TestChildFolder", string.Empty); report.DesignTimeDataSources.Add(northwind); report.DesignTimeDataSources.Add(fakeDefinition1); report.DesignTimeDataSources.Add(fakeDefinition2); report.DesignTimeDataSources.Add(fakeDefinition3); DynamicTree<DesignTimeDataSourceTreeItem> tree; List<DesignTimeDataSourceTreeItem> flatList; var treeItems = DesignTimeHelper.BuildDesignTimeDataSourceTreeItems(locator, report, out tree, out flatList).ToList(); //// Show TreeView, debug only //var form = new SelectDesignTimeDataSourceForm(designContext, report, (selectedDefinition) => { }); //form.ShowDialog(); Assert.AreEqual(8, treeItems.Count); }
public SelectDesignTimeDataSourceForm(IDesignerContext context, MyReportBase report, Action<DesignTimeDataSourceDefinition> callback) { InitializeComponent(); _context = context; _report = report; _callback = callback; }
public static void AssertDatasourceHasItems(MyReportBase report) { var datasource = report.DataSource; Assert.IsNotNull(datasource); var collection = (datasource as IEnumerable).Cast<object>().ToList(); Assert.AreNotEqual(0, collection.Count); }
public static MyReportBase ConvertReportToMyReportBase(this XtraReport report) { if (report == null) return null; // return, do not convert if input is already myReportBase var convertReportToMyReportBase = report as MyReportBase; if (convertReportToMyReportBase != null) return convertReportToMyReportBase; var stream = new MemoryStream(); report.SaveLayout(stream); stream.Position = 0; var newReport = new MyReportBase(); newReport.LoadLayout(stream); newReport.DataSource = report.DataSource; return newReport; }
private static MyReportBase CreateReport(string reportName) { var report = new MyReportBase(); report.Name = reportName; report.DisplayName = reportName; var Detail = new DetailBand(); var TopMargin = new TopMarginBand(); var BottomMargin = new BottomMarginBand(); report.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] { Detail, TopMargin, BottomMargin }); return report; }
public static IEnumerable<DesignTimeDataSourceTreeItem> BuildDesignTimeDataSourceTreeItems(DataSourceLocator locator, MyReportBase report, out DynamicTree<DesignTimeDataSourceTreeItem> tree, out List<DesignTimeDataSourceTreeItem> flatList) { var treeItems = BuildDesignTimeDataSourceTreeItems(locator, report); Func<string, string, DesignTimeDataSourceTreeItem> structureBuilder = (string1, string2) => { return new DesignTimeDataSourceTreeItem() { Name = string1, Path = string2, IsStructure = true }; }; var treeView = new TreeviewStructureBuilder<DesignTimeDataSourceTreeItem>(); treeView.Delimiter = @"\"; treeView.CreateTree(treeItems, structureBuilder, out tree, out flatList, DuplicateTreeItemBehavior.ShowOnlyOneItem); return treeItems; }
public void Handler_wireup_should_be_predicatable() { var myBase = new MyReportBase(); var detailBand = new DetailBand(); var container = new XRSubreport(); var subReport = new MyReportBase(); container.ReportSource = subReport; detailBand.Controls.Add(container); myBase.Bands.Add(detailBand); myBase.DataSource = new[] { new object(), new object(), new object(), new object() }; var controller = new DataSourceTrackingController(myBase, (s, ds) => _counter++); controller.Print(r => r.ExportToMemory()); _counter.Should().Be(4); }
public void Should_pass_root_hashcode() { var view = new XtraReport {DataSource = new[] {new object(), new object()}}; var detailBand = new DetailBand(); var container = new XRSubreport(); var subReport = new MyReportBase(); container.ReportSource = subReport; detailBand.Controls.Add(container); view.Bands.Add(detailBand); IReportController myController = new XRReportController(view); Action<XtraReport> printAction = r => r.ExportToMemory(); var newView = myController.Print(printAction); var subReportsHashcode = ((MyReportBase) ((XRSubreport) newView.Bands[BandKind.Detail].Controls[0]).ReportSource).RootHashCode; newView.RootHashCode.Should().NotBe(0); subReportsHashcode.Should().Be(newView.RootHashCode); }
private void PromptSelectDatasource(XRDesignForm form, MyReportBase report) { Form dialog = null; // Datasource Selected Callback Action<DesignTimeDataSourceDefinition> callback = (definition) => { dialog.Close(); // Change Report Datasource report.ChangeDesignTimeDatasource(definition, this); }; // Create Select Datasource Dialog dialog = new SelectDesignTimeDataSourceForm(this, report, callback); dialog.BringToFront(); dialog.ShowDialog(); }
public void ThenTheSubreportSDatasourceShouldBeTheSameAsTheParentReportSDatasource() { _newSubReport = (MyReportBase)_newSubReportContainer.ReportSource; var parentList = (List<Person>)_newParentReport.DataSource; var childList = (List<Person>)_newSubReport.DataSource; parentList.Should().Equal(childList); }
public static void PassDesignTimeDataSourceToSubreport(SubreportBase container, MyReportBase subreport, IDesignerContext designContext) { var parentReport = (MyReportBase)container.RootReport; var parentDataSourceItem = parentReport.GetSelectedDesignTimeDatasource(); if (parentDataSourceItem != null) { var path = DesignTimeHelper.GetFullDataMemberPath(container.Band); var datasourceDefinition = new DesignTimeDataSourceDefinition(parentDataSourceItem.DataSourceName, parentDataSourceItem.DataSourceAssemblyLocationPath, path); // Go! subreport.ChangeDesignTimeDatasource(datasourceDefinition, designContext); } }
bool IsReportInDesigner(MyReportBase report) { // TODO: Implement, in case there are multiple DesignerContext's return true; }
public XRRuntimeVisitor(IEventAggregator eventAggregator, MyReportBase report) { _eventAggregator = eventAggregator; _report = report; }
private static IEnumerable<DesignTimeDataSourceTreeItem> BuildDesignTimeDataSourceTreeItems(DataSourceLocator locator, MyReportBase report) { // Report Requested Datasource Definitions var requestedDatasources = report.DesignTimeDataSources; // Folders var requestedFolders = requestedDatasources.Select(definition => locator.FormatRelativePath(definition.DataSourceAssemblyLocationPath)); var realFolders = locator.GetAllFoldersWithinBasePathContainingDLLs().Select(folder => locator.FormatRelativePath(folder)); var allFolders = requestedFolders.Union(realFolders); Func<string, IEnumerable<IReportDatasourceMetadata>> GetExportsFromRelativeFolder = relativeFolder => { var exports = locator.GetDatasources(relativeFolder); var metadatas = exports.Select((lazy) => lazy.Metadata); return metadatas; }; Func<IReportDatasourceMetadata, DesignTimeDataSourceDefinition, bool> match = (metadata, requested) => { if (metadata == null || requested == null) return false; else return metadata.Name == requested.DataSourceName; }; Func<string, IReportDatasourceMetadata, DesignTimeDataSourceDefinition, DesignTimeDataSourceTreeItem> CreateDataSourceTreeItem = (relativeFolder, metadataNullable, definitionNullable) => { var definition = definitionNullable ?? new DesignTimeDataSourceDefinition(metadataNullable.Name, relativeFolder, string.Empty); return new DesignTimeDataSourceTreeItem() { Path = relativeFolder, Name = definition.DataSourceName, DesignTimeDataSourceDefinition = definition, MEFMetadata = metadataNullable, PreviouslyUsedWithThisReport = (definitionNullable != null).ToString(), RelationPath = definition.DataSourceRelationPath }; }; var dataSourceTreeItems = (from relativeFolder in allFolders let exports = GetExportsFromRelativeFolder(relativeFolder) let definitions = requestedDatasources.Where(definition => definition.DataSourceAssemblyLocationPath == relativeFolder) // Join exports & definitions on folder + datasource name from tuple in exports.FullOuterJoin(definitions, match) let export = tuple.T1Object let definition = tuple.T2Object select CreateDataSourceTreeItem(relativeFolder, export, definition)).ToList(); return dataSourceTreeItems; }
public void WhenTheReportEngineRuns() { _newReport = _controller.Print(r => r.ExportToMemory()); _newChangeMeLabel = (XRLabel)_newReport.Bands[0].Controls[_changeMeLabel.Name]; _newDontChangeMeLabel = (XRLabel) _newReport.Bands[0].Controls[_dontChangeMeLabel.Name]; }
public XRLoadDesignTimeDatasourceMessage(MyReportBase report, DesignTimeDataSourceDefinition datasourceDefinition, Action<object> setDatasourceCallback) { Report = report; DatasourceDefinition = datasourceDefinition; SetDatasourceCallback = setDatasourceCallback; }
public void WhenTheReportEngineRuns() { _newParentReport = _controller.Print(r => r.ExportToMemory()); _newSubReportContainer = _getContainerFunc(_newParentReport); }
public XRBeforePrintMessage(MyReportBase report, PrintEventArgs e) { Report = report; PrintArgs = e; }
private static IEnumerable<DesignTimeDataSourceTreeItem> BuildDesignTimeDataSourceTreeItems(IDataSourceLocator locator, MyReportBase report) { // Report Requested Datasource Definitions var requestedDatasources = report.DesignTimeDataSources; Func<IReportDatasourceMetadata, DesignTimeDataSourceDefinition, bool> match = (metadata, requested) => { if (metadata == null || requested == null) return false; else return metadata.UniqueId == requested.DataSourceName; }; Func<IReportDatasourceMetadata, DesignTimeDataSourceDefinition, DesignTimeDataSourceTreeItem> CreateDataSourceTreeItem = (metadataNullable, definitionNullable) => { var definition = definitionNullable ?? new DesignTimeDataSourceDefinition(metadataNullable.UniqueId, metadataNullable.Name, String.Empty); return new DesignTimeDataSourceTreeItem() { Path = string.Empty, Name = definition.DataSourceName, DesignTimeDataSourceDefinition = definition, Metadata = metadataNullable, PreviouslyUsedWithThisReport = (definitionNullable != null).ToString(), RelationPath = definition.DataSourceRelationPath }; }; var dataSourceTreeItems = (from datasourceProvider in locator.GetReportDatasourceProviders() let availableDatasources = datasourceProvider.GetReportDatasources() // Join availableDatasources & requestedDatasources on datasource name from tuple in availableDatasources.FullOuterJoin(requestedDatasources, match) let export = tuple.T1Object let definition = tuple.T2Object select CreateDataSourceTreeItem(export, definition)).ToList(); return dataSourceTreeItems; }