コード例 #1
0
        protected ICollection <SiteDatasource> DownloadDatasourceList()
        {
            var downloadDataSourceListRequest = new DownloadDatasourcesList(Urls, Login, HttpClientFactory);

            downloadDataSourceListRequest.ExecuteRequest();
            return(downloadDataSourceListRequest.Datasources);
        }
コード例 #2
0
    /// <summary>
    /// Follows the instructions for any content ownership changes we want to make
    /// </summary>
    /// <param name="siteSignIn"></param>
    /// <param name="workingList_allKnownUsers"></param>
    private void Execute_ProvisionContentOwnershipChanges(TableauServerSignIn siteSignIn, WorkingListSiteUsers workingList_allKnownUsers)
    {
        //===============================================================================================
        //If there are no content ownership changes to perform, then just exit this step
        //===============================================================================================
        if ((_provisionInstructions.ContentOwnershipToProvision == null) ||
            (_provisionInstructions.ContentOwnershipToProvision.Count == 0))
        {
            _statusLogs.AddStatus("Skipping content ownership mapping, because there are no instructions for this...");
            return;
        }


        _statusLogs.AddStatusHeader("Provision content ownership changes");

        //=================================================================================
        //If we do not have it already, load the set of users for the site...we will need this to look up users
        //=================================================================================
        if (workingList_allKnownUsers == null)
        {
            var existingUsers = DownloadUsersList.CreateAndExecute(siteSignIn);
            existingUsers.ExecuteRequest();

            workingList_allKnownUsers = new WorkingListSiteUsers(existingUsers.Users);
        }

        //=================================================================================
        //Unlike Workbooks, there is not a simple URL to download the list of Datasources
        //for a single user.  (There is a filter parameter that can be added to the REST
        //API that queries data sources, but that takes a "user name" not a User ID).
        //Here we can query for ALL the data sources pass that to all teh remappign request
        //=================================================================================
        var downloadDataSources = new DownloadDatasourcesList(siteSignIn);

        downloadDataSources.ExecuteRequest();
        var allSiteDataSources = downloadDataSources.Datasources;

        //=================================================================================
        //Get the list of flows in the iste
        //=================================================================================
        var downloadFlows = new DownloadFlowsList(siteSignIn);

        downloadFlows.ExecuteRequest();
        var allSiteFlows = downloadFlows.Flows;

        //Go through each of the ownership change instructions...
        foreach (var thisOwnershipChange in _provisionInstructions.ContentOwnershipToProvision)
        {
            Execute_ProvisionOwnership_SingleUserChange(
                siteSignIn,
                thisOwnershipChange, workingList_allKnownUsers,
                allSiteDataSources,
                allSiteFlows);
        }
    }
コード例 #3
0
    /// <summary>
    /// Download the data sources
    /// </summary>
    /// <param name="onlineLogin"></param>
    private void Execute_DownloadDatasourcesList(TableauServerSignIn onlineLogin)
    {
        _statusLog.AddStatusHeader("Download datasources list");
        try
        {
            //Get the list of workbooks
            var datasources = new DownloadDatasourcesList(_onlineUrls, onlineLogin);
            datasources.ExecuteRequest();

            //Store them in our object
            _downloadedList_Datasources = datasources.Datasources;
        }
        catch (Exception exDatasourceDownload)
        {
            _statusLog.AddError("Error during datasource list download, " + exDatasourceDownload.ToString());
        }
    }
コード例 #4
0
ファイル: TaskMaster.cs プロジェクト: tableau/TabMigrate
    /// <summary>
    /// Download the data sources
    /// </summary>
    /// <param name="onlineLogin"></param>
    private void Execute_DownloadDatasourcesList(TableauServerSignIn onlineLogin)
    {
        _statusLog.AddStatusHeader("Download datasources list");
        try
        {
            //Get the list of workbooks
            var datasources = new DownloadDatasourcesList(_onlineUrls, onlineLogin);
            datasources.ExecuteRequest();

            //Store them in our object
            _downloadedList_Datasources = datasources.Datasources;
        }
        catch (Exception exDatasourceDownload)
        {
            _statusLog.AddError("Error during datasource list download, " + exDatasourceDownload.ToString());
        }
    }
