Changes properties to use automatic property initializers

This commit is contained in:
Kamron Batman 2018-09-14 15:23:29 -07:00
parent f0a48ad431
commit 06fa31a7bf
623 changed files with 13072 additions and 19304 deletions

View file

@ -22,50 +22,28 @@ namespace Server.Engines.Reports
public override PersistableType TypeID => ThisTypeID;
#endregion
private int m_Ticks;
private BarGraphRenderMode m_RenderMode;
public int Ticks { get; set; }
private string m_xTitle;
private string m_yTitle;
public BarGraphRenderMode RenderMode { get; set; }
private int m_FontSize = 7;
private int m_Interval = 1;
public string xTitle { get; set; }
private BarRegion[] m_Regions;
public string yTitle { get; set; }
public int Ticks{ get => m_Ticks;
set => m_Ticks = value;
}
public BarGraphRenderMode RenderMode{ get => m_RenderMode;
set => m_RenderMode = value;
}
public int FontSize { get; set; } = 7;
public string xTitle{ get => m_xTitle;
set => m_xTitle = value;
}
public string yTitle{ get => m_yTitle;
set => m_yTitle = value;
}
public int Interval { get; set; } = 1;
public int FontSize{ get => m_FontSize;
set => m_FontSize = value;
}
public int Interval{ get => m_Interval;
set => m_Interval = value;
}
public BarRegion[] Regions{ get => m_Regions;
set => m_Regions = value;
}
public BarRegion[] Regions { get; set; }
public BarGraph( string name, string fileName, int ticks, string xTitle, string yTitle, BarGraphRenderMode rm )
{
m_Name = name;
m_FileName = fileName;
m_Ticks = ticks;
m_xTitle = xTitle;
m_yTitle = yTitle;
m_RenderMode = rm;
Ticks = ticks;
this.xTitle = xTitle;
this.yTitle = yTitle;
RenderMode = rm;
}
private BarGraph()
@ -76,28 +54,28 @@ namespace Server.Engines.Reports
{
base.SerializeAttributes( op );
op.SetInt32( "t", m_Ticks );
op.SetInt32( "r", (int) m_RenderMode );
op.SetInt32( "t", Ticks );
op.SetInt32( "r", (int) RenderMode );
op.SetString( "x", m_xTitle );
op.SetString( "y", m_yTitle );
op.SetString( "x", xTitle );
op.SetString( "y", yTitle );
op.SetInt32( "s", m_FontSize );
op.SetInt32( "i", m_Interval );
op.SetInt32( "s", FontSize );
op.SetInt32( "i", Interval );
}
public override void DeserializeAttributes( PersistanceReader ip )
{
base.DeserializeAttributes( ip );
m_Ticks = ip.GetInt32( "t" );
m_RenderMode = (BarGraphRenderMode) ip.GetInt32( "r" );
Ticks = ip.GetInt32( "t" );
RenderMode = (BarGraphRenderMode) ip.GetInt32( "r" );
m_xTitle = Utility.Intern( ip.GetString( "x" ) );
m_yTitle = Utility.Intern( ip.GetString( "y" ) );
xTitle = Utility.Intern( ip.GetString( "x" ) );
yTitle = Utility.Intern( ip.GetString( "y" ) );
m_FontSize = ip.GetInt32( "s" );
m_Interval = ip.GetInt32( "i" );
FontSize = ip.GetInt32( "s" );
Interval = ip.GetInt32( "i" );
}
public static int LookupReportValue( Snapshot ss, string reportName, string valueName )
@ -148,7 +126,7 @@ namespace Server.Engines.Reports
BarGraph barGraph = new BarGraph( "Hourly average " + valueName, "graphs_" + valueName.ToLower() + "_avg", 10, "Time", valueName, BarGraphRenderMode.Lines );
barGraph.m_FontSize = 6;
barGraph.FontSize = 6;
for ( int i = 7; i <= totals.Length+7; ++i )
{

View file

@ -13,15 +13,9 @@ namespace Server.Engines.Reports
public override PersistableType TypeID => ThisTypeID;
#endregion
private string m_Name;
private int m_Value;
public string Name { get; set; }
public string Name{ get => m_Name;
set => m_Name = value;
}
public int Value{ get => m_Value;
set => m_Value = value;
}
public int Value { get; set; }
private ChartItem()
{
@ -29,20 +23,20 @@ namespace Server.Engines.Reports
public ChartItem( string name, int value )
{
m_Name = name;
m_Value = value;
Name = name;
Value = value;
}
public override void SerializeAttributes( PersistanceWriter op )
{
op.SetString( "n", m_Name );
op.SetInt32( "v", m_Value );
op.SetString( "n", Name );
op.SetInt32( "v", Value );
}
public override void DeserializeAttributes( PersistanceReader ip )
{
m_Name = Utility.Intern( ip.GetString( "n" ) );
m_Value = ip.GetInt32( "v" );
Name = Utility.Intern( ip.GetString( "n" ) );
Value = ip.GetInt32( "v" );
}
}
}

View file

@ -13,17 +13,13 @@ namespace Server.Engines.Reports
public override PersistableType TypeID => ThisTypeID;
#endregion
private bool m_ShowPercents;
public bool ShowPercents{ get => m_ShowPercents;
set => m_ShowPercents = value;
}
public bool ShowPercents { get; set; }
public PieChart( string name, string fileName, bool showPercents )
{
m_Name = name;
m_FileName = fileName;
m_ShowPercents = showPercents;
ShowPercents = showPercents;
}
private PieChart()
@ -34,14 +30,14 @@ namespace Server.Engines.Reports
{
base.SerializeAttributes( op );
op.SetBoolean( "p", m_ShowPercents );
op.SetBoolean( "p", ShowPercents );
}
public override void DeserializeAttributes( PersistanceReader ip )
{
base.DeserializeAttributes( ip );
m_ShowPercents = ip.GetBoolean( "p" );
ShowPercents = ip.GetBoolean( "p" );
}
}
}

View file

