Beispiel #1
0
        private void Refresh( )
        {
            var hackItem = new TableSizeData
            {
                Name   = "",
                Amount = 0
            };

            SeriesData.Add(hackItem);
            SeriesData.Remove(hackItem);
        }
Beispiel #2
0
        private void Load( )
        {
            try
            {
                IndexData index = null;

                ChartTitle = "";
                SeriesData.Clear( );

                using (var cmd = DatabaseManager.CreateCommand(@"--ReadiMon - TableSizes (Load)
SELECT TOP 1 i.[Id], i.[Timestamp] FROM [dbo].[Lic_Index] i ORDER BY i.[Timestamp] DESC"))
                {
                    using (IDataReader reader = cmd.ExecuteReader( ))
                    {
                        if (reader.Read( ))
                        {
                            index = new IndexData
                            {
                                Id        = reader.GetInt64(0),
                                TimeStamp = reader.GetDateTime(1)
                            };
                        }
                    }
                }

                if (index == null)
                {
                    return;
                }

                ChartTitle = index.TimeStamp.ToLocalTime( ).ToString("F");

                const string commandText = @"--ReadiMon - TableSizes (Load)
SELECT 
tn.[Name], t.[RowCount], t.[MinRowBytes], t.[MaxRowBytes], t.[AvgRowBytes]
FROM [dbo].[Lic_Table] t
JOIN [dbo].[Lic_Table_Name] tn ON t.TableId = tn.Id
WHERE t.IndexId = @id;";

                using (var command = DatabaseManager.CreateCommand(commandText))
                {
                    DatabaseManager.AddParameter(command, "@id", index.Id);

                    using (IDataReader reader = command.ExecuteReader( ))
                    {
                        while (reader.Read( ))
                        {
                            var data = new TableSizeData( );

                            if (!reader.IsDBNull(0))
                            {
                                data.Name = reader.GetString(0);
                            }

                            if (!reader.IsDBNull(1))
                            {
                                data.RowCount = reader.GetInt32(1);
                            }

                            if (!reader.IsDBNull(2))
                            {
                                data.MinRowBytes = reader.GetInt32(2);
                            }

                            if (!reader.IsDBNull(3))
                            {
                                data.MaxRowBytes = reader.GetInt32(3);
                            }

                            if (!reader.IsDBNull(4))
                            {
                                data.AvgRowBytes = reader.GetInt32(4);
                            }

                            data.Amount = Math.Round(( double )(data.RowCount * data.AvgRowBytes) / (1024 * 1024), 2);                                    // megabytes

                            SeriesData.Add(data);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                PluginSettings.EventLog.WriteException(e);
            }
        }