private Watermarker create_watermarker_from_config() { Watermarker wm = new Watermarker(); string[] page_locations = { "top_left", "top_center", "top_right", "bottom_left", "bottom_center", "bottom_right" }; foreach (string page_location in page_locations) { string settingsPageLocation = page_location.Split('_')[0] + page_location.Split('_')[1].First() + page_location.Split('_')[1].Substring(1); wm.setPageLocationWatermarkFromConfig(page_location, Configurator.GetConfigSerializableStringDict(settingsPageLocation)); } return(wm); }
/* * Test Page Methods */ private void create_test_export(object sender, EventArgs e) { // Needs validation here TextBox[] elements_to_validate = { testFileSaveLocation, testFilename, testSite, testUsernameForImpersonation, testViewLocation }; bool validation = this.validate_set_of_elements(elements_to_validate); if (validation == false) { return; } Progress progress = new Progress(0, "Creating test file"); progress.Show(this); progress.Update(); try { TableauRepository tabrep = new TableauRepository(tableau_server_url.Text, repositoryPW.Text, "readonly"); tabrep.logger = this.logger; Tabcmd tabcmd = new Tabcmd(tabcmdProgramLocation.Text, tableau_server_url.Text, server_admin_username.Text, server_password.Text, testSite.Text, tabcmdConfigLocation.Text, tabrep, this.logger); // Emailer here is used because the Watermarking is built in there. Would it make more sense to move it to Tabcmd eventually, or its own class? BeholdEmailer tabemailer = new BeholdEmailer(tabcmd, emailServer.Text); Watermarker wm = new Watermarker(); string[] page_locations = { "top_left", "top_center", "top_right", "bottom_left", "bottom_center", "bottom_right" }; foreach (string page_location in page_locations) { string settingsPageLocation = page_location.Split('_')[0] + page_location.Split('_')[1].First() + page_location.Split('_')[1].Substring(1); wm.setPageLocationWatermarkFromConfig(page_location, Configurator.GetConfigSerializableStringDict(settingsPageLocation)); } string filename = tabemailer.generate_export_and_watermark(testUsernameForImpersonation.Text, testViewLocation.Text, "fullpdf", new Dictionary <string, string>(), wm); string[] file_ending = filename.Split('.'); string final_filename = String.Format("{0}{1}.{2}", testFileSaveLocation.Text, testFilename.Text, file_ending[file_ending.Length - 1]); this.logger.Log(String.Format("Finalizing file and putting it here: {0}", final_filename)); File.Copy(filename, final_filename, true); this.logger.Log(String.Format("Removing original file {0}", filename)); File.Delete(filename); progress.finish_progress_bar(100); progress.update_status("Export created successfully!"); } catch (ConfigurationException ce) { progress.finish_progress_bar(33); progress.update_status("Export failed for some reason, most likely bad settings.\nCheck logs for more info"); this.logger.Log(ce.Message); } }