private void bt_addMetamodelTables_Click(object sender, EventArgs e)
        {
            MetamodelTables mtTables = new MetamodelTables();

            List <string> listBoxTableList = lb_metamodelTables.Items.Cast <string>().ToList();

            if (mtTables.ValidateMetamodelTableName(tb_inptMetamodelTables.Text.ToString().ToLower(), listBoxTableList.ConvertAll(d => d.ToLower())))
            {
                string escapedTableName = mtTables.TableNameEscapeCharacters(tb_inptMetamodelTables.Text.ToString());

                this.lb_metamodelTables.Items.Add(escapedTableName);
                this.tb_inptMetamodelTables.Text = "";
            }
            else
            {
                puf_popUpForm popup = new puf_popUpForm(puf_popUpForm._feedbackErrorType, "Failed to add table: " + Environment.NewLine + "Input contains spaces, already exists or " + Environment.NewLine + "does not have prefix OSSYS or OSLTM.");
                DialogResult  dg    = popup.ShowDialog();
            }
        }
        private void bt_TestSaConnection_Click(object sender, EventArgs e, string dbms, DBConnector.SQLConnStringModel SQLConnectionString = null, DBConnector.OracleConnStringModel OracleConnectionString = null)
        {
            string testConnectionResult = null;

            if (dbms.ToLower().Equals("sqlserver"))
            {
                SQLConnectionString.userId = this.tb_iptSaUsername.Text;
                SQLConnectionString.pwd    = this.tb_iptSaPwd.Text;

                try {
                    var           connector  = new DBConnector.SLQDBConnector();
                    SqlConnection connection = connector.SQLOpenConnection(SQLConnectionString);
                    connector.SQLCloseConnection(connection);
                    testConnectionResult = _successConnectionTest;
                } catch {
                    testConnectionResult = _failedConnectionTest;
                }
            }
            else if (dbms.ToLower().Equals("oracle"))
            {
                OracleConnectionString.userId = this.tb_iptSaUsername.Text;
                OracleConnectionString.pwd    = this.tb_iptSaPwd.Text;

                try {
                    var connector = new DBConnector.OracleDBConnector();
                    OracleConnection connection = connector.OracleOpenConnection(OracleConnectionString);
                    connector.OracleCloseConnection(connection);
                    testConnectionResult = _successConnectionTest;
                } catch {
                    testConnectionResult = _failedConnectionTest;
                }
            }

            puf_popUpForm popup = new puf_popUpForm(puf_popUpForm._feedbackTestConnectionType, testConnectionResult);
            DialogResult  dg    = popup.ShowDialog();
        }
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            /* REFACTOR */

            OSDiagToolForm.DataHelperClass.strConfigurations configurationsHelper = (OSDiagToolForm.DataHelperClass.strConfigurations)e.Argument;

            // Initialization
            Program.OSDiagToolInitialization();


            // Get Platform and Server files
            if (!backgroundWorker1.CancellationPending)
            {
                if (configurationsHelper.FormConfigurations.cbConfs.TryGetValue(OSDiagToolForm.OsDiagForm._plPlatformAndServerFiles, out bool getPSandServerConfFiles) && getPSandServerConfFiles == true)
                {
                    backgroundWorker1.ReportProgress(8, configurationsHelper.popup);
                    Program.GetPlatformAndServerFiles();
                }
            }


            // Export Event Viewer and Server logs
            if (!backgroundWorker1.CancellationPending)
            {
                if (configurationsHelper.FormConfigurations.cbConfs.TryGetValue(OSDiagToolForm.OsDiagForm._slEvt, out bool getEvt) && getEvt == true)
                {
                    backgroundWorker1.ReportProgress(5, configurationsHelper.popup);
                    Program.ExportEventViewerAndServerLogs();
                }
            }

            // Copy IIS Access logs
            if (!backgroundWorker1.CancellationPending)
            {
                if (configurationsHelper.FormConfigurations.cbConfs.TryGetValue(OSDiagToolForm.OsDiagForm._slIisLogs, out bool getIisLogs) && getIisLogs == true)
                {
                    backgroundWorker1.ReportProgress(6, configurationsHelper.popup);
                    Program.CopyIISAccessLogs(configurationsHelper.FormConfigurations.iisLogsNrDays);
                }
            }

            // Database Troubleshoot
            if (!backgroundWorker1.CancellationPending)
            {
                if (configurationsHelper.FormConfigurations.cbConfs.TryGetValue(OSDiagToolForm.OsDiagForm._diDbTroubleshoot, out bool _doDbTroubleshoot) && _doDbTroubleshoot == true)
                {
                    backgroundWorker1.ReportProgress(10, configurationsHelper.popup);
                    Platform.PlatformConnectionStringDefiner ConnectionStringDefiner = new Platform.PlatformConnectionStringDefiner();
                    Platform.PlatformConnectionStringDefiner ConnStringHelper        = ConnectionStringDefiner.GetConnectionString(Program.dbEngine, false, true, ConnectionStringDefiner, configurationsHelper.FormConfigurations.saUser, configurationsHelper.FormConfigurations.saPwd);

                    if (Program.dbEngine.Equals("sqlserver"))
                    {
                        Program.DatabaseTroubleshootProgram(configurationsHelper.ConfigFileConfigurations, ConnStringHelper.SQLConnString);
                    }
                    else if (Program.dbEngine.Equals("oracle"))
                    {
                        Program.DatabaseTroubleshootProgram(configurationsHelper.ConfigFileConfigurations, null, ConnStringHelper.OracleConnString);
                    }
                }
            }

            // Export Platform Metamodel
            if (!backgroundWorker1.CancellationPending)
            {
                if (configurationsHelper.FormConfigurations.cbConfs.TryGetValue(OSDiagToolForm.OsDiagForm._diMetamodel, out bool _getPlatformMetamodel) && _getPlatformMetamodel == true)
                {
                    backgroundWorker1.ReportProgress(9, configurationsHelper.popup);
                    Platform.PlatformConnectionStringDefiner ConnectionStringDefiner = new Platform.PlatformConnectionStringDefiner();
                    Platform.PlatformConnectionStringDefiner ConnStringHelper        = ConnectionStringDefiner.GetConnectionString(Program.dbEngine, false, false, ConnectionStringDefiner);

                    if (Program.dbEngine.Equals("sqlserver"))
                    {
                        Program.ExportPlatformMetamodel(Program.dbEngine, configurationsHelper.ConfigFileConfigurations, configurationsHelper.FormConfigurations, ConnStringHelper.SQLConnString, null);
                    }
                    else if (Program.dbEngine.Equals("oracle"))
                    {
                        Program.ExportPlatformMetamodel(Program.dbEngine, configurationsHelper.ConfigFileConfigurations, configurationsHelper.FormConfigurations, null, ConnStringHelper.OracleConnString);
                    }
                }
            }

            // Export Platform Logs
            if (!backgroundWorker1.CancellationPending)
            {
                if (configurationsHelper.FormConfigurations.cbConfs.TryGetValue(OSDiagToolForm.OsDiagForm._plPlatformLogs, out bool _getPlatformLogs) && _getPlatformLogs == true)
                {
                    backgroundWorker1.ReportProgress(7, configurationsHelper.popup);
                    Platform.PlatformConnectionStringDefiner ConnectionStringDefiner = new Platform.PlatformConnectionStringDefiner();
                    Platform.PlatformConnectionStringDefiner ConnStringHelper        = ConnectionStringDefiner.GetConnectionString(Program.dbEngine, Program.separateLogCatalog, false, ConnectionStringDefiner);

                    if (Program.dbEngine.Equals("sqlserver"))
                    {
                        Program.ExportServiceCenterLogs(Program.dbEngine, configurationsHelper.ConfigFileConfigurations, configurationsHelper.FormConfigurations, ConnStringHelper.SQLConnString, null);
                    }
                    else if (Program.dbEngine.Equals("oracle"))
                    {
                        Program.ExportServiceCenterLogs(Program.dbEngine, configurationsHelper.ConfigFileConfigurations, configurationsHelper.FormConfigurations, null, ConnStringHelper.OracleConnString, ConnStringHelper.AdminSchema);
                    }
                }
            }

            // IIS Thread dumps
            if (!backgroundWorker1.CancellationPending)
            {
                if (configurationsHelper.FormConfigurations.cbConfs.TryGetValue(OSDiagToolForm.OsDiagForm._tdIis, out bool getIisThreadDumps) && getIisThreadDumps == true)
                {
                    backgroundWorker1.ReportProgress(1, configurationsHelper.popup);
                    Program.CollectThreadDumpsProgram(getIisThreadDumps, false);
                }
            }

            // OutSystems Services Thread dumps
            if (!backgroundWorker1.CancellationPending)
            {
                if (configurationsHelper.FormConfigurations.cbConfs.TryGetValue(OSDiagToolForm.OsDiagForm._tdOsServices, out bool _getOsThreadDumps) && _getOsThreadDumps == true)
                {
                    backgroundWorker1.ReportProgress(2, configurationsHelper.popup);
                    Program.CollectThreadDumpsProgram(false, _getOsThreadDumps);
                }
            }

            // IIS Memory Dumps
            if (!backgroundWorker1.CancellationPending)
            {
                if (configurationsHelper.FormConfigurations.cbConfs.TryGetValue(OSDiagToolForm.OsDiagForm._mdIis, out bool getIisMemDumps) && getIisMemDumps == true)
                {
                    backgroundWorker1.ReportProgress(3, configurationsHelper.popup);
                    Program.CollectMemoryDumpsProgram(getIisMemDumps, false);
                }
            }

            // OutSystems Services Memory Dumps
            if (!backgroundWorker1.CancellationPending)
            {
                if (configurationsHelper.FormConfigurations.cbConfs.TryGetValue(OSDiagToolForm.OsDiagForm._mdOsServices, out bool getOsMemDumps) && getOsMemDumps == true)
                {
                    backgroundWorker1.ReportProgress(4, configurationsHelper.popup);
                    Program.CollectMemoryDumpsProgram(false, getOsMemDumps);
                }
            }

            backgroundWorker1.ReportProgress(11, configurationsHelper.popup);
            Program.GenerateZipFile();
            backgroundWorker1.ReportProgress(12, configurationsHelper.popup); // Last step to close pop up

            /* REFACTOR */



            if (!backgroundWorker1.CancellationPending == true)
            {
                puf_popUpForm popup2 = new puf_popUpForm(puf_popUpForm._feedbackDoneType, _doneMessage + Environment.NewLine + Program._endFeedback);
                popup2.ShowDialog();
            }
            else
            {
                puf_popUpForm popup2 = new puf_popUpForm(puf_popUpForm._feedbackDoneType, _operationCancelled + Environment.NewLine + Program._endFeedback);
                popup2.ShowDialog();
            }
        }