private void LoadGridData()
        {
            if (String.IsNullOrEmpty(comboBox1.Text))
            {
                return;
            }
            String sql = "SELECT SERVERPROPERTY('ServerName') AS SN";
            String SN  = (String)CollectorUtils.GetScalar(Manager.ServerName, "master", sql);

            sql = @"
                SELECT TOP(1) QUOTENAME(OBJECT_SCHEMA_NAME(object_id)) + '.' + QUOTENAME(OBJECT_NAME(object_id))
                FROM sys.tables
                WHERE name = '{0}'
                ORDER BY OBJECT_SCHEMA_NAME(object_id) DESC";
            sql = String.Format(sql, comboBox1.Text);
            String selectedTable = (String)CollectorUtils.GetScalar(MDWInstance, MDWDatabase, sql);

            sql = @"
                SELECT source.*
                FROM core.snapshots AS sn
                INNER JOIN {3} AS source
	                ON source.snapshot_id = sn.snapshot_id
                WHERE sn.instance_name = '{0}'
                    AND sn.snapshot_time BETWEEN '{1}' AND '{2}'
                ORDER BY snapshot_time;
            ";
            DateTime dateFrom = DateTime.Parse(textBox1.Text);
            DateTime dateTo   = DateTime.Parse(textBox2.Text);

            sql = String.Format(sql, SN, dateFrom.ToString("yyyy-MM-dd hh:mm:ss.fff"), dateTo.ToString("yyyy-MM-dd hh:mm:ss.fff"), selectedTable);
            DataTable dt = CollectorUtils.GetDataTable(MDWInstance, MDWDatabase, sql);

            dataGridView1.DataSource = dt;
        }
예제 #2
0
 public CollectionItemControl(Guid collectionSetUid, Main main) : this(main)
 {
     _collectionSetUid = collectionSetUid;
     String sql = @"
         SELECT collection_set_id
         FROM syscollector_collection_sets
         WHERE collection_set_uid = '{0}'
     ";
     sql = String.Format(sql, _collectionSetUid);
     int collectionSetId = Convert.ToInt32(CollectorUtils.GetScalar(Manager.ServerName, "msdb", sql));
     textBox1.Text = collectionSetId.ToString();
 }
        private void FillTimeSlider()
        {
            if (String.IsNullOrEmpty(comboBox1.Text))
            {
                return;
            }
            String sql = @"
                SELECT TOP(1) QUOTENAME(OBJECT_SCHEMA_NAME(object_id)) + '.' + QUOTENAME(OBJECT_NAME(object_id))
                FROM sys.tables
                WHERE name = '{0}'
                ORDER BY OBJECT_SCHEMA_NAME(object_id) DESC";

            sql = String.Format(sql, comboBox1.Text);
            String selectedTable = (String)CollectorUtils.GetScalar(MDWInstance, MDWDatabase, sql);

            sql = @"
                SELECT MIN(sn.snapshot_time) AS mintime, MAX(sn.snapshot_time) AS maxtime
                FROM core.snapshots AS sn
                INNER JOIN {0} AS source
	                ON source.snapshot_id = sn.snapshot_id
            ";
            sql = String.Format(sql, selectedTable);
            DataTable dt = CollectorUtils.GetDataTable(MDWInstance, MDWDatabase, sql);

            if (dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                if (dr[0] == null || dr[1] == null)
                {
                    return;
                }
                if (dr[0].GetType() == typeof(DBNull) || dr[1].GetType() == typeof(DBNull))
                {
                    return;
                }


                DateTime min = ((DateTimeOffset)dr[0]).DateTime;
                DateTime max = ((DateTimeOffset)dr[1]).DateTime;

                dateRangeSlider1.Minimum = min;
                dateRangeSlider1.Maximum = max;

                dateRangeSlider1.LowerValue = min;
                dateRangeSlider1.UpperValue = max;

                dateRangeSlider1.LowerValue = min;
                dateRangeSlider1.UpperValue = max;
            }
        }
예제 #4
0
        private void checkCollectionSetEnabled()
        {
            String sql = @"
                SELECT is_running
                FROM msdb.dbo.syscollector_collection_sets
                WHERE collection_set_uid = '{0}'
            ";

            sql = String.Format(sql, this.CollectionSetUid);

            while (true)
            {
                Boolean is_running = (Boolean)CollectorUtils.GetScalar(SourceServerInstance, "master", sql);

                if (!is_running)
                {
                    stopCollector();
                }
                else
                {
                    Thread.Sleep(60000);
                }
            }
        }