Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
|
|
@ -3,299 +3,305 @@ using System.Collections;
|
|||
|
||||
namespace Server.Engines.Reports
|
||||
{
|
||||
public enum BarGraphRenderMode
|
||||
{
|
||||
Bars,
|
||||
Lines
|
||||
}
|
||||
public enum BarGraphRenderMode
|
||||
{
|
||||
Bars,
|
||||
Lines
|
||||
}
|
||||
|
||||
public class BarGraph : Chart
|
||||
{
|
||||
#region Type Identification
|
||||
public static readonly PersistableType ThisTypeID = new PersistableType( "bg", Construct );
|
||||
public class BarGraph : Chart
|
||||
{
|
||||
public BarGraph(string name, string fileName, int ticks, string xTitle, string yTitle, BarGraphRenderMode rm)
|
||||
{
|
||||
m_Name = name;
|
||||
m_FileName = fileName;
|
||||
Ticks = ticks;
|
||||
this.xTitle = xTitle;
|
||||
this.yTitle = yTitle;
|
||||
RenderMode = rm;
|
||||
}
|
||||
|
||||
private static PersistableObject Construct()
|
||||
{
|
||||
return new BarGraph();
|
||||
}
|
||||
private BarGraph()
|
||||
{
|
||||
}
|
||||
|
||||
public override PersistableType TypeID => ThisTypeID;
|
||||
#endregion
|
||||
public int Ticks{ get; set; }
|
||||
|
||||
public int Ticks { get; set; }
|
||||
public BarGraphRenderMode RenderMode{ get; set; }
|
||||
|
||||
public BarGraphRenderMode RenderMode { get; set; }
|
||||
public string xTitle{ get; set; }
|
||||
|
||||
public string xTitle { get; set; }
|
||||
public string yTitle{ get; set; }
|
||||
|
||||
public string yTitle { get; set; }
|
||||
public int FontSize{ get; set; } = 7;
|
||||
|
||||
public int FontSize { get; set; } = 7;
|
||||
public int Interval{ get; set; } = 1;
|
||||
|
||||
public int Interval { get; set; } = 1;
|
||||
public BarRegion[] Regions{ get; set; }
|
||||
|
||||
public BarRegion[] Regions { get; set; }
|
||||
public override void SerializeAttributes(PersistanceWriter op)
|
||||
{
|
||||
base.SerializeAttributes(op);
|
||||
|
||||
public BarGraph( string name, string fileName, int ticks, string xTitle, string yTitle, BarGraphRenderMode rm )
|
||||
{
|
||||
m_Name = name;
|
||||
m_FileName = fileName;
|
||||
Ticks = ticks;
|
||||
this.xTitle = xTitle;
|
||||
this.yTitle = yTitle;
|
||||
RenderMode = rm;
|
||||
}
|
||||
op.SetInt32("t", Ticks);
|
||||
op.SetInt32("r", (int)RenderMode);
|
||||
|
||||
private BarGraph()
|
||||
{
|
||||
}
|
||||
op.SetString("x", xTitle);
|
||||
op.SetString("y", yTitle);
|
||||
|
||||
public override void SerializeAttributes( PersistanceWriter op )
|
||||
{
|
||||
base.SerializeAttributes( op );
|
||||
op.SetInt32("s", FontSize);
|
||||
op.SetInt32("i", Interval);
|
||||
}
|
||||
|
||||
op.SetInt32( "t", Ticks );
|
||||
op.SetInt32( "r", (int) RenderMode );
|
||||
public override void DeserializeAttributes(PersistanceReader ip)
|
||||
{
|
||||
base.DeserializeAttributes(ip);
|
||||
|
||||
op.SetString( "x", xTitle );
|
||||
op.SetString( "y", yTitle );
|
||||
Ticks = ip.GetInt32("t");
|
||||
RenderMode = (BarGraphRenderMode)ip.GetInt32("r");
|
||||
|
||||
op.SetInt32( "s", FontSize );
|
||||
op.SetInt32( "i", Interval );
|
||||
}
|
||||
xTitle = Utility.Intern(ip.GetString("x"));
|
||||
yTitle = Utility.Intern(ip.GetString("y"));
|
||||
|
||||
public override void DeserializeAttributes( PersistanceReader ip )
|
||||
{
|
||||
base.DeserializeAttributes( ip );
|
||||
FontSize = ip.GetInt32("s");
|
||||
Interval = ip.GetInt32("i");
|
||||
}
|
||||
|
||||
Ticks = ip.GetInt32( "t" );
|
||||
RenderMode = (BarGraphRenderMode) ip.GetInt32( "r" );
|
||||
public static int LookupReportValue(Snapshot ss, string reportName, string valueName)
|
||||
{
|
||||
for (int j = 0; j < ss.Children.Count; ++j)
|
||||
{
|
||||
if (!(ss.Children[j] is Report report) || report.Name != reportName)
|
||||
continue;
|
||||
|
||||
xTitle = Utility.Intern( ip.GetString( "x" ) );
|
||||
yTitle = Utility.Intern( ip.GetString( "y" ) );
|
||||
for (int k = 0; k < report.Items.Count; ++k)
|
||||
{
|
||||
ReportItem item = report.Items[k];
|
||||
|
||||
FontSize = ip.GetInt32( "s" );
|
||||
Interval = ip.GetInt32( "i" );
|
||||
}
|
||||
if (item.Values[0].Value == valueName)
|
||||
return Utility.ToInt32(item.Values[1].Value);
|
||||
}
|
||||
|
||||
public static int LookupReportValue( Snapshot ss, string reportName, string valueName )
|
||||
{
|
||||
for ( int j = 0; j < ss.Children.Count; ++j )
|
||||
{
|
||||
if ( !(ss.Children[j] is Report report) || report.Name != reportName )
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
for ( int k = 0; k < report.Items.Count; ++k )
|
||||
{
|
||||
ReportItem item = report.Items[k];
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( item.Values[0].Value == valueName )
|
||||
return Utility.ToInt32( item.Values[1].Value );
|
||||
}
|
||||
public static BarGraph DailyAverage(SnapshotHistory history, string reportName, string valueName)
|
||||
{
|
||||
int[] totals = new int[24];
|
||||
int[] counts = new int[24];
|
||||
|
||||
break;
|
||||
}
|
||||
int min = history.Snapshots.Count - 7 * 24; // averages over one week
|
||||
|
||||
return -1;
|
||||
}
|
||||
if (min < 0)
|
||||
min = 0;
|
||||
|
||||
public static BarGraph DailyAverage( SnapshotHistory history, string reportName, string valueName )
|
||||
{
|
||||
int[] totals = new int[24];
|
||||
int[] counts = new int[24];
|
||||
for (int i = min; i < history.Snapshots.Count; ++i)
|
||||
{
|
||||
Snapshot ss = history.Snapshots[i];
|
||||
|
||||
int min = history.Snapshots.Count - (7 * 24); // averages over one week
|
||||
int val = LookupReportValue(ss, reportName, valueName);
|
||||
|
||||
if ( min < 0 )
|
||||
min = 0;
|
||||
if (val == -1)
|
||||
continue;
|
||||
|
||||
for ( int i = min; i < history.Snapshots.Count; ++i )
|
||||
{
|
||||
Snapshot ss = history.Snapshots[i];
|
||||
int hour = ss.TimeStamp.TimeOfDay.Hours;
|
||||
|
||||
int val = LookupReportValue( ss, reportName, valueName );
|
||||
totals[hour] += val;
|
||||
counts[hour]++;
|
||||
}
|
||||
|
||||
if ( val == -1 )
|
||||
continue;
|
||||
BarGraph barGraph = new BarGraph("Hourly average " + valueName, "graphs_" + valueName.ToLower() + "_avg", 10,
|
||||
"Time", valueName, BarGraphRenderMode.Lines);
|
||||
|
||||
int hour = ss.TimeStamp.TimeOfDay.Hours;
|
||||
barGraph.FontSize = 6;
|
||||
|
||||
totals[hour] += val;
|
||||
counts[hour]++;
|
||||
}
|
||||
for (int i = 7; i <= totals.Length + 7; ++i)
|
||||
{
|
||||
int val;
|
||||
|
||||
BarGraph barGraph = new BarGraph( "Hourly average " + valueName, "graphs_" + valueName.ToLower() + "_avg", 10, "Time", valueName, BarGraphRenderMode.Lines );
|
||||
if (counts[i % totals.Length] == 0)
|
||||
val = 0;
|
||||
else
|
||||
val = (totals[i % totals.Length] + counts[i % totals.Length] / 2) / counts[i % totals.Length];
|
||||
|
||||
barGraph.FontSize = 6;
|
||||
int realHours = i % totals.Length;
|
||||
int hours;
|
||||
|
||||
for ( int i = 7; i <= totals.Length+7; ++i )
|
||||
{
|
||||
int val;
|
||||
if (realHours == 0)
|
||||
hours = 12;
|
||||
else if (realHours > 12)
|
||||
hours = realHours - 12;
|
||||
else
|
||||
hours = realHours;
|
||||
|
||||
if ( counts[i%totals.Length] == 0 )
|
||||
val = 0;
|
||||
else
|
||||
val = (totals[i%totals.Length] + (counts[i%totals.Length] / 2)) / counts[i%totals.Length];
|
||||
barGraph.Items.Add(hours + (realHours >= 12 ? " PM" : " AM"), val);
|
||||
}
|
||||
|
||||
int realHours = i%totals.Length;
|
||||
int hours;
|
||||
return barGraph;
|
||||
}
|
||||
|
||||
if ( realHours == 0 )
|
||||
hours = 12;
|
||||
else if ( realHours > 12 )
|
||||
hours = realHours - 12;
|
||||
else
|
||||
hours = realHours;
|
||||
public static BarGraph Growth(SnapshotHistory history, string reportName, string valueName)
|
||||
{
|
||||
BarGraph barGraph = new BarGraph("Growth of " + valueName + " over time",
|
||||
"graphs_" + valueName.ToLower() + "_growth", 10, "Time", valueName, BarGraphRenderMode.Lines);
|
||||
|
||||
barGraph.Items.Add( hours + (realHours >= 12 ? " PM" : " AM"), val );
|
||||
}
|
||||
barGraph.FontSize = 6;
|
||||
barGraph.Interval = 7;
|
||||
|
||||
return barGraph;
|
||||
}
|
||||
DateTime startPeriod = history.Snapshots[0].TimeStamp.Date + TimeSpan.FromDays(1.0);
|
||||
DateTime endPeriod = history.Snapshots[history.Snapshots.Count - 1].TimeStamp.Date;
|
||||
|
||||
public static BarGraph Growth( SnapshotHistory history, string reportName, string valueName )
|
||||
{
|
||||
BarGraph barGraph = new BarGraph( "Growth of " + valueName + " over time", "graphs_" + valueName.ToLower() + "_growth", 10, "Time", valueName, BarGraphRenderMode.Lines );
|
||||
ArrayList regions = new ArrayList();
|
||||
|
||||
barGraph.FontSize = 6;
|
||||
barGraph.Interval = 7;
|
||||
DateTime curDate = DateTime.MinValue;
|
||||
int curPeak = -1;
|
||||
int curLow = 1000;
|
||||
int curTotl = 0;
|
||||
int curCont = 0;
|
||||
int curValu = 0;
|
||||
|
||||
DateTime startPeriod = history.Snapshots[0].TimeStamp.Date + TimeSpan.FromDays( 1.0 );
|
||||
DateTime endPeriod = history.Snapshots[history.Snapshots.Count - 1].TimeStamp.Date;
|
||||
for (int i = 0; i < history.Snapshots.Count; ++i)
|
||||
{
|
||||
Snapshot ss = history.Snapshots[i];
|
||||
DateTime timeStamp = ss.TimeStamp;
|
||||
|
||||
ArrayList regions = new ArrayList();
|
||||
if (timeStamp < startPeriod || timeStamp >= endPeriod)
|
||||
continue;
|
||||
|
||||
DateTime curDate = DateTime.MinValue;
|
||||
int curPeak = -1;
|
||||
int curLow = 1000;
|
||||
int curTotl = 0;
|
||||
int curCont = 0;
|
||||
int curValu = 0;
|
||||
int val = LookupReportValue(ss, reportName, valueName);
|
||||
|
||||
for ( int i = 0; i < history.Snapshots.Count; ++i )
|
||||
{
|
||||
Snapshot ss = history.Snapshots[i];
|
||||
DateTime timeStamp = ss.TimeStamp;
|
||||
if (val == -1)
|
||||
continue;
|
||||
|
||||
if ( timeStamp < startPeriod || timeStamp >= endPeriod )
|
||||
continue;
|
||||
DateTime thisDate = timeStamp.Date;
|
||||
|
||||
int val = LookupReportValue( ss, reportName, valueName );
|
||||
if (curDate == DateTime.MinValue)
|
||||
curDate = thisDate;
|
||||
|
||||
if ( val == -1 )
|
||||
continue;
|
||||
curCont++;
|
||||
curTotl += val;
|
||||
curValu = curTotl / curCont;
|
||||
|
||||
DateTime thisDate = timeStamp.Date;
|
||||
if (curDate != thisDate && curValu >= 0)
|
||||
{
|
||||
string mnthName = thisDate.ToString("MMMM");
|
||||
|
||||
if ( curDate == DateTime.MinValue )
|
||||
curDate = thisDate;
|
||||
if (regions.Count == 0)
|
||||
{
|
||||
regions.Add(new BarRegion(barGraph.Items.Count, barGraph.Items.Count, mnthName));
|
||||
}
|
||||
else
|
||||
{
|
||||
BarRegion region = (BarRegion)regions[regions.Count - 1];
|
||||
|
||||
curCont++;
|
||||
curTotl += val;
|
||||
curValu = curTotl / curCont;
|
||||
if (region.m_Name == mnthName)
|
||||
region.m_RangeTo = barGraph.Items.Count;
|
||||
else
|
||||
regions.Add(new BarRegion(barGraph.Items.Count, barGraph.Items.Count, mnthName));
|
||||
}
|
||||
|
||||
if ( curDate != thisDate && curValu >= 0 )
|
||||
{
|
||||
string mnthName = thisDate.ToString( "MMMM" );
|
||||
barGraph.Items.Add(thisDate.Day.ToString(), curValu);
|
||||
|
||||
if ( regions.Count == 0 )
|
||||
{
|
||||
regions.Add( new BarRegion( barGraph.Items.Count, barGraph.Items.Count, mnthName ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
BarRegion region = (BarRegion)regions[regions.Count - 1];
|
||||
curPeak = val;
|
||||
curLow = val;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (val > curPeak)
|
||||
curPeak = val;
|
||||
|
||||
if ( region.m_Name == mnthName )
|
||||
region.m_RangeTo = barGraph.Items.Count;
|
||||
else
|
||||
regions.Add( new BarRegion( barGraph.Items.Count, barGraph.Items.Count, mnthName ) );
|
||||
}
|
||||
if (val > 0 && val < curLow)
|
||||
curLow = val;
|
||||
}
|
||||
|
||||
barGraph.Items.Add( thisDate.Day.ToString(), curValu );
|
||||
curDate = thisDate;
|
||||
}
|
||||
|
||||
curPeak = val;
|
||||
curLow = val;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( val > curPeak )
|
||||
curPeak = val;
|
||||
barGraph.Regions = (BarRegion[])regions.ToArray(typeof(BarRegion));
|
||||
|
||||
if ( val > 0 && val < curLow )
|
||||
curLow = val;
|
||||
}
|
||||
return barGraph;
|
||||
}
|
||||
|
||||
curDate = thisDate;
|
||||
}
|
||||
public static BarGraph OverTime(SnapshotHistory history, string reportName, string valueName, int step, int max,
|
||||
int ival)
|
||||
{
|
||||
BarGraph barGraph = new BarGraph(valueName + " over time", "graphs_" + valueName.ToLower() + "_ot", 10, "Time",
|
||||
valueName, BarGraphRenderMode.Lines);
|
||||
|
||||
barGraph.Regions = (BarRegion[])regions.ToArray( typeof( BarRegion ) );
|
||||
TimeSpan ts = TimeSpan.FromHours(max * step - 0.5);
|
||||
|
||||
return barGraph;
|
||||
}
|
||||
DateTime mostRecent = history.Snapshots[history.Snapshots.Count - 1].TimeStamp;
|
||||
DateTime minTime = mostRecent - ts;
|
||||
|
||||
public static BarGraph OverTime( SnapshotHistory history, string reportName, string valueName, int step, int max, int ival )
|
||||
{
|
||||
BarGraph barGraph = new BarGraph( valueName + " over time", "graphs_" + valueName.ToLower() + "_ot", 10, "Time", valueName, BarGraphRenderMode.Lines );
|
||||
barGraph.FontSize = 6;
|
||||
barGraph.Interval = ival;
|
||||
|
||||
TimeSpan ts = TimeSpan.FromHours( (max*step)-0.5 );
|
||||
ArrayList regions = new ArrayList();
|
||||
|
||||
DateTime mostRecent = history.Snapshots[history.Snapshots.Count - 1].TimeStamp;
|
||||
DateTime minTime = mostRecent - ts;
|
||||
for (int i = 0; i < history.Snapshots.Count; ++i)
|
||||
{
|
||||
Snapshot ss = history.Snapshots[i];
|
||||
DateTime timeStamp = ss.TimeStamp;
|
||||
|
||||
barGraph.FontSize = 6;
|
||||
barGraph.Interval = ival;
|
||||
if (timeStamp < minTime)
|
||||
continue;
|
||||
|
||||
ArrayList regions = new ArrayList();
|
||||
if (i % step != 0)
|
||||
continue;
|
||||
|
||||
for ( int i = 0; i < history.Snapshots.Count; ++i )
|
||||
{
|
||||
Snapshot ss = history.Snapshots[i];
|
||||
DateTime timeStamp = ss.TimeStamp;
|
||||
int val = LookupReportValue(ss, reportName, valueName);
|
||||
|
||||
if ( timeStamp < minTime )
|
||||
continue;
|
||||
if (val == -1)
|
||||
continue;
|
||||
|
||||
if ( (i % step) != 0 )
|
||||
continue;
|
||||
int realHours = timeStamp.TimeOfDay.Hours;
|
||||
int hours;
|
||||
|
||||
int val = LookupReportValue( ss, reportName, valueName );
|
||||
if (realHours == 0)
|
||||
hours = 12;
|
||||
else if (realHours > 12)
|
||||
hours = realHours - 12;
|
||||
else
|
||||
hours = realHours;
|
||||
|
||||
if ( val == -1 )
|
||||
continue;
|
||||
string dayName = timeStamp.DayOfWeek.ToString();
|
||||
|
||||
int realHours = timeStamp.TimeOfDay.Hours;
|
||||
int hours;
|
||||
if (regions.Count == 0)
|
||||
{
|
||||
regions.Add(new BarRegion(barGraph.Items.Count, barGraph.Items.Count, dayName));
|
||||
}
|
||||
else
|
||||
{
|
||||
BarRegion region = (BarRegion)regions[regions.Count - 1];
|
||||
|
||||
if ( realHours == 0 )
|
||||
hours = 12;
|
||||
else if ( realHours > 12 )
|
||||
hours = realHours - 12;
|
||||
else
|
||||
hours = realHours;
|
||||
if (region.m_Name == dayName)
|
||||
region.m_RangeTo = barGraph.Items.Count;
|
||||
else
|
||||
regions.Add(new BarRegion(barGraph.Items.Count, barGraph.Items.Count, dayName));
|
||||
}
|
||||
|
||||
string dayName = timeStamp.DayOfWeek.ToString();
|
||||
barGraph.Items.Add(hours + (realHours >= 12 ? " PM" : " AM"), val);
|
||||
}
|
||||
|
||||
if ( regions.Count == 0 )
|
||||
{
|
||||
regions.Add( new BarRegion( barGraph.Items.Count, barGraph.Items.Count, dayName ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
BarRegion region = (BarRegion) regions[regions.Count - 1];
|
||||
barGraph.Regions = (BarRegion[])regions.ToArray(typeof(BarRegion));
|
||||
|
||||
if ( region.m_Name == dayName )
|
||||
region.m_RangeTo = barGraph.Items.Count;
|
||||
else
|
||||
regions.Add( new BarRegion( barGraph.Items.Count, barGraph.Items.Count, dayName ) );
|
||||
}
|
||||
return barGraph;
|
||||
}
|
||||
|
||||
barGraph.Items.Add( hours + (realHours >= 12 ? " PM" : " AM"), val );
|
||||
}
|
||||
#region Type Identification
|
||||
|
||||
barGraph.Regions = (BarRegion[])regions.ToArray( typeof( BarRegion ) );
|
||||
public static readonly PersistableType ThisTypeID = new PersistableType("bg", Construct);
|
||||
|
||||
return barGraph;
|
||||
}
|
||||
}
|
||||
}
|
||||
private static PersistableObject Construct()
|
||||
{
|
||||
return new BarGraph();
|
||||
}
|
||||
|
||||
public override PersistableType TypeID => ThisTypeID;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +1,52 @@
|
|||
namespace Server.Engines.Reports
|
||||
{
|
||||
public abstract class Chart : PersistableObject
|
||||
{
|
||||
protected string m_Name;
|
||||
protected string m_FileName;
|
||||
protected ChartItemCollection m_Items;
|
||||
public abstract class Chart : PersistableObject
|
||||
{
|
||||
protected string m_FileName;
|
||||
protected ChartItemCollection m_Items;
|
||||
protected string m_Name;
|
||||
|
||||
public string Name{ get => m_Name;
|
||||
set => m_Name = value;
|
||||
}
|
||||
public string FileName{ get => m_FileName;
|
||||
set => m_FileName = value;
|
||||
}
|
||||
public ChartItemCollection Items => m_Items;
|
||||
public Chart()
|
||||
{
|
||||
m_Items = new ChartItemCollection();
|
||||
}
|
||||
|
||||
public Chart()
|
||||
{
|
||||
m_Items = new ChartItemCollection();
|
||||
}
|
||||
public string Name
|
||||
{
|
||||
get => m_Name;
|
||||
set => m_Name = value;
|
||||
}
|
||||
|
||||
public override void SerializeAttributes( PersistanceWriter op )
|
||||
{
|
||||
op.SetString( "n", m_Name );
|
||||
op.SetString( "f", m_FileName );
|
||||
}
|
||||
public string FileName
|
||||
{
|
||||
get => m_FileName;
|
||||
set => m_FileName = value;
|
||||
}
|
||||
|
||||
public override void DeserializeAttributes( PersistanceReader ip )
|
||||
{
|
||||
m_Name = Utility.Intern( ip.GetString( "n" ) );
|
||||
m_FileName = Utility.Intern( ip.GetString( "f" ) );
|
||||
}
|
||||
public ChartItemCollection Items => m_Items;
|
||||
|
||||
public override void SerializeChildren( PersistanceWriter op )
|
||||
{
|
||||
for ( int i = 0; i < m_Items.Count; ++i )
|
||||
m_Items[i].Serialize( op );
|
||||
}
|
||||
public override void SerializeAttributes(PersistanceWriter op)
|
||||
{
|
||||
op.SetString("n", m_Name);
|
||||
op.SetString("f", m_FileName);
|
||||
}
|
||||
|
||||
public override void DeserializeChildren( PersistanceReader ip )
|
||||
{
|
||||
while ( ip.HasChild )
|
||||
m_Items.Add( ip.GetChild() as ChartItem );
|
||||
}
|
||||
}
|
||||
public override void DeserializeAttributes(PersistanceReader ip)
|
||||
{
|
||||
m_Name = Utility.Intern(ip.GetString("n"));
|
||||
m_FileName = Utility.Intern(ip.GetString("f"));
|
||||
}
|
||||
|
||||
public override void SerializeChildren(PersistanceWriter op)
|
||||
{
|
||||
for (int i = 0; i < m_Items.Count; ++i)
|
||||
m_Items[i].Serialize(op);
|
||||
}
|
||||
|
||||
public override void DeserializeChildren(PersistanceReader ip)
|
||||
{
|
||||
while (ip.HasChild)
|
||||
m_Items.Add(ip.GetChild() as ChartItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +1,44 @@
|
|||
namespace Server.Engines.Reports
|
||||
{
|
||||
public class ChartItem : PersistableObject
|
||||
{
|
||||
#region Type Identification
|
||||
public static readonly PersistableType ThisTypeID = new PersistableType( "ci", Construct );
|
||||
public class ChartItem : PersistableObject
|
||||
{
|
||||
private ChartItem()
|
||||
{
|
||||
}
|
||||
|
||||
private static PersistableObject Construct()
|
||||
{
|
||||
return new ChartItem();
|
||||
}
|
||||
public ChartItem(string name, int value)
|
||||
{
|
||||
Name = name;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public override PersistableType TypeID => ThisTypeID;
|
||||
#endregion
|
||||
public string Name{ get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public int Value{ get; set; }
|
||||
|
||||
public int Value { get; set; }
|
||||
public override void SerializeAttributes(PersistanceWriter op)
|
||||
{
|
||||
op.SetString("n", Name);
|
||||
op.SetInt32("v", Value);
|
||||
}
|
||||
|
||||
private ChartItem()
|
||||
{
|
||||
}
|
||||
public override void DeserializeAttributes(PersistanceReader ip)
|
||||
{
|
||||
Name = Utility.Intern(ip.GetString("n"));
|
||||
Value = ip.GetInt32("v");
|
||||
}
|
||||
|
||||
public ChartItem( string name, int value )
|
||||
{
|
||||
Name = name;
|
||||
Value = value;
|
||||
}
|
||||
#region Type Identification
|
||||
|
||||
public override void SerializeAttributes( PersistanceWriter op )
|
||||
{
|
||||
op.SetString( "n", Name );
|
||||
op.SetInt32( "v", Value );
|
||||
}
|
||||
public static readonly PersistableType ThisTypeID = new PersistableType("ci", Construct);
|
||||
|
||||
public override void DeserializeAttributes( PersistanceReader ip )
|
||||
{
|
||||
Name = Utility.Intern( ip.GetString( "n" ) );
|
||||
Value = ip.GetInt32( "v" );
|
||||
}
|
||||
}
|
||||
}
|
||||
private static PersistableObject Construct()
|
||||
{
|
||||
return new ChartItem();
|
||||
}
|
||||
|
||||
public override PersistableType TypeID => ThisTypeID;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -8,187 +8,180 @@
|
|||
// </autogenerated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Server.Engines.Reports
|
||||
{
|
||||
using System.Collections;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Strongly typed collection of Server.Engines.Reports.ChartItem.
|
||||
/// </summary>
|
||||
public class ChartItemCollection : CollectionBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Strongly typed collection of Server.Engines.Reports.ChartItem.
|
||||
/// Gets or sets the value of the Server.Engines.Reports.ChartItem at a specific position in the ChartItemCollection.
|
||||
/// </summary>
|
||||
public class ChartItemCollection : CollectionBase
|
||||
public ChartItem this[int index]
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
public ChartItemCollection() :
|
||||
base()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the Server.Engines.Reports.ChartItem at a specific position in the ChartItemCollection.
|
||||
/// </summary>
|
||||
public ChartItem this[int index]
|
||||
{
|
||||
get => ((ChartItem)(List[index]));
|
||||
set => List[index] = value;
|
||||
}
|
||||
|
||||
public int Add( string name, int value )
|
||||
{
|
||||
return Add( new ChartItem( name, value ) );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append a Server.Engines.Reports.ChartItem entry to this collection.
|
||||
/// </summary>
|
||||
/// <param name="value">Server.Engines.Reports.ChartItem instance.</param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(ChartItem value)
|
||||
{
|
||||
return List.Add(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a specified Server.Engines.Reports.ChartItem instance is in this collection.
|
||||
/// </summary>
|
||||
/// <param name="value">Server.Engines.Reports.ChartItem instance to search for.</param>
|
||||
/// <returns>True if the Server.Engines.Reports.ChartItem instance is in the collection; otherwise false.</returns>
|
||||
public bool Contains(ChartItem value)
|
||||
{
|
||||
return List.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the index a specified Server.Engines.Reports.ChartItem instance is in this collection.
|
||||
/// </summary>
|
||||
/// <param name="value">Server.Engines.Reports.ChartItem instance to find.</param>
|
||||
/// <returns>The zero-based index of the specified Server.Engines.Reports.ChartItem instance. If the object is not found, the return value is -1.</returns>
|
||||
public int IndexOf(ChartItem value)
|
||||
{
|
||||
return List.IndexOf(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a specified Server.Engines.Reports.ChartItem instance from this collection.
|
||||
/// </summary>
|
||||
/// <param name="value">The Server.Engines.Reports.ChartItem instance to remove.</param>
|
||||
public void Remove(ChartItem value)
|
||||
{
|
||||
List.Remove(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an enumerator that can iterate through the Server.Engines.Reports.ChartItem instance.
|
||||
/// </summary>
|
||||
/// <returns>An Server.Engines.Reports.ChartItem's enumerator.</returns>
|
||||
public new ChartItemCollectionEnumerator GetEnumerator()
|
||||
{
|
||||
return new ChartItemCollectionEnumerator(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Insert a Server.Engines.Reports.ChartItem instance into this collection at a specified index.
|
||||
/// </summary>
|
||||
/// <param name="index">Zero-based index.</param>
|
||||
/// <param name="value">The Server.Engines.Reports.ChartItem instance to insert.</param>
|
||||
public void Insert(int index, ChartItem value)
|
||||
{
|
||||
List.Insert(index, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Strongly typed enumerator of Server.Engines.Reports.ChartItem.
|
||||
/// </summary>
|
||||
public class ChartItemCollectionEnumerator : IEnumerator
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Current index
|
||||
/// </summary>
|
||||
private int _index;
|
||||
|
||||
/// <summary>
|
||||
/// Current element pointed to.
|
||||
/// </summary>
|
||||
private ChartItem _currentElement;
|
||||
|
||||
/// <summary>
|
||||
/// Collection to enumerate.
|
||||
/// </summary>
|
||||
private ChartItemCollection _collection;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor for enumerator.
|
||||
/// </summary>
|
||||
/// <param name="collection">Instance of the collection to enumerate.</param>
|
||||
internal ChartItemCollectionEnumerator(ChartItemCollection collection)
|
||||
{
|
||||
_index = -1;
|
||||
_collection = collection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Server.Engines.Reports.ChartItem object in the enumerated ChartItemCollection currently indexed by this instance.
|
||||
/// </summary>
|
||||
public ChartItem Current
|
||||
{
|
||||
get
|
||||
{
|
||||
if (((_index == -1)
|
||||
|| (_index >= _collection.Count)))
|
||||
{
|
||||
throw new System.IndexOutOfRangeException("Enumerator not started.");
|
||||
}
|
||||
|
||||
return _currentElement;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current element in the collection.
|
||||
/// </summary>
|
||||
object IEnumerator.Current
|
||||
{
|
||||
get
|
||||
{
|
||||
if (((_index == -1)
|
||||
|| (_index >= _collection.Count)))
|
||||
{
|
||||
throw new System.IndexOutOfRangeException("Enumerator not started.");
|
||||
}
|
||||
|
||||
return _currentElement;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset the cursor, so it points to the beginning of the enumerator.
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
_index = -1;
|
||||
_currentElement = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Advances the enumerator to the next queue of the enumeration, if one is currently available.
|
||||
/// </summary>
|
||||
/// <returns>true, if the enumerator was successfully advanced to the next queue; false, if the enumerator has reached the end of the enumeration.</returns>
|
||||
public bool MoveNext()
|
||||
{
|
||||
if ((_index
|
||||
< (_collection.Count - 1)))
|
||||
{
|
||||
_index = (_index + 1);
|
||||
_currentElement = _collection[_index];
|
||||
return true;
|
||||
}
|
||||
_index = _collection.Count;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
get => (ChartItem)List[index];
|
||||
set => List[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Add(string name, int value)
|
||||
{
|
||||
return Add(new ChartItem(name, value));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append a Server.Engines.Reports.ChartItem entry to this collection.
|
||||
/// </summary>
|
||||
/// <param name="value">Server.Engines.Reports.ChartItem instance.</param>
|
||||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(ChartItem value)
|
||||
{
|
||||
return List.Add(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a specified Server.Engines.Reports.ChartItem instance is in this collection.
|
||||
/// </summary>
|
||||
/// <param name="value">Server.Engines.Reports.ChartItem instance to search for.</param>
|
||||
/// <returns>True if the Server.Engines.Reports.ChartItem instance is in the collection; otherwise false.</returns>
|
||||
public bool Contains(ChartItem value)
|
||||
{
|
||||
return List.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the index a specified Server.Engines.Reports.ChartItem instance is in this collection.
|
||||
/// </summary>
|
||||
/// <param name="value">Server.Engines.Reports.ChartItem instance to find.</param>
|
||||
/// <returns>
|
||||
/// The zero-based index of the specified Server.Engines.Reports.ChartItem instance. If the object is not found, the
|
||||
/// return value is -1.
|
||||
/// </returns>
|
||||
public int IndexOf(ChartItem value)
|
||||
{
|
||||
return List.IndexOf(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a specified Server.Engines.Reports.ChartItem instance from this collection.
|
||||
/// </summary>
|
||||
/// <param name="value">The Server.Engines.Reports.ChartItem instance to remove.</param>
|
||||
public void Remove(ChartItem value)
|
||||
{
|
||||
List.Remove(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an enumerator that can iterate through the Server.Engines.Reports.ChartItem instance.
|
||||
/// </summary>
|
||||
/// <returns>An Server.Engines.Reports.ChartItem's enumerator.</returns>
|
||||
public new ChartItemCollectionEnumerator GetEnumerator()
|
||||
{
|
||||
return new ChartItemCollectionEnumerator(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Insert a Server.Engines.Reports.ChartItem instance into this collection at a specified index.
|
||||
/// </summary>
|
||||
/// <param name="index">Zero-based index.</param>
|
||||
/// <param name="value">The Server.Engines.Reports.ChartItem instance to insert.</param>
|
||||
public void Insert(int index, ChartItem value)
|
||||
{
|
||||
List.Insert(index, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Strongly typed enumerator of Server.Engines.Reports.ChartItem.
|
||||
/// </summary>
|
||||
public class ChartItemCollectionEnumerator : IEnumerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Collection to enumerate.
|
||||
/// </summary>
|
||||
private ChartItemCollection _collection;
|
||||
|
||||
/// <summary>
|
||||
/// Current element pointed to.
|
||||
/// </summary>
|
||||
private ChartItem _currentElement;
|
||||
|
||||
/// <summary>
|
||||
/// Current index
|
||||
/// </summary>
|
||||
private int _index;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor for enumerator.
|
||||
/// </summary>
|
||||
/// <param name="collection">Instance of the collection to enumerate.</param>
|
||||
internal ChartItemCollectionEnumerator(ChartItemCollection collection)
|
||||
{
|
||||
_index = -1;
|
||||
_collection = collection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Server.Engines.Reports.ChartItem object in the enumerated ChartItemCollection currently indexed by this instance.
|
||||
/// </summary>
|
||||
public ChartItem Current
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_index == -1
|
||||
|| _index >= _collection.Count)
|
||||
throw new IndexOutOfRangeException("Enumerator not started.");
|
||||
|
||||
return _currentElement;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current element in the collection.
|
||||
/// </summary>
|
||||
object IEnumerator.Current
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_index == -1
|
||||
|| _index >= _collection.Count)
|
||||
throw new IndexOutOfRangeException("Enumerator not started.");
|
||||
|
||||
return _currentElement;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset the cursor, so it points to the beginning of the enumerator.
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
_index = -1;
|
||||
_currentElement = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Advances the enumerator to the next queue of the enumeration, if one is currently available.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// true, if the enumerator was successfully advanced to the next queue; false, if the enumerator has reached the end
|
||||
/// of the enumeration.
|
||||
/// </returns>
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (_index
|
||||
< _collection.Count - 1)
|
||||
{
|
||||
_index = _index + 1;
|
||||
_currentElement = _collection[_index];
|
||||
return true;
|
||||
}
|
||||
|
||||
_index = _collection.Count;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,43 +1,45 @@
|
|||
namespace Server.Engines.Reports
|
||||
{
|
||||
public class PieChart : Chart
|
||||
{
|
||||
#region Type Identification
|
||||
public static readonly PersistableType ThisTypeID = new PersistableType( "pc", Construct );
|
||||
public class PieChart : Chart
|
||||
{
|
||||
public PieChart(string name, string fileName, bool showPercents)
|
||||
{
|
||||
m_Name = name;
|
||||
m_FileName = fileName;
|
||||
ShowPercents = showPercents;
|
||||
}
|
||||
|
||||
private static PersistableObject Construct()
|
||||
{
|
||||
return new PieChart();
|
||||
}
|
||||
private PieChart()
|
||||
{
|
||||
}
|
||||
|
||||
public override PersistableType TypeID => ThisTypeID;
|
||||
#endregion
|
||||
public bool ShowPercents{ get; set; }
|
||||
|
||||
public bool ShowPercents { get; set; }
|
||||
public override void SerializeAttributes(PersistanceWriter op)
|
||||
{
|
||||
base.SerializeAttributes(op);
|
||||
|
||||
public PieChart( string name, string fileName, bool showPercents )
|
||||
{
|
||||
m_Name = name;
|
||||
m_FileName = fileName;
|
||||
ShowPercents = showPercents;
|
||||
}
|
||||
op.SetBoolean("p", ShowPercents);
|
||||
}
|
||||
|
||||
private PieChart()
|
||||
{
|
||||
}
|
||||
public override void DeserializeAttributes(PersistanceReader ip)
|
||||
{
|
||||
base.DeserializeAttributes(ip);
|
||||
|
||||
public override void SerializeAttributes( PersistanceWriter op )
|
||||
{
|
||||
base.SerializeAttributes( op );
|
||||
ShowPercents = ip.GetBoolean("p");
|
||||
}
|
||||
|
||||
op.SetBoolean( "p", ShowPercents );
|
||||
}
|
||||
#region Type Identification
|
||||
|
||||
public override void DeserializeAttributes( PersistanceReader ip )
|
||||
{
|
||||
base.DeserializeAttributes( ip );
|
||||
public static readonly PersistableType ThisTypeID = new PersistableType("pc", Construct);
|
||||
|
||||
ShowPercents = ip.GetBoolean( "p" );
|
||||
}
|
||||
}
|
||||
}
|
||||
private static PersistableObject Construct()
|
||||
{
|
||||
return new PieChart();
|
||||
}
|
||||
|
||||
public override PersistableType TypeID => ThisTypeID;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue