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];
        }
示例#2
0
        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);
        }
        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 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 SelectDesignTimeDataSourceForm(IDesignerContext context, MyReportBase report, Action <DesignTimeDataSourceDefinition> callback)
        {
            InitializeComponent();

            _context  = context;
            _report   = report;
            _callback = callback;
        }
示例#6
0
        public void GivenASubreportExistsAsAFile()
        {
            _subReportFilePath = Helpers.GetNewTempFile() + ".repx";
            Path.GetDirectoryName(_subReportFilePath).Should().NotBeNullOrEmpty();
            var subReport = new MyReportBase();

            subReport.SaveLayout(_subReportFilePath);
            File.Exists(_subReportFilePath).Should().BeTrue();
        }
示例#7
0
        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 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 CloneLayoutAsMyReportBase(this XtraReport report)
        {
            var stream = new MemoryStream();

            report.SaveLayout(stream);
            stream.Position = 0;

            var newReport = new MyReportBase();

            newReport.LoadLayout(stream);
            newReport.DataSource = report.DataSource;

            return(newReport);
        }
        public static bool ChangeDesignTimeDatasource(this MyReportBase report, DesignTimeDataSourceDefinition definition, IDesignerContext designContext)
        {
            object datasource = null;

            if (definition != null)
            {
                // Get Traversed Datasource
                var traversedResult = designContext.DataSourceLocator.GetDataSource(definition);
                datasource = traversedResult.TraversedDataSource;

                if (traversedResult.RootDataSource == null)
                {
                    MessageBox.Show("Datasource: {0} could not be found or did not return a datasource.".FormatString(definition.ToString()));
                }
                else
                {
                    // Store Definition on Report

                    // If already in list, Remore & Re-add, so as to move definition to index 0
                    if (report.DesignTimeDataSources.Contains(definition))
                    {
                        var index = report.DesignTimeDataSources.IndexOf(definition);
                        report.DesignTimeDataSources.RemoveAt(index);
                    }

                    // Add item as first in list - So we know it was the last one used
                    report.DesignTimeDataSources.Insert(0, definition);

                    // Verify Traversal worked
                    if (traversedResult.TraversedDataSource == null)
                    {
                        MessageBox.Show("Datasource: {0} was found, but the traversed Relation Path did not return a value.".FormatString(definition.ToString()));
                    }
                }
            }

            // Set DataSource
            report.SetReportDataSource(datasource);

            // Refresh Design Panel Fields List
            var designPanel = designContext.DesignForm.DesignMdiController.ActiveDesignPanel;

            if (designPanel != null)
            {
                designPanel.Activate();
            }

            return(report.DataSource != null);
        }
        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();
        }
        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 void PassDesignTimeDataSourceToSubreport(SubreportBase container, MyReportBase subreport, IDesignerContext designContext)
        {
            var parentReport = (MyReportBase)container.RootReport;

            var parentDataSourceItem = parentReport.GetSelectedDesignTimeDatasource();

            if (parentDataSourceItem != null)
            {
                var path = GetFullDataMemberPath(container.Band);

                var datasourceDefinition = new DesignTimeDataSourceDefinition(parentDataSourceItem.DataSourceUniqueId, parentDataSourceItem.DataSourceName, path);

                // Go!
                subreport.ChangeDesignTimeDatasource(datasourceDefinition, designContext);
            }
        }
示例#14
0
 public void WhenTheReportEngineRuns()
 {
     _newParentReport = _controller.Print(r => r.ExportToMemory());
 }
 bool IsReportInDesigner(MyReportBase report)
 {
     // TODO: Implement, in case there are multiple DesignerContext's
     return(true);
 }
        public static bool ChangeDesignTimeDatasourceToDefault(this MyReportBase report, IDesignerContext designContext)
        {
            var selectedSource = report.DesignTimeDataSources.FirstOrDefault();

            return(ChangeDesignTimeDatasource(report, selectedSource, designContext));
        }
        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);
        }
 public XRBeforePrintMessage(MyReportBase report, PrintEventArgs e)
 {
     Report    = report;
     PrintArgs = e;
 }
示例#19
0
 public XRLoadDesignTimeDatasourceMessage(MyReportBase report, DesignTimeDataSourceDefinition datasourceDefinition, Action <object> setDatasourceCallback)
 {
     Report = report;
     DatasourceDefinition  = datasourceDefinition;
     SetDatasourceCallback = setDatasourceCallback;
 }
示例#20
0
        public void WhenTheReportEngineRuns()
        {
            _newParentReport = _controller.Print(r => r.ExportToMemory());

            _newSubReportContainer = _getContainerFunc(_newParentReport);
        }
 public static DesignTimeDataSourceDefinition GetSelectedDesignTimeDatasource(this MyReportBase report)
 {
     return(report.DesignTimeDataSources.FirstOrDefault());
 }
        public static IEnumerable <DesignTimeDataSourceTreeItem> BuildDesignTimeDataSourceTreeItems(IDataSourceLocator 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 XRRuntimeVisitor(IEventAggregator eventAggregator, MyReportBase report)
 {
     _eventAggregator = eventAggregator;
     _report          = report;
 }