public HtmlRenderer(string outputDirectory, Snapshot ss, SnapshotHistory history) { m_OutputDirectory = Path.Combine("C:\\wamp\\www\\", outputDirectory); if (!Directory.Exists(m_OutputDirectory)) { Directory.CreateDirectory(m_OutputDirectory); } m_TimeStamp = ss.TimeStamp; m_Objects = new ObjectCollection(); for (int i = 0; i < ss.Children.Count; ++i) { m_Objects.Add(ss.Children[i]); } m_Objects.Add(BarGraph.OverTime(history, "General Stats", "Characters", 24, 9, 1)); m_Objects.Add(BarGraph.OverTime(history, "General Stats", "Items", 24, 9, 1)); m_Objects.Add(BarGraph.OverTime(history, "General Stats", "NPCs", 24, 9, 1)); m_Objects.Add(BarGraph.OverLongTime(history, "General Stats", "Active Players", 24 * 7, 12, 30)); m_Objects.Add(BarGraph.OverTime(history, "General Stats", "Clients", 1, 100, 6)); m_Objects.Add(BarGraph.DailyAverage(history, "General Stats", "Clients")); }
public static void Initialize() { m_History = new SnapshotHistory(); m_History.Load(); DateTime now = DateTime.Now; DateTime date = now.Date; TimeSpan timeOfDay = now.TimeOfDay; m_GenerateTime = date + TimeSpan.FromHours( Math.Ceiling( timeOfDay.TotalHours ) ); //Timer.DelayCall( TimeSpan.FromMinutes( 0.5 ), TimeSpan.FromMinutes( 0.5 ), new TimerCallback( CheckRegenerate ) ); }
public static void Initialize() { m_History = new SnapshotHistory(); m_History.Load(); DateTime now = DateTime.Now; DateTime date = now.Date; TimeSpan timeOfDay = now.TimeOfDay; m_GenerateTime = date + TimeSpan.FromHours(Math.Ceiling(timeOfDay.TotalHours)); Timer.DelayCall(TimeSpan.FromMinutes(0.5), TimeSpan.FromMinutes(0.5), new TimerCallback(CheckRegenerate)); }
public HtmlRenderer( string outputDirectory, Snapshot ss, SnapshotHistory history ) : this( outputDirectory ) { m_TimeStamp = ss.TimeStamp; m_Objects = new ObjectCollection(); for ( int i = 0; i < ss.Children.Count; ++i ) m_Objects.Add( ss.Children[i] ); m_Objects.Add( BarGraph.OverTime( history, "General Stats", "Clients", 1, 100, 6 ) ); m_Objects.Add( BarGraph.OverTime( history, "General Stats", "Items", 24, 9, 1 ) ); m_Objects.Add( BarGraph.OverTime( history, "General Stats", "Players", 24, 9, 1 ) ); m_Objects.Add( BarGraph.OverTime( history, "General Stats", "NPCs", 24, 9, 1 ) ); m_Objects.Add( BarGraph.DailyAverage( history, "General Stats", "Clients" ) ); m_Objects.Add( BarGraph.Growth( history, "General Stats", "Clients" ) ); }
public static void Initialize() { //Turned off due to lag -Valik m_History = new SnapshotHistory(); m_History.Load(); DateTime now = DateTime.Now; DateTime date = now.Date; TimeSpan timeOfDay = now.TimeOfDay; m_GenerateTime = date + TimeSpan.FromHours(Math.Ceiling(timeOfDay.TotalHours)); Timer.DelayCall(TimeSpan.FromMinutes(0.5), TimeSpan.FromMinutes(0.5), new TimerCallback(CheckRegenerate)); Server.Commands.Register("RenderReport", AccessLevel.Administrator, new CommandEventHandler(Render_OnCommand)); }
public HtmlRenderer(string outputDirectory, Snapshot ss, SnapshotHistory history) : this( outputDirectory ) { m_TimeStamp = ss.TimeStamp; m_Objects = new ObjectCollection(); for (int i = 0; i < ss.Children.Count; ++i) { m_Objects.Add(ss.Children[i]); } m_Objects.Add(BarGraph.OverTime(history, "General Stats", "Clients", 1, 100, 6)); m_Objects.Add(BarGraph.OverTime(history, "General Stats", "Items", 24, 9, 1)); m_Objects.Add(BarGraph.OverTime(history, "General Stats", "Players", 24, 9, 1)); m_Objects.Add(BarGraph.OverTime(history, "General Stats", "NPCs", 24, 9, 1)); m_Objects.Add(BarGraph.DailyAverage(history, "General Stats", "Clients")); m_Objects.Add(BarGraph.Growth(history, "General Stats", "Clients")); }
public static void Initialize() { CommandSystem.Register("GenReports", AccessLevel.Administrator, new CommandEventHandler(GenReports_OnCommand)); m_StatsHistory = new SnapshotHistory(); m_StatsHistory.Load(); m_StaffHistory = new StaffHistory(); m_StaffHistory.Load(); DateTime now = DateTime.UtcNow; if (!Enabled) return; DateTime date = now.Date; TimeSpan timeOfDay = now.TimeOfDay; m_GenerateTime = date + TimeSpan.FromHours(Math.Ceiling(timeOfDay.TotalHours)); Timer.DelayCall(TimeSpan.FromMinutes(0.5), TimeSpan.FromMinutes(0.5), new TimerCallback(CheckRegenerate)); }
public static void Initialize() { if (!Enabled) { return; } m_StatsHistory = new SnapshotHistory(); m_StatsHistory.Load(); m_StaffHistory = new StaffHistory(); m_StaffHistory.Load(); DateTime now = DateTime.UtcNow; DateTime date = now.Date; TimeSpan timeOfDay = now.TimeOfDay; m_GenerateTime = date + TimeSpan.FromHours(Math.Ceiling(timeOfDay.TotalHours)); Timer.DelayCall(TimeSpan.FromMinutes(0.5), TimeSpan.FromMinutes(0.5), CheckRegenerate); }
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 ); TimeSpan ts = TimeSpan.FromHours( (max*step)-0.5 ); DateTime mostRecent = history.Snapshots[history.Snapshots.Count - 1].TimeStamp; DateTime minTime = mostRecent - ts; barGraph.FontSize = 6; barGraph.Interval = ival; ArrayList regions = new ArrayList(); for ( int i = 0; i < history.Snapshots.Count; ++i ) { Snapshot ss = history.Snapshots[i]; DateTime timeStamp = ss.TimeStamp; if ( timeStamp < minTime ) continue; if ( (i % step) != 0 ) continue; int val = LookupReportValue( ss, reportName, valueName ); if ( val == -1 ) continue; int realHours = timeStamp.TimeOfDay.Hours; int hours; if ( realHours == 0 ) hours = 12; else if ( realHours > 12 ) hours = realHours - 12; else hours = realHours; string dayName = timeStamp.DayOfWeek.ToString(); if ( regions.Count == 0 ) { regions.Add( new BarRegion( barGraph.Items.Count, barGraph.Items.Count, dayName ) ); } else { BarRegion region = (BarRegion) regions[regions.Count - 1]; if ( region.m_Name == dayName ) region.m_RangeTo = barGraph.Items.Count; else regions.Add( new BarRegion( barGraph.Items.Count, barGraph.Items.Count, dayName ) ); } barGraph.Items.Add( hours + (realHours >= 12 ? " PM" : " AM"), val ); } barGraph.Regions = (BarRegion[])regions.ToArray( typeof( BarRegion ) ); return barGraph; }
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.FontSize = 6; barGraph.Interval = 7; DateTime startPeriod = history.Snapshots[0].TimeStamp.Date + TimeSpan.FromDays( 1.0 ); DateTime endPeriod = history.Snapshots[history.Snapshots.Count - 1].TimeStamp.Date; ArrayList regions = new ArrayList(); DateTime curDate = DateTime.MinValue; int curPeak = -1; int curLow = 1000; int curTotl = 0; int curCont = 0; int curValu = 0; for ( int i = 0; i < history.Snapshots.Count; ++i ) { Snapshot ss = history.Snapshots[i]; DateTime timeStamp = ss.TimeStamp; if ( timeStamp < startPeriod || timeStamp >= endPeriod ) continue; int val = LookupReportValue( ss, reportName, valueName ); if ( val == -1 ) continue; DateTime thisDate = timeStamp.Date; if ( curDate == DateTime.MinValue ) curDate = thisDate; curCont++; curTotl += val; curValu = curTotl / curCont; if ( curDate != thisDate && curValu >= 0 ) { string mnthName = thisDate.ToString( "MMMM" ); if ( regions.Count == 0 ) { regions.Add( new BarRegion( barGraph.Items.Count, barGraph.Items.Count, mnthName ) ); } else { BarRegion region = (BarRegion)regions[regions.Count - 1]; if ( region.m_Name == mnthName ) region.m_RangeTo = barGraph.Items.Count; else regions.Add( new BarRegion( barGraph.Items.Count, barGraph.Items.Count, mnthName ) ); } barGraph.Items.Add( thisDate.Day.ToString(), curValu ); curPeak = val; curLow = val; } else { if ( val > curPeak ) curPeak = val; if ( val > 0 && val < curLow ) curLow = val; } curDate = thisDate; } barGraph.Regions = (BarRegion[])regions.ToArray( typeof( BarRegion ) ); return barGraph; }
public static BarGraph DailyAverage( SnapshotHistory history, string reportName, string valueName ) { int[] totals = new int[24]; int[] counts = new int[24]; int min = history.Snapshots.Count - (7 * 24); // averages over one week if ( min < 0 ) min = 0; for ( int i = min; i < history.Snapshots.Count; ++i ) { Snapshot ss = history.Snapshots[i]; int val = LookupReportValue( ss, reportName, valueName ); if ( val == -1 ) continue; int hour = ss.TimeStamp.TimeOfDay.Hours; totals[hour] += val; counts[hour]++; } BarGraph barGraph = new BarGraph( "Hourly average " + valueName, "graphs_" + valueName.ToLower() + "_avg", 10, "Time", valueName, BarGraphRenderMode.Lines ); barGraph.m_FontSize = 6; for ( int i = 7; i <= totals.Length+7; ++i ) { int val; if ( counts[i%totals.Length] == 0 ) val = 0; else val = (totals[i%totals.Length] + (counts[i%totals.Length] / 2)) / counts[i%totals.Length]; int realHours = i%totals.Length; int hours; if ( realHours == 0 ) hours = 12; else if ( realHours > 12 ) hours = realHours - 12; else hours = realHours; barGraph.Items.Add( hours + (realHours >= 12 ? " PM" : " AM"), val ); } return barGraph; }
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); TimeSpan ts = TimeSpan.FromHours(max * step - 0.5); DateTime mostRecent = history.Snapshots[history.Snapshots.Count - 1].TimeStamp; DateTime minTime = mostRecent - ts; barGraph.FontSize = 6; barGraph.Interval = ival; ArrayList regions = new ArrayList(); for (int i = 0; i < history.Snapshots.Count; ++i) { Snapshot ss = history.Snapshots[i]; DateTime timeStamp = ss.TimeStamp; if (timeStamp < minTime) { continue; } if (i % step != 0) { continue; } int val = LookupReportValue(ss, reportName, valueName); if (val == -1) { continue; } int realHours = timeStamp.TimeOfDay.Hours; int hours; if (realHours == 0) { hours = 12; } else if (realHours > 12) { hours = realHours - 12; } else { hours = realHours; } string dayName = timeStamp.DayOfWeek.ToString(); if (regions.Count == 0) { regions.Add(new BarRegion(barGraph.Items.Count, barGraph.Items.Count, dayName)); } else { BarRegion region = (BarRegion)regions[regions.Count - 1]; if (region.m_Name == dayName) { region.m_RangeTo = barGraph.Items.Count; } else { regions.Add(new BarRegion(barGraph.Items.Count, barGraph.Items.Count, dayName)); } } barGraph.Items.Add(hours + (realHours >= 12 ? " PM" : " AM"), val); } barGraph.Regions = (BarRegion[])regions.ToArray(typeof(BarRegion)); return(barGraph); }
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.FontSize = 6; barGraph.Interval = 7; DateTime startPeriod = history.Snapshots[0].TimeStamp.Date + TimeSpan.FromDays(1.0); DateTime endPeriod = history.Snapshots[history.Snapshots.Count - 1].TimeStamp.Date; ArrayList regions = new ArrayList(); DateTime curDate = DateTime.MinValue; int curPeak = -1; int curLow = 1000; int curTotl = 0; int curCont = 0; int curValu = 0; for (int i = 0; i < history.Snapshots.Count; ++i) { Snapshot ss = history.Snapshots[i]; DateTime timeStamp = ss.TimeStamp; if (timeStamp < startPeriod || timeStamp >= endPeriod) { continue; } int val = LookupReportValue(ss, reportName, valueName); if (val == -1) { continue; } DateTime thisDate = timeStamp.Date; if (curDate == DateTime.MinValue) { curDate = thisDate; } curCont++; curTotl += val; curValu = curTotl / curCont; if (curDate != thisDate && curValu >= 0) { string mnthName = thisDate.ToString("MMMM"); if (regions.Count == 0) { regions.Add(new BarRegion(barGraph.Items.Count, barGraph.Items.Count, mnthName)); } else { BarRegion region = (BarRegion)regions[regions.Count - 1]; if (region.m_Name == mnthName) { region.m_RangeTo = barGraph.Items.Count; } else { regions.Add(new BarRegion(barGraph.Items.Count, barGraph.Items.Count, mnthName)); } } barGraph.Items.Add(thisDate.Day.ToString(), curValu); curPeak = val; curLow = val; } else { if (val > curPeak) { curPeak = val; } if (val > 0 && val < curLow) { curLow = val; } } curDate = thisDate; } barGraph.Regions = (BarRegion[])regions.ToArray(typeof(BarRegion)); return(barGraph); }
public static BarGraph DailyAverage(SnapshotHistory history, string reportName, string valueName) { int[] totals = new int[24]; int[] counts = new int[24]; int min = history.Snapshots.Count - 7 * 24; // averages over one week if (min < 0) { min = 0; } for (int i = min; i < history.Snapshots.Count; ++i) { Snapshot ss = history.Snapshots[i]; int val = LookupReportValue(ss, reportName, valueName); if (val == -1) { continue; } int hour = ss.TimeStamp.TimeOfDay.Hours; totals[hour] += val; counts[hour]++; } BarGraph barGraph = new BarGraph("Hourly average " + valueName, "graphs_" + valueName.ToLower() + "_avg", 10, "Time", valueName, BarGraphRenderMode.Lines); barGraph.m_FontSize = 6; for (int i = 7; i <= totals.Length + 7; ++i) { int val; if (counts[i % totals.Length] == 0) { val = 0; } else { val = (totals[i % totals.Length] + counts[i % totals.Length] / 2) / counts[i % totals.Length]; } int realHours = i % totals.Length; int hours; if (realHours == 0) { hours = 12; } else if (realHours > 12) { hours = realHours - 12; } else { hours = realHours; } barGraph.Items.Add(hours + (realHours >= 12 ? " PM" : " AM"), val); } return(barGraph); }
public static BarGraph OverLongTime(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); TimeSpan ts = TimeSpan.FromDays((max * step) - (step * .5)); DateTime mostRecent = history.Snapshots[history.Snapshots.Count - 1].TimeStamp; DateTime minTime = mostRecent - ts; barGraph.FontSize = 8; barGraph.Interval = ival; ArrayList regions = new ArrayList(); for (int i = 0; i < history.Snapshots.Count; ++i) { Snapshot ss = history.Snapshots[i]; DateTime timeStamp = ss.TimeStamp; if (timeStamp < minTime) { continue; } if ((i % step) != 0) { continue; } int val = LookupReportValue(ss, reportName, valueName); if (val == -1) { continue; } string monthName = timeStamp.ToString("MMMM"); if (regions.Count == 0) { regions.Add(new BarRegion(barGraph.Items.Count, barGraph.Items.Count, monthName)); } else { BarRegion region = (BarRegion)regions[regions.Count - 1]; if (region.m_Name == monthName) { region.m_RangeTo = barGraph.Items.Count; } else { regions.Add(new BarRegion(barGraph.Items.Count, barGraph.Items.Count, monthName)); } } barGraph.Items.Add(timeStamp.Day.ToString(), val); } barGraph.Regions = (BarRegion[])regions.ToArray(typeof(BarRegion)); return(barGraph); }