Uploads a directory full of workbooks
Inheritance: TableauServerSignedInRequestBase
Example #1
0
    /// <summary>
    /// Called to perform Uploads of the workbooks
    /// </summary>
    /// <param name="onlineLogin"></param>
    /// <param name="localBasePath"></param>
    /// <param name="remapWorkbookReferences">TRUE is we want to transform workbooks to remap any published datasources to the new server/site we are uploading to</param>
    /// <param name="credentialManager">Database credentials to associate with content we are uploading</param>
    private void Execute_UploadWorkbooks(
        TableauServerSignIn onlineLogin,
        string localBasePath,
        bool remapWorkbookReferences,
        CredentialManager credentialManager)
    {
        StatusLog.AddStatusHeader("Upload workbooks");

        if (string.IsNullOrWhiteSpace(localBasePath))
        {
            _statusLog.AddError("Abort uploads. Local path is not specified");
            return;
        }

        string pathWorkbooks = Path.Combine(localBasePath, "workbooks");

        if (!Directory.Exists(pathWorkbooks))
        {
            _statusLog.AddStatus("Skipping workbooks upload. Local workbooks path does not exist: \"" + pathWorkbooks + "\"");
            return;
        }

        //Do we have a directory to perform remapping
        string pathRemappingTempspace = Path.Combine(localBasePath, "_remapTempspace");

        if (!Directory.Exists(pathRemappingTempspace))
        {
            Directory.CreateDirectory(pathRemappingTempspace);
        }


        //Upload all the files
        var uploadProjectBehavior = new UploadBehaviorProjects(
            _taskOptions.IsOptionSet(TaskMasterOptions.Option_UploadCreateNeededProjects),
            true);

        var dsUploader = new UploadWorkbooks(
            _onlineUrls,
            onlineLogin,
            credentialManager,
            pathWorkbooks,
            remapWorkbookReferences,
            pathRemappingTempspace,
            uploadProjectBehavior,
            _manualActions,
            this.UploadChunksSizeBytes,
            this.UploadChunksDelaySeconds);

        try
        {
            dsUploader.ExecuteRequest();
        }
        catch (Exception exUploader)
        {
            StatusLog.AddError("Aborted upload workbooks. Unexpected error + " + exUploader.Message);
        }
    }
Example #2
0
        protected void UploadWorkbooks(string projectName, string datasourceUsername, string datasourcePassword, bool isEmbedded, string path)
        {
            var credentialManager = new CredentialManager();

            foreach (var thisFilePath in Directory.GetFiles(path))
            {
                credentialManager.AddWorkbookCredential(Path.GetFileName(thisFilePath), projectName, datasourceUsername, datasourcePassword, isEmbedded);
            }
            var uploadWorkbooksRequest = new UploadWorkbooks(Urls, Login, credentialManager, path, HttpClientFactory);

            uploadWorkbooksRequest.ExecuteRequest();
        }
Example #3
0
    /// <summary>
    /// Called to perform Uploads of the workbooks
    /// </summary>
    /// <param name="onlineLogin"></param>
    /// <param name="localBasePath"></param>
    /// <param name="remapWorkbookReferences">TRUE is we want to transform workbooks to remap any published datasources to the new server/site we are uploading to</param>
    /// <param name="attemptContentOwnershipAssignment">TRUE: Look for content metadata files, and attempt to assign the owner to the published content</param>
    /// <param name="credentialManager">Database credentials to associate with content we are uploading</param>
    /// <param name="siteUsers">Users in site, needed for content ownership remapping</param>
    private void Execute_UploadWorkbooks(
        TableauServerSignIn onlineLogin, 
        string localBasePath, 
        bool remapWorkbookReferences, 
        CredentialManager credentialManager,
        bool attemptContentOwnershipAssignment,
        IEnumerable<SiteUser> siteUsers)
    {
        StatusLog.AddStatusHeader("Upload workbooks");

        if (string.IsNullOrWhiteSpace(localBasePath))
        {
            _statusLog.AddError("Abort uploads. Local path is not specified");
            return;
        }

        string pathWorkbooks = Path.Combine(localBasePath, "workbooks");
        if (!Directory.Exists(pathWorkbooks))
        {
            _statusLog.AddStatus("Skipping workbooks upload. Local workbooks path does not exist: \"" + pathWorkbooks + "\"");
            return;
        }

        //Do we have a directory to perform remapping
        string pathRemappingTempspace = Path.Combine(localBasePath, "_remapTempspace");
        if (!Directory.Exists(pathRemappingTempspace))
        {
            Directory.CreateDirectory(pathRemappingTempspace);
        }

        //Upload all the files
        var uploadProjectBehavior = new UploadBehaviorProjects(
            _taskOptions.IsOptionSet(TaskMasterOptions.Option_UploadCreateNeededProjects),
            true);

        var dsUploader = new UploadWorkbooks(
            _onlineUrls,
            onlineLogin,
            credentialManager,
            pathWorkbooks,
            remapWorkbookReferences,
            pathRemappingTempspace,
            uploadProjectBehavior,
            _manualActions,
            attemptContentOwnershipAssignment,
            siteUsers,
            this.UploadChunksSizeBytes,
            this.UploadChunksDelaySeconds
            );
        try
        {
            dsUploader.ExecuteRequest();
        }
        catch (Exception exUploader)
        {
            StatusLog.AddError("Aborted upload workbooks. Unexpected error + " + exUploader.Message);
        }
    }