Пример #1
0
        private void toolStripSave_Click(object sender, EventArgs e)
        {
            try
            {
                richTextBoxInformationMain.Clear();

                var chosenFile = textBoxLoadPatternPath.Text;

                // Prepare the data grid and make sure the output is sorted
                DataTable gridDataTable = (DataTable)_bindingSourceLoadPatternDefinition.DataSource;

                gridDataTable.DefaultView.Sort = "[KEY] ASC";
                gridDataTable.TableName        = "LoadPatternDefinition";

                JArray outputFileArray = new JArray();
                foreach (DataRow singleRow in gridDataTable.DefaultView.ToTable().Rows)
                {
                    JObject individualRow = JObject.FromObject(new
                    {
                        loadPatternKey                        = singleRow[0].ToString(),
                        loadPatternType                       = singleRow[1].ToString(),
                        LoadPatternSelectionQuery             = singleRow[2].ToString(),
                        loadPatternBaseQuery                  = singleRow[3].ToString(),
                        loadPatternAttributeQuery             = singleRow[4].ToString(),
                        loadPatternAdditionalBusinessKeyQuery = singleRow[5].ToString(),
                        loadPatternNotes                      = singleRow[6].ToString(),
                        LoadPatternConnectionKey              = singleRow[7].ToString()
                    });
                    outputFileArray.Add(individualRow);
                }

                string json = JsonConvert.SerializeObject(outputFileArray, Formatting.Indented);

                // Create a backup file, if enabled, and inform the user.
                if (checkBoxBackupFiles.Checked)
                {
                    richTextBoxInformationMain.AppendText(LoadPatternDefinition.BackupLoadPatternDefinition(chosenFile) + "\r\n");
                }

                // Save the file, and inform the user.
                richTextBoxInformationMain.AppendText(LoadPatternDefinition.SaveLoadPatternDefinition(chosenFile, json));

                try
                {
                    ConfigurationSettings.patternDefinitionList = JsonConvert.DeserializeObject <List <LoadPatternDefinition> >(File.ReadAllText(chosenFile));
                }
                catch (Exception ex)
                {
                    richTextBoxInformationMain.AppendText("An issue was encountered committing the information to memory. The reported error is " + ex);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #2
0
        private void UpdatePatternDefinitions(string filePath)
        {
            filePath = Path.GetFullPath(filePath);

            ConfigurationSettings.patternDefinitionList = LoadPatternDefinition.DeserializeLoadPatternDefinition(filePath);

            // Load Pattern definition in memory
            if ((ConfigurationSettings.patternDefinitionList != null) && (!ConfigurationSettings.patternDefinitionList.Any()))
            {
                richTextBoxInformationMain.Text = "There are no pattern definitions / types found in the designated load pattern directory. Please verify if the file " + filePath + " exists.";
            }

            if (ConfigurationSettings.patternDefinitionList != null)
            {
                PopulateLoadPatternDefinitionDataGrid();
                textBoxLoadPatternPath.Text = filePath;
            }
            else
            {
                richTextBoxInformationMain.Text = "The pattern definition file could not be loaded. Please verify if the file " + filePath + " exists.";
            }
        }
Пример #3
0
        public FormMain()
        {
            InitializeComponent();

            // Instantiate the logging
            EventLog eventLog = new EventLog();

            // Set the version of the build for everything
            const string versionNumberForTeamApplication = "v1.6.0";

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

            //richTextBoxInformation.AppendText("Starting from "+GlobalParameters.RootPath+"\r\n\r\n");
            //richTextBoxInformation.AppendText("Script path is " + GlobalParameters.ScriptPath + "\r\n\r\n");

            richTextBoxInformation.AppendText("Initialising the application.\r\n\r\n");

            // Make sure the application and custom location directories exist
            try
            {
                EnvironmentConfiguration.InitialiseRootPath();
                eventLog.Add(Event.CreateNewEvent(EventTypes.Information, "... The TEAM directories are available and initialised.\r\n"));
            }
            catch
            {
                eventLog.Add(Event.CreateNewEvent(EventTypes.Error, "The directories required to operate TEAM are not available and can not be created. Do you have administrative priviliges in the installation directory to create these additional directories?"));
            }

            // Set the root path, to be able to locate the customisable configuration file
            try
            {
                EnvironmentConfiguration.LoadRootPathFile();
                eventLog.Add(Event.CreateNewEvent(EventTypes.Information, "... The core configuration file has been loaded.\r\n"));
            }
            catch
            {
                eventLog.Add(Event.CreateNewEvent(EventTypes.Error, "The core configuration file could not be loaded. Is there a Configuration directory in the TEAM installation location?"));
            }

            // Make sure the configuration file is in memory
            try
            {
                EnvironmentConfiguration.InitialiseConfigurationPath();
                eventLog.Add(Event.CreateNewEvent(EventTypes.Information, "... The user configuration paths are available.\r\n"));
            }
            catch
            {
                eventLog.Add(Event.CreateNewEvent(EventTypes.Error, "An issue was encountered creating or detecting the configuration paths."));
            }

            // Load the available configuration file
            try
            {
                EnvironmentConfiguration.LoadConfigurationFile(GlobalParameters.ConfigurationPath + GlobalParameters.ConfigFileName + '_' + GlobalParameters.WorkingEnvironment + GlobalParameters.FileExtension);
                eventLog.Add(Event.CreateNewEvent(EventTypes.Information, "... The user configuration settings (file) have been loaded.\r\n"));
            }
            catch
            {
                eventLog.Add(Event.CreateNewEvent(EventTypes.Error, "An issue was encountered loading the user configuration file."));
            }

            // Load the pattern definition file
            try
            {
                ConfigurationSettings.patternDefinitionList = LoadPatternDefinition.DeserializeLoadPatternDefinition(GlobalParameters.LoadPatternPath + GlobalParameters.LoadPatternDefinitionFile);
                eventLog.Add(Event.CreateNewEvent(EventTypes.Information, "... The pattern definition file was loaded successfully.\r\n"));
            }
            catch
            {
                eventLog.Add(Event.CreateNewEvent(EventTypes.Error, "An issue was encountered loading the pattern definition file."));
            }


            // Report the events (including errors) back to the user
            int errorCounter = 0;

            foreach (Event individualEvent in eventLog)
            {
                if (individualEvent.eventCode == (int)EventTypes.Error)
                {
                    errorCounter++;
                }

                richTextBoxInformation.AppendText(individualEvent.eventDescription);
            }

            richTextBoxInformation.AppendText($"\r\n{errorCounter} error(s) have been found at startup.\r\n\r\n");


            TestConnections();

            //Startup information
            richTextBoxInformation.AppendText("\r\nApplication initialised - the Taxonomy of ETL Automation Metadata (TEAM). \r\n");
            richTextBoxInformation.AppendText("Welcome to version " + versionNumberForTeamApplication + ".\r\n\r\n");

            labelWorkingEnvironment.Text = "The working environment is: " + GlobalParameters.WorkingEnvironment;
        }
Пример #4
0
        public FormMain()
        {
            InitializeComponent();

            // Set the version of the build for everything
            const string versionNumberForTeamApplication = "v1.6.3";

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

            GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Information, $"The TEAM root path is {GlobalParameters.RootPath}."));
            GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Information, $"The TEAM script path is {GlobalParameters.ScriptPath}."));

            richTextBoxInformation.AppendText("Initialising the application.\r\n\r\n");

            // Root paths (mandatory TEAM directories)
            // Make sure the application and custom location directories exist as per the start-up default.
            try
            {
                LocalTeamEnvironmentConfiguration.InitialiseEnvironmentPaths();
            }
            catch (Exception ex)
            {
                GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error, $"An error was encountered while creating the standard TEAM paths: \r\n\r\n{ex}"));
            }

            #region Load the root path configuration settings (user defined paths and working environment)

            // Load the root file, to be able to locate the (customisable) configuration file.
            // This file contains the configuration directory, the output directory and the working environment.
            string rootPathFileName = GlobalParameters.CorePath + GlobalParameters.PathFileName + GlobalParameters.FileExtension;
            try
            {
                LocalTeamEnvironmentConfiguration.LoadRootPathFile(rootPathFileName, GlobalParameters.ConfigurationPath, GlobalParameters.OutputPath);
                GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Information,
                                                                       $"The core configuration file {rootPathFileName} has been loaded."));
            }
            catch
            {
                GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error,
                                                                       $"The core configuration file {rootPathFileName} could not be loaded. Is there a Configuration directory in the TEAM installation location?"));
            }

            // Environments file
            string environmentFile = GlobalParameters.CorePath + GlobalParameters.JsonEnvironmentFileName + GlobalParameters.JsonExtension;
            try
            {
                TeamEnvironmentCollection.LoadTeamEnvironmentCollection(environmentFile);
                GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Information,
                                                                       $"The environment file {environmentFile} has been loaded."));
            }
            catch
            {
                GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error,
                                                                       $"The environment file {environmentFile} could not be loaded. Does the file exists in the designated (root) location?"));
            }

            #endregion

            #region Check if user configured paths exists (now that they have been loaded from the root file), and create dummy Configuration and Validation files if necessary
            // Configuration Path
            try
            {
                FileHandling.InitialisePath(GlobalParameters.ConfigurationPath);
                GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Information, $"The user defined configuration path {GlobalParameters.ConfigurationPath} is available."));
            }
            catch
            {
                GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error, "The directories required to operate TEAM are not available and can not be created. Do you have administrative privileges in the installation directory to create these additional directories?"));
            }

            // Output Path
            try
            {
                FileHandling.InitialisePath(GlobalParameters.OutputPath);
                GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Information, $"The user defined output path {GlobalParameters.OutputPath} is available."));
            }
            catch
            {
                GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error, "The directories required to operate TEAM are not available and can not be created. Do you have administrative privileges in the installation directory to create these additional directories?"));
            }

            // Create a dummy configuration file if it does not exist.
            var configurationFileName =
                GlobalParameters.ConfigurationPath +
                GlobalParameters.ConfigFileName + '_' +
                GlobalParameters.WorkingEnvironment +
                GlobalParameters.FileExtension;

            try
            {
                if (!File.Exists(configurationFileName))
                {
                    TeamConfiguration.CreateDummyEnvironmentConfigurationFile(configurationFileName);
                    GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Information, $"A new configuration file {configurationFileName} was created."));
                }
                else
                {
                    GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Information, $"The existing configuration file {configurationFileName} was detected."));
                }
            }
            catch
            {
                GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error, $"An issue was encountered creating or detecting the configuration paths for {configurationFileName}."));
            }

            // Create a default validation file if the file does not exist as expected.
            var validationFileName =
                GlobalParameters.ConfigurationPath +
                GlobalParameters.ValidationFileName + '_' +
                GlobalParameters.WorkingEnvironment +
                GlobalParameters.FileExtension;

            try
            {
                ValidationSetting.CreateDummyValidationFile(validationFileName);
            }
            catch
            {
                GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error, $"An issue was encountered creating or detecting the configuration paths for {validationFileName}."));
            }

            // Create a default json configuration file if the file does not exist as expected.
            var jsonConfigurationFileName =
                GlobalParameters.ConfigurationPath +
                GlobalParameters.JsonExportConfigurationFileName + '_' +
                GlobalParameters.WorkingEnvironment +
                GlobalParameters.FileExtension;

            try
            {
                JsonExportSetting.CreateDummyJsonConfigurationFile(jsonConfigurationFileName);
            }
            catch
            {
                GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error, $"An issue was encountered creating or detecting the configuration paths for {jsonConfigurationFileName}."));
            }
            #endregion

            // Load the connections file for the respective environment.
            var connectionFileName =
                GlobalParameters.ConfigurationPath +
                GlobalParameters.JsonConnectionFileName + '_' +
                GlobalParameters.WorkingEnvironment +
                GlobalParameters.JsonExtension;

            TeamConfiguration.ConnectionDictionary = TeamConnectionFile.LoadConnectionFile(connectionFileName);

            #region Load configuration file
            // Load the available configuration file into memory.
            var configurationFile = GlobalParameters.ConfigurationPath + GlobalParameters.ConfigFileName + '_' + GlobalParameters.WorkingEnvironment + GlobalParameters.FileExtension;
            try
            {
                // Load the configuration file.
                TeamConfiguration.LoadTeamConfigurationFile(configurationFile);
                GlobalParameters.EnvironmentMode = TeamConfiguration.EnvironmentMode;
                // Retrieve the events into the main event log.
                GlobalParameters.TeamEventLog.MergeEventLog(TeamConfiguration.ConfigurationSettingsEventLog);
                GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Information, $"The user configuration settings ({configurationFile}) have been loaded."));
            }
            catch
            {
                GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error, $"An issue was encountered loading the user configuration file ({configurationFile})."));
            }
            #endregion

            //FormBase.EnvironmentVersion.GetEnvironmentVersionsFromFile(Path.GetDirectoryName(configurationFile));

            TeamVersionList.LoadVersionList(GlobalParameters.CorePath + GlobalParameters.VersionFileName + GlobalParameters.JsonExtension);

            // Load the pattern definition file.
            try
            {
                GlobalParameters.PatternDefinitionList = LoadPatternDefinition.DeserializeLoadPatternDefinition(GlobalParameters.LoadPatternPath + GlobalParameters.LoadPatternDefinitionFile);
                GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Information, "The pattern definition file was loaded successfully."));
            }
            catch
            {
                GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error, "An issue was encountered loading the pattern definition file."));
            }

            // Report the events (including errors) back to the user
            int errorCounter = 0;
            foreach (Event individualEvent in GlobalParameters.TeamEventLog)
            {
                if (individualEvent.eventCode == (int)EventTypes.Error)
                {
                    errorCounter++;
                }
            }

            if (errorCounter > 0)
            {
                richTextBoxInformation.AppendText(
                    $"{errorCounter} error(s) have been found at startup. Please check the Event Log in the menu.\r\n\r\n");
            }

            TestConnections();

            //Startup information
            richTextBoxInformation.AppendText("\r\nApplication initialised - the Taxonomy of ETL Automation Metadata (TEAM). \r\n");
            richTextBoxInformation.AppendText("Welcome to version " + versionNumberForTeamApplication + ".\r\n\r\n");

            labelWorkingEnvironment.Text = GlobalParameters.WorkingEnvironment; //+"("+GlobalParameters.WorkingEnvironmentInternalId+")";
            labelEnvironmentMode.Text    = GlobalParameters.EnvironmentMode.ToString();
        }