Пример #1
0
        private void bt_runOsDiagTool_Click(object sender, EventArgs e, OSDiagToolConf.ConfModel.strConfModel configurations)
        {
            var           formConfigurations = new OSDiagToolForm.OsDiagFormConfModel.strFormConfigurationsModel();
            List <string> tableNameHelper    = new List <string>();

            if (tb_iptSaUsername.Text.Equals("") || tb_iptSaPwd.Text.Equals(""))  // if no input is provided in user or pwd, then DBTroubleshoot doesn't run
            {
                cb_dbTroubleshoot.Checked = false;
            }

            formConfigurations.saUser          = tb_iptSaUsername.Text.ToString();
            formConfigurations.saPwd           = tb_iptSaPwd.Text.ToString();
            formConfigurations.iisLogsNrDays   = Convert.ToInt32(nud_iisLogsNrDays.Value);
            formConfigurations.osLogTopRecords = Convert.ToInt32(nud_topLogs.Value);
            foreach (object item in lb_metamodelTables.Items)
            {
                tableNameHelper.Add(item.ToString());
            }

            formConfigurations.metamodelTables = tableNameHelper;

            Dictionary <string, bool> dictHelper = new Dictionary <string, bool>()
            {
                { _tdIis, cb_iisThreads.Checked },
                { _tdOsServices, cb_osServicesThreads.Checked },
                { _mdIis, cb_iisMemDumps.Checked },
                { _mdOsServices, cb_osMemDumps.Checked },
                { _slEvt, cb_EvtViewerLogs.Checked },
                { _slIisLogs, cb_iisAccessLogs.Checked },
                { _diMetamodel, cb_dbPlatformMetamodel.Checked },
                { _diDbTroubleshoot, cb_dbTroubleshoot.Checked },
                { _plPlatformLogs, cb_platformLogs.Checked },
                { _plPlatformAndServerFiles, cb_platformAndServerFiles.Checked },
            };

            formConfigurations.cbConfs = dictHelper;

            var configurationsHelper = new DataHelperClass.strConfigurations();

            configurationsHelper.FormConfigurations = new OSDiagToolForm.OsDiagFormConfModel.strFormConfigurationsModel();
            configurationsHelper.FormConfigurations = formConfigurations;

            int           numberOfSteps = OSDiagToolHelper.CountSteps(configurationsHelper.FormConfigurations.cbConfs);
            puf_popUpForm popup         = new puf_popUpForm(puf_popUpForm._feedbackWaitType, OsDiagForm._waitMessage, totalSteps: numberOfSteps + 2); // totalSteps + 2 for the zipping and pop up close

            popup.Show();
            popup.Refresh();
            configurationsHelper.popup = popup;

            configurationsHelper.ConfigFileConfigurations = new OSDiagToolConf.ConfModel.strConfModel();
            configurationsHelper.ConfigFileConfigurations = configurations;


            backgroundWorker1.RunWorkerAsync(configurationsHelper);
            Cursor = Cursors.Arrow;
        }
Пример #2
0
        public static void PlatformLogExporter(string dbEngine, List <string> tableNames, OSDiagToolForm.OsDiagFormConfModel.strFormConfigurationsModel FormConfigurations, string outputDestination, int queryTimeout, DBConnector.SQLConnStringModel SQLConnectionString = null,
                                               DBConnector.OracleConnStringModel OracleConnectionString = null, string adminSchema = null)
        {
            if (dbEngine.ToLower().Equals("sqlserver"))
            {
                var           connector  = new DBConnector.SLQDBConnector();
                SqlConnection connection = connector.SQLOpenConnection(SQLConnectionString);

                using (connection) {
                    foreach (string table in tableNames)
                    {
                        string sqlQuery = "SELECT TOP {0} * FROM {1} ORDER BY INSTANT DESC";
                        sqlQuery = string.Format(sqlQuery, FormConfigurations.osLogTopRecords, table);

                        FileLogger.TraceLog(string.Format("Exporting log table {0} ", table));

                        CSVExporter.SQLToCSVExport(dbEngine, table, Path.Combine(outputDestination), queryTimeout, sqlQuery, connection, null);
                    }
                }
            }
            else if (dbEngine.ToLower().Equals("oracle"))
            {
                var connector = new DBConnector.OracleDBConnector();
                OracleConnection connection = connector.OracleOpenConnection(OracleConnectionString);

                using (connection) {
                    foreach (string table in tableNames)
                    {
                        string oracleQuery = "SELECT * FROM (SELECT * FROM {0}.{1} ORDER BY INSTANT DESC) WHERE ROWNUM < {2}";
                        oracleQuery = string.Format(oracleQuery, adminSchema, table, FormConfigurations.osLogTopRecords);

                        FileLogger.TraceLog(string.Format("Exporting log table {0} ", table));

                        CSVExporter.SQLToCSVExport(dbEngine, table, outputDestination, queryTimeout, oracleQuery, null, connection);
                    }
                }
            }
        }