Esempio n. 1
0
        /*
         * Watermarking Tab Events
         */
        private void edit_watermarker(object sender, EventArgs e)
        {
            Control box    = (Control)sender;
            Button  button = (Button)sender;

            string page_location = box.Name.Split('_')[1];
            Label  label         = this.Controls.Find("label_" + page_location, true).FirstOrDefault() as Label;

            if (label.Text == "")
            {
                watermarkContextMenu.Show(button, new Point(0, button.Height));
            }
            else
            {
                SerializableStringDictionary related_config = Configurator.GetConfigSerializableStringDict(page_location);
                if (label.Text == "Text")
                {
                    Form wm = new Text_Watermark(page_location, related_config);
                    wm.ShowDialog(this);
                }
                else if (label.Text == "Page Number")
                {
                    Form wm = new Page_Number_Watermark(page_location, related_config);
                    wm.ShowDialog(this);
                }
                else if (label.Text == "Image")
                {
                    Form wm = new Image_Watermark(page_location, related_config);
                    wm.ShowDialog(this);
                }
            }
        }
Esempio n. 2
0
 private void loadPageLayoutConfigs()
 {
     foreach (string page_layout_location in this.watermark_page_location_names)
     {
         SerializableStringDictionary watermark_settings = Configurator.GetConfigSerializableStringDict(page_layout_location);
         if (watermark_settings != null)
         {
             Label  label          = this.Controls.Find("label_" + page_layout_location, true).FirstOrDefault() as Label;
             string new_label_text = "";
             if (watermark_settings["watermark_type"] == "text")
             {
                 new_label_text = "Text";
             }
             else if (watermark_settings["watermark_type"] == "image")
             {
                 new_label_text = "Image";
             }
             else if (watermark_settings["watermark_type"] == "page_number")
             {
                 new_label_text = "Page Number";
             }
             // Don't change labels if no response, exit early
             else
             {
                 return;
             }
             label.Text = new_label_text;
             Button button = this.Controls.Find("edit_" + page_layout_location, true).FirstOrDefault() as Button;
             button.Text = "Edit";
         }
     }
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
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.");
            }
        }
Esempio n. 5
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);
            }
        }