FromCommandLine() public static method

Creates a TaskMaster from command line arguments
public static FromCommandLine ( CommandLineParser, commandLine ) : TaskMaster,
commandLine CommandLineParser,
return TaskMaster,
Ejemplo n.º 1
0
        /// <summary>
        /// Called to run us in commandn line mode
        /// </summary>
        /// <param name="commandLine"></param>
        internal void RunStartupCommandLine()
        {
            //Set up the UI to indicate we are going to run a commandl ine
            ShowSinglePanelHideOthers(panelRunCommandLine);
            textBoxErrors.Text = "";
            textBoxStatus.Text = "";

            TaskMaster task = null;

            //Parse the details from the command line
            try
            {
                task = TaskMaster.FromCommandLine(_startupCommandLine);
            }
            catch (Exception exParseCommandLine)
            {
                textBoxErrors.Text = "Error parsing command line: " + exParseCommandLine;
            }

            _onlineTaskMaster = task;

            //Set the work running
            StartRunningAsyncTask();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the task we use to export a Tableau Server sites content to the local file system
        /// </summary>
        /// <returns></returns>
        private TaskMaster CreateAsyncImportTask(bool showPasswordInUi)
        {
            string siteUrl               = txtUrlImportTo.Text;
            bool   useAccessToken        = (comboBoxAuthMethodImportTo.SelectedIndex == 1);
            string signInUser            = txtIdImportTo.Text;
            string signInPassword        = txtPasswordImportTo.Text;
            bool   isSiteAdmin           = chkImportIsSiteAdmin.Checked;
            string localPathImportFrom   = txtSiteImportContentPath.Text;
            bool   remapContentOwnership = chkImportRemapContentOwnership.Checked;

            //Check that this contains Workbooks or Data Sources; otherwise it's not a valid path with content
            if (!TaskMaster.IsValidImportFromDirectory(localPathImportFrom))
            {
                throw new Exception("The import directory specified does not contain datasources/workbooks sub directories. Import aborted.");
            }

            //If there is a DB credentials file path make sure it actually points to a file
            string pathDBCredentials = GetDBCredentialsImportPath();

            if (!string.IsNullOrWhiteSpace(pathDBCredentials))
            {
                if (!File.Exists(pathDBCredentials))
                {
                    throw new Exception("The path to the db credentials file does not exist, " + pathDBCredentials);
                }
            }

            //----------------------------------------------------------------------
            //Sanity test the sign in.  If this fails, then there is no point in
            //moving forward
            //----------------------------------------------------------------------
            bool signInTest = ValidateSignInPossible(siteUrl, useAccessToken, signInUser, signInPassword);

            if (!signInTest)
            {
                return(null);
            }

            var onlineUrls = TableauServerUrls.FromContentUrl(siteUrl, TaskMasterOptions.RestApiReponsePageSizeDefault);

            //Local path
            string localPathForSiteOutput = GeneratePathFromSiteUrl(onlineUrls);

            //Output file
            var    nowTime = DateTime.Now;
            string localPathForOutputFile =
                Path.Combine(localPathForSiteOutput,
                             FileIOHelper.FilenameWithDateTimeUnique("siteImport.csv", nowTime));

            //Log file
            string localPathForLogFile =
                Path.Combine(localPathForSiteOutput,
                             FileIOHelper.FilenameWithDateTimeUnique("siteImport_log.txt", nowTime));

            //Errors file
            string localPathForErrorsFile =
                Path.Combine(localPathForSiteOutput,
                             FileIOHelper.FilenameWithDateTimeUnique("siteImport_errors.txt", nowTime));

            //Manual steps file
            string localPathForManualStepsFile =
                Path.Combine(localPathForSiteOutput,
                             FileIOHelper.FilenameWithDateTimeUnique("siteImport_manualSteps.csv", nowTime));


            //-----------------------------------------------------------------
            //Generate a command line
            //-----------------------------------------------------------------
            string            commandLineAsText;
            CommandLineParser commandLineParsed;

            CommandLineParser.GenerateCommandLine_SiteImport(
                showPasswordInUi,
                localPathImportFrom,
                siteUrl,
                useAccessToken,
                signInUser,
                signInPassword,
                isSiteAdmin,
                chkRemapWorkbookDataserverReferences.Checked,
                pathDBCredentials,
                localPathForLogFile,
                localPathForErrorsFile,
                localPathForManualStepsFile,
                remapContentOwnership,
                chkVerboseLog.Checked,
                out commandLineAsText,
                out commandLineParsed);

            //Show the user the command line, so that they can copy/paste and run it
            txtSiteImportCommandLineExample.Text = PathHelper.GetApplicaitonPath() + " " + commandLineAsText;

            //=====================================================================
            //Create the task
            //=====================================================================
            return(TaskMaster.FromCommandLine(commandLineParsed));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get an inventory of content on the specified server
        /// </summary>
        private TaskMaster CreateAsyncInventoryTask(bool showPasswordInUi)
        {
            string siteUrl        = txtUrlInventoryFrom.Text;
            bool   useAccessToken = (comboBoxAuthMethodInventoryFrom.SelectedIndex == 1);
            string signInUser     = txtIdInventoryFromUserId.Text;
            string signInPassword = txtPasswordInventoryFrom.Text;
            bool   isSystemAdmin  = chkInventoryUserIsAdmin.Checked;
            var    nowTime        = DateTime.Now;

            //----------------------------------------------------------------------
            //Sanity test the sign in.  If this fails, then there is no point in
            //moving forward
            //----------------------------------------------------------------------
            bool signInTest = ValidateSignInPossible(siteUrl, useAccessToken, signInUser, signInPassword);

            if (!signInTest)
            {
                return(null);
            }

            var onlineUrls = TableauServerUrls.FromContentUrl(siteUrl, TaskMasterOptions.RestApiReponsePageSizeDefault);

            //Local path
            string localPathForSiteOutput = GeneratePathFromSiteUrl(onlineUrls);

            //Output file
            string localPathForOutputFile =
                Path.Combine(localPathForSiteOutput,
                             FileIOHelper.FilenameWithDateTimeUnique("siteInventory.csv", nowTime));

            //Log file
            string localPathForLogFile =
                Path.Combine(localPathForSiteOutput,
                             FileIOHelper.FilenameWithDateTimeUnique("siteInventory_log.txt", nowTime));

            //Errors file
            string localPathForErrorsFile =
                Path.Combine(localPathForSiteOutput,
                             FileIOHelper.FilenameWithDateTimeUnique("siteInventory_errors.txt", nowTime));

            //-----------------------------------------------------------------
            //Generate a command line
            //-----------------------------------------------------------------
            string            commandLineAsText;
            CommandLineParser commandLineParsed;

            CommandLineParser.GenerateCommandLine_SiteInventory(
                showPasswordInUi,
                localPathForOutputFile,
                siteUrl,
                useAccessToken,
                signInUser,
                signInPassword,
                isSystemAdmin,
                localPathForLogFile,
                localPathForErrorsFile,
                chkGenerateInventoryTwb.Checked,
                chkVerboseLog.Checked,
                out commandLineAsText,
                out commandLineParsed);

            //Show the user the command line, so that they can copy/paste and run it
            txtInventoryExampleCommandLine.Text = PathHelper.GetApplicaitonPath() + " " + commandLineAsText;


            //=====================================================================
            //Create the task
            //=====================================================================
            return(TaskMaster.FromCommandLine(commandLineParsed));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates the task we use to export a Tableau Server sites content to the local file system
        /// </summary>
        /// <returns></returns>
        private TaskMaster CreateAsyncExportTask(bool showPasswordInUi)
        {
            string siteUrl                 = txtUrlExportFrom.Text;
            bool   useAccessToken          = (comboBoxAuthMethodExportFrom.SelectedIndex == 1);
            string signInUser              = txtIdExportFrom.Text;
            string signInPassword          = txtPasswordExportFrom.Text;
            bool   isSiteAdmin             = chkExportUserIsAdmin.Checked;
            string exportOnlySingleProject = txtExportSingleProject.Text.Trim();
            string exportOnlyWithTag       = txtExportOnlyTagged.Text.Trim();


            //----------------------------------------------------------------------
            //Sanity test the sign in.  If this fails, then there is no point in
            //moving forward
            //----------------------------------------------------------------------
            bool signInTest = ValidateSignInPossible(siteUrl, useAccessToken, signInUser, signInPassword);

            if (!signInTest)
            {
                return(null);
            }

            var onlineUrls = TableauServerUrls.FromContentUrl(siteUrl, TaskMasterOptions.RestApiReponsePageSizeDefault);

            var nowTime = DateTime.Now;
            //Local path
            string localPathForSiteOutput = GeneratePathFromSiteUrl(onlineUrls);

            localPathForSiteOutput = FileIOHelper.PathDateTimeSubdirectory(localPathForSiteOutput, true, "siteExport", nowTime);

            //Log file
            string localPathForLogFile =
                Path.Combine(localPathForSiteOutput, "siteExport_log.txt");

            //Errors file
            string localPathForErrorsFile =
                Path.Combine(localPathForSiteOutput, "siteExport_errors.txt");

            //-----------------------------------------------------------------
            //Generate a command line
            //-----------------------------------------------------------------
            string            commandLineAsText;
            CommandLineParser commandLineParsed;

            CommandLineParser.GenerateCommandLine_SiteExport(
                showPasswordInUi,
                localPathForSiteOutput,
                siteUrl,
                useAccessToken,
                signInUser,
                signInPassword,
                isSiteAdmin,
                exportOnlySingleProject,
                exportOnlyWithTag,
                chkExportRemoveExportTag.Checked,
                localPathForLogFile,
                localPathForErrorsFile,
                chkExportContentsWithKeepAlive.Checked,
                chkVerboseLog.Checked,
                chkGenerateDownloadMetadataFiles.Checked,
                out commandLineAsText,
                out commandLineParsed);

            //Show the user the command line, so that they can copy/paste and run it
            textSiteExportCommandLine.Text = PathHelper.GetApplicaitonPath() + " " + commandLineAsText;

            //=====================================================================
            //Create the task
            //=====================================================================
            return(TaskMaster.FromCommandLine(commandLineParsed));
        }