Esempio n. 1
0
        private void GetTables(CUCMAXLProfile myAXLProfile)
        {
            // Clear table list
            tvTables.Nodes.Clear();

            // Run AXL Query
            CUCMAXLClient myClient = new CUCMAXLClient(myAXLProfile.AXLHost, myAXLProfile.AXLUser, myAXLProfile.AXLPass);

            if (myClient.RunQuery(@"select tabname, nrows  from systables where flags = 8 order by tabname asc"))
            {
                // We received an error; put the error in the status bar
                toolStripStatusLabel1.Text = "SQL Error: " + myClient.ErrorMsg;
                return;
            }

            // Set the record count in the status bar
            toolStripStatusLabel1.Text = "Table count: " + myClient.ReturnDataSet.Count.ToString();

            // Loop over all records
            foreach (Dictionary <string, string> sqlRecord in myClient.ReturnDataSet)
            {
                // Add to TreeView
                TreeNode rootNode = new TreeNode();
                Decimal  rowCount = Decimal.Parse(sqlRecord["nrows"]);
                rootNode.Text = sqlRecord["tabname"] + " (" + rowCount.ToString("0.#") + ")";
                rootNode.Tag  = sqlRecord["tabname"];
                tvTables.Nodes.Add(rootNode);
            }
        }
Esempio n. 2
0
        public bool Validate()
        {
            bool          isValid    = false;
            CUCMAXLClient testClient = new CUCMAXLClient(AXLHost, AXLUser, AXLPass);

            if (testClient.RunQuery("select count(*) from applicationuser as appusercount"))
            {
                // We received an error
                AXLError = testClient.ErrorMsg;
            }
            else
            {
                isValid = true;
            }
            return(isValid);
        }
Esempio n. 3
0
        private void RunQueryToPane(CUCMAXLProfile myAXLProfile, string sqlQuery)
        {
            // Clear existing results
            dataGridView1.DataSource = null;
            dataGridView1.Rows.Clear();
            if (myAXLSQLApp.currentAXLProfile != null)
            {
                // Run AXL Query
                CUCMAXLClient myClient = new CUCMAXLClient(
                    myAXLProfile.AXLHost,
                    myAXLProfile.AXLUser,
                    myAXLProfile.AXLPass
                    );
                if (myClient.RunQuery(sqlQuery))
                {
                    // We received an error; put the error in the status bar
                    toolStripStatusLabel1.Text = "SQL Error: " + myClient.ErrorMsg;
                    return;
                }

                // Set the record count in the status bar
                toolStripStatusLabel1.Text = "Record count: " + myClient.ReturnDataSet.Count.ToString();

                // If we received no results, don't bother populating the data table
                if (myClient.ReturnDataSet.Count == 0)
                {
                    return;
                }

                // Create a new data table
                DataTable sqlResultsTable = new DataTable("sqlResults");

                List <string> ColumnList = new List <string>();

                // Loop over the first record fields to get key names
                foreach (KeyValuePair <string, string> fieldPair in myClient.ReturnDataSet.First())
                {
                    ColumnList.Add(fieldPair.Key);
                    sqlResultsTable.Columns.Add(new DataColumn(fieldPair.Key));
                }

                // Loop over all records
                foreach (Dictionary <string, string> sqlRecord in myClient.ReturnDataSet)
                {
                    // Create row
                    DataRow newRow;
                    newRow = sqlResultsTable.NewRow();

                    // Loop over columns
                    foreach (string colName in ColumnList)
                    {
                        if (sqlRecord[colName] == null)
                        {
                            newRow[colName] = "<null>";
                        }
                        else
                        {
                            newRow[colName] = sqlRecord[colName];
                        }
                    }

                    // Add row
                    sqlResultsTable.Rows.Add(newRow);
                }

                dataGridView1.DataSource = sqlResultsTable;
            }
        }