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));
        }