Esempio n. 1
0
        public void Test_Reporting_GetReports()
        {
            using (var rs = new ReportingServer())
            {
                var folders = rs.GetFolders().ToList();
                Assert.AreEqual(1, folders.Count());

                var serviceFolders = rs.GetFolders(folders.Single().Path);
                Assert.AreEqual(2, serviceFolders.Count());

                var askTheLibFolder = serviceFolders.Where(x => x.Name.ToLower().Contains("askthelib")).SingleOrDefault();
                Assert.IsNotNull(askTheLibFolder);
                var reports = rs.GetReports(askTheLibFolder.Path);
                Assert.AreEqual(1, reports.Count());
            }
        }
Esempio n. 2
0
        public void Test_Reporting_CreateFolder()
        {
            using (var rs = new ReportingServer())
            {
                var folders = rs.GetFolders().ToList();
                Assert.AreEqual(1, folders.Count());

                var exFolders = rs.GetFolders(folders.Single().Path).ToList();

                string toCreate = "test";
                bool ok = rs.CreateFolder(toCreate, folders[0].Path);
                Assert.IsTrue(ok);
                var newFolders = rs.GetFolders(folders.Single().Path).ToList();
                Assert.AreEqual(exFolders.Count + 1, newFolders.Count);
                Assert.IsNotNull(newFolders.SingleOrDefault(x => x.Name == toCreate));
            }
        }
Esempio n. 3
0
 public bool DeleteReport(string service, string report)
 {
     if (_securityService.CurrentUser.UserType != Domain.UserTypes.Admin)
         return false;
     else if (!_modulesMap.ContainsKey(service))
         return false;
     try
     {
         using (var rs = new ReportingServer())
         {
             return rs.DeleteReport(report, String.Format("/libservices/{0}", service));
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.WriteLine(ex);
         _loggingService.WriteEvent(LogEventType.Error, string.Format("({0}) {1}", ex.GetType().Name, ex.Message));
         return false;
     }
 }
Esempio n. 4
0
        public void Test_Reporting_CreateReport()
        {
            using (var rs = new ReportingServer())
            {
                var folders = rs.GetFolders().ToList();
                Assert.AreEqual(1, folders.Count());

                var exFolders = rs.GetFolders(folders.Single().Path).ToList();

                string toCreate = "test";
                bool ok = rs.CreateFolder(toCreate, folders[0].Path);
                Assert.IsTrue(ok);
                var newFolders = rs.GetFolders(folders.Single().Path).ToList();
                var newFolder = newFolders.SingleOrDefault(x => x.Name == toCreate);

                string rdlPath = @"D:\Users\kiko\Documents\Visual Studio 2008\Projects\NbuLibReport1\NbuLibReport1\Report3.rdl";
                ok = rs.CreateReport("testreport1", File.ReadAllBytes(rdlPath), newFolder.Path);
                Assert.IsTrue(ok);
                var reports = rs.GetReports(newFolder.Path).ToList();
                Assert.AreEqual(1, reports.Count);
                Assert.AreEqual("testreport1", reports[0].Name);
            }
        }
Esempio n. 5
0
        public string GetReportPath(string service, string report)
        {
            if (!CanAccess(service))
                return null;
            else
            {
                var rs = new ReportingServer();
                var reportItem = rs.GetReports(String.Format("/libservices/{0}", service)).Where(r => r.Name.Equals(report, StringComparison.InvariantCultureIgnoreCase)).SingleOrDefault();
                if (reportItem == null)
                    return null;

                return reportItem.Path;
            }
        }
Esempio n. 6
0
        public IEnumerable<ServiceFolder> GetServiceFolders()
        {
            using (var rs = new ReportingServer())
            {
                var folders = rs.GetFolders("/libservices");
                Dictionary<string, Folder> map = new Dictionary<string, Folder>(StringComparer.InvariantCultureIgnoreCase);
                foreach (var folder in folders)
                    map.Add(folder.Name, folder);
                foreach (var module in _modules)
                {
                    var serviceFolder = new ServiceFolder()
                    {
                        Exists = map.ContainsKey(module.Name),
                        Name = module.Name
                    };
                    if (serviceFolder.Exists)
                    {
                        serviceFolder.Reports = rs.GetReports(map[module.Name].Path).Select(r => new Core.Services.Report()
                        {
                            Name = r.Name,
                            Description = r.Description
                        });
                    }

                    yield return serviceFolder;
                }
            }
        }
Esempio n. 7
0
 public IEnumerable<string> GetReports(string service)
 {
     using (var rs = new ReportingServer())
     {
         return rs.GetReports(String.Format("/libservices/{0}", service)).Select(r => r.Name);
     }
 }