コード例 #5
0
ファイル: TaskMaster.cs プロジェクト: tableau/TabMigrate
    /// <summary>
    /// 
    /// </summary>
    /// <param name="onlineLogin"></param>
    /// <param name="exportToPath"></param>
    /// <param name="projectsList"></param>
    /// <param name="singleProjectIdFilter"></param>
    /// <param name="exportOnlyWithThisTag"></param>
    /// <param name="deleteTagAfterExport"></param>
    /// <param name="generateInfoFile">TRUE: Each downloaded workbook will get an information file generated that has additional metadata about it</param>
    /// <param name="siteUsers"> If not NULL, then this will get used to look the user name for each downloaded workbook, and safe it into the info file</param>
    private void Execute_DownloadDatasources(
        TableauServerSignIn onlineLogin, 
        string exportToPath, 
        IProjectsList projectsList,
        SiteProject singleProjectIdFilter = null,
        string exportOnlyWithThisTag      = null,
        bool deleteTagAfterExport         = false,
        bool generateInfoFile             = false,
        IEnumerable<SiteUser>   siteUsers = null
        )
    {
        _statusLog.AddStatusHeader("Download datasources");
        ICollection<SiteDatasource> datasourcesList = null;
        try
        {
            //Get the list of datasources
            var datasourcesManager = new DownloadDatasourcesList(_onlineUrls, onlineLogin);
            datasourcesManager.ExecuteRequest();
            datasourcesList = datasourcesManager.Datasources;
        }
        catch(Exception exGetContentList)
        {
            _statusLog.AddError("Error querying for list of datasources, " + exGetContentList.Message.ToString());
        }

        if(datasourcesList == null)
        {
            _statusLog.AddError("Aborting datasources download");
            return;
        }

        //====================================================================================================
        //Apply filters to the list of content to see if we need to reduce the set of content to be downloaded
        //====================================================================================================
        var filteredList = datasourcesList;
        _statusLog.AddStatus("Download datasources count before filters: " + filteredList.Count.ToString());

        //See if we have a PROJECTS filter to apply to the set of content to download
        filteredList = FilterProjectMembership<SiteDatasource>.KeepOnlyProjectMembers(
            filteredList,
            singleProjectIdFilter,
            true);
        _statusLog.AddStatus("Download datasources count after projects filter: " + filteredList.Count.ToString());

        //See if we have a TAGS filter to apply to the set of content to be downloaded
        filteredList = FilterTagSet<SiteDatasource>.KeepOnlyTagged(
            filteredList,
            exportOnlyWithThisTag,
            true);
        _statusLog.AddStatus("Download datasources count after tags filter: " + filteredList.Count.ToString());

        ICollection<SiteDatasource> successfullExportSet = null;
        var datasourcePath = Path.Combine(exportToPath, "datasources");
        FileIOHelper.CreatePathIfNeeded(datasourcePath);

        //-----------------------------------------------------------
        //Download the data sources
        //-----------------------------------------------------------
        //If we are going to write out metadata for each download, then create the object that lets us look up the owner of each workbook
        KeyedLookup<SiteUser> contentOwnerLookup = null;
        if ((generateInfoFile) && (siteUsers != null))
        {
            contentOwnerLookup = new KeyedLookup<SiteUser>(siteUsers);
        }
        try
        {
            var datasourceDownloads = new DownloadDatasources(
                _onlineUrls,
                onlineLogin,
                filteredList,
                datasourcePath,
                projectsList,
                generateInfoFile,
                contentOwnerLookup);
            successfullExportSet = datasourceDownloads.ExecuteRequest();
        }
        catch (Exception exDatasourceDownload)
        {
            _statusLog.AddError("Error during datasource download, " + exDatasourceDownload.ToString());
        }

        //--------------------------------------------------------------------------------
        //Do we want to remove tags from successfully downloaded content?
        //--------------------------------------------------------------------------------
        if ((successfullExportSet != null) && (deleteTagAfterExport) && (!string.IsNullOrWhiteSpace(exportOnlyWithThisTag)))
        {
            Execute_DeleteTagFromDatasources(onlineLogin, successfullExportSet, exportOnlyWithThisTag);
        }
    }
コード例 #6
0
    /// <summary>
    /// Download the data sources
    /// </summary>
    /// <param name="onlineLogin"></param>
    private void Execute_DownloadDatasources(
        TableauServerSignIn onlineLogin,
        string exportToPath,
        IProjectsList projectsList,
        SiteProject singleProjectIdFilter = null,
        string exportOnlyWithThisTag      = null,
        bool deleteTagAfterExport         = false)
    {
        _statusLog.AddStatusHeader("Download datasources");
        ICollection <SiteDatasource> datasourcesList = null;

        try
        {
            //Get the list of datasources
            var datasourcesManager = new DownloadDatasourcesList(_onlineUrls, onlineLogin);
            datasourcesManager.ExecuteRequest();
            datasourcesList = datasourcesManager.Datasources;
        }
        catch (Exception exGetContentList)
        {
            _statusLog.AddError("Error querying for list of datasources, " + exGetContentList.Message.ToString());
        }

        if (datasourcesList == null)
        {
            _statusLog.AddError("Aborting datasources download");
            return;
        }

        //====================================================================================================
        //Apply filters to the list of content to see if we need to reduce the set of content to be downloaded
        //====================================================================================================
        var filteredList = datasourcesList;

        _statusLog.AddStatus("Download datasources count before filters: " + filteredList.Count.ToString());

        //See if we have a PROJECTS filter to apply to the set of content to download
        filteredList = FilterProjectMembership <SiteDatasource> .KeepOnlyProjectMembers(
            filteredList,
            singleProjectIdFilter,
            true);

        _statusLog.AddStatus("Download datasources count after projects filter: " + filteredList.Count.ToString());

        //See if we have a TAGS filter to apply to the set of content to be downloaded
        filteredList = FilterTagSet <SiteDatasource> .KeepOnlyTagged(
            filteredList,
            exportOnlyWithThisTag,
            true);

        _statusLog.AddStatus("Download datasources count after tags filter: " + filteredList.Count.ToString());

        ICollection <SiteDatasource> successfullExportSet = null;
        var datasourcePath = Path.Combine(exportToPath, "datasources");

        FileIOHelper.CreatePathIfNeeded(datasourcePath);

        //-----------------------------------------------------------
        //Download the data sources
        //-----------------------------------------------------------
        try
        {
            var datasourceDownloads = new DownloadDatasources(
                _onlineUrls,
                onlineLogin,
                filteredList,
                datasourcePath,
                projectsList);
            successfullExportSet = datasourceDownloads.ExecuteRequest();
        }
        catch (Exception exDatasourceDownload)
        {
            _statusLog.AddError("Error during datasource download, " + exDatasourceDownload.ToString());
        }

        //--------------------------------------------------------------------------------
        //Do we want to remove tags from successfully downloaded content?
        //--------------------------------------------------------------------------------
        if ((successfullExportSet != null) && (deleteTagAfterExport) && (!string.IsNullOrWhiteSpace(exportOnlyWithThisTag)))
        {
            Execute_DeleteTagFromDatasources(onlineLogin, successfullExportSet, exportOnlyWithThisTag);
        }
    }