@ -14,14 +14,11 @@ namespace Server.Engines.Reports
#endregion
private string m_Value;
private string m_Format;
public string Value{ get => m_Value;
set => m_Value = value;
}
public string Format{ get => m_Format;
set => m_Format = value;
}
public string Format { get; set; }
private ItemValue()
{
@ -34,21 +31,21 @@ namespace Server.Engines.Reports
public ItemValue( string value, string format )
{
m_Value = value;
m_Format = format;
Format = format;
}
public override void SerializeAttributes( PersistanceWriter op )
{
op.SetString( "v", m_Value );
op.SetString( "f", m_Format );
op.SetString( "f", Format );
}
public override void DeserializeAttributes( PersistanceReader ip )
{
m_Value = ip.GetString( "v" );
m_Format = Utility.Intern( ip.GetString( "f" ) );
Format = Utility.Intern( ip.GetString( "f" ) );
if ( m_Format == null )
if ( Format == null )
Utility.Intern( ref m_Value );
}
}

View file

@ -13,19 +13,13 @@ namespace Server.Engines.Reports
public override PersistableType TypeID => ThisTypeID;
#endregion
private string m_Name;
private string m_Width;
private ReportColumnCollection m_Columns;
private ReportItemCollection m_Items;
public string Name { get; set; }
public string Name{ get => m_Name;
set => m_Name = value;
}
public string Width{ get => m_Width;
set => m_Width = value;
}
public ReportColumnCollection Columns => m_Columns;
public ReportItemCollection Items => m_Items;
public string Width { get; set; }
public ReportColumnCollection Columns { get; }
public ReportItemCollection Items { get; }
private Report() : this( null, null )
{
@ -33,31 +27,31 @@ namespace Server.Engines.Reports
public Report( string name, string width )
{
m_Name = name;
m_Width = width;
m_Columns = new ReportColumnCollection();
m_Items = new ReportItemCollection();
Name = name;
Width = width;
Columns = new ReportColumnCollection();
Items = new ReportItemCollection();
}
public override void SerializeAttributes( PersistanceWriter op )
{
op.SetString( "n", m_Name );
op.SetString( "w", m_Width );
op.SetString( "n", Name );
op.SetString( "w", Width );
}
public override void DeserializeAttributes( PersistanceReader ip )
{
m_Name = Utility.Intern( ip.GetString( "n" ) );
m_Width = Utility.Intern( ip.GetString( "w" ) );
Name = Utility.Intern( ip.GetString( "n" ) );
Width = Utility.Intern( ip.GetString( "w" ) );
}
public override void SerializeChildren( PersistanceWriter op )
{
for ( int i = 0; i < m_Columns.Count; ++i )
m_Columns[i].Serialize( op );
for ( int i = 0; i < Columns.Count; ++i )
Columns[i].Serialize( op );
for ( int i = 0; i < m_Items.Count; ++i )
m_Items[i].Serialize( op );
for ( int i = 0; i < Items.Count; ++i )
Items[i].Serialize( op );
}
public override void DeserializeChildren( PersistanceReader ip )
@ -67,9 +61,9 @@ namespace Server.Engines.Reports
PersistableObject child = ip.GetChild();
if ( child is ReportColumn column )
m_Columns.Add( column );
Columns.Add( column );
else if ( child is ReportItem item )
m_Items.Add( item );
Items.Add( item );
}
}
}

View file

@ -13,19 +13,11 @@ namespace Server.Engines.Reports
public override PersistableType TypeID => ThisTypeID;
#endregion
private string m_Width;
private string m_Align;
private string m_Name;
public string Width { get; set; }
public string Width{ get => m_Width;
set => m_Width = value;
}
public string Align{ get => m_Align;
set => m_Align = value;
}
public string Name{ get => m_Name;
set => m_Name = value;
}
public string Align { get; set; }
public string Name { get; set; }
private ReportColumn()
{
@ -37,23 +29,23 @@ namespace Server.Engines.Reports
public ReportColumn( string width, string align, string name )
{
m_Width = width;
m_Align = align;
m_Name = name;
Width = width;
Align = align;
Name = name;
}
public override void SerializeAttributes( PersistanceWriter op )
{
op.SetString( "w", m_Width );
op.SetString( "a", m_Align );
op.SetString( "n", m_Name );
op.SetString( "w", Width );
op.SetString( "a", Align );
op.SetString( "n", Name );
}
public override void DeserializeAttributes( PersistanceReader ip )
{
m_Width = Utility.Intern( ip.GetString( "w" ) );
m_Align = Utility.Intern( ip.GetString( "a" ) );
m_Name = Utility.Intern( ip.GetString( "n" ) );
Width = Utility.Intern( ip.GetString( "w" ) );
Align = Utility.Intern( ip.GetString( "a" ) );
Name = Utility.Intern( ip.GetString( "n" ) );
}
}
}

View file

@ -13,25 +13,23 @@ namespace Server.Engines.Reports
public override PersistableType TypeID => ThisTypeID;
#endregion
private ItemValueCollection m_Values;
public ItemValueCollection Values => m_Values;
public ItemValueCollection Values { get; }
public ReportItem()
{
m_Values = new ItemValueCollection();
Values = new ItemValueCollection();
}
public override void SerializeChildren( PersistanceWriter op )
{
for ( int i = 0; i < m_Values.Count; ++i )
m_Values[i].Serialize( op );
for ( int i = 0; i < Values.Count; ++i )
Values[i].Serialize( op );
}
public override void DeserializeChildren( PersistanceReader ip )
{
while ( ip.HasChild )
m_Values.Add( ip.GetChild() as ItemValue );
Values.Add( ip.GetChild() as ItemValue );
}
}
}

View file

