/// <summary> /// Publish report through reporting service /// </summary> /// <param name="reportDefinition">Byte Array of RDL format report</param> /// <param name="reportName">Report Name</param> /// <param name="reportPath">Report Full Path</param> /// <returns>true: successful; false: failed</returns> public bool PublishReport(Byte[] reportDefinition, string reportName, string reportPath, string dataSourceName) { Warning[] warnings = null; ReportingService2010.ReportingService2010 CurrentService = new ReportingService2010.ReportingService2010(); CurrentService.Credentials = System.Net.CredentialCache.DefaultCredentials; //set the credentials string UserReportID = ConfigurationManager.AppSettings["userReportID"]; string UerReportPassword = ConfigurationManager.AppSettings["userReportPassword"]; string UserReportDomain = ConfigurationManager.AppSettings["userReportDomain"]; CurrentService.Credentials = new NetworkCredential(UserReportID, UerReportPassword, UserReportDomain); if (reportPath.Substring(reportPath.Length - 1) == "/") { reportPath = reportPath.Substring(0, reportPath.Length - 1); } CatalogItem myItem = CurrentService.CreateCatalogItem("Report", reportName, "/" + reportPath, true, reportDefinition, null, out warnings); //test if create worked OK if (warnings == null) { DataSource[] dsArray = CurrentService.GetItemDataSources("/" + reportPath + "/" + reportName); DataSourceReference dsRef = new DataSourceReference(); dsRef.Reference = "/" + dataSourceName; dsArray[0].Item = dsRef; CurrentService.SetItemDataSources("/" + reportPath + "/" + reportName, dsArray); return(true); } else { return(false); } }
// // GET: /Report/ public ActionResult Index() { ReportingService2010.ReportingService2010 rs = new ReportingService2010.ReportingService2010(); rs.Credentials = System.Net.CredentialCache.DefaultCredentials; rs.Url = System.Configuration.ConfigurationManager.AppSettings["ReportServerUrl"] + "/ReportService2010.asmx"; var rootPath = System.Configuration.ConfigurationManager.AppSettings["ReportRootPath"]; ReportingService2010.CatalogItem[] items = rs.ListChildren(rootPath, true); return(Json(items.Where(i => i.TypeName == "Folder" || i.TypeName == "Report").Select(i => new ReportDTO { Name = i.Name, TypeName = i.TypeName, Description = i.Description, Path = i.Path.Substring(rootPath.Length, i.Path.Length - i.Name.Length - rootPath.Length) }), JsonRequestBehavior.AllowGet)); //List<ReportDTO> reports = new List<ReportDTO>(); //foreach (string reportFilePath in Directory.GetFiles(Server.MapPath("~/Reporting/Files"))) //{ // reports.Add(new ReportDTO() { Name = Path.GetFileName(reportFilePath), Path = "/", TypeName = "Report", Description = Path.GetFileNameWithoutExtension(reportFilePath) }); //} //return Json(reports, JsonRequestBehavior.AllowGet); }
public bool RenameFolder(ReportGroup folder, string oldPath) { ReportingService2010.ReportingService2010 CurrentService = new ReportingService2010.ReportingService2010(); CurrentService.Credentials = System.Net.CredentialCache.DefaultCredentials; //set the credentials string UserReportID = ConfigurationManager.AppSettings["userReportID"]; string UerReportPassword = ConfigurationManager.AppSettings["userReportPassword"]; string UserReportDomain = ConfigurationManager.AppSettings["userReportDomain"]; string PathName = folder.PathName; if (PathName.Substring(PathName.Length - 1) == "/") { PathName = PathName.Substring(0, PathName.Length - 1); } string OldPathName = oldPath; if (OldPathName.Substring(OldPathName.Length - 1) == "/") { OldPathName = OldPathName.Substring(0, OldPathName.Length - 1); } CurrentService.Credentials = new NetworkCredential(UserReportID, UerReportPassword, UserReportDomain); CurrentService.MoveItem("/" + OldPathName, "/" + PathName); return(true); }
public bool DeleteReport(ReportGroup folder, Report reportItem) { ReportingService2010.ReportingService2010 CurrentService = new ReportingService2010.ReportingService2010(); CurrentService.Credentials = System.Net.CredentialCache.DefaultCredentials; //set the credentials string UserReportID = ConfigurationManager.AppSettings["userReportID"]; string UerReportPassword = ConfigurationManager.AppSettings["userReportPassword"]; string UserReportDomain = ConfigurationManager.AppSettings["userReportDomain"]; CurrentService.Credentials = new NetworkCredential(UserReportID, UerReportPassword, UserReportDomain); CurrentService.DeleteItem("/" + folder.PathName + reportItem.Name); return(true); }
public bool InsertFolder(ReportGroup folder) { ReportingService2010.ReportingService2010 CurrentService = new ReportingService2010.ReportingService2010(); CurrentService.Credentials = System.Net.CredentialCache.DefaultCredentials; //set the credentials string UserReportID = ConfigurationManager.AppSettings["userReportID"]; string UerReportPassword = ConfigurationManager.AppSettings["userReportPassword"]; string UserReportDomain = ConfigurationManager.AppSettings["userReportDomain"]; string ParentPath = folder.ParentPath; if (ParentPath.Substring(ParentPath.Length - 1) == "/") { ParentPath = ParentPath.Substring(0, ParentPath.Length - 1); } CurrentService.Credentials = new NetworkCredential(UserReportID, UerReportPassword, UserReportDomain); CatalogItem newFolder = CurrentService.CreateFolder(folder.Name, "/" + ParentPath, null); return(true); }
public bool CopyReport(Report reportToPublish, StandardReport reportInfo) { Warning[] warnings = null; string reportPath = ConfigurationManager.AppSettings["ReportPublishedLocation"]; string reportName = reportInfo.ReportName; string dataSourceName = reportToPublish.DataModel_1.DatasourceName; ReportingService2010.ReportingService2010 CurrentService = new ReportingService2010.ReportingService2010(); CurrentService.Credentials = System.Net.CredentialCache.DefaultCredentials; //set the credentials string UserReportID = ConfigurationManager.AppSettings["userReportID"]; string UerReportPassword = ConfigurationManager.AppSettings["userReportPassword"]; string UserReportDomain = ConfigurationManager.AppSettings["userReportDomain"]; CurrentService.Credentials = new NetworkCredential(UserReportID, UerReportPassword, UserReportDomain); byte[] reportDefinition = CurrentService.GetItemDefinition("/" + reportToPublish.ReportGroup.PathName + reportToPublish.Name); CatalogItem myItem = CurrentService.CreateCatalogItem("Report", reportName, "/" + reportPath, true, reportDefinition, null, out warnings); //test if create worked OK if (warnings == null) { DataSource[] dsArray = CurrentService.GetItemDataSources("/" + reportPath + "/" + reportName); DataSourceReference dsRef = new DataSourceReference(); dsRef.Reference = "/" + dataSourceName; dsArray[0].Item = dsRef; CurrentService.SetItemDataSources("/" + reportPath + "/" + reportName, dsArray); return(true); } else { return(false); } }
private bool Authenticate() { bool result = false; if (this.m_client != null) this.m_client = new ReportingService2010.ReportingService2010(); try { // Basic this.m_client.Credentials = new System.Net.NetworkCredential("IISServiceAct", "!QAZxsw2", "acro"); this.m_client.Url = ConfigurationManager.AppSettings["ReportServerUrl"]; result = true; } catch (Exception x) { result = false; throw x; } return result; }