Пример #1
0
        public bool send_email()
        {
            try
            {
                BeholdEmailer tabemailer = this.create_behold_emailer_from_config();
                Watermarker   wm         = this.create_watermarker_from_config();

                try
                {
                    bool result;


                    result = tabemailer.generate_email_from_view(emailSender.Text, new string[1] {
                        testEmailRecipient.Text
                    }, new string[0] {
                    }, new string[0] {
                    }, testEmailSubject.Text, "Please see attached Tableau PDF", testUsernameForImpersonation.Text,
                                                                 testViewLocation.Text, "fullpdf", new Dictionary <String, String>(), wm);

                    return(result);
                }
                catch (ConfigurationException ce)
                {
                    this.logger.Log(ce.Message);
                    return(false);
                }
            }
            // From Repository Failing
            catch (ConfigurationException ce)
            {
                this.logger.Log(ce.Message);
                return(false);
            }
        }
Пример #2
0
        public bool send_email(string site, string[] email_to, string[] email_cc, string[] email_bcc, string email_subject, string username_for_impersonation, string view_location, Dictionary <String, String> view_filter_dictionary)
        {
            try
            {
                BeholdEmailer tabemailer = this.create_behold_emailer_from_config(site);
                Watermarker   wm         = this.create_watermarker_from_config();

                try
                {
                    bool result;


                    result = tabemailer.generate_email_from_view(emailSender.Text, email_to, email_cc, email_bcc, email_subject, "Please see attached Tableau PDF", username_for_impersonation,
                                                                 view_location, "fullpdf", view_filter_dictionary, wm);

                    return(result);
                }
                catch (ConfigurationException ce)
                {
                    this.logger.Log(ce.Message);
                    return(false);
                }
            }
            // From Repository Failing
            catch (ConfigurationException ce)
            {
                this.logger.Log(ce.Message);
                return(false);
            }
        }
Пример #3
0
        public bool SendEmail(string site, string[] emailTo, string[] emailCc, string[] emailBcc, string emailSubject, string usernameForImpersonation, string viewLocation, Dictionary <String, String> viewFiltersMap, string attachmentContentType)
        {
            try
            {
                BeholdEmailer tabemailer = this.CreateBeholdEmailerFromConfig(site);
                Watermarker   wm         = this.CreateWatermarkerFromConfig();

                try
                {
                    bool result;
                    this.Logger.Log("Fixin' to send the e-mail");
                    result = tabemailer.GenerateEmailFromView(Configurator.GetConfig("email_sender"), emailTo, emailCc, emailBcc, emailSubject, "Please see attached Tableau file", usernameForImpersonation,
                                                              viewLocation, attachmentContentType.ToLower(), viewFiltersMap, wm);

                    return(result);
                }
                catch (ConfigurationException ce)
                {
                    this.Logger.Log(ce.Message);
                    return(false);
                }
            }
            // From Repository Failing
            catch (ConfigurationException ce)
            {
                this.Logger.Log(ce.Message);
                return(false);
            }
        }
Пример #4
0
        public bool SendEmail()
        {
            try
            {
                BeholdEmailer tabemailer = this.CreateBeholdEmailerFromConfig();
                Watermarker   wm         = this.CreateWatermarkerFromConfig();

                try
                {
                    bool result;

                    result = tabemailer.GenerateEmailFromView(Configurator.GetConfig("email_sender"), new string[1] {
                        testEmailRecipient.Text
                    }, new string[0] {
                    }, new string[0] {
                    }, testEmailSubject.Text, "Please see attached Tableau file", singleUsernameForImpersonation.Text,
                                                              singleViewLocation.Text, "fullpdf", new Dictionary <String, String>(), wm);

                    return(result);
                }
                catch (ConfigurationException ce)
                {
                    this.Logger.Log(ce.Message);
                    return(false);
                }
            }
            // From Repository Failing
            catch (ConfigurationException ce)
            {
                this.Logger.Log(ce.Message);
                return(false);
            }
        }
Пример #5
0
        private BeholdEmailer CreateBeholdEmailerFromConfig(string site)
        {
            var tabrep = new TableauRepository(
                Configurator.GetConfig("tableau_server"),
                Configurator.GetConfig("repository_pw"),
                "readonly"
                )
            {
                logger = this.Logger
            };
            var tabcmd = new Tabcmd(
                Configurator.GetConfig("tabcmd_program_location"),
                Configurator.GetConfig("tableau_server"),
                Configurator.GetConfig("server_admin_username"),
                Configurator.GetConfig("server_admin_password"),
                site,
                Configurator.GetConfig("tabcmd_config_location"),
                tabrep,
                this.Logger
                );

            BeholdEmailer tabemailer = new BeholdEmailer(tabcmd, this.CreateSmtpClientFromConfig());

            tabemailer.Logger = this.Logger;
            tabemailer.HtmlEmailTemplateFilename = Configurator.GetConfig("html_email_template_filename");
            tabemailer.TextEmailTemplateFilename = Configurator.GetConfig("text_email_template_filename");
            return(tabemailer);
        }
Пример #6
0
        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.");
            }
        }
Пример #7
0
        /*
         * 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);
            }
        }
Пример #8
0
        private BeholdEmailer create_behold_emailer_from_config(string site)
        {
            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, site,
                                       tabcmdConfigLocation.Text, tabrep, this.logger);


            BeholdEmailer tabemailer = new BeholdEmailer(tabcmd, this.create_smtp_client_from_config());

            tabemailer.logger = this.logger;
            tabemailer.html_email_template_filename = htmlEmailFilename.Text;
            tabemailer.text_email_template_filename = textEmailFilename.Text;
            return(tabemailer);
        }
Пример #9
0
        public bool SendEmail(string scheduleName)
        {
            try
            {
                BeholdEmailer tabemailer = this.CreateBeholdEmailerFromConfig();
                Watermarker   wm         = this.CreateWatermarkerFromConfig();

                try
                {
                    bool result;

                    if (scheduleName != "")
                    {
                        tabemailer.ExportArchiveFolderPath = Configurator.GetConfig("export_archive_folder");
                        result = tabemailer.GenerateEmailsFromNamedScheduleInRepository(scheduleName, Configurator.GetConfig("email_sender"), wm);
                    }
                    else
                    {
                        result = tabemailer.GenerateEmailFromView(Configurator.GetConfig("email_sender"), new string[1] {
                            testEmailRecipient.Text
                        }, new string[0] {
                        }, new string[0] {
                        }, testEmailSubject.Text, "Please see attached file", singleUsernameForImpersonation.Text,
                                                                  singleViewLocation.Text, ExportTypeIndexMap[Int32.Parse(Configurator.GetConfig("single_export_type_index"))], new Dictionary <String, String>(), wm);
                    }

                    return(result);
                }
                catch (ConfigurationException ce)
                {
                    this.Logger.Log(ce.Message);
                    return(false);
                }
            }
            // From Repository Failing
            catch (ConfigurationException ce)
            {
                this.Logger.Log(ce.Message);
                return(false);
            }
        }