@ -15,41 +15,35 @@ namespace Server.Engines.Reports
public override PersistableType TypeID => ThisTypeID;
#endregion
private DateTime m_TimeStamp;
private ObjectCollection m_Children;
public DateTime TimeStamp { get; set; }
public DateTime TimeStamp{ get => m_TimeStamp;
set => m_TimeStamp = value;
}
public ObjectCollection Children{ get => m_Children;
set => m_Children = value;
}
public ObjectCollection Children { get; set; }
public Snapshot()
{
m_Children = new ObjectCollection();
Children = new ObjectCollection();
}
public override void SerializeAttributes( PersistanceWriter op )
{
op.SetDateTime( "t", m_TimeStamp );
op.SetDateTime( "t", TimeStamp );
}
public override void DeserializeAttributes( PersistanceReader ip )
{
m_TimeStamp = ip.GetDateTime( "t" );
TimeStamp = ip.GetDateTime( "t" );
}
public override void SerializeChildren( PersistanceWriter op )
{
for ( int i = 0; i < m_Children.Count; ++i )
m_Children[i].Serialize( op );
for ( int i = 0; i < Children.Count; ++i )
Children[i].Serialize( op );
}
public override void DeserializeChildren( PersistanceReader ip )
{
while ( ip.HasChild )
m_Children.Add( ip.GetChild() );
Children.Add( ip.GetChild() );
}
}
}

View file

@ -15,15 +15,11 @@ namespace Server.Engines.Reports
public override PersistableType TypeID => ThisTypeID;
#endregion
private SnapshotCollection m_Snapshots;
public SnapshotCollection Snapshots{ get => m_Snapshots;
set => m_Snapshots = value;
}
public SnapshotCollection Snapshots { get; set; }
public SnapshotHistory()
{
m_Snapshots = new SnapshotCollection();
Snapshots = new SnapshotCollection();
}
public void Save()
@ -52,14 +48,14 @@ namespace Server.Engines.Reports
public override void SerializeChildren( PersistanceWriter op )
{
for ( int i = 0; i < m_Snapshots.Count; ++i )
m_Snapshots[i].Serialize( op );
for ( int i = 0; i < Snapshots.Count; ++i )
Snapshots[i].Serialize( op );
}
public override void DeserializeChildren( PersistanceReader ip )
{
while ( ip.HasChild )
m_Snapshots.Add( ip.GetChild() as Snapshot );
Snapshots.Add( ip.GetChild() as Snapshot );
}
}
}

View file

@ -5,22 +5,13 @@ namespace Server.Engines.Reports
{
public abstract class BaseInfo : IComparable
{
private static TimeSpan m_SortRange;
public static TimeSpan SortRange { get; set; }
public static TimeSpan SortRange{ get => m_SortRange;
set => m_SortRange = value;
}
private string m_Account;
private string m_Display;
private PageInfoCollection m_Pages;
public string Account{ get => m_Account;
set => m_Account = value;
}
public PageInfoCollection Pages{ get => m_Pages;
set => m_Pages = value;
}
public string Account { get; set; }
public PageInfoCollection Pages { get; set; }
public string Display
{
@ -29,9 +20,9 @@ namespace Server.Engines.Reports
if ( m_Display != null )
return m_Display;
if ( m_Account != null )
if ( Account != null )
{
IAccount acct = Accounts.GetAccount( m_Account );
IAccount acct = Accounts.GetAccount( Account );
if ( acct != null )
{
@ -50,37 +41,37 @@ namespace Server.Engines.Reports
}
}
return ( m_Display = m_Account );
return ( m_Display = Account );
}
}
public int GetPageCount( PageResolution res, DateTime min, DateTime max )
{
return StaffHistory.GetPageCount( m_Pages, res, min, max );
return StaffHistory.GetPageCount( Pages, res, min, max );
}
public BaseInfo( string account )
{
m_Account = account;
m_Pages = new PageInfoCollection();
Account = account;
Pages = new PageInfoCollection();
}
public void Register( PageInfo page )
{
m_Pages.Add( page );
Pages.Add( page );
}
public void Unregister( PageInfo page )
{
m_Pages.Remove( page );
Pages.Remove( page );
}
public int CompareTo( object obj )
{
BaseInfo cmp = obj as BaseInfo;
int v = cmp.GetPageCount( cmp is StaffInfo ? PageResolution.Handled : PageResolution.None, DateTime.UtcNow - m_SortRange, DateTime.UtcNow )
- GetPageCount( this is StaffInfo ? PageResolution.Handled : PageResolution.None, DateTime.UtcNow - m_SortRange, DateTime.UtcNow );
int v = cmp.GetPageCount( cmp is StaffInfo ? PageResolution.Handled : PageResolution.None, DateTime.UtcNow - SortRange, DateTime.UtcNow )
- GetPageCount( this is StaffInfo ? PageResolution.Handled : PageResolution.None, DateTime.UtcNow - SortRange, DateTime.UtcNow );
if ( v == 0 )
v = string.Compare( Display, cmp.Display );

View file

@ -68,17 +68,7 @@ namespace Server.Engines.Reports
}
}
private PageType m_PageType;
private PageResolution m_Resolution;
private DateTime m_TimeSent;
private DateTime m_TimeResolved;
private string m_SentBy;
private string m_ResolvedBy;
private string m_Message;
private ResponseInfoCollection m_Responses;
public StaffHistory History
{
@ -104,15 +94,13 @@ namespace Server.Engines.Reports
}
}
public PageType PageType{ get => m_PageType;
set => m_PageType = value;
}
public PageResolution Resolution => m_Resolution;
public PageType PageType { get; set; }
public DateTime TimeSent{ get => m_TimeSent;
set => m_TimeSent = value;
}
public DateTime TimeResolved => m_TimeResolved;
public PageResolution Resolution { get; private set; }
public DateTime TimeSent { get; set; }
public DateTime TimeResolved { get; private set; }
public string SentBy
{
@ -126,14 +114,11 @@ namespace Server.Engines.Reports
}
}
public string ResolvedBy => m_ResolvedBy;
public string ResolvedBy { get; private set; }
public string Message{ get => m_Message;
set => m_Message = value;
}
public ResponseInfoCollection Responses{ get => m_Responses;
set => m_Responses = value;
}
public string Message { get; set; }
public ResponseInfoCollection Responses { get; set; }
public void UpdateResolver()
{
@ -146,9 +131,9 @@ namespace Server.Engines.Reports
else
Resolver = null;
m_ResolvedBy = resolvedBy;
m_TimeResolved = timeResolved;
m_Resolution = res;
ResolvedBy = resolvedBy;
TimeResolved = timeResolved;
Resolution = res;
}
public bool IsStaffResolution( PageResolution res )
@ -171,9 +156,9 @@ namespace Server.Engines.Reports
public PageResolution GetResolution( out string resolvedBy, out DateTime timeResolved )
{
for ( int i = m_Responses.Count - 1; i >= 0; --i )
for ( int i = Responses.Count - 1; i >= 0; --i )
{
ResponseInfo resp = m_Responses[i];
ResponseInfo resp = Responses[i];
PageResolution res = ResFromResp( resp.Message );
if ( res != PageResolution.None )
@ -185,7 +170,7 @@ namespace Server.Engines.Reports
}
resolvedBy = m_SentBy;
timeResolved = m_TimeSent;
timeResolved = TimeSent;
return PageResolution.None;
}
@ -196,53 +181,53 @@ namespace Server.Engines.Reports
public PageInfo()
{
m_Responses = new ResponseInfoCollection();
Responses = new ResponseInfoCollection();
}
public PageInfo( PageEntry entry )
{
m_PageType = entry.Type;
PageType = entry.Type;
m_TimeSent = entry.Sent;
TimeSent = entry.Sent;
m_SentBy = GetAccount( entry.Sender );
m_Message = entry.Message;
m_Responses = new ResponseInfoCollection();
Message = entry.Message;
Responses = new ResponseInfoCollection();
}
public override void SerializeAttributes( PersistanceWriter op )
{
op.SetInt32( "p", (int)m_PageType );
op.SetInt32( "p", (int)PageType );
op.SetDateTime( "ts", m_TimeSent );
op.SetDateTime( "ts", TimeSent );
op.SetString( "s", m_SentBy );
op.SetString( "m", m_Message );
op.SetString( "m", Message );
}
public override void DeserializeAttributes( PersistanceReader ip )
{
m_PageType = (PageType) ip.GetInt32( "p" );
PageType = (PageType) ip.GetInt32( "p" );
m_TimeSent = ip.GetDateTime( "ts" );
TimeSent = ip.GetDateTime( "ts" );
m_SentBy = ip.GetString( "s" );
m_Message = ip.GetString( "m" );
Message = ip.GetString( "m" );
}
public override void SerializeChildren( PersistanceWriter op )
{
lock ( this )
{
for ( int i = 0; i < m_Responses.Count; ++i )
m_Responses[i].Serialize( op );
for ( int i = 0; i < Responses.Count; ++i )
Responses[i].Serialize( op );
}
}
public override void DeserializeChildren( PersistanceReader ip )
{
while ( ip.HasChild )
m_Responses.Add( ip.GetChild() as ResponseInfo );
Responses.Add( ip.GetChild() as ResponseInfo );
}
}
}

