//readonly CsvDataGenerator _csvProvisionResults = null; /*/// <summary> * /// CSV for generated report * /// </summary> * public CsvDataGenerator CSVResultsReport * { * get * { * return _csvProvisionResults; * } * } */ /// <summary> /// Constructor /// </summary> /// <param name="config"></param> /// <param name="configSyncGroups"></param> /// <param name="showLogsHere"></param> /// <param name="statusLogs"></param> /// <param name="ignoreAllUsersGroup">(True recommended) Do not export the 'all users' group</param> public TableauProvisionDownload( ProvisionConfigSiteAccess config, IShowLogs showLogsHere, TaskStatusLogs statusLogs, bool ignoreAllUsersGroup = true) { _ignoreAllUsersGroupInExport = ignoreAllUsersGroup; _showLogsHere = showLogsHere; _configTableauSecrets = config; if (statusLogs == null) { statusLogs = new TaskStatusLogs(); } _statusLogs = statusLogs; //Either use one passed in, or create one /*if (csvDataGenerator == null) * { * csvDataGenerator = new CsvDataGenerator(); * } */ //_csvProvisionResults = csvDataGenerator; }
/// <summary> /// Provision the site based on the provisioning manifest in a file /// </summary> /// <param name="statusLogs">Store status logs here</param> /// <param name="pathSecrets">Where the log in secrets are</param> /// <param name="pathProvisioningManifest">Where the provisioning steps are</param> /// <param name="outputPath">Where output files go</param> private void ProvisionFromFileManifest(TaskStatusLogs statusLogs, string pathSecrets, string pathProvisioningManifest, string outputPath) { //Load the config from the files var secretsConfig = new ProvisionConfigSiteAccess(pathSecrets); //Load the user provisioning instructions var provisionUsersInfo = new ProvisionUserInstructions( pathProvisioningManifest); var provisionSite = new ProvisionSite(secretsConfig, provisionUsersInfo, this, statusLogs); provisionSite.Execute(); //--------------------------------------------------------------------- //Generate an output file //--------------------------------------------------------------------- FileIOHelper.CreatePathIfNeeded(outputPath); var outputFilePath = Path.Combine(outputPath, "ProvisionSiteOutput.csv"); provisionSite.CSVResultsReport.GenerateCSVFile(outputFilePath); statusLogs.AddStatusHeader("Done!"); ((IShowLogs)this).NewLogResultsToShow(statusLogs); }
/// <summary> /// Constructor /// </summary> /// <param name="config"></param> /// <param name="provisionInstructions"></param> /// <param name="showLogsHere"></param> /// <param name="statusLogs"></param> public ProvisionSite(ProvisionConfigSiteAccess config, ProvisionUserInstructions provisionInstructions, IShowLogs showLogsHere, TaskStatusLogs statusLogs) { _showLogsHere = showLogsHere; _config = config; _provisionInstructions = provisionInstructions; if (statusLogs == null) { statusLogs = new TaskStatusLogs(); } _statusLogs = statusLogs; }
/// <summary> /// Generate a maniefest file based on the current Online site /// </summary> /// <param name="statusLogs"></param> /// <param name="pathSecrets"></param> /// <param name="pathOutputFile"></param> /// <param name="ignoreAllUsersGroup">(recommend TRUE) If false, the manifest file will contain the "all users" group</param> private void GenerateManifestFromOnlineSite( TaskStatusLogs statusLogs, string pathSecrets, string pathOutputFile, bool ignoreAllUsersGroup) { var pathOutputs = Path.GetDirectoryName(pathOutputFile); ProvisionConfigSiteAccess secretsConfig; //=========================================================================================== //Get the sign in information //=========================================================================================== try { //Load the config from the files secretsConfig = new ProvisionConfigSiteAccess(pathSecrets); } catch (Exception exSignInConfig) { statusLogs.AddError("Error loading sign in config file"); throw new Exception("1012-327: Error parsing sign in config, " + exSignInConfig.Message); } //=========================================================================================== //Create a place for out output files //=========================================================================================== FileIOHelper.CreatePathIfNeeded(pathOutputs); var provisionSettings = ProvisionConfigExternalDirectorySync.FromDefaults(); //=========================================================================================== //Download all the data we need from the Tableau Online site //=========================================================================================== statusLogs.AddStatusHeader("Retrieving information from Tableau"); UpdateStatusText(statusLogs); var tableauDownload = new TableauProvisionDownload( secretsConfig, this, statusLogs, ignoreAllUsersGroup); try { tableauDownload.Execute(); } catch (Exception exTableauDownload) { statusLogs.AddError("Error retrieving data from Tableau"); throw new Exception("813-0148: Error in Tableau Download, " + exTableauDownload.Message); } //=========================================================================================== //Write the provisioning manifest out to a file //=========================================================================================== statusLogs.AddStatusHeader("Writing out manifest file for Tableau provisioning"); UpdateStatusText(statusLogs); var outputProvisioningRoles = tableauDownload.ProvisioningManifestResults; try { outputProvisioningRoles.GenerateProvisioningManifestFile(pathOutputFile, provisionSettings); } catch (Exception exWriteProvisioningManifest) { statusLogs.AddError("Error creating provisioning manifest"); throw new Exception("1012-252: Error writing provisioning manifest, " + exWriteProvisioningManifest.Message); } }