public void CreateReportRedirectSharedDatasets()
        {
            var rs = GetReportingService();

            var dataSources = new Dictionary <string, string>();

            dataSources.Add("AdventureWorks", "/Data Sources/AdventureWorks");

            var dataSetNames = new[] { "EmployeeSalesDetail", "EmployeeSalesYearOverYear", "EmpSalesMonth", "SalesEmployees" };

            var dsService = new SharedDatasetService(rs);
            var dataSets  = new Dictionary <string, string>();

            foreach (var dataSetName in dataSetNames)
            {
                dsService.Create(dataSetName, "/ReportFolder", SharedDatasetPath + dataSetName + ".rsd", string.Empty, false);
                dataSets.Add(dataSetName, "/ReportFolder/" + dataSetName);
            }

            var service = new ReportService(rs);

            service.Create("Employee sales summary", "/ReportFolder", EmployeeSalesSummaryPath, "My description", false, dataSources, dataSets);

            var dsRef = rs.GetItemReferences("/ReportFolder/Employee sales summary", "DataSet");

            Assert.That(dsRef.Count(), Is.EqualTo(4));
            foreach (var dsRefItem in dsRef)
            {
                Assert.That(dsRefItem.Reference, Is.Not.Null.Or.Empty);
            }
        }
Esempio n. 2
0
        public void CreateSharedDataset()
        {
            var rs = GetReportingService();

            var service = new SharedDatasetService(rs);

            service.Create("EmployeeSalesDetail", "/SharedDatasetFolder", SharedDatasetPaths[0], string.Empty, false);

            Assert.That(rs.GetItemType("/SharedDatasetFolder/EmployeeSalesDetail"), Is.EqualTo("DataSet"));
        }
Esempio n. 3
0
        public void CreateSharedDatasetRedirectMissingDataSource()
        {
            var rs = GetReportingService();

            var ds = new Dictionary <string, string>();

            var service = new SharedDatasetService(rs);
            var error   = false;

            service.MessageSent += (o, e) => error |= e.Level == MessageEventArgs.LevelOption.Error;

            Assert.Catch <InvalidOperationException>(() => service.Create("EmployeeSalesDetail", "/SharedDatasetFolder", SharedDatasetPath, string.Empty, false, "AdventureWorks", ds));
            Assert.That(error, Is.True);
        }
Esempio n. 4
0
        public void CreateVisibleSharedDataset()
        {
            var rs = GetReportingService();

            var service = new SharedDatasetService(rs);

            service.Create("EmployeeSalesDetail", "/SharedDatasetFolder", SharedDatasetPaths[0], "My description", false);

            Assert.That(rs.GetItemType("/SharedDatasetFolder/EmployeeSalesDetail"), Is.EqualTo("DataSet"));
            var properties = rs.GetProperties("/SharedDatasetFolder/EmployeeSalesDetail", new[] { new Property()
                                                                                                  {
                                                                                                      Name = "Hidden"
                                                                                                  } });

            Assert.That(properties[0].Value, Is.EqualTo(false.ToString()));
        }
Esempio n. 5
0
        public void CreateSharedDatasetRedirectDataSource()
        {
            var rs = GetReportingService();

            var ds = new Dictionary <string, string>();

            ds.Add("AdventureWorks", "/Data Sources/AdventureWorks");

            var service = new SharedDatasetService(rs);

            service.Create("EmployeeSalesDetail", "/SharedDatasetFolder", SharedDatasetPaths[0], "My description", false, "AdventureWorks", ds);

            var dsRef = rs.GetItemDataSources("/SharedDatasetFolder/EmployeeSalesDetail");

            Assert.That(dsRef.Count(), Is.EqualTo(1));
            Assert.That(dsRef[0].Item, Is.TypeOf <DataSourceReference>());
            Assert.That((dsRef[0].Item as DataSourceReference).Reference, Is.EqualTo("/Data Sources/AdventureWorks"));
        }
Esempio n. 6
0
        public virtual void Execute(XmlNode node)
        {
            var sharedDatasetNodes = node.SelectNodes("./Dataset | ./SharedDataset");

            foreach (XmlNode sharedDatasetNode in sharedDatasetNodes)
            {
                var name = sharedDatasetNode.Attributes["Name"].Value;

                var path = sharedDatasetNode.SelectSingleNode("./Path")?.InnerXml;
                path = path ?? $"{Root.NamingConvention.Apply(name)}.rsd";
                if (!Path.IsPathRooted(path))
                {
                    path = Path.Combine(RootPath ?? string.Empty, path);
                }

                var description    = sharedDatasetNode.SelectSingleNode("./Description")?.InnerXml;
                var hidden         = bool.Parse(sharedDatasetNode.Attributes["Hidden"]?.Value ?? bool.FalseString);
                var dataSourceName = sharedDatasetNode.Attributes["DataSource"]?.Value ?? string.Empty;

                sharedDatasetService.Create(name, ParentPath, path, description, hidden, dataSourceName, Root?.DataSources);
                Root.SharedDatasets.Add(name, $"{ParentPath}/{name}");
            }
        }