View file

@ -15,15 +15,9 @@ namespace Server.Engines.Reports
public override PersistableType TypeID => ThisTypeID;
#endregion
private DateTime m_TimeStamp;
private int m_Count;
public DateTime TimeStamp { get; set; }
public DateTime TimeStamp{ get => m_TimeStamp;
set => m_TimeStamp = value;
}
public int Count{ get => m_Count;
set => m_Count = value;
}
public int Count { get; set; }
public QueueStatus()
{
@ -31,20 +25,20 @@ namespace Server.Engines.Reports
public QueueStatus( int count )
{
m_TimeStamp = DateTime.UtcNow;
m_Count = count;
TimeStamp = DateTime.UtcNow;
Count = count;
}
public override void SerializeAttributes( PersistanceWriter op )
{
op.SetDateTime( "t", m_TimeStamp );
op.SetInt32( "c", m_Count );
op.SetDateTime( "t", TimeStamp );
op.SetInt32( "c", Count );
}
public override void DeserializeAttributes( PersistanceReader ip )
{
m_TimeStamp = ip.GetDateTime( "t" );
m_Count = ip.GetInt32( "c" );
TimeStamp = ip.GetDateTime( "t" );
Count = ip.GetInt32( "c" );
}
}
}

View file

@ -15,21 +15,11 @@ namespace Server.Engines.Reports
public override PersistableType TypeID => ThisTypeID;
#endregion
private DateTime m_TimeStamp;
public DateTime TimeStamp { get; set; }
private string m_SentBy;
private string m_Message;
public string SentBy { get; set; }
public DateTime TimeStamp{ get => m_TimeStamp;
set => m_TimeStamp = value;
}
public string SentBy{ get => m_SentBy;
set => m_SentBy = value;
}
public string Message{ get => m_Message;
set => m_Message = value;
}
public string Message { get; set; }
public ResponseInfo()
{
@ -37,25 +27,25 @@ namespace Server.Engines.Reports
public ResponseInfo( string sentBy, string message )
{
m_TimeStamp = DateTime.UtcNow;
m_SentBy = sentBy;
m_Message = message;
TimeStamp = DateTime.UtcNow;
SentBy = sentBy;
Message = message;
}
public override void SerializeAttributes( PersistanceWriter op )
{
op.SetDateTime( "t", m_TimeStamp );
op.SetDateTime( "t", TimeStamp );
op.SetString( "s", m_SentBy );
op.SetString( "m", m_Message );
op.SetString( "s", SentBy );
op.SetString( "m", Message );
}
public override void DeserializeAttributes( PersistanceReader ip )
{
m_TimeStamp = ip.GetDateTime( "t" );
TimeStamp = ip.GetDateTime( "t" );
m_SentBy = ip.GetString( "s" );
m_Message = ip.GetString( "m" );
SentBy = ip.GetString( "s" );
Message = ip.GetString( "m" );
}
}
}

View file

@ -17,41 +17,29 @@ namespace Server.Engines.Reports
public override PersistableType TypeID => ThisTypeID;
#endregion
private PageInfoCollection m_Pages;
private QueueStatusCollection m_QueueStats;
public PageInfoCollection Pages { get; set; }
private Hashtable m_UserInfo;
private Hashtable m_StaffInfo;
public QueueStatusCollection QueueStats { get; set; }
public PageInfoCollection Pages{ get => m_Pages;
set => m_Pages = value;
}
public QueueStatusCollection QueueStats{ get => m_QueueStats;
set => m_QueueStats = value;
}
public Hashtable UserInfo { get; set; }
public Hashtable UserInfo{ get => m_UserInfo;
set => m_UserInfo = value;
}
public Hashtable StaffInfo{ get => m_StaffInfo;
set => m_StaffInfo = value;
}
public Hashtable StaffInfo { get; set; }
public void AddPage( PageInfo info )
{
lock ( SaveLock )
m_Pages.Add( info );
Pages.Add( info );
info.History = this;
}
public StaffHistory()
{
m_Pages = new PageInfoCollection();
m_QueueStats = new QueueStatusCollection();
Pages = new PageInfoCollection();
QueueStats = new QueueStatusCollection();
m_UserInfo = new Hashtable( StringComparer.OrdinalIgnoreCase );
m_StaffInfo = new Hashtable( StringComparer.OrdinalIgnoreCase );
UserInfo = new Hashtable( StringComparer.OrdinalIgnoreCase );
StaffInfo = new Hashtable( StringComparer.OrdinalIgnoreCase );
}
public StaffInfo GetStaffInfo( string account )
@ -61,8 +49,8 @@ namespace Server.Engines.Reports
if ( string.IsNullOrEmpty(account) )
return null;
if ( !(m_StaffInfo[account] is StaffInfo info) )
m_StaffInfo[account] = info = new StaffInfo( account );
if ( !(StaffInfo[account] is StaffInfo info) )
StaffInfo[account] = info = new StaffInfo( account );
return info;
}
@ -73,8 +61,8 @@ namespace Server.Engines.Reports
if ( string.IsNullOrEmpty(account) )
return null;
if ( !(m_UserInfo[account] is UserInfo info) )
m_UserInfo[account] = info = new UserInfo( account );
if ( !(UserInfo[account] is UserInfo info) )
UserInfo[account] = info = new UserInfo( account );
return info;
}
@ -111,11 +99,11 @@ namespace Server.Engines.Reports
public override void SerializeChildren( PersistanceWriter op )
{
for ( int i = 0; i < m_Pages.Count; ++i )
m_Pages[i].Serialize( op );
for ( int i = 0; i < Pages.Count; ++i )
Pages[i].Serialize( op );
for ( int i = 0; i < m_QueueStats.Count; ++i )
m_QueueStats[i].Serialize( op );
for ( int i = 0; i < QueueStats.Count; ++i )
QueueStats[i].Serialize( op );
}
public override void DeserializeChildren( PersistanceReader ip )
@ -132,7 +120,7 @@ namespace Server.Engines.Reports
if ( pageInfo.TimeSent >= min || pageInfo.TimeResolved >= min )
{
m_Pages.Add( pageInfo );
Pages.Add( pageInfo );
pageInfo.History = this;
}
else
@ -144,17 +132,17 @@ namespace Server.Engines.Reports
else if ( obj is QueueStatus queueStatus )
{
if ( queueStatus.TimeStamp >= min )
m_QueueStats.Add( queueStatus );
QueueStats.Add( queueStatus );
}
}
}
public StaffInfo[] GetStaff()
{
StaffInfo[] staff = new StaffInfo[m_StaffInfo.Count];
StaffInfo[] staff = new StaffInfo[StaffInfo.Count];
int index = 0;
foreach ( StaffInfo staffInfo in m_StaffInfo.Values )
foreach ( StaffInfo staffInfo in StaffInfo.Values )
staff[index++] = staffInfo;
return staff;
@ -171,11 +159,11 @@ namespace Server.Engines.Reports
BaseInfo.SortRange = TimeSpan.FromDays( 7.0 );
Array.Sort( staff );
objects.Add( GraphHourlyPages( m_Pages, PageResolution.None, "New pages by hour", "graph_new_pages_hr" ) );
objects.Add( GraphHourlyPages( m_Pages, PageResolution.Handled, "Handled pages by hour", "graph_handled_pages_hr" ) );
objects.Add( GraphHourlyPages( m_Pages, PageResolution.Deleted, "Deleted pages by hour", "graph_deleted_pages_hr" ) );
objects.Add( GraphHourlyPages( m_Pages, PageResolution.Canceled, "Canceled pages by hour", "graph_canceled_pages_hr" ) );
objects.Add( GraphHourlyPages( m_Pages, PageResolution.Logged, "Logged-out pages by hour", "graph_logged_pages_hr" ) );
objects.Add( GraphHourlyPages( Pages, PageResolution.None, "New pages by hour", "graph_new_pages_hr" ) );
objects.Add( GraphHourlyPages( Pages, PageResolution.Handled, "Handled pages by hour", "graph_handled_pages_hr" ) );
objects.Add( GraphHourlyPages( Pages, PageResolution.Deleted, "Deleted pages by hour", "graph_deleted_pages_hr" ) );
objects.Add( GraphHourlyPages( Pages, PageResolution.Canceled, "Canceled pages by hour", "graph_canceled_pages_hr" ) );
objects.Add( GraphHourlyPages( Pages, PageResolution.Logged, "Logged-out pages by hour", "graph_logged_pages_hr" ) );
BaseInfo.SortRange = TimeSpan.FromDays( 1.0 );
Array.Sort( staff );
@ -231,9 +219,9 @@ namespace Server.Engines.Reports
DateTime max = DateTime.UtcNow;
DateTime min = max - TimeSpan.FromDays( 7.0 );
for ( int i = 0; i < m_QueueStats.Count; ++i )
for ( int i = 0; i < QueueStats.Count; ++i )
{
DateTime ts = m_QueueStats[i].TimeStamp;
DateTime ts = QueueStats[i].TimeStamp;
if ( ts >= min && ts < max )
{
@ -242,7 +230,7 @@ namespace Server.Engines.Reports
int hour = time.Hours;
totals[hour] += m_QueueStats[i].Count;
totals[hour] += QueueStats[i].Count;
counts[hour]++;
}
}
@ -386,11 +374,11 @@ namespace Server.Engines.Reports
PieChart resChart = new PieChart( title + " Resolutions", fname + "_resol", true );
int countTotal = GetPageCount( m_Pages, PageResolution.None, min, max );
int countHandled = GetPageCount( m_Pages, PageResolution.Handled, min, max );
int countDeleted = GetPageCount( m_Pages, PageResolution.Deleted, min, max );
int countCanceled = GetPageCount( m_Pages, PageResolution.Canceled, min, max );
int countLogged = GetPageCount( m_Pages, PageResolution.Logged, min, max );
int countTotal = GetPageCount( Pages, PageResolution.None, min, max );
int countHandled = GetPageCount( Pages, PageResolution.Handled, min, max );
int countDeleted = GetPageCount( Pages, PageResolution.Deleted, min, max );
int countCanceled = GetPageCount( Pages, PageResolution.Canceled, min, max );
int countLogged = GetPageCount( Pages, PageResolution.Logged, min, max );
int countUnres = countTotal - ( countHandled + countDeleted + countCanceled + countLogged );
resChart.Items.Add( "Handled", countHandled );

View file

@ -43,16 +43,14 @@ namespace Server.Engines.Reports
public sealed class PersistableType
{
private string m_Name;
private ConstructCallback m_Constructor;
public string Name { get; }
public string Name => m_Name;
public ConstructCallback Constructor => m_Constructor;
public ConstructCallback Constructor { get; }
public PersistableType( string name, ConstructCallback constructor )
{
m_Name = name;
m_Constructor = constructor;
Name = name;
Constructor = constructor;
}
}
}

