Exemple #1
0
        public FormMain()
        {
            // Set the version of the build for everything
            const string versionNumberForTeamApplication = "v1.5.5.2";

            // Placeholder for the error handling
            var errorMessage = new StringBuilder();

            errorMessage.AppendLine("Error were detected:");
            errorMessage.AppendLine();
            var errorDetails = new StringBuilder();

            errorDetails.AppendLine();
            var errorCounter = 0;

            InitializeComponent();
            Text = "TEAM - Taxonomy for ETL Automation Metadata " + versionNumberForTeamApplication;

            // Make sure the application and custom location directories exist
            ClassEnvironmentConfiguration.InitialiseRootPath();

            // Set the root path, to be able to locate the customisable configuration file
            ClassEnvironmentConfiguration.LoadRootPathFile();

            // Make sure the configuration file is in memory
            ClassEnvironmentConfiguration.InitialiseConfigurationPath();

            // Load the available configuration file
            ClassEnvironmentConfiguration.LoadConfigurationFile(GlobalParameters.ConfigurationPath + GlobalParameters.ConfigfileName + '_' + GlobalParameters.WorkingEnvironment + GlobalParameters.FileExtension);

            //Startup information
            richTextBoxInformation.Text = "Application initialised - the Taxonomy of ETL Automation Metadata (TEAM). \r\n";
            richTextBoxInformation.AppendText("Version " + versionNumberForTeamApplication + "\r\n\r\n");
            //richTextBoxInformation.AppendText("Source code on Github: https://github.com/RoelantVos/TEAM \r\n\r\n");

            labelWorkingEnvironment.Text = "The working environment is: " + GlobalParameters.WorkingEnvironment;

            TestConnections();

            if (errorCounter > 0)
            {
                richTextBoxInformation.AppendText(errorMessage.ToString());
            }
        }
        /// <summary>
        ///    Commit the changes to memory, save the configuration settings to disk and create a backup
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void saveConfigurationFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string workingEnvironment = "";

            if (radioButtonDevelopment.Checked)
            {
                workingEnvironment = "Development";
            }
            else if (radioButtonProduction.Checked)
            {
                workingEnvironment = "Production";
            }
            else
            {
                MessageBox.Show("An error occurred: neither the Development or Production radiobutton was selected.", "An issue has been encountered", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // Update the root path file, part of the core solution to be able to store the config and output path
            var rootPathConfigurationFile = new StringBuilder();

            rootPathConfigurationFile.AppendLine("/* TEAM File Path Settings */");
            rootPathConfigurationFile.AppendLine("/* Saved at " + DateTime.Now + " */");
            rootPathConfigurationFile.AppendLine("ConfigurationPath|" + textBoxConfigurationPath.Text + "");
            rootPathConfigurationFile.AppendLine("OutputPath|" + textBoxOutputPath.Text + "");
            rootPathConfigurationFile.AppendLine("WorkingEnvironment|" + workingEnvironment + "");
            rootPathConfigurationFile.AppendLine("/* End of file */");

            using (var outfile = new StreamWriter(GlobalParameters.RootPath + GlobalParameters.PathfileName + GlobalParameters.FileExtension))
            {
                outfile.Write(rootPathConfigurationFile.ToString());
                outfile.Close();
            }

            // Update the paths in memory
            GlobalParameters.OutputPath        = textBoxOutputPath.Text;
            GlobalParameters.ConfigurationPath = textBoxConfigurationPath.Text;

            GlobalParameters.WorkingEnvironment = workingEnvironment;

            // Make sure the new paths as updated are available upon save for backup etc.
            ClassEnvironmentConfiguration.InitialiseConfigurationPath();

            // Create a file backup for the configuration file
            try
            {
                ClassEnvironmentConfiguration.CreateEnvironmentConfigurationBackupFile();
                richTextBoxInformation.Text = "A backup of the current configuration was made at " + DateTime.Now + " in " + textBoxConfigurationPath.Text + ".";
            }
            catch (Exception)
            {
                richTextBoxInformation.Text = "TEAM was unable to create a backup of the configuration file.";
            }


            // Update the in-memory variables for use throughout the application, to commit the saved changes for runtime use.
            // This is needed before saving to disk, as the EnvironmentConfiguration Class retrieves the values from memory.
            UpdateConfigurationInMemory();


            // Save the information
            ClassEnvironmentConfiguration.SaveConfigurationFile();
            parentFormMain.RevalidateFlag = true;
        }