/// <summary> /// Initialize the SOAP and the URL Report Server Accessors /// </summary> private void InitializeReportServerAccesors() { Logging.Log("Initialize Report Server Accessors for Native Environment"); _executionCredentials = CredentialCache.DefaultNetworkCredentials; if (!String.IsNullOrEmpty(ReportServerInformation.DefaultInformation.ExecutionAccount)) { CredentialCache myCache = new CredentialCache(); Uri reportServerUri = new Uri(ReportServerInformation.DefaultInformation.ReportServerUrl); myCache.Add(new Uri(reportServerUri.GetLeftPart(UriPartial.Authority)), "NTLM", new NetworkCredential(ReportServerInformation.DefaultInformation.ExecutionAccount, ReportServerInformation.DefaultInformation.ExecutionAccountPwd)); _executionCredentials = myCache; } RSSoapAccessor soapAcessor = new RSSoapAccessor(ReportServerInformation.DefaultInformation.ReportServerUrl, _executionCredentials); Logging.Log("InitializeReportServerAccesors SoapAcessor is null={0}", soapAcessor == null); this.SoapAccessor = soapAcessor; RSUrlAccessor urlAcessor = new RSUrlAccessor(ReportServerInformation.DefaultInformation.ReportServerUrl); Logging.Log("InitializeReportServerAccesors UrlAcessor is null={0}", urlAcessor == null); urlAcessor.ExecuteCredentials = _executionCredentials; this.URLAccessor = urlAcessor; RSPortalAccessorV1 portalAcessor = new RSPortalAccessorV1(ReportServerInformation.DefaultInformation.RestApiV1Url); Logging.Log("InitializeReportServerAccesors PortalAccessor is null={0}", portalAcessor == null); portalAcessor.ExecuteCredentials = _executionCredentials; this.PortalAccessorV1 = portalAcessor; RSPortalAccessorV2 portalAcessorV2 = new RSPortalAccessorV2(ReportServerInformation.DefaultInformation.RestApiV2Url); Logging.Log("InitializeReportServerAccesors PortalAccessor is null={0}", portalAcessor == null); portalAcessorV2.ExecuteCredentials = _executionCredentials; this.PortalAccessorV2 = portalAcessorV2; }
private string PublishItemToPortal(string report, string displayName, string parentFolder, byte[] content) { switch (Path.GetExtension(report)) { case ".rdl": string path = RSPortalAccessorV1.CreateFullPath(parentFolder, displayName); var item = new Report { Name = displayName, Path = path, Content = content }; PortalAccessorV1.AddToCatalogItems(item); return(path); case ".rsmobile": return(PortalAccessorV1.AddToCatalogItems <MobileReport>(displayName, parentFolder, content)); case ".kpi": string json = Encoding.UTF8.GetString(content); return(PortalAccessorV1.AddToCatalogItems <Kpi>(displayName, parentFolder, json)); case ".pbix": return(PortalAccessorV1.AddToCatalogItems <PowerBIReport>(displayName, parentFolder, content)); default: return(null); } }
private string CreateRSFolder(string parent, string folderName) { try { var folder = RSPortalAccessorV1.CreateFullPath(parent, folderName); var path = parent ?? RootPath; PortalAccessorV1.AddToCatalogItems(new Folder { Name = folderName, Path = path }); return(folder); } catch (Exception e) { Logging.Log("Folder create failed: {0}", e.Message); throw; } }
public override string CreateDataSource(string name, RSDataSourceDefinition dsDef, string parent) { var dataSource = new DataSource { ConnectionString = dsDef.ConnectString, IsConnectionStringOverridden = true, CredentialRetrieval = dsDef.CredentialRetrieval == RSCredentialRetrievalEnum.Integrated ? CredentialRetrievalType.Integrated : dsDef.CredentialRetrieval == RSCredentialRetrievalEnum.Prompt ? CredentialRetrievalType.Prompt : dsDef.CredentialRetrieval == RSCredentialRetrievalEnum.Store ? CredentialRetrievalType.Store : CredentialRetrievalType.None, CredentialsByUser = dsDef.CredentialRetrieval == RSCredentialRetrievalEnum.Prompt ? new CredentialsSuppliedByUser { UseAsWindowsCredentials = dsDef.WindowsCredentials, DisplayText = dsDef.Prompt } : null, CredentialsInServer = dsDef.CredentialRetrieval == RSCredentialRetrievalEnum.Store ? new CredentialsStoredInServer { ImpersonateAuthenticatedUser = dsDef.ImpersonateUserSpecified, UserName = dsDef.UserName, Password = dsDef.Password, UseAsWindowsCredentials = dsDef.WindowsCredentials } : null, DataSourceType = dsDef.Extension, IsOriginalConnectionStringExpressionBased = dsDef.OriginalConnectStringExpressionBased, IsEnabled = dsDef.Enabled, Path = parent, Name = name }; try { PortalAccessorV1.AddToCatalogItems(dataSource); } catch (Exception ex) { Logging.Log("Folder create failed: {0}", ex.Message); throw; } return(RSPortalAccessorV1.CreateFullPath(parent, name)); }
public static void LoadMobileReport(RSPortalAccessorV1 portalAccessor, string report) { lock (_lock) { var ctx = portalAccessor.CreateContext(); // runtime ProceedIfOk(() => ctx.SafeGetSystemResourceContent("mobilereportruntime", "web").GetValue()); // report MobileReport mobileReport = null; ProceedIfOk(() => mobileReport = ctx.CatalogItemByPath(report).GetValue() as MobileReport); // definition ProceedIfOk(() => ctx.CatalogItems.ByKey(mobileReport.Manifest.Definition.Id).GetValue()); // resources foreach (var resource in mobileReport.Manifest.Resources) { foreach (var item in resource.Items) { if (resource.Type == MobileReportResourceGroupType.Map && item.Key == "json") { LoadResource(portalAccessor, item.Id); } else if (resource.Type == MobileReportResourceGroupType.Style && new[] { "colors", "Windows8-Style.xaml" }.Contains(item.Key)) { LoadResource(portalAccessor, item.Id); } } } // datasets foreach (var dataset in mobileReport.Manifest.DataSets.RandomWhere(x => x.Type == MobileReportDataSetType.Shared)) { ProceedIfOk(() => ctx.CatalogItems.ByKey(dataset.Id).CastToDataSet().GetData(new DataSetParameter[] { }, null).GetValue()); } } }
private static void LoadResource(RSPortalAccessorV1 portalAccessor, Guid id) { var ctx = portalAccessor.CreateContext(); ProceedIfOk(() => ctx.CatalogItems.ByKey(id).CastToResource().Select(x => x.Content).GetValue()); }