/// <summary> /// Teardowns the environment. /// </summary> /// <param name="url">The URL.</param> /// <param name="credentials">The credentials.</param> /// <param name="path">The path to delete.</param>/param> /// <exception cref="System.ArgumentException"> /// url /// or /// path /// </exception> public static void TeardownEnvironment(string url, ICredentials credentials, string path) { if (string.IsNullOrEmpty(url)) { throw new ArgumentException("url"); } if (string.IsNullOrEmpty(path)) { throw new ArgumentException("path"); } ReportingService2010 service = ReportingService2010TestEnvironment.GetReportingService(url, credentials); // If the path exists, delete it to clean up after the tests if (ReportingService2010TestEnvironment.ItemExists(service, path, "Folder")) { service.DeleteItem(path); } if (ReportingService2010TestEnvironment.ItemExists(service, path, "Folder")) { service.DeleteItem(path); } }
public static void SetupReportWriterEnvironment(string url, ICredentials credentials, string path, List <ReportItem> reports) { if (string.IsNullOrEmpty(url)) { throw new ArgumentException("path"); } if (string.IsNullOrEmpty(url)) { throw new ArgumentException("path"); } if (reports == null) { throw new ArgumentNullException("reports"); } ReportingService2010 service = ReportingService2010TestEnvironment.GetReportingService(url, credentials); // If the path exists, delete it so we don't get any unexpected 'ItemAlreadyExists' exceptions while testing if (ReportingService2010TestEnvironment.ItemExists(service, path, "Folder")) { service.DeleteItem(path); } // Go through each report and if it exists, delete it and then recreate it foreach (ReportItem report in reports) { if (ReportingService2010TestEnvironment.ItemExists(service, report.Path, "Report")) { service.DeleteItem(report.Path); } ReportingService2010TestEnvironment.CreateReport(service, report); } }
/// <summary> /// Setups the folder writer environment. /// </summary> /// <param name="url">The URL.</param> /// <param name="credentials">The credentials.</param> /// <param name="path">The parent path to write items to (e.g. /SSRSMigrate_Tests).</param> /// <param name="folders">The folders to create.</param> /// <exception cref="System.ArgumentException">url</exception> /// <exception cref="System.ArgumentNullException">folders</exception> public static void SetupFolderWriterEnvironment(string url, ICredentials credentials, string path, List <FolderItem> folders) { if (string.IsNullOrEmpty(url)) { throw new ArgumentException("path"); } if (string.IsNullOrEmpty(url)) { throw new ArgumentException("path"); } if (folders == null) { throw new ArgumentNullException("folders"); } ReportingService2010 service = ReportingService2010TestEnvironment.GetReportingService(url, credentials); // If the path exists, delete it so we don't get any unexpected 'ItemAlreadyExists' exceptions while testing if (ReportingService2010TestEnvironment.ItemExists(service, path, "Folder")) { service.DeleteItem(path); } // Go through each folder and if it exists, delete it and then recreate it foreach (FolderItem folder in folders) { if (ReportingService2010TestEnvironment.ItemExists(service, folder.Path, "Folder")) { service.DeleteItem(folder.Path); } ReportingService2010TestEnvironment.CreateFolderFromPath(service, folder.Path); } }
private void RestoreRdlFile(string rdlFilePath, string reportingServerUrl, string analysisFolderName, string parentFolderName) { try { CreateFoldersIfNotExists(analysisFolderName, parentFolderName, reportingServerUrl); string rdlName = Path.GetFileNameWithoutExtension(rdlFilePath); string rdlFile = string.Format("/{0}/{1}/{2}", parentFolderName, analysisFolderName, rdlName); using (ReportingService2010 rs = new ReportingService2010()) { rs.Credentials = CredentialCache.DefaultCredentials; rs.Url = string.Format("{0}/ReportService2010.asmx?wsdl", reportingServerUrl); string fileExists = rs.GetItemType(rdlFile); if (fileExists.Equals(parentFolderName, StringComparison.OrdinalIgnoreCase)) { rs.DeleteItem(rdlFile); } FileInfo fileInfo = new FileInfo(rdlFilePath); string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.FullName); Warning[] warnings = null; byte[] fileContents = File.ReadAllBytes(fileInfo.FullName); string parentPath = string.Format("/{0}/{1}", parentFolderName, analysisFolderName); rs.CreateCatalogItem(itemTypeName, fileNameWithoutExtension, parentPath, true, fileContents, null, out warnings); if (IsWindowsAuthenticated) { RDLDeploy.SetDataSource($"{parentPath}/{fileNameWithoutExtension}", rs); } else { RDLDeploy.SetDataSource($"{parentPath}/{fileNameWithoutExtension}", rs, ReportingServiceUserName, ReportingServicePassword, ReportingServiceExpireTime); } } } catch (NullReferenceException nex) { FailedToRestore(nex.Message); } catch (Exception ex) { FailedToRestore(ex.Message); } }
public static void TeardownReportWriterEnvironment(string url, ICredentials credentials, string path, List <ReportItem> reports) { if (string.IsNullOrEmpty(url)) { throw new ArgumentException("url"); } if (string.IsNullOrEmpty(path)) { throw new ArgumentException("path"); } if (reports == null) { throw new ArgumentNullException("reports"); } ReportingService2010 service = ReportingService2010TestEnvironment.GetReportingService(url, credentials); // Go through each folder and delete it if it exists foreach (ReportItem report in reports) { if (ReportingService2010TestEnvironment.ItemExists(service, report.Path, "Folder")) { service.DeleteItem(report.Path); } } // Delete the path if it exists if (ReportingService2010TestEnvironment.ItemExists(service, path, "Folder")) { service.DeleteItem(path); } }
public static void SetupEnvironment(string url, ICredentials credentials, string path, string testPath) { if (string.IsNullOrEmpty(url)) { throw new ArgumentException("url"); } if (string.IsNullOrEmpty(path)) { throw new ArgumentException("path"); } mTestPath = testPath; // Create a report named 'Report Already Exists' so when we run integration tests that expect // this report to exist, it does SetupReportItems.Add(new ReportItem() { Name = "Report Already Exists", Path = "{0}/Reports/Report Already Exists", Definition = TesterUtility.StringToByteArray( TesterUtility.LoadRDLFile(Path.Combine(mTestPath, "Test AW Reports\\2005\\Company Sales.rdl"))) }); ReportingService2010 service = ReportingService2010TestEnvironment.GetReportingService(url, credentials); if (ReportingService2010TestEnvironment.ItemExists(service, path, "Folder")) { service.DeleteItem(path); } // Create the parent (base) folder where the integration tests will be written to (e.g. /DEST_SSRSMigrate_Tests) ReportingService2010TestEnvironment.CreateFolderFromPath(service, path); // Create folder structure ReportingService2010TestEnvironment.CreateFolders(service, path); // Create the the data sources ReportingService2010TestEnvironment.CreateDataSources(service, path); // Create the the reports //ReportingService2010TestEnvironment.CreateReports(service, path); }
private void DeleteSubFolderIfExists(string parentFolder, string subFolder) { var items = rs.ListChildren("/" + parentFolder, false); var subFolderExists = items.Any(catalogItem => catalogItem.Name.ToUpperInvariant() == subFolder.ToUpperInvariant() && catalogItem.TypeName.ToUpperInvariant() == "FOLDER"); if (subFolderExists) { Log(@"Deleting sub folder '{0}\{1}'.", parentFolder, subFolder); rs.DeleteItem(string.Format("/{0}/{1}", parentFolder, subFolder)); Log(@"Deleted sub folder '{0}\{1}'.", parentFolder, subFolder); } else { Log(@"Sub folder '{0}\{1}' does not exist.", parentFolder, subFolder); } }
public void DeleteItem(string path) { webserviceProxy.DeleteItem(path); }
public void DeleteItem(string ItemPath) { rs.DeleteItem(ItemPath); }