View file

@ -38,11 +38,8 @@ namespace Server.Engines.Reports
public BarRegion[] _regions;
private BarGraphRenderMode _renderMode;
// Overall related members
private Color _backColor;
private string _fontFamily;
private string _longestTickValue = string.Empty; // Used to calculate max value width
private float _maxTickValueWidth; // Used to calculate left offset of bar graph
private float _totalHeight;
@ -51,7 +48,6 @@ namespace Server.Engines.Reports
// Graph related members
private float _barWidth;
private float _bottomBuffer; // Space from bottom to x axis
private bool _displayBarData;
private Color _fontColor;
private float _graphHeight;
private float _graphWidth;
@ -61,27 +57,16 @@ namespace Server.Engines.Reports
private float _topBuffer; // Space from top to the top of y axis
private float _xOrigin; // x position where graph starts drawing
private float _yOrigin; // y position where graph starts drawing
private string _yLabel;
private int _yTickCount;
private float _yTickValue; // Value for each tick = _maxValue/_yTickCount
// Legend related members
private bool _displayLegend;
private float _legendWidth;
private string _longestLabel = string.Empty; // Used to calculate legend width
private float _maxLabelWidth;
public string FontFamily
{
get => _fontFamily;
set => _fontFamily = value;
}
public string FontFamily { get; set; }
public BarGraphRenderMode RenderMode
{
get => _renderMode;
set => _renderMode = value;
}
public BarGraphRenderMode RenderMode { get; set; }
public Color BackgroundColor
{
@ -110,33 +95,18 @@ namespace Server.Engines.Reports
set => _totalWidth = Convert.ToSingle(value);
}
public bool ShowLegend
{
get => _displayLegend;
set => _displayLegend = value;
}
public bool ShowLegend { get; set; }
public bool ShowData { get; set; }
public bool ShowData
{
get => _displayBarData;
set => _displayBarData = value;
}
public int TopBuffer
{
set => _topBuffer = Convert.ToSingle(value);
}
public string VerticalLabel
{
get => _yLabel;
set => _yLabel = value;
}
public string VerticalLabel { get; set; }
public int VerticalTickCount
{
get => _yTickCount;
set => _yTickCount = value;
}
public int VerticalTickCount { get; set; }
private string _xTitle, _yTitle;
@ -182,7 +152,7 @@ namespace Server.Engines.Reports
if (_maxValue < temp) _maxValue = temp;
// Find the longest description
if (_displayLegend)
if (ShowLegend)
{
string currentLbl = labels[i] + " (" + shortLbl + ")";
float currentWidth = CalculateImgFontWidth(currentLbl, _legendFontSize, FontFamily);
@ -225,7 +195,7 @@ namespace Server.Engines.Reports
textFormat.Alignment = StringAlignment.Center;
textFormat.LineAlignment = StringAlignment.Center;
using ( Font font = new Font( _fontFamily, _labelFontSize ) )
using ( Font font = new Font( FontFamily, _labelFontSize ) )
{
using ( Brush textBrush = new SolidBrush( _fontColor ) )
{
@ -288,7 +258,7 @@ namespace Server.Engines.Reports
DrawBars(graph);
DrawXLabelArea(graph);
if (_displayLegend)
if (ShowLegend)
DrawLegend(graph);
}
@ -312,14 +282,14 @@ namespace Server.Engines.Reports
try
{
brsFont = new SolidBrush(_fontColor);
valFont = new Font(_fontFamily, _labelFontSize);
valFont = new Font(FontFamily, _labelFontSize);
sfFormat = new StringFormat();
sfFormat.Alignment = StringAlignment.Center;
int i = 0;
PointF[] linePoints = null;
if ( _renderMode == BarGraphRenderMode.Lines )
if ( RenderMode == BarGraphRenderMode.Lines )
linePoints = new PointF[DataPoints.Count];
int pointIndex = 0;
@ -335,11 +305,11 @@ namespace Server.Engines.Reports
{
float itemY = _yOrigin + _graphHeight - item.SweepSize;
if ( _renderMode == BarGraphRenderMode.Lines )
if ( RenderMode == BarGraphRenderMode.Lines )
{
linePoints[pointIndex++] = new PointF( _xOrigin + item.StartPos + (_barWidth / 2), itemY );
}
else if ( _renderMode == BarGraphRenderMode.Bars )
else if ( RenderMode == BarGraphRenderMode.Bars )
{
float ox = _xOrigin + item.StartPos;
float oy = itemY;
@ -376,7 +346,7 @@ namespace Server.Engines.Reports
graph.DrawLine( pen, pts[3], pts[6] );
// Draw data value
if (_displayBarData&&(i%_interval)==0)
if (ShowData&&(i%_interval)==0)
{
float sectionWidth = ( _barWidth + _spaceBtwBars );
float startX = _xOrigin + (i * sectionWidth) + (sectionWidth / 2); // This draws the value on center of the bar
@ -408,7 +378,7 @@ namespace Server.Engines.Reports
}
}
if ( _renderMode == BarGraphRenderMode.Lines )
if ( RenderMode == BarGraphRenderMode.Lines )
{
if ( linePoints.Length >= 2 )
{
@ -426,7 +396,7 @@ namespace Server.Engines.Reports
float itemY = _yOrigin + _graphHeight - item.SweepSize;
// Draw data value
if (_displayBarData&&(j%_interval)==0)
if (ShowData&&(j%_interval)==0)
{
graph.FillEllipse( brsFont, new RectangleF( linePoints[j].X-2.0f, linePoints[j].Y-2.0f, 4.0f, 4.0f ) );
@ -495,7 +465,7 @@ namespace Server.Engines.Reports
sfVLabel.LineAlignment = StringAlignment.Center;
sfVLabel.FormatFlags=StringFormatFlags.DirectionVertical;
lblFont = new Font(_fontFamily, _labelFontSize+4.0f);
lblFont = new Font(FontFamily, _labelFontSize+4.0f);
graph.DrawString(_yTitle,lblFont,brs,new RectangleF( 0.0f, _yOrigin, 20.0f, _graphHeight ), sfVLabel );
lblFont.Dispose();
}
@ -505,19 +475,19 @@ namespace Server.Engines.Reports
lblFormat.FormatFlags|=StringFormatFlags.NoClip;
// Draw vertical label at the top of y-axis and place it in the middle top of y-axis
lblFont = new Font(_fontFamily, _labelFontSize+2.0f,FontStyle.Bold);
lblFont = new Font(FontFamily, _labelFontSize+2.0f,FontStyle.Bold);
RectangleF recVLabel = new RectangleF(0, _yOrigin-2*_spacer-lblFont.Height, _xOrigin*2, lblFont.Height);
sfVLabel.Alignment = StringAlignment.Center;
sfVLabel.FormatFlags|=StringFormatFlags.NoClip;
//graph.DrawRectangle(Pens.Black,Rectangle.Truncate(recVLabel));
graph.DrawString(_yLabel, lblFont, brs, recVLabel, sfVLabel);
graph.DrawString(VerticalLabel, lblFont, brs, recVLabel, sfVLabel);
lblFont.Dispose();
lblFont = new Font(_fontFamily, _labelFontSize);
lblFont = new Font(FontFamily, _labelFontSize);
// Draw all tick values and tick marks
using ( Pen smallPen = new Pen(Color.FromArgb(96,_fontColor),0.8f) )
{
for (int i=0; i<_yTickCount; i++)
for (int i=0; i<VerticalTickCount; i++)
{
float currentY = _topBuffer + (i * _yTickValue/_scaleFactor); // Position for tick mark
float labelY = currentY-lblFont.Height/2; // Place label in the middle of tick
@ -559,7 +529,7 @@ namespace Server.Engines.Reports
try
{
lblFont = new Font(_fontFamily, _labelFontSize);
lblFont = new Font(FontFamily, _labelFontSize);
brs = new SolidBrush(_fontColor);
lblFormat = new StringFormat();
pen = new Pen(_fontColor);
@ -597,11 +567,11 @@ namespace Server.Engines.Reports
lblFormat.LineAlignment = StringAlignment.Center;
// sfVLabel.FormatFlags=StringFormatFlags.DirectionVertical;
lblFont = new Font(_fontFamily, _labelFontSize+2.0f, FontStyle.Bold);
graph.DrawString(_xTitle,lblFont,brs,new RectangleF( _xOrigin, _yOrigin+_graphHeight+14.0f+(_renderMode==BarGraphRenderMode.Bars?10.0f:0.0f)+((DataPoints.Count/_interval)>24?16.0f:0.0f), _graphWidth, 20.0f ), lblFormat );
lblFont = new Font(FontFamily, _labelFontSize+2.0f, FontStyle.Bold);
graph.DrawString(_xTitle,lblFont,brs,new RectangleF( _xOrigin, _yOrigin+_graphHeight+14.0f+(RenderMode==BarGraphRenderMode.Bars?10.0f:0.0f)+((DataPoints.Count/_interval)>24?16.0f:0.0f), _graphWidth, 20.0f ), lblFormat );
}
lblFont = new Font(_fontFamily, _labelFontSize);
lblFont = new Font(FontFamily, _labelFontSize);
lblFormat = new StringFormat();
lblFormat.Alignment = StringAlignment.Center;
lblFormat.FormatFlags |= StringFormatFlags.NoClip;
@ -610,7 +580,7 @@ namespace Server.Engines.Reports
float of = 0.0f;
if ( _renderMode == BarGraphRenderMode.Bars )
if ( RenderMode == BarGraphRenderMode.Bars )
{
of = 10.0f;
@ -633,7 +603,7 @@ namespace Server.Engines.Reports
{
currentX = _xOrigin + (i * labelWidth)+of+(labelWidth/2);
RectangleF recLbl = new RectangleF(currentX-((labelWidth*_interval)/2), currentY+of, labelWidth*_interval, lblFont.Height*2);
string lblString = _displayLegend ? item.Label : item.Description; // Decide what to show: short or long
string lblString = ShowLegend ? item.Label : item.Description; // Decide what to show: short or long
graph.DrawString(lblString, lblFont, brs, recLbl, lblFormat);
}
@ -665,7 +635,7 @@ namespace Server.Engines.Reports
try
{
lblFont = new Font(_fontFamily, _legendFontSize);
lblFont = new Font(FontFamily, _legendFontSize);
brs = new SolidBrush(_fontColor);
lblFormat = new StringFormat();
pen = new Pen(_fontColor);
@ -723,7 +693,7 @@ namespace Server.Engines.Reports
float currentTick;
string tickString;
for (int i=0; i<_yTickCount; i++)
for (int i=0; i<VerticalTickCount; i++)
{
currentTick = _maxValue - i*_yTickValue;
tickString = currentTick.ToString("#,###.##");
@ -737,7 +707,7 @@ namespace Server.Engines.Reports
float leftOffset = _spacer + _maxTickValueWidth + (_yTitle == null ? 0.0f : 20.0f);
float rtOffset = 0.0f;
if (_displayLegend)
if (ShowLegend)
{
_legendWidth = _spacer + _legendRectangleSize + _spacer + _maxLabelWidth + _spacer;
rtOffset = _graphLegendSpacer + _legendWidth + _spacer;
@ -745,7 +715,7 @@ namespace Server.Engines.Reports
else
rtOffset = _spacer; // Make graph in the middle
if ( _renderMode == BarGraphRenderMode.Bars )
if ( RenderMode == BarGraphRenderMode.Bars )
rtOffset += 10.0f;
rtOffset+=10.0f;
@ -770,7 +740,7 @@ namespace Server.Engines.Reports
{
float currentTick;
string tickString;
for (int i=0; i<_yTickCount; i++)
for (int i=0; i<VerticalTickCount; i++)
{
currentTick = _maxValue - i*_yTickValue;
tickString = currentTick.ToString("#,###.##");
@ -852,12 +822,12 @@ namespace Server.Engines.Reports
tempMax = 1.0f;
// Once max value is calculated, tick value can be determined; tick value should be a whole number
_yTickValue = tempMax / _yTickCount;
_yTickValue = tempMax / VerticalTickCount;
double expTick = Convert.ToDouble(Math.Floor(Math.Log10(_yTickValue)));
_yTickValue = Convert.ToSingle(Math.Ceiling(_yTickValue / Math.Pow(10, expTick)) * Math.Pow(10, expTick));
// Re-calculate the max value with the new tick value
_maxValue = _yTickValue * _yTickCount;
_maxValue = _yTickValue * VerticalTickCount;
}
//*********************************************************************
@ -908,14 +878,14 @@ namespace Server.Engines.Reports
// default values
_totalWidth = 680f;
_totalHeight = 450f;
_fontFamily = "Verdana";
FontFamily = "Verdana";
_backColor = Color.White;
_fontColor = Color.Black;
_topBuffer = 30f;
_bottomBuffer = 30f;
_yTickCount = 2;
_displayLegend = false;
_displayBarData = false;
VerticalTickCount = 2;
ShowLegend = false;
ShowData = false;
}
}
}

View file

@ -29,16 +29,11 @@ namespace Server.Engines.Reports
};
// Represent collection of all data points for the chart
private ChartItemsCollection _dataPoints = new ChartItemsCollection();
// The implementation of this method is provided by derived classes
public abstract Bitmap Draw();
public ChartItemsCollection DataPoints
{
get => _dataPoints;
set => _dataPoints = value;
}
public ChartItemsCollection DataPoints { get; set; } = new ChartItemsCollection();
public void SetColor(int index, Color NewColor)
{

View file

@ -15,60 +15,29 @@ namespace Server.Engines.Reports
public class DataItem
{
private string _label;
private string _description;
private float _value;
private Color _color;
private float _startPos;
private float _sweepSize;
private DataItem() {}
public DataItem(string label, string desc, float data, float start, float sweep, Color clr)
{
_label = label;
_description = desc;
_value = data;
_startPos = start;
_sweepSize = sweep;
_color = clr;
Label = label;
Description = desc;
Value = data;
StartPos = start;
SweepSize = sweep;
ItemColor = clr;
}
public string Label
{
get => _label;
set => _label = value;
}
public string Label { get; set; }
public string Description
{
get => _description;
set => _description = value;
}
public string Description { get; set; }
public float Value
{
get => _value;
set => _value = value;
}
public float Value { get; set; }
public Color ItemColor
{
get => _color;
set => _color = value;
}
public Color ItemColor { get; set; }
public float StartPos
{
get => _startPos;
set => _startPos = value;
}
public float StartPos { get; set; }
public float SweepSize
{
get => _sweepSize;
set => _sweepSize = value;
}
public float SweepSize { get; set; }
}
//*********************************************************************

View file

@ -28,11 +28,8 @@ namespace Server.Engines.Reports
private int _legendFontHeight;
private string _legendFontStyle;
private float _legendFontSize;
private bool _showPercents;
public bool ShowPercents{ get => _showPercents;
set => _showPercents = value;
}
public bool ShowPercents { get; set; }
public PieChartRenderer()
{
@ -131,7 +128,7 @@ namespace Server.Engines.Reports
if ( fnt == null )
fnt = new Font( _legendFontStyle, _legendFontSize );
if ( _showPercents && item.SweepSize > 10 )
if ( ShowPercents && item.SweepSize > 10 )
{
if ( sfp == null )
{

View file

@ -22,8 +22,8 @@ namespace Server.Engines.Reports
m_StatsHistory = new SnapshotHistory();
m_StatsHistory.Load();
m_StaffHistory = new StaffHistory();
m_StaffHistory.Load();
StaffHistory = new StaffHistory();
StaffHistory.Load();
DateTime now = DateTime.UtcNow;
@ -47,9 +47,8 @@ namespace Server.Engines.Reports
}
private static SnapshotHistory m_StatsHistory;
private static StaffHistory m_StaffHistory;
public static StaffHistory StaffHistory => m_StaffHistory;
public static StaffHistory StaffHistory { get; private set; }
public static void Generate()
{
@ -60,7 +59,7 @@ namespace Server.Engines.Reports
FillSnapshot( ss );
m_StatsHistory.Snapshots.Add( ss );
m_StaffHistory.QueueStats.Add( new QueueStatus( Help.PageQueue.List.Count ) );
StaffHistory.QueueStats.Add( new QueueStatus( Help.PageQueue.List.Count ) );
ThreadPool.QueueUserWorkItem( UpdateOutput, ss );
}
@ -68,13 +67,13 @@ namespace Server.Engines.Reports
private static void UpdateOutput( object state )
{
m_StatsHistory.Save();
m_StaffHistory.Save();
StaffHistory.Save();
HtmlRenderer renderer = new HtmlRenderer( "stats", (Snapshot) state, m_StatsHistory );
renderer.Render();
renderer.Upload();
renderer = new HtmlRenderer( "staff", m_StaffHistory );
renderer = new HtmlRenderer( "staff", StaffHistory );
renderer.Render();
renderer.Upload();
}