private Watermarker CreateWatermarkerFromConfig() { Watermarker wm = new Watermarker(); string[] pageLocations = { "top_left", "top_center", "top_right", "bottom_left", "bottom_center", "bottom_right" }; foreach (string pageLocation in pageLocations) { string settingsPageLocation = pageLocation.Split('_')[0] + pageLocation.Split('_')[1].First() + pageLocation.Split('_')[1].Substring(1); wm.SetPageLocationWatermarkFromConfig(pageLocation, Configurator.GetConfigSerializableStringDict(settingsPageLocation)); } return(wm); }
private string GenerateSingleExport(string exportSite, string exportUsername, string exportViewLocation, string exportAttachmentType, string exportFilename, Dictionary <string, string> viewFilterDictionary) { // Generate Single File try { TableauRepository tabrep = new TableauRepository( Configurator.GetConfig("tableau_server"), Configurator.GetConfig("repository_pw"), "readonly" ); tabrep.logger = this.Logger; Tabcmd tabcmd = new Tabcmd( Configurator.GetConfig("tabcmd_program_location"), Configurator.GetConfig("tableau_server"), Configurator.GetConfig("server_admin_username"), Configurator.GetConfig("server_admin_password"), exportSite, Configurator.GetConfig("tabcmd_config_location"), 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, Configurator.GetConfig("smtp_server")); Watermarker wm = new Watermarker(); string[] pageLocations = { "top_left", "top_center", "top_right", "bottom_left", "bottom_center", "bottom_right" }; foreach (string pageLocation in pageLocations) { string settingsPageLocation = pageLocation.Split('_')[0] + pageLocation.Split('_')[1].First() + pageLocation.Split('_')[1].Substring(1); wm.SetPageLocationWatermarkFromConfig(pageLocation, Configurator.GetConfigSerializableStringDict(settingsPageLocation)); } string filename = tabemailer.GenerateExportAndWatermark(exportUsername, exportViewLocation, exportAttachmentType, viewFilterDictionary, wm); string[] fileEnding = filename.Split('.'); string finalFilename = String.Format("{0}{1}.{2}", Configurator.GetConfig("export_archive_folder"), exportFilename, fileEnding[fileEnding.Length - 1]); this.Logger.Log(String.Format("Finalizing file and putting it here: {0}", finalFilename)); File.Copy(filename, finalFilename, true); this.Logger.Log(String.Format("Removing original file {0}", filename)); File.Delete(filename); return("Finished single export file creation. Saved to: " + finalFilename); } 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); return("Single export failed. Please see logs for more